From 5ff240acc0850332de103513e66b1b93d1dd7a77 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 31 Jul 2015 10:54:46 +0300 Subject: [PATCH 001/457] Implement ServerInfo get info endpoint --- .../api/v2/JsonHttpRequestInterceptor.java | 39 +++++++++ .../sdk/client/api/v2/ServerRestApi.java | 76 ++++++++++++++++++ .../api/v2/XmlHttpRequestInterceptor.java | 39 +++++++++ .../sdk/client/api/v2/ServerRestApiTest.java | 79 +++++++++++++++++++ 4 files changed, 233 insertions(+) create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java new file mode 100644 index 00000000..58347fa7 --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java @@ -0,0 +1,39 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.api.v2; + +import retrofit.RequestInterceptor; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class JsonHttpRequestInterceptor implements RequestInterceptor { + @Override + public void intercept(RequestFacade request) { + request.addHeader("Accept", "application/json"); + request.addHeader("Accept", "application/*+json"); + } +} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java new file mode 100644 index 00000000..c3e83143 --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java @@ -0,0 +1,76 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.api.v2; + +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; + +import retrofit.Endpoint; +import retrofit.Endpoints; +import retrofit.RestAdapter; +import retrofit.http.GET; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ServerRestApi { + + @GET(value = "/rest_v2/serverInfo") + ServerInfo getServerInfo(); + + class Builder { + private final String mBaseUrl; + private boolean mXmlDataType; + + Builder(@Nullable String baseUrl) { + mBaseUrl = baseUrl; + mXmlDataType = true; + } + + public Builder useXmlDataType() { + mXmlDataType = true; + return this; + } + + public Builder useJsonDataType() { + mXmlDataType = false; + return this; + } + + public ServerRestApi build() { + Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); + + RestAdapter.Builder builder = new RestAdapter.Builder(); + builder.setRequestInterceptor(mXmlDataType ? new XmlHttpRequestInterceptor() : new JsonHttpRequestInterceptor()); +// builder.setConverter(mXmlDataType ? new SimpleXMLConverter() : new JsonHttpRequestInterceptor()); + builder.setEndpoint(endpoint); + RestAdapter restAdapter = builder.build(); + + return restAdapter.create(ServerRestApi.class); + } + } +} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java new file mode 100644 index 00000000..e6b4cd3b --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java @@ -0,0 +1,39 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.api.v2; + +import retrofit.RequestInterceptor; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class XmlHttpRequestInterceptor implements RequestInterceptor { + @Override + public void intercept(RequestFacade request) { + request.addHeader("Accept", "application/xml"); + request.addHeader("Accept", "application/*+xml"); + } +} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java new file mode 100644 index 00000000..22a9266d --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java @@ -0,0 +1,79 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.api.v2; + +import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; +import org.robolectric.shadows.FakeHttp; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNot.not; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(RobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class ServerRestApiTest { + + @Before + public void setup() { + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + } + + @Test + public void shouldRequestInfoForXml() { + ServerRestApi restApi = new ServerRestApi.Builder("http://mobiledemo.jaspersoft.com/jasperserver-pro") + .useXmlDataType() + .build(); + + ServerInfo serverInfo = restApi.getServerInfo(); + serverInfo.setVersion(serverInfo.getVersion()); + + double version = serverInfo.getVersionCode(); + assertThat(version, is(not(0d))); + } + + @Test + public void shouldRequestInfoForJson() { + ServerRestApi restApi = new ServerRestApi.Builder("http://mobiledemo.jaspersoft.com/jasperserver-pro") + .useJsonDataType() + .build(); + + ServerInfo serverInfo = restApi.getServerInfo(); + serverInfo.setVersion(serverInfo.getVersion()); + + double version = serverInfo.getVersionCode(); + assertThat(version, is(not(0d))); + } + +} From ea764f3f0bfc24d96d9280bca3b5ac9704f844df Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 4 Aug 2015 14:45:59 +0300 Subject: [PATCH 002/457] Implement converter factory --- client/build.gradle | 11 +++ .../sdk/client/api/v2/ConverterFactory.java | 70 +++++++++++++++++++ .../android/sdk/client/api/v2/DataType.java | 9 +++ .../sdk/client/api/v2/ServerRestApi.java | 19 ++--- .../client/api/v2/ConverterFactoryTest.java | 53 ++++++++++++++ .../sdk/client/api/v2/ServerRestApiTest.java | 6 +- 6 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java diff --git a/client/build.gradle b/client/build.gradle index a0a93a9a..e173501b 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -43,6 +43,12 @@ android { } dependencies { + compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' + compile 'com.squareup.retrofit:retrofit:1.9.0' + compile('com.squareup.retrofit:converter-simplexml:1.9.0') { + transitive = false + } + compile 'com.android.support:support-annotations:22.2.0' compile 'com.google.code.gson:gson:2.3.1' compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE' @@ -71,6 +77,11 @@ dependencies { exclude group: 'org.apache.httpcomponents', module: 'httpclient' } testCompile 'org.robolectric:shadows-httpclient:3.0-rc3' + + testCompile('com.squareup.okhttp:mockwebserver:2.1.0') { + transitive = false + } + } apply from: '../scripts/android-release-aar.gradle' \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java new file mode 100644 index 00000000..df03eb17 --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.api.v2; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; +import com.jaspersoft.android.sdk.client.oxm.report.adapter.ReportParametersListDeserializer; + +import org.simpleframework.xml.Serializer; +import org.simpleframework.xml.convert.AnnotationStrategy; +import org.simpleframework.xml.core.Persister; +import org.simpleframework.xml.strategy.Strategy; + +import retrofit.converter.Converter; +import retrofit.converter.GsonConverter; +import retrofit.converter.SimpleXMLConverter; + +/** + * @author Tom Koptel + * @since 2.2 + */ +final class ConverterFactory { + + public static Converter create(DataType dataType) { + if (dataType == DataType.JSON) { + return createJsonConverter(); + } + if (dataType == DataType.XML) { + return createXmlConverter(); + } + throw new UnsupportedOperationException("Following DataType[ " + dataType + "] has no converter resolution."); + } + + private static Converter createXmlConverter() { + Strategy annotationStrategy = new AnnotationStrategy(); + Serializer serializer = new Persister(annotationStrategy); + return new SimpleXMLConverter(serializer); + } + + private static Converter createJsonConverter() { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapter(ReportParametersList.class, new ReportParametersListDeserializer()); + Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); + return new GsonConverter(gson); + } + +} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java new file mode 100644 index 00000000..378cea21 --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.client.api.v2; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public enum DataType { + XML, JSON +} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java index c3e83143..f4fcf095 100644 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java @@ -44,20 +44,24 @@ public interface ServerRestApi { class Builder { private final String mBaseUrl; - private boolean mXmlDataType; + private DataType mDataType = DataType.XML; Builder(@Nullable String baseUrl) { mBaseUrl = baseUrl; - mXmlDataType = true; } - public Builder useXmlDataType() { - mXmlDataType = true; + public Builder setDataType(DataType dataType) { + mDataType = dataType; return this; } - public Builder useJsonDataType() { - mXmlDataType = false; + public Builder consumeJson() { + mDataType = DataType.JSON; + return this; + } + + public Builder consumeXml() { + mDataType = DataType.JSON; return this; } @@ -65,8 +69,7 @@ public ServerRestApi build() { Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); RestAdapter.Builder builder = new RestAdapter.Builder(); - builder.setRequestInterceptor(mXmlDataType ? new XmlHttpRequestInterceptor() : new JsonHttpRequestInterceptor()); -// builder.setConverter(mXmlDataType ? new SimpleXMLConverter() : new JsonHttpRequestInterceptor()); + builder.setConverter(ConverterFactory.create(mDataType)); builder.setEndpoint(endpoint); RestAdapter restAdapter = builder.build(); diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java new file mode 100644 index 00000000..ff75f498 --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.api.v2; + +import org.junit.Test; + +import retrofit.converter.GsonConverter; +import retrofit.converter.SimpleXMLConverter; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public class ConverterFactoryTest { + + @Test + public void shouldCreateJsonConverter() { + GsonConverter converter = (GsonConverter) ConverterFactory.create(DataType.JSON); + assertThat(converter, notNullValue()); + } + + @Test + public void shouldCreateXmlConverter() { + SimpleXMLConverter converter = (SimpleXMLConverter) ConverterFactory.create(DataType.XML); + assertThat(converter, notNullValue()); + } + +} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java index 22a9266d..6aaeb494 100644 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -53,7 +53,7 @@ public void setup() { @Test public void shouldRequestInfoForXml() { ServerRestApi restApi = new ServerRestApi.Builder("http://mobiledemo.jaspersoft.com/jasperserver-pro") - .useXmlDataType() + .consumeJson() .build(); ServerInfo serverInfo = restApi.getServerInfo(); @@ -66,7 +66,7 @@ public void shouldRequestInfoForXml() { @Test public void shouldRequestInfoForJson() { ServerRestApi restApi = new ServerRestApi.Builder("http://mobiledemo.jaspersoft.com/jasperserver-pro") - .useJsonDataType() + .consumeXml() .build(); ServerInfo serverInfo = restApi.getServerInfo(); From 5bd7fb117b92eb148902dc6af472be53d00d4b62 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 4 Aug 2015 14:59:48 +0300 Subject: [PATCH 003/457] Add standalone data module --- data/build.gradle | 14 ++ .../android/sdk/data/server/ServerInfo.java | 176 ++++++++++++++++++ settings.gradle | 4 +- 3 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 data/build.gradle create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfo.java diff --git a/data/build.gradle b/data/build.gradle new file mode 100644 index 00000000..956676a0 --- /dev/null +++ b/data/build.gradle @@ -0,0 +1,14 @@ +apply plugin: 'java' + +repositories { + jcenter() +} + +dependencies { + compile('org.simpleframework:simple-xml:2.7') { + exclude group: 'stax', module: 'stax' + exclude group: 'stax', module: 'stax-api' + exclude group: 'xpp3', module: 'xpp3' + } + compile 'com.google.code.gson:gson:2.3.1' +} \ No newline at end of file diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfo.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfo.java new file mode 100644 index 00000000..666a8ec8 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfo.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. + * http://www.jaspersoft.com. + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.jaspersoft.android.sdk.data.server; + +import com.google.gson.annotations.Expose; + +import org.simpleframework.xml.Element; +import org.simpleframework.xml.Root; + +import java.math.BigDecimal; + +/** + * @author Ivan Gadzhega + * @since 1.4 + */ +@Root(strict=false) +public class ServerInfo { + + public static class VERSION_CODES { + public static final int UNKNOWN = 0; + public static final double EMERALD = 5.0; + public static final double EMERALD_MR1 = 5.2; + public static final double EMERALD_TWO = 5.5; + public static final double EMERALD_THREE = 5.6; + public static final double AMBER = 6.0; + } + + public static class EDITIONS { + public static final String CE = "CE"; + public static final String PRO = "PRO"; + } + + @Expose + @Element(required=false) + private String build; + + @Expose + @Element + private String edition; + + @Expose + @Element(required=false) + private String editionName; + + @Expose + @Element(required=false) + private String expiration; + + @Expose + @Element(required=false) + private String features; + + @Expose + @Element(required=false) + private String licenseType; + + private String version; + + private double versionCode; + + + public ServerInfo() { + edition = EDITIONS.CE; + version = String.valueOf(VERSION_CODES.UNKNOWN); + } + + @Element + public void setVersion(String version) { + this.version = version; + this.versionCode = 0; + // update version code + if (version != null) { + String[] subs = version.split("\\."); + + BigDecimal decimalSubVersion, decimalFactor, decimalResult; + BigDecimal decimalVersion = new BigDecimal("0"); + for (int i = 0; i < subs.length; i++) { + try { + decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); + } catch (NumberFormatException ex) { + decimalSubVersion = new BigDecimal("0"); + } + + decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); + decimalResult = decimalSubVersion.multiply(decimalFactor); + decimalVersion = decimalVersion.add(decimalResult); + } + versionCode = decimalVersion.doubleValue(); + } + } + + @Element + public String getVersion() { + return version; + } + + //--------------------------------------------------------------------- + // Getters & Setters + //--------------------------------------------------------------------- + + public String getBuild() { + return build; + } + + public void setBuild(String build) { + this.build = build; + } + + public String getEdition() { + return edition; + } + + public void setEdition(String edition) { + this.edition = edition; + } + + public String getEditionName() { + return editionName; + } + + public void setEditionName(String editionName) { + this.editionName = editionName; + } + + public String getExpiration() { + return expiration; + } + + public void setExpiration(String expiration) { + this.expiration = expiration; + } + + public String getFeatures() { + return features; + } + + public void setFeatures(String features) { + this.features = features; + } + + public String getLicenseType() { + return licenseType; + } + + public void setLicenseType(String licenseType) { + this.licenseType = licenseType; + } + + public double getVersionCode() { + return versionCode; + } + + public void setVersionCode(double versionCode) { + this.versionCode = versionCode; + } + +} diff --git a/settings.gradle b/settings.gradle index 28f4ecb0..bb35078a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,7 @@ include ':js-android-sdk-client' include ':js-android-sdk-ui' +include ':js-android-sdk-data' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File -project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File \ No newline at end of file +project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File +project(':js-android-sdk-data').projectDir = "$rootDir/data" as File From 924330ecb5534cf15f1c1cef677d6dac7836a821 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 4 Aug 2015 15:12:51 +0300 Subject: [PATCH 004/457] Add standalone retrofit client module --- client-retrofit/build.gradle | 12 +++ .../retrofit/converter/ConverterFactory.java | 39 +++++++++ .../client/retrofit/server/ServerRestApi.java | 79 +++++++++++++++++++ .../jaspersoft/android/sdk/data/DataType.java | 9 +++ ...erverInfo.java => ServerInfoResponse.java} | 9 +-- settings.gradle | 2 + 6 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 client-retrofit/build.gradle create mode 100644 client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java create mode 100644 client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java rename data/src/main/java/com/jaspersoft/android/sdk/data/server/{ServerInfo.java => ServerInfoResponse.java} (97%) diff --git a/client-retrofit/build.gradle b/client-retrofit/build.gradle new file mode 100644 index 00000000..b72a4ee4 --- /dev/null +++ b/client-retrofit/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'java' + +repositories { + jcenter() +} + +dependencies { + compile project(':js-android-sdk-data') + compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' + compile 'com.squareup.retrofit:converter-simplexml:1.9.0' + +} \ No newline at end of file diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java new file mode 100644 index 00000000..d9cf0a07 --- /dev/null +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java @@ -0,0 +1,39 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.retrofit.converter; + +import com.jaspersoft.android.sdk.data.DataType; + +import retrofit.converter.Converter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ConverterFactory { + public static Converter create(DataType dataType) { + throw new UnsupportedOperationException(); + } +} diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java new file mode 100644 index 00000000..a5b1fc80 --- /dev/null +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java @@ -0,0 +1,79 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.retrofit.server; + +import com.jaspersoft.android.sdk.client.retrofit.converter.ConverterFactory; +import com.jaspersoft.android.sdk.data.DataType; +import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; + +import retrofit.Endpoint; +import retrofit.Endpoints; +import retrofit.RestAdapter; +import retrofit.http.GET; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ServerRestApi { + + @GET(value = "/rest_v2/serverInfo") + ServerInfoResponse getServerInfo(); + + class Builder { + private final String mBaseUrl; + private DataType mDataType = DataType.XML; + + Builder(String baseUrl) { + mBaseUrl = baseUrl; + } + + public Builder setDataType(DataType dataType) { + mDataType = dataType; + return this; + } + + public Builder consumeJson() { + mDataType = DataType.JSON; + return this; + } + + public Builder consumeXml() { + mDataType = DataType.JSON; + return this; + } + + public ServerRestApi build() { + Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); + + RestAdapter.Builder builder = new RestAdapter.Builder(); + builder.setConverter(ConverterFactory.create(mDataType)); + builder.setEndpoint(endpoint); + RestAdapter restAdapter = builder.build(); + + return restAdapter.create(ServerRestApi.class); + } + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java b/data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java new file mode 100644 index 00000000..312ab7fe --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.data; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum DataType { + XML, JSON +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfo.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java similarity index 97% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfo.java rename to data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java index 666a8ec8..f18c3d47 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfo.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java @@ -29,11 +29,11 @@ import java.math.BigDecimal; /** - * @author Ivan Gadzhega - * @since 1.4 + * @author Tom Koptel + * @since 2.0 */ @Root(strict=false) -public class ServerInfo { +public final class ServerInfoResponse { public static class VERSION_CODES { public static final int UNKNOWN = 0; @@ -77,8 +77,7 @@ public static class EDITIONS { private double versionCode; - - public ServerInfo() { + public ServerInfoResponse() { edition = EDITIONS.CE; version = String.valueOf(VERSION_CODES.UNKNOWN); } diff --git a/settings.gradle b/settings.gradle index bb35078a..67852d56 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,9 @@ include ':js-android-sdk-client' include ':js-android-sdk-ui' include ':js-android-sdk-data' +include ':js-android-sdk-client-retrofit' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File project(':js-android-sdk-data').projectDir = "$rootDir/data" as File +project(':js-android-sdk-client-retrofit').projectDir = "$rootDir/client-retrofit" as File From c0cc15915ea8cfe992b920800ddd089caf6231e8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 4 Aug 2015 15:29:08 +0300 Subject: [PATCH 005/457] Add data bundle for server info response test --- data/build.gradle | 2 + .../data/server/ServerInfoResponseTest.java | 38 +++++++++++++++++++ .../resources/json/default_server_info.json | 10 +++++ .../resources/xml/default_server_info.xml | 12 ++++++ 4 files changed, 62 insertions(+) create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java create mode 100644 data/src/test/resources/json/default_server_info.json create mode 100644 data/src/test/resources/xml/default_server_info.xml diff --git a/data/build.gradle b/data/build.gradle index 956676a0..f43e8eea 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -11,4 +11,6 @@ dependencies { exclude group: 'xpp3', module: 'xpp3' } compile 'com.google.code.gson:gson:2.3.1' + + testCompile 'junit:junit:4.12' } \ No newline at end of file diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java new file mode 100644 index 00000000..34eecd41 --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -0,0 +1,38 @@ +package com.jaspersoft.android.sdk.data.server; +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +import org.junit.Test; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerInfoResponseTest { + @Test + public void shouldParseDefaultJsonResponse() {} + + @Test + public void shouldParseDefaultXmlResponse() {} +} diff --git a/data/src/test/resources/json/default_server_info.json b/data/src/test/resources/json/default_server_info.json new file mode 100644 index 00000000..4e8768a0 --- /dev/null +++ b/data/src/test/resources/json/default_server_info.json @@ -0,0 +1,10 @@ +{ + "dateFormatPattern": "yyyy-MM-dd", + "datetimeFormatPattern": "yyyy-MM-dd'T'HH:mm:ss", + "version": "6.1", + "edition": "PRO", + "editionName": "Enterprise for AWS", + "licenseType": "Commercial", + "build": "20150527_1447", + "features": "Fusion AHD EXP DB AUD ANA MT " +} \ No newline at end of file diff --git a/data/src/test/resources/xml/default_server_info.xml b/data/src/test/resources/xml/default_server_info.xml new file mode 100644 index 00000000..b2b0bd0a --- /dev/null +++ b/data/src/test/resources/xml/default_server_info.xml @@ -0,0 +1,12 @@ + + + + 20150527_1447 + yyyy-MM-dd + yyyy-MM-dd'T'HH:mm:ss + PRO + Enterprise for AWS + Fusion AHD EXP DB AUD ANA MT + Commercial + 6.1 + \ No newline at end of file From ccf3b08b867c00bf2da14f1850f0e17f9fa0b160 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 4 Aug 2015 16:11:30 +0300 Subject: [PATCH 006/457] Add TestResource utility for test convinience --- .../data/server/ServerInfoResponseTest.java | 29 ++++- .../sdk/test/resource/ResourceFile.java | 16 +++ .../sdk/test/resource/TestResource.java | 105 ++++++++++++++++++ .../resource/inject/TestResourceInjector.java | 67 +++++++++++ 4 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java index 34eecd41..a58b8ed4 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.data.server; /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -23,16 +23,39 @@ * . */ +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + /** * @author Tom Koptel * @since 2.0 */ public class ServerInfoResponseTest { + @ResourceFile("json/default_server_info.json") + TestResource mJsonResource; + @ResourceFile("xml/default_server_info.xml") + TestResource mXmlResource; + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + @Test - public void shouldParseDefaultJsonResponse() {} + public void shouldParseDefaultJsonResponse() { + assertThat(mJsonResource.asString(), is(notNullValue())); + } @Test - public void shouldParseDefaultXmlResponse() {} + public void shouldParseDefaultXmlResponse() { + assertThat(mXmlResource.asString(), is(notNullValue())); + } } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java new file mode 100644 index 00000000..216b26da --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java @@ -0,0 +1,16 @@ +package com.jaspersoft.android.sdk.test.resource; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author Tom Koptel + * @since 2.2 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface ResourceFile { + String value(); +} diff --git a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java new file mode 100644 index 00000000..bb32619e --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java @@ -0,0 +1,105 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.resource; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class TestResource { + private final File mResource; + + private TestResource(String fileName) { + if (fileName == null || fileName.length() == 0) { + throw new IllegalArgumentException("Resource name should not be null"); + } + ClassLoader classLoader = getClass().getClassLoader(); + URL url = classLoader.getResource("."); + File classesFolder = new File(url.getFile()); + File resourcesFolder = new File( + new File(classesFolder.getParent()).getParent() + "/resources/test" + ); + + File file = new File(resourcesFolder, fileName); + if (!file.exists()) { + throw new RuntimeException( + new FileNotFoundException("Resource on path: " + file.getPath() + " not found") + ); + } + mResource = file; + } + + public static TestResource create(String fileName) { + return new TestResource(fileName); + } + + public String asString() { + return readFile(asFile()); + } + + public InputStream asStream() { + try { + return new FileInputStream(mResource); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } + + public File asFile() { + return mResource; + } + + @Override + public String toString() { + return "TestResource{" + + "path='" + mResource.getPath() + '\'' + + '}'; + } + + private static String readFile(File f) { + StringBuilder sb = new StringBuilder(); + try (BufferedReader br = new BufferedReader(new FileReader(f))) { + String sCurrentLine; + while ((sCurrentLine = br.readLine()) != null) { + sb.append(sCurrentLine); + } + + } catch (IOException e) { + System.err.println("I/O Exception:" + e.getMessage()); + return null; + } + return sb.toString(); + } + +} diff --git a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java new file mode 100644 index 00000000..cfd380e8 --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java @@ -0,0 +1,67 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.resource.inject; + +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; + +import java.lang.reflect.Field; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class TestResourceInjector { + private final Object mTarget; + + TestResourceInjector(Object target) { + mTarget = target; + } + + public static void inject(Object object) { + if (object == null) { + throw new IllegalArgumentException("Target object should not be null"); + } + TestResourceInjector injector = new TestResourceInjector(object); + injector.inject(); + } + + void inject() { + Class clazz = mTarget.getClass(); + for (Field field : clazz.getDeclaredFields()) { + if (field.isAnnotationPresent(ResourceFile.class)) { + ResourceFile annotation = field.getAnnotation(ResourceFile.class); + String path = annotation.value(); + TestResource resource = TestResource.create(path); + try { + field.setAccessible(true); + field.set(mTarget, resource); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + } +} From d34a0555aa42d7d2a7104340ce6a0b9fe6c418b9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 4 Aug 2015 16:33:50 +0300 Subject: [PATCH 007/457] Implementing GsonFactory --- data/build.gradle | 9 +++ .../android/sdk/data/GsonFactory.java | 51 ++++++++++++++++ .../android/sdk/data/GsonFactoryTest.java | 61 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java diff --git a/data/build.gradle b/data/build.gradle index f43e8eea..3a638bb0 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -13,4 +13,13 @@ dependencies { compile 'com.google.code.gson:gson:2.3.1' testCompile 'junit:junit:4.12' + testCompile 'org.mockito:mockito-core:1.10.19' + testCompile ('org.powermock:powermock-api-mockito:1.6.2') { + exclude module: 'hamcrest-core' + exclude module: 'objenesis' + } + testCompile ('org.powermock:powermock-module-junit4:1.6.2') { + exclude module: 'hamcrest-core' + exclude module: 'objenesis' + } } \ No newline at end of file diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java new file mode 100644 index 00000000..5bbc12e2 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java @@ -0,0 +1,51 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class GsonFactory { + private final GsonBuilder mBuilder; + + GsonFactory(GsonBuilder gsonBuilder) { + mBuilder = gsonBuilder; + } + + public static Gson create() { + GsonBuilder gsonBuilder = new GsonBuilder(); + GsonFactory gsonFactory = new GsonFactory(gsonBuilder); + return gsonFactory.get(); + } + + Gson get() { + mBuilder.excludeFieldsWithoutExposeAnnotation(); + return mBuilder.create(); + } +} diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java new file mode 100644 index 00000000..3378e99b --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java @@ -0,0 +1,61 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data; + +import com.google.gson.GsonBuilder; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(GsonBuilder.class) +public class GsonFactoryTest { + + GsonBuilder mBuilder; + GsonFactory underTest; + + @Before + public void setup() { + mBuilder = PowerMockito.spy(new GsonBuilder()); + underTest = new GsonFactory(mBuilder); + } + + @Test + public void shouldEnableGsonExposeAnnotationField() { + underTest.get(); + verify(mBuilder, times(1)).excludeFieldsWithoutExposeAnnotation(); + } +} From 7ede4b8da4bf3b8f0b8eb177f5a068ccdc614993 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 09:48:46 +0300 Subject: [PATCH 008/457] Implementing XmlSerializerFactory --- .../sdk/data/XmlSerializerFactory.java | 41 +++++++++++ .../sdk/data/XmlSerializerFactoryTest.java | 73 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/XmlSerializerFactory.java create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/XmlSerializerFactoryTest.java diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/XmlSerializerFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/XmlSerializerFactory.java new file mode 100644 index 00000000..81f12338 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/XmlSerializerFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data; + +import org.simpleframework.xml.Serializer; +import org.simpleframework.xml.convert.AnnotationStrategy; +import org.simpleframework.xml.core.Persister; +import org.simpleframework.xml.strategy.Strategy; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class XmlSerializerFactory { + public static Serializer create() { + Strategy annotationStrategy = new AnnotationStrategy(); + return new Persister(annotationStrategy); + } +} diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/XmlSerializerFactoryTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/XmlSerializerFactoryTest.java new file mode 100644 index 00000000..6abb5db8 --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/XmlSerializerFactoryTest.java @@ -0,0 +1,73 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.simpleframework.xml.Serializer; +import org.simpleframework.xml.convert.AnnotationStrategy; +import org.simpleframework.xml.core.Persister; +import org.simpleframework.xml.strategy.Strategy; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.powermock.api.mockito.PowerMockito.whenNew; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(XmlSerializerFactory.class) +public class XmlSerializerFactoryTest { + @Mock + Persister mPersister; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void shouldCreatePersisterWithAnnotationStrategy() throws Exception { + whenNew(Persister.class).withParameterTypes(Strategy.class).withArguments(Mockito.any(Strategy.class)).thenReturn(mPersister); + XmlSerializerFactory.create(); + PowerMockito.verifyNew(Persister.class).withArguments(Mockito.any(AnnotationStrategy.class)); + } + + @Test + public void shouldCreateSerializerInstance() { + Serializer serializer = XmlSerializerFactory.create(); + assertThat(serializer, is(notNullValue())); + } +} From cac5d71f0e11a9cf8b6b83a8d65f8d1151b27c04 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 09:59:35 +0300 Subject: [PATCH 009/457] Refactoring GsonFactory --- .../android/sdk/data/GsonFactory.java | 15 ++-------- .../android/sdk/data/GsonFactoryTest.java | 29 ++++++++++--------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java index 5bbc12e2..c65b76e4 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java @@ -32,20 +32,9 @@ * @since 2.0 */ public final class GsonFactory { - private final GsonBuilder mBuilder; - - GsonFactory(GsonBuilder gsonBuilder) { - mBuilder = gsonBuilder; - } - public static Gson create() { GsonBuilder gsonBuilder = new GsonBuilder(); - GsonFactory gsonFactory = new GsonFactory(gsonBuilder); - return gsonFactory.get(); - } - - Gson get() { - mBuilder.excludeFieldsWithoutExposeAnnotation(); - return mBuilder.create(); + gsonBuilder.excludeFieldsWithoutExposeAnnotation(); + return gsonBuilder.create(); } } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java index 3378e99b..65bad20b 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java @@ -24,38 +24,41 @@ package com.jaspersoft.android.sdk.data; +import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.whenNew; /** * @author Tom Koptel * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest(GsonBuilder.class) +@PrepareForTest({GsonBuilder.class, GsonFactory.class}) public class GsonFactoryTest { - - GsonBuilder mBuilder; - GsonFactory underTest; - - @Before - public void setup() { - mBuilder = PowerMockito.spy(new GsonBuilder()); - underTest = new GsonFactory(mBuilder); + @Test + public void shouldEnableGsonExposeAnnotationField() throws Exception { + GsonBuilder gsonBuilder = PowerMockito.mock(GsonBuilder.class); + whenNew(GsonBuilder.class).withNoArguments().thenReturn(gsonBuilder); + GsonFactory.create(); + verify(gsonBuilder, times(1)).excludeFieldsWithoutExposeAnnotation(); + PowerMockito.verifyNew(GsonBuilder.class).withNoArguments(); } @Test - public void shouldEnableGsonExposeAnnotationField() { - underTest.get(); - verify(mBuilder, times(1)).excludeFieldsWithoutExposeAnnotation(); + public void shouldCreateInstanceOfGson() { + Gson gson = GsonFactory.create(); + assertThat(gson, is(notNullValue())); } } From 9d8f9516baeca52f0fc24ef22e81a3204080bb1e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 10:16:48 +0300 Subject: [PATCH 010/457] Implementing ConverterFactory --- client-retrofit/build.gradle | 10 +++ .../retrofit/converter/ConverterFactory.java | 17 +++- .../converter/ConverterFactoryTest.java | 87 +++++++++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java diff --git a/client-retrofit/build.gradle b/client-retrofit/build.gradle index b72a4ee4..1b4d220e 100644 --- a/client-retrofit/build.gradle +++ b/client-retrofit/build.gradle @@ -9,4 +9,14 @@ dependencies { compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' compile 'com.squareup.retrofit:converter-simplexml:1.9.0' + testCompile 'junit:junit:4.12' + testCompile 'org.mockito:mockito-core:1.10.19' + testCompile ('org.powermock:powermock-api-mockito:1.6.2') { + exclude module: 'hamcrest-core' + exclude module: 'objenesis' + } + testCompile ('org.powermock:powermock-module-junit4:1.6.2') { + exclude module: 'hamcrest-core' + exclude module: 'objenesis' + } } \ No newline at end of file diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java index d9cf0a07..a7d2d083 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -25,8 +25,12 @@ package com.jaspersoft.android.sdk.client.retrofit.converter; import com.jaspersoft.android.sdk.data.DataType; +import com.jaspersoft.android.sdk.data.GsonFactory; +import com.jaspersoft.android.sdk.data.XmlSerializerFactory; import retrofit.converter.Converter; +import retrofit.converter.GsonConverter; +import retrofit.converter.SimpleXMLConverter; /** * @author Tom Koptel @@ -34,6 +38,15 @@ */ public final class ConverterFactory { public static Converter create(DataType dataType) { - throw new UnsupportedOperationException(); + if (dataType == null) { + throw new IllegalArgumentException("DataType should not be null"); + } + if (dataType == DataType.JSON) { + return new GsonConverter(GsonFactory.create()); + } + if (dataType == DataType.XML) { + return new SimpleXMLConverter(XmlSerializerFactory.create()); + } + throw new UnsupportedOperationException("Supplied DataType[ " + dataType + " ] invalid"); } } diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java new file mode 100644 index 00000000..76c94558 --- /dev/null +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java @@ -0,0 +1,87 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.retrofit.converter; + +import com.jaspersoft.android.sdk.data.DataType; +import com.jaspersoft.android.sdk.data.GsonFactory; +import com.jaspersoft.android.sdk.data.XmlSerializerFactory; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import retrofit.converter.Converter; +import retrofit.converter.GsonConverter; +import retrofit.converter.SimpleXMLConverter; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsInstanceOf.instanceOf; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.mockito.Mockito.times; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ConverterFactory.class, GsonFactory.class, XmlSerializerFactory.class}) +public class ConverterFactoryTest { + @Rule + public ExpectedException mException = ExpectedException.none(); + + @Test + public void shouldCreateGsonConverterForJsonDataType() { + PowerMockito.mockStatic(GsonFactory.class); + Converter converter = ConverterFactory.create(DataType.JSON); + + PowerMockito.verifyStatic(times(1)); + + assertThat(converter, is(instanceOf(GsonConverter.class))); + assertThat(converter, is(notNullValue())); + } + + @Test + public void shouldCreateGsonConverterForXMLDataType() { + PowerMockito.mockStatic(XmlSerializerFactory.class); + Converter converter = ConverterFactory.create(DataType.XML); + + PowerMockito.verifyStatic(times(1)); + + assertThat(converter, is(instanceOf(SimpleXMLConverter.class))); + assertThat(converter, is(notNullValue())); + } + + @Test + public void shouldThrowExceptionIfDataTypeNull() { + mException.expectMessage("DataType should not be null"); + mException.expect(IllegalArgumentException.class); + ConverterFactory.create(null); + } +} From deef871ad8dca0035d920e7f44a4cc2890adb7a8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 13:54:38 +0300 Subject: [PATCH 011/457] Implmenting ServerVersion --- .../retrofit/converter/ConverterFactory.java | 4 +- .../converter/ConverterFactoryTest.java | 4 +- data/build.gradle | 3 + .../sdk/data/server/DefaultVersionParser.java | 77 ++++++++++++ .../sdk/data/server/ServerInfoResponse.java | 114 ++++-------------- .../sdk/data/server/ServerVersion.java | 72 +++++++++++ .../sdk/data/server/ServerVersionAdapter.java | 48 ++++++++ .../android/sdk/data/type/CommonMatcher.java | 53 ++++++++ .../sdk/data/{ => type}/GsonFactory.java | 3 +- .../sdk/data/type/ServerVersionMatcher.java | 56 +++++++++ .../data/{ => type}/XmlSerializerFactory.java | 14 ++- .../sdk/data/{ => json}/GsonFactoryTest.java | 12 +- .../data/server/DefaultVersionParserTest.java | 75 ++++++++++++ .../data/server/ServerInfoResponseTest.java | 40 +++++- .../sdk/data/server/ServerVersionTest.java | 85 +++++++++++++ .../{ => type}/XmlSerializerFactoryTest.java | 8 +- .../sdk/test/resource/ResourceFile.java | 2 +- 17 files changed, 565 insertions(+), 105 deletions(-) create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java rename data/src/main/java/com/jaspersoft/android/sdk/data/{ => type}/GsonFactory.java (93%) create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java rename data/src/main/java/com/jaspersoft/android/sdk/data/{ => type}/XmlSerializerFactory.java (75%) rename data/src/test/java/com/jaspersoft/android/sdk/data/{ => json}/GsonFactoryTest.java (84%) create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java rename data/src/test/java/com/jaspersoft/android/sdk/data/{ => type}/XmlSerializerFactoryTest.java (89%) diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java index a7d2d083..1f5fc238 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java @@ -25,8 +25,8 @@ package com.jaspersoft.android.sdk.client.retrofit.converter; import com.jaspersoft.android.sdk.data.DataType; -import com.jaspersoft.android.sdk.data.GsonFactory; -import com.jaspersoft.android.sdk.data.XmlSerializerFactory; +import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.data.type.XmlSerializerFactory; import retrofit.converter.Converter; import retrofit.converter.GsonConverter; diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java index 76c94558..1c7c5571 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java @@ -25,8 +25,8 @@ package com.jaspersoft.android.sdk.client.retrofit.converter; import com.jaspersoft.android.sdk.data.DataType; -import com.jaspersoft.android.sdk.data.GsonFactory; -import com.jaspersoft.android.sdk.data.XmlSerializerFactory; +import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.data.type.XmlSerializerFactory; import org.junit.Rule; import org.junit.Test; diff --git a/data/build.gradle b/data/build.gradle index 3a638bb0..d3c2fa27 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -13,6 +13,9 @@ dependencies { compile 'com.google.code.gson:gson:2.3.1' testCompile 'junit:junit:4.12' + testCompile('pl.pragmatists:JUnitParams:1.0.4') { + exclude group: 'org.hamcrest' + } testCompile 'org.mockito:mockito-core:1.10.19' testCompile ('org.powermock:powermock-api-mockito:1.6.2') { exclude module: 'hamcrest-core' diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java new file mode 100644 index 00000000..1028a96d --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +import java.math.BigDecimal; + +/** + * @author Tom Koptel + * @since 2.0 + */ +enum DefaultVersionParser implements ServerVersion.Parser { + INSTANCE; + + @Override + public ServerVersion parse(String rawVersion) { + double value = convertToDouble(rawVersion); + ServerVersion serverVersion = findReleaseByCode(value); + serverVersion.setRawValue(rawVersion); + return serverVersion; + } + + private ServerVersion findReleaseByCode(final double versionCode) { + for (ServerVersion release : ServerVersion.values()) { + if (Double.compare(release.getVersionCode(), versionCode) == 0) { + return release; + } + } + ServerVersion.UNKNOWN.setVersionCode(versionCode); + return ServerVersion.UNKNOWN; + } + + double convertToDouble(String version) { + double versionCode = 0d; + // update version code + if (version != null) { + String[] subs = version.split("\\."); + + BigDecimal decimalSubVersion, decimalFactor, decimalResult; + BigDecimal decimalVersion = new BigDecimal("0"); + for (int i = 0; i < subs.length; i++) { + try { + decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); + } catch (NumberFormatException ex) { + decimalSubVersion = new BigDecimal("0"); + } + + decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); + decimalResult = decimalSubVersion.multiply(decimalFactor); + decimalVersion = decimalVersion.add(decimalResult); + } + versionCode = decimalVersion.doubleValue(); + } + return versionCode; + } +} \ No newline at end of file diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java index f18c3d47..4aecec0f 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java @@ -22,12 +22,11 @@ package com.jaspersoft.android.sdk.data.server; import com.google.gson.annotations.Expose; +import com.google.gson.annotations.JsonAdapter; import org.simpleframework.xml.Element; import org.simpleframework.xml.Root; -import java.math.BigDecimal; - /** * @author Tom Koptel * @since 2.0 @@ -35,23 +34,18 @@ @Root(strict=false) public final class ServerInfoResponse { - public static class VERSION_CODES { - public static final int UNKNOWN = 0; - public static final double EMERALD = 5.0; - public static final double EMERALD_MR1 = 5.2; - public static final double EMERALD_TWO = 5.5; - public static final double EMERALD_THREE = 5.6; - public static final double AMBER = 6.0; - } + @Expose + @Element + private String dateFormatPattern; - public static class EDITIONS { - public static final String CE = "CE"; - public static final String PRO = "PRO"; - } + @Expose + @Element + private String datetimeFormatPattern; @Expose - @Element(required=false) - private String build; + @Element + @JsonAdapter(ServerVersionAdapter.class) + private ServerVersion version; @Expose @Element @@ -59,117 +53,61 @@ public static class EDITIONS { @Expose @Element(required=false) - private String editionName; + private String licenseType; @Expose @Element(required=false) - private String expiration; + private String build; @Expose @Element(required=false) - private String features; + private String editionName; @Expose @Element(required=false) - private String licenseType; - - private String version; - - private double versionCode; - - public ServerInfoResponse() { - edition = EDITIONS.CE; - version = String.valueOf(VERSION_CODES.UNKNOWN); - } - - @Element - public void setVersion(String version) { - this.version = version; - this.versionCode = 0; - // update version code - if (version != null) { - String[] subs = version.split("\\."); - - BigDecimal decimalSubVersion, decimalFactor, decimalResult; - BigDecimal decimalVersion = new BigDecimal("0"); - for (int i = 0; i < subs.length; i++) { - try { - decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); - } catch (NumberFormatException ex) { - decimalSubVersion = new BigDecimal("0"); - } - - decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); - decimalResult = decimalSubVersion.multiply(decimalFactor); - decimalVersion = decimalVersion.add(decimalResult); - } - versionCode = decimalVersion.doubleValue(); - } - } + private String expiration; - @Element - public String getVersion() { - return version; - } + @Expose + @Element(required=false) + private String features; //--------------------------------------------------------------------- - // Getters & Setters + // Getters //--------------------------------------------------------------------- public String getBuild() { return build; } - public void setBuild(String build) { - this.build = build; + public String getDateFormatPattern() { + return dateFormatPattern; } - public String getEdition() { - return edition; + public String getDatetimeFormatPattern() { + return datetimeFormatPattern; } - public void setEdition(String edition) { - this.edition = edition; + public String getEdition() { + return edition; } public String getEditionName() { return editionName; } - public void setEditionName(String editionName) { - this.editionName = editionName; - } - public String getExpiration() { return expiration; } - public void setExpiration(String expiration) { - this.expiration = expiration; - } - public String getFeatures() { return features; } - public void setFeatures(String features) { - this.features = features; - } - public String getLicenseType() { return licenseType; } - public void setLicenseType(String licenseType) { - this.licenseType = licenseType; - } - - public double getVersionCode() { - return versionCode; - } - - public void setVersionCode(double versionCode) { - this.versionCode = versionCode; + public ServerVersion getVersion() { + return version; } - } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java new file mode 100644 index 00000000..c832888c --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java @@ -0,0 +1,72 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum ServerVersion { + UNKNOWN(0d), + EMERALD(5.0d), + EMERALD_MR1(5.2d), + EMERALD_MR2(5.5d), + EMERALD_MR3(5.6d), + EMERALD_MR4(5.61d), + AMBER(6.0d), + AMBER_MR1(6.01d), + AMBER_MR2(6.1d); + + private double mVersionCode; + private String mRawValue; + + ServerVersion(double versionCode) { + this.mVersionCode = versionCode; + } + + public String getRawValue() { + return mRawValue; + } + + public double getVersionCode() { + return mVersionCode; + } + + void setVersionCode(double versionCode) { + mVersionCode = versionCode; + } + + void setRawValue(String rawValue) { + mRawValue = rawValue; + } + + public static Parser defaultParser() { + return DefaultVersionParser.INSTANCE; + } + + public interface Parser { + ServerVersion parse(String rawVersion); + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java new file mode 100644 index 00000000..d02ab936 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ServerVersionAdapter extends TypeAdapter { + @Override + public void write(JsonWriter out, ServerVersion value) throws IOException { + out.value(value.getRawValue()); + } + + @Override + public ServerVersion read(JsonReader in) throws IOException { + String rawValue = in.nextString(); + return ServerVersion.defaultParser().parse(rawValue); + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java new file mode 100644 index 00000000..8f21fc00 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java @@ -0,0 +1,53 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.type; + +import org.simpleframework.xml.transform.Matcher; +import org.simpleframework.xml.transform.Transform; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class CommonMatcher implements Matcher { + + private final Collection mMatchers = new ArrayList<>(); + + + public void registerMatcher(Matcher matcher) { + mMatchers.add(matcher); + } + + @Override + public Transform match(Class type) throws Exception { + for (Matcher matcher : mMatchers) { + return matcher.match(type); + } + return null; + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java similarity index 93% rename from data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java rename to data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java index c65b76e4..8b61626a 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/GsonFactory.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data; +package com.jaspersoft.android.sdk.data.type; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -35,6 +35,7 @@ public final class GsonFactory { public static Gson create() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.excludeFieldsWithoutExposeAnnotation(); + gsonBuilder.disableHtmlEscaping(); return gsonBuilder.create(); } } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java new file mode 100644 index 00000000..7dba547e --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java @@ -0,0 +1,56 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.type; + +import com.jaspersoft.android.sdk.data.server.ServerVersion; + +import org.simpleframework.xml.transform.Matcher; +import org.simpleframework.xml.transform.Transform; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ServerVersionMatcher implements Matcher { + @Override + public Transform match(Class type) throws Exception { + if (type.equals(ServerVersion.class)) { + return new ServerVersionTransformer(); + } + return null; + } + + private static class ServerVersionTransformer implements Transform { + @Override + public ServerVersion read(String value) throws Exception { + return ServerVersion.defaultParser().parse(value); + } + + @Override + public String write(ServerVersion value) throws Exception { + return value.getRawValue(); + } + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/XmlSerializerFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java similarity index 75% rename from data/src/main/java/com/jaspersoft/android/sdk/data/XmlSerializerFactory.java rename to data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java index 81f12338..6e18078d 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/XmlSerializerFactory.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java @@ -22,12 +22,16 @@ * . */ -package com.jaspersoft.android.sdk.data; +package com.jaspersoft.android.sdk.data.type; import org.simpleframework.xml.Serializer; import org.simpleframework.xml.convert.AnnotationStrategy; import org.simpleframework.xml.core.Persister; import org.simpleframework.xml.strategy.Strategy; +import org.simpleframework.xml.transform.Matcher; + +import java.util.ArrayList; +import java.util.Collection; /** * @author Tom Koptel @@ -36,6 +40,12 @@ public final class XmlSerializerFactory { public static Serializer create() { Strategy annotationStrategy = new AnnotationStrategy(); - return new Persister(annotationStrategy); + Collection matchers = new ArrayList<>(); + matchers.add(new ServerVersionMatcher()); + + CommonMatcher commonMatcher = new CommonMatcher(); + commonMatcher.registerMatcher(new ServerVersionMatcher()); + + return new Persister(annotationStrategy, commonMatcher); } } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/json/GsonFactoryTest.java similarity index 84% rename from data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java rename to data/src/test/java/com/jaspersoft/android/sdk/data/json/GsonFactoryTest.java index 65bad20b..17c2f35a 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/GsonFactoryTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/json/GsonFactoryTest.java @@ -22,10 +22,11 @@ * . */ -package com.jaspersoft.android.sdk.data; +package com.jaspersoft.android.sdk.data.json; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.jaspersoft.android.sdk.data.type.GsonFactory; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,7 +54,14 @@ public void shouldEnableGsonExposeAnnotationField() throws Exception { whenNew(GsonBuilder.class).withNoArguments().thenReturn(gsonBuilder); GsonFactory.create(); verify(gsonBuilder, times(1)).excludeFieldsWithoutExposeAnnotation(); - PowerMockito.verifyNew(GsonBuilder.class).withNoArguments(); + } + + @Test + public void shouldDisableHtmlEscaping() throws Exception { + GsonBuilder gsonBuilder = PowerMockito.mock(GsonBuilder.class); + whenNew(GsonBuilder.class).withNoArguments().thenReturn(gsonBuilder); + GsonFactory.create(); + verify(gsonBuilder, times(1)).disableHtmlEscaping(); } @Test diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java new file mode 100644 index 00000000..b1a72ead --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java @@ -0,0 +1,75 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class DefaultVersionParserTest { + @Test + @Parameters({ + "5.0.0, 5", + "5.1.0, 5.1", + "5.2.0, 5.2", + "5.5.0, 5.5", + "5.6.0, 5.6", + "5.6.1, 5.61", + "6.0, 6", + "6.0.1, 6.01", + "6.1, 6.1", + "6.1.1, 6.11", + }) + public void shouldParseSemanticVersioning(String versionCode, String expected) { + double expectedCode = Double.valueOf(expected); + double resultCode = DefaultVersionParser.INSTANCE.convertToDouble(versionCode); + assertThat(resultCode, is(expectedCode)); + } + + @Test + @Parameters({ + "5.6.1.2, 5.612", + "5.6.1.2.0, 5.612", + "5.5.6.1.2, 5.5612", + "5.5.6.1.2.0, 5.5612", + "5.5.6.1.2.3, 5.56123", + "5.5.6.1.2.3.0, 5.56123", + }) + public void shouldParseLongSemanticVersioning(String versionCode, String expected) { + double expectedCode = Double.valueOf(expected); + double resultCode = DefaultVersionParser.INSTANCE.convertToDouble(versionCode); + assertThat(resultCode, is(expectedCode)); + } +} \ No newline at end of file diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java index a58b8ed4..4f8a783a 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -23,12 +23,19 @@ * . */ +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.data.type.XmlSerializerFactory; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import org.junit.Before; import org.junit.Test; +import org.simpleframework.xml.Serializer; + +import java.io.ByteArrayOutputStream; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -44,6 +51,9 @@ public class ServerInfoResponseTest { @ResourceFile("xml/default_server_info.xml") TestResource mXmlResource; + Gson mGson = GsonFactory.create(); + Serializer mSerializer = XmlSerializerFactory.create(); + @Before public void setup() { TestResourceInjector.inject(this); @@ -51,11 +61,35 @@ public void setup() { @Test public void shouldParseDefaultJsonResponse() { - assertThat(mJsonResource.asString(), is(notNullValue())); + ServerInfoResponse response = mGson.fromJson(mJsonResource.asString(), ServerInfoResponse.class); + assertThat(response, is(notNullValue())); + assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); + } + + @Test + public void shouldSerializeServerVersionToJson() { + String initialJson = mJsonResource.asString(); + ServerInfoResponse response = mGson.fromJson(initialJson, ServerInfoResponse.class); + JsonElement element = mGson.toJsonTree(response, ServerInfoResponse.class); + String serializedVersion = element.getAsJsonObject().get("version").getAsString(); + assertThat(serializedVersion, is("6.1")); } @Test - public void shouldParseDefaultXmlResponse() { - assertThat(mXmlResource.asString(), is(notNullValue())); + public void shouldParseDefaultXmlResponse() throws Exception { + ServerInfoResponse response = mSerializer.read(ServerInfoResponse.class, mXmlResource.asString()); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldSerializeServerVersionToXml() throws Exception { + String initialXml = mXmlResource.asString(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ServerInfoResponse serverInfoResponse1 = mSerializer.read(ServerInfoResponse.class, initialXml); + mSerializer.write(serverInfoResponse1, outputStream); + + String xml = new String(outputStream.toByteArray()); + ServerInfoResponse serverInfoResponse2 = mSerializer.read(ServerInfoResponse.class, xml); + assertThat(serverInfoResponse1.getVersion(), is(serverInfoResponse2.getVersion())); } } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java new file mode 100644 index 00000000..c40739a3 --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java @@ -0,0 +1,85 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ServerVersionTest { + @Test + @Parameters({ + "5.0.0, EMERALD", + "5.2.0, EMERALD_MR1", + "5.5.0, EMERALD_MR2", + "5.6.0, EMERALD_MR3", + "5.6.1, EMERALD_MR4", + "6.0, AMBER", + "6.0.1, AMBER_MR1", + "6.1, AMBER_MR2", + }) + public void shouldParseSemanticVersioning(String versionCode, String enumName) { + ServerVersion expectedRelease = ServerVersion.valueOf(enumName); + ServerVersion resultRelease = ServerVersion.defaultParser().parse(versionCode); + assertThat(resultRelease, is(expectedRelease)); + } + + @Test + @Parameters({ + "5.0, EMERALD", + "5.2, EMERALD_MR1", + "5.5, EMERALD_MR2", + "5.6, EMERALD_MR3", + "5.61, EMERALD_MR4", + "6.0, AMBER", + "6.01, AMBER_MR1", + "6.1, AMBER_MR2", + }) + public void shouldParseCode(String versionCode, String enumName) { + ServerVersion expectedRelease = ServerVersion.valueOf(enumName); + ServerVersion resultRelease = ServerVersion.defaultParser().parse(versionCode); + assertThat(resultRelease, is(expectedRelease)); + } + + @Test + @Parameters({ + "5.6.0 Preview", + "5.6.0-BETA", + }) + public void shouldParseNonSemanticVersioning(String nonSemanticVersion) { + ServerVersion resultRelease = ServerVersion.defaultParser().parse(nonSemanticVersion); + assertThat(resultRelease, is(ServerVersion.EMERALD_MR3)); + } +} \ No newline at end of file diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/XmlSerializerFactoryTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactoryTest.java similarity index 89% rename from data/src/test/java/com/jaspersoft/android/sdk/data/XmlSerializerFactoryTest.java rename to data/src/test/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactoryTest.java index 6abb5db8..4c2edb34 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/XmlSerializerFactoryTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactoryTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data; +package com.jaspersoft.android.sdk.data.type; import org.junit.Before; import org.junit.Test; @@ -48,7 +48,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest(XmlSerializerFactory.class) +@PrepareForTest(com.jaspersoft.android.sdk.data.type.XmlSerializerFactory.class) public class XmlSerializerFactoryTest { @Mock Persister mPersister; @@ -61,13 +61,13 @@ public void setup() { @Test public void shouldCreatePersisterWithAnnotationStrategy() throws Exception { whenNew(Persister.class).withParameterTypes(Strategy.class).withArguments(Mockito.any(Strategy.class)).thenReturn(mPersister); - XmlSerializerFactory.create(); + com.jaspersoft.android.sdk.data.type.XmlSerializerFactory.create(); PowerMockito.verifyNew(Persister.class).withArguments(Mockito.any(AnnotationStrategy.class)); } @Test public void shouldCreateSerializerInstance() { - Serializer serializer = XmlSerializerFactory.create(); + Serializer serializer = com.jaspersoft.android.sdk.data.type.XmlSerializerFactory.create(); assertThat(serializer, is(notNullValue())); } } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java index 216b26da..819d40b1 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java @@ -7,7 +7,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) From a6ec03ae995513ddd7d18837b4fbd215697ce5ad Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 14:02:13 +0300 Subject: [PATCH 012/457] Implment ServerEdition --- .../sdk/data/server/ServerEdition.java | 33 ++++++++++++++++ .../sdk/data/server/ServerInfoResponse.java | 4 +- .../data/server/ServerInfoResponseTest.java | 38 +++++++++++++++++-- 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java new file mode 100644 index 00000000..64a73263 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java @@ -0,0 +1,33 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum ServerEdition { + PRO, CE +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java index 4aecec0f..ff564806 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java @@ -49,7 +49,7 @@ public final class ServerInfoResponse { @Expose @Element - private String edition; + private ServerEdition edition; @Expose @Element(required=false) @@ -87,7 +87,7 @@ public String getDatetimeFormatPattern() { return datetimeFormatPattern; } - public String getEdition() { + public ServerEdition getEdition() { return edition; } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java index 4f8a783a..57672980 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -64,25 +64,54 @@ public void shouldParseDefaultJsonResponse() { ServerInfoResponse response = mGson.fromJson(mJsonResource.asString(), ServerInfoResponse.class); assertThat(response, is(notNullValue())); assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); + assertThat(response.getEdition(), is(ServerEdition.PRO)); } @Test public void shouldSerializeServerVersionToJson() { - String initialJson = mJsonResource.asString(); - ServerInfoResponse response = mGson.fromJson(initialJson, ServerInfoResponse.class); - JsonElement element = mGson.toJsonTree(response, ServerInfoResponse.class); + JsonElement element = serializeJson(); String serializedVersion = element.getAsJsonObject().get("version").getAsString(); assertThat(serializedVersion, is("6.1")); } + @Test + public void shouldSerializeServerEditionToJson() { + JsonElement element = serializeJson(); + String serializedVersion = element.getAsJsonObject().get("edition").getAsString(); + assertThat(serializedVersion, is("PRO")); + } + @Test public void shouldParseDefaultXmlResponse() throws Exception { ServerInfoResponse response = mSerializer.read(ServerInfoResponse.class, mXmlResource.asString()); assertThat(response, is(notNullValue())); + assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); + assertThat(response.getEdition(), is(ServerEdition.PRO)); } @Test public void shouldSerializeServerVersionToXml() throws Exception { + ServerInfoResponse[] dtoArray = serializeXml(); + ServerInfoResponse serverInfoResponse1 = dtoArray[0]; + ServerInfoResponse serverInfoResponse2 = dtoArray[1]; + assertThat(serverInfoResponse1.getVersion(), is(serverInfoResponse2.getVersion())); + } + + @Test + public void shouldSerializeServerEditionToXml() throws Exception { + ServerInfoResponse[] dtoArray = serializeXml(); + ServerInfoResponse serverInfoResponse1 = dtoArray[0]; + ServerInfoResponse serverInfoResponse2 = dtoArray[1]; + assertThat(serverInfoResponse1.getEdition(), is(serverInfoResponse2.getEdition())); + } + + private JsonElement serializeJson() { + String initialJson = mJsonResource.asString(); + ServerInfoResponse response = mGson.fromJson(initialJson, ServerInfoResponse.class); + return mGson.toJsonTree(response, ServerInfoResponse.class); + } + + private ServerInfoResponse[] serializeXml() throws Exception { String initialXml = mXmlResource.asString(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ServerInfoResponse serverInfoResponse1 = mSerializer.read(ServerInfoResponse.class, initialXml); @@ -90,6 +119,7 @@ public void shouldSerializeServerVersionToXml() throws Exception { String xml = new String(outputStream.toByteArray()); ServerInfoResponse serverInfoResponse2 = mSerializer.read(ServerInfoResponse.class, xml); - assertThat(serverInfoResponse1.getVersion(), is(serverInfoResponse2.getVersion())); + + return new ServerInfoResponse[] {serverInfoResponse1, serverInfoResponse2}; } } From 00048a852c855b02dbc4cf938eae0a025dc4a8e5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 15:01:40 +0300 Subject: [PATCH 013/457] Add FeatureSet implementation --- .../client/retrofit/server/ServerRestApi.java | 4 +- .../converter/ConverterFactoryTest.java | 4 ++ .../android/sdk/data/server/FeatureSet.java | 70 +++++++++++++++++++ .../sdk/data/server/FeaturesAdapter.java | 48 +++++++++++++ .../sdk/data/server/ServerInfoResponse.java | 13 +--- .../android/sdk/data/type/CommonMatcher.java | 11 ++- .../sdk/data/type/FeatureSetMatcher.java | 56 +++++++++++++++ .../sdk/data/type/XmlSerializerFactory.java | 1 + .../data/server/ServerInfoResponseTest.java | 28 ++++++-- 9 files changed, 217 insertions(+), 18 deletions(-) create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java index a5b1fc80..c5b5e005 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -46,7 +46,7 @@ class Builder { private final String mBaseUrl; private DataType mDataType = DataType.XML; - Builder(String baseUrl) { + public Builder(String baseUrl) { mBaseUrl = baseUrl; } diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java index 1c7c5571..38ab697a 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.client.retrofit.converter; +import com.jaspersoft.android.sdk.client.retrofit.server.ServerRestApi; import com.jaspersoft.android.sdk.data.DataType; import com.jaspersoft.android.sdk.data.type.GsonFactory; import com.jaspersoft.android.sdk.data.type.XmlSerializerFactory; @@ -76,6 +77,9 @@ public void shouldCreateGsonConverterForXMLDataType() { assertThat(converter, is(instanceOf(SimpleXMLConverter.class))); assertThat(converter, is(notNullValue())); + + ServerRestApi serverRestApi = new ServerRestApi.Builder("").build(); + serverRestApi.getServerInfo(); } @Test diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java new file mode 100644 index 00000000..1e2ca583 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java @@ -0,0 +1,70 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class FeatureSet { + private final String mRawData; + + FeatureSet(String rawData) { + mRawData = rawData; + } + + public Set asSet() { + String[] split = mRawData.split(" "); + return new HashSet<>(Arrays.asList(split)); + } + + public String asString() { + return mRawData; + } + + public static FeatureSet create(String rawString) { + return new FeatureSet(rawString); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + FeatureSet that = (FeatureSet) o; + + return !(mRawData != null ? !mRawData.equals(that.mRawData) : that.mRawData != null); + + } + + @Override + public int hashCode() { + return mRawData != null ? mRawData.hashCode() : 0; + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java new file mode 100644 index 00000000..e2fa73f1 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java @@ -0,0 +1,48 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.server; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class FeaturesAdapter extends TypeAdapter { + @Override + public void write(JsonWriter out, FeatureSet value) throws IOException { + out.value(value.asString()); + } + + @Override + public FeatureSet read(JsonReader in) throws IOException { + String rawFeatures = in.nextString(); + return FeatureSet.create(rawFeatures); + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java index ff564806..4c78ef5d 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java @@ -65,11 +65,8 @@ public final class ServerInfoResponse { @Expose @Element(required=false) - private String expiration; - - @Expose - @Element(required=false) - private String features; + @JsonAdapter(FeaturesAdapter.class) + private FeatureSet features; //--------------------------------------------------------------------- // Getters @@ -95,11 +92,7 @@ public String getEditionName() { return editionName; } - public String getExpiration() { - return expiration; - } - - public String getFeatures() { + public FeatureSet getFeatureSet() { return features; } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java index 8f21fc00..406eafe5 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java @@ -38,16 +38,23 @@ final class CommonMatcher implements Matcher { private final Collection mMatchers = new ArrayList<>(); - public void registerMatcher(Matcher matcher) { mMatchers.add(matcher); } @Override public Transform match(Class type) throws Exception { + return findTransformer(type); + } + + private Transform findTransformer(Class type) throws Exception { for (Matcher matcher : mMatchers) { - return matcher.match(type); + Transform transformer = matcher.match(type); + if (transformer != null) { + return transformer; + } } return null; } + } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java new file mode 100644 index 00000000..746e4247 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java @@ -0,0 +1,56 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.type; + +import com.jaspersoft.android.sdk.data.server.FeatureSet; + +import org.simpleframework.xml.transform.Matcher; +import org.simpleframework.xml.transform.Transform; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class FeatureSetMatcher implements Matcher { + @Override + public Transform match(Class type) throws Exception { + if (type.equals(FeatureSet.class)) { + return new FeatureSetTransformer(); + } + return null; + } + + private static class FeatureSetTransformer implements Transform { + @Override + public FeatureSet read(String value) throws Exception { + return FeatureSet.create(value); + } + + @Override + public String write(FeatureSet value) throws Exception { + return value.asString(); + } + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java index 6e18078d..6cae9804 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java @@ -45,6 +45,7 @@ public static Serializer create() { CommonMatcher commonMatcher = new CommonMatcher(); commonMatcher.registerMatcher(new ServerVersionMatcher()); + commonMatcher.registerMatcher(new FeatureSetMatcher()); return new Persister(annotationStrategy, commonMatcher); } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java index 57672980..b1cb106a 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -39,6 +39,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsCollectionContaining.hasItems; import static org.hamcrest.core.IsNull.notNullValue; /** @@ -63,8 +64,7 @@ public void setup() { public void shouldParseDefaultJsonResponse() { ServerInfoResponse response = mGson.fromJson(mJsonResource.asString(), ServerInfoResponse.class); assertThat(response, is(notNullValue())); - assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); - assertThat(response.getEdition(), is(ServerEdition.PRO)); + assertFields(response); } @Test @@ -81,12 +81,18 @@ public void shouldSerializeServerEditionToJson() { assertThat(serializedVersion, is("PRO")); } + @Test + public void shouldSerializeFeaturesToJson() { + JsonElement element = serializeJson(); + String serializedVersion = element.getAsJsonObject().get("features").getAsString(); + assertThat(serializedVersion, is("Fusion AHD EXP DB AUD ANA MT ")); + } + @Test public void shouldParseDefaultXmlResponse() throws Exception { ServerInfoResponse response = mSerializer.read(ServerInfoResponse.class, mXmlResource.asString()); assertThat(response, is(notNullValue())); - assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); - assertThat(response.getEdition(), is(ServerEdition.PRO)); + assertFields(response); } @Test @@ -105,6 +111,20 @@ public void shouldSerializeServerEditionToXml() throws Exception { assertThat(serverInfoResponse1.getEdition(), is(serverInfoResponse2.getEdition())); } + @Test + public void shouldSerializeFeaturesToXml() throws Exception { + ServerInfoResponse[] dtoArray = serializeXml(); + ServerInfoResponse serverInfoResponse1 = dtoArray[0]; + ServerInfoResponse serverInfoResponse2 = dtoArray[1]; + assertThat(serverInfoResponse1.getFeatureSet(), is(serverInfoResponse2.getFeatureSet())); + } + + private void assertFields(ServerInfoResponse response) { + assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); + assertThat(response.getEdition(), is(ServerEdition.PRO)); + assertThat(response.getFeatureSet().asSet(), hasItems("Fusion", "AHD", "EXP", "DB", "AUD", "ANA", "MT")); + } + private JsonElement serializeJson() { String initialJson = mJsonResource.asString(); ServerInfoResponse response = mGson.fromJson(initialJson, ServerInfoResponse.class); From 5eaccd86c29f70f68d582908948344729bf10049 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 15:50:43 +0300 Subject: [PATCH 014/457] Remove XML support --- client-retrofit/build.gradle | 10 +- .../retrofit/converter/ConverterFactory.java | 52 ----------- .../client/retrofit/server/RestBuilder.java | 39 ++++---- .../client/retrofit/server/ServerRestApi.java | 37 +------- .../converter/ConverterFactoryTest.java | 91 ------------------- .../retrofit/server/ServerRestApiTest.java | 39 +++----- data/build.gradle | 5 - .../jaspersoft/android/sdk/data/DataType.java | 9 -- .../sdk/data/server/ServerInfoResponse.java | 12 --- .../sdk/data/type/ServerVersionMatcher.java | 56 ------------ .../sdk/data/type/XmlSerializerFactory.java | 52 ----------- .../data/server/ServerInfoResponseTest.java | 59 +----------- .../data/{json => type}/GsonFactoryTest.java | 3 +- .../data/type/XmlSerializerFactoryTest.java | 73 --------------- .../resources/xml/default_server_info.xml | 12 --- 15 files changed, 41 insertions(+), 508 deletions(-) delete mode 100644 client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java rename data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java => client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java (57%) delete mode 100644 client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java rename data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java => client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java (56%) delete mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java delete mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java delete mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java rename data/src/test/java/com/jaspersoft/android/sdk/data/{json => type}/GsonFactoryTest.java (96%) delete mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactoryTest.java delete mode 100644 data/src/test/resources/xml/default_server_info.xml diff --git a/client-retrofit/build.gradle b/client-retrofit/build.gradle index 1b4d220e..a79f90fd 100644 --- a/client-retrofit/build.gradle +++ b/client-retrofit/build.gradle @@ -7,16 +7,8 @@ repositories { dependencies { compile project(':js-android-sdk-data') compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' - compile 'com.squareup.retrofit:converter-simplexml:1.9.0' + compile 'com.squareup.retrofit:retrofit:1.9.0' testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' - testCompile ('org.powermock:powermock-api-mockito:1.6.2') { - exclude module: 'hamcrest-core' - exclude module: 'objenesis' - } - testCompile ('org.powermock:powermock-module-junit4:1.6.2') { - exclude module: 'hamcrest-core' - exclude module: 'objenesis' - } } \ No newline at end of file diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java deleted file mode 100644 index 1f5fc238..00000000 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.retrofit.converter; - -import com.jaspersoft.android.sdk.data.DataType; -import com.jaspersoft.android.sdk.data.type.GsonFactory; -import com.jaspersoft.android.sdk.data.type.XmlSerializerFactory; - -import retrofit.converter.Converter; -import retrofit.converter.GsonConverter; -import retrofit.converter.SimpleXMLConverter; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ConverterFactory { - public static Converter create(DataType dataType) { - if (dataType == null) { - throw new IllegalArgumentException("DataType should not be null"); - } - if (dataType == DataType.JSON) { - return new GsonConverter(GsonFactory.create()); - } - if (dataType == DataType.XML) { - return new SimpleXMLConverter(XmlSerializerFactory.create()); - } - throw new UnsupportedOperationException("Supplied DataType[ " + dataType + " ] invalid"); - } -} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java similarity index 57% rename from data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java index 746e4247..f950e553 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/FeatureSetMatcher.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java @@ -22,35 +22,32 @@ * . */ -package com.jaspersoft.android.sdk.data.type; +package com.jaspersoft.android.sdk.client.retrofit.server; -import com.jaspersoft.android.sdk.data.server.FeatureSet; - -import org.simpleframework.xml.transform.Matcher; -import org.simpleframework.xml.transform.Transform; +import retrofit.Endpoint; +import retrofit.Endpoints; +import retrofit.RestAdapter; /** * @author Tom Koptel * @since 2.0 */ -final class FeatureSetMatcher implements Matcher { - @Override - public Transform match(Class type) throws Exception { - if (type.equals(FeatureSet.class)) { - return new FeatureSetTransformer(); - } - return null; +abstract class RestBuilder { + private final String mBaseUrl; + + public RestBuilder(String baseUrl) { + mBaseUrl = baseUrl; } - private static class FeatureSetTransformer implements Transform { - @Override - public FeatureSet read(String value) throws Exception { - return FeatureSet.create(value); - } + protected abstract Api createApiService(RestAdapter restAdapter); + + public Api build() { + Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); + + RestAdapter.Builder builder = new RestAdapter.Builder(); + builder.setEndpoint(endpoint); + RestAdapter restAdapter = builder.build(); - @Override - public String write(FeatureSet value) throws Exception { - return value.asString(); - } + return createApiService(restAdapter); } } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java index c5b5e005..a627d564 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java @@ -24,12 +24,8 @@ package com.jaspersoft.android.sdk.client.retrofit.server; -import com.jaspersoft.android.sdk.client.retrofit.converter.ConverterFactory; -import com.jaspersoft.android.sdk.data.DataType; import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; -import retrofit.Endpoint; -import retrofit.Endpoints; import retrofit.RestAdapter; import retrofit.http.GET; @@ -38,41 +34,16 @@ * @since 2.0 */ public interface ServerRestApi { - @GET(value = "/rest_v2/serverInfo") ServerInfoResponse getServerInfo(); - class Builder { - private final String mBaseUrl; - private DataType mDataType = DataType.XML; - + class Builder extends RestBuilder { public Builder(String baseUrl) { - mBaseUrl = baseUrl; - } - - public Builder setDataType(DataType dataType) { - mDataType = dataType; - return this; - } - - public Builder consumeJson() { - mDataType = DataType.JSON; - return this; - } - - public Builder consumeXml() { - mDataType = DataType.JSON; - return this; + super(baseUrl); } - public ServerRestApi build() { - Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); - - RestAdapter.Builder builder = new RestAdapter.Builder(); - builder.setConverter(ConverterFactory.create(mDataType)); - builder.setEndpoint(endpoint); - RestAdapter restAdapter = builder.build(); - + @Override + protected ServerRestApi createApiService(RestAdapter restAdapter) { return restAdapter.create(ServerRestApi.class); } } diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java deleted file mode 100644 index 38ab697a..00000000 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/converter/ConverterFactoryTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.retrofit.converter; - -import com.jaspersoft.android.sdk.client.retrofit.server.ServerRestApi; -import com.jaspersoft.android.sdk.data.DataType; -import com.jaspersoft.android.sdk.data.type.GsonFactory; -import com.jaspersoft.android.sdk.data.type.XmlSerializerFactory; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import retrofit.converter.Converter; -import retrofit.converter.GsonConverter; -import retrofit.converter.SimpleXMLConverter; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.mockito.Mockito.times; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ConverterFactory.class, GsonFactory.class, XmlSerializerFactory.class}) -public class ConverterFactoryTest { - @Rule - public ExpectedException mException = ExpectedException.none(); - - @Test - public void shouldCreateGsonConverterForJsonDataType() { - PowerMockito.mockStatic(GsonFactory.class); - Converter converter = ConverterFactory.create(DataType.JSON); - - PowerMockito.verifyStatic(times(1)); - - assertThat(converter, is(instanceOf(GsonConverter.class))); - assertThat(converter, is(notNullValue())); - } - - @Test - public void shouldCreateGsonConverterForXMLDataType() { - PowerMockito.mockStatic(XmlSerializerFactory.class); - Converter converter = ConverterFactory.create(DataType.XML); - - PowerMockito.verifyStatic(times(1)); - - assertThat(converter, is(instanceOf(SimpleXMLConverter.class))); - assertThat(converter, is(notNullValue())); - - ServerRestApi serverRestApi = new ServerRestApi.Builder("").build(); - serverRestApi.getServerInfo(); - } - - @Test - public void shouldThrowExceptionIfDataTypeNull() { - mException.expectMessage("DataType should not be null"); - mException.expect(IllegalArgumentException.class); - ConverterFactory.create(null); - } -} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java similarity index 56% rename from data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java index 406eafe5..34f7c1aa 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/CommonMatcher.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java @@ -22,39 +22,28 @@ * . */ -package com.jaspersoft.android.sdk.data.type; +package com.jaspersoft.android.sdk.client.retrofit.server; -import org.simpleframework.xml.transform.Matcher; -import org.simpleframework.xml.transform.Transform; +import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; -import java.util.ArrayList; -import java.util.Collection; +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; /** * @author Tom Koptel * @since 2.0 */ -final class CommonMatcher implements Matcher { - - private final Collection mMatchers = new ArrayList<>(); - - public void registerMatcher(Matcher matcher) { - mMatchers.add(matcher); - } +public class ServerRestApiTest { - @Override - public Transform match(Class type) throws Exception { - return findTransformer(type); - } + String fixedEndpoint = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; - private Transform findTransformer(Class type) throws Exception { - for (Matcher matcher : mMatchers) { - Transform transformer = matcher.match(type); - if (transformer != null) { - return transformer; - } - } - return null; + @Test + public void shouldRequestServerInfo() { + ServerRestApi restApi = new ServerRestApi.Builder(fixedEndpoint).build(); + ServerInfoResponse response = restApi.getServerInfo(); + assertThat(response, is(notNullValue())); } - } diff --git a/data/build.gradle b/data/build.gradle index d3c2fa27..a6f28d78 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -5,11 +5,6 @@ repositories { } dependencies { - compile('org.simpleframework:simple-xml:2.7') { - exclude group: 'stax', module: 'stax' - exclude group: 'stax', module: 'stax-api' - exclude group: 'xpp3', module: 'xpp3' - } compile 'com.google.code.gson:gson:2.3.1' testCompile 'junit:junit:4.12' diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java b/data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java deleted file mode 100644 index 312ab7fe..00000000 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/DataType.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jaspersoft.android.sdk.data; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public enum DataType { - XML, JSON -} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java index 4c78ef5d..6c9ec6aa 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java @@ -24,47 +24,35 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.JsonAdapter; -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - /** * @author Tom Koptel * @since 2.0 */ -@Root(strict=false) public final class ServerInfoResponse { @Expose - @Element private String dateFormatPattern; @Expose - @Element private String datetimeFormatPattern; @Expose - @Element @JsonAdapter(ServerVersionAdapter.class) private ServerVersion version; @Expose - @Element private ServerEdition edition; @Expose - @Element(required=false) private String licenseType; @Expose - @Element(required=false) private String build; @Expose - @Element(required=false) private String editionName; @Expose - @Element(required=false) @JsonAdapter(FeaturesAdapter.class) private FeatureSet features; diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java deleted file mode 100644 index 7dba547e..00000000 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/ServerVersionMatcher.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.data.type; - -import com.jaspersoft.android.sdk.data.server.ServerVersion; - -import org.simpleframework.xml.transform.Matcher; -import org.simpleframework.xml.transform.Transform; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ServerVersionMatcher implements Matcher { - @Override - public Transform match(Class type) throws Exception { - if (type.equals(ServerVersion.class)) { - return new ServerVersionTransformer(); - } - return null; - } - - private static class ServerVersionTransformer implements Transform { - @Override - public ServerVersion read(String value) throws Exception { - return ServerVersion.defaultParser().parse(value); - } - - @Override - public String write(ServerVersion value) throws Exception { - return value.getRawValue(); - } - } -} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java deleted file mode 100644 index 6cae9804..00000000 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.data.type; - -import org.simpleframework.xml.Serializer; -import org.simpleframework.xml.convert.AnnotationStrategy; -import org.simpleframework.xml.core.Persister; -import org.simpleframework.xml.strategy.Strategy; -import org.simpleframework.xml.transform.Matcher; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class XmlSerializerFactory { - public static Serializer create() { - Strategy annotationStrategy = new AnnotationStrategy(); - Collection matchers = new ArrayList<>(); - matchers.add(new ServerVersionMatcher()); - - CommonMatcher commonMatcher = new CommonMatcher(); - commonMatcher.registerMatcher(new ServerVersionMatcher()); - commonMatcher.registerMatcher(new FeatureSetMatcher()); - - return new Persister(annotationStrategy, commonMatcher); - } -} diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java index b1cb106a..cd05c1cf 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -26,16 +26,12 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.jaspersoft.android.sdk.data.type.GsonFactory; -import com.jaspersoft.android.sdk.data.type.XmlSerializerFactory; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import org.junit.Before; import org.junit.Test; -import org.simpleframework.xml.Serializer; - -import java.io.ByteArrayOutputStream; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -49,11 +45,8 @@ public class ServerInfoResponseTest { @ResourceFile("json/default_server_info.json") TestResource mJsonResource; - @ResourceFile("xml/default_server_info.xml") - TestResource mXmlResource; Gson mGson = GsonFactory.create(); - Serializer mSerializer = XmlSerializerFactory.create(); @Before public void setup() { @@ -64,7 +57,9 @@ public void setup() { public void shouldParseDefaultJsonResponse() { ServerInfoResponse response = mGson.fromJson(mJsonResource.asString(), ServerInfoResponse.class); assertThat(response, is(notNullValue())); - assertFields(response); + assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); + assertThat(response.getEdition(), is(ServerEdition.PRO)); + assertThat(response.getFeatureSet().asSet(), hasItems("Fusion", "AHD", "EXP", "DB", "AUD", "ANA", "MT")); } @Test @@ -88,58 +83,10 @@ public void shouldSerializeFeaturesToJson() { assertThat(serializedVersion, is("Fusion AHD EXP DB AUD ANA MT ")); } - @Test - public void shouldParseDefaultXmlResponse() throws Exception { - ServerInfoResponse response = mSerializer.read(ServerInfoResponse.class, mXmlResource.asString()); - assertThat(response, is(notNullValue())); - assertFields(response); - } - - @Test - public void shouldSerializeServerVersionToXml() throws Exception { - ServerInfoResponse[] dtoArray = serializeXml(); - ServerInfoResponse serverInfoResponse1 = dtoArray[0]; - ServerInfoResponse serverInfoResponse2 = dtoArray[1]; - assertThat(serverInfoResponse1.getVersion(), is(serverInfoResponse2.getVersion())); - } - - @Test - public void shouldSerializeServerEditionToXml() throws Exception { - ServerInfoResponse[] dtoArray = serializeXml(); - ServerInfoResponse serverInfoResponse1 = dtoArray[0]; - ServerInfoResponse serverInfoResponse2 = dtoArray[1]; - assertThat(serverInfoResponse1.getEdition(), is(serverInfoResponse2.getEdition())); - } - - @Test - public void shouldSerializeFeaturesToXml() throws Exception { - ServerInfoResponse[] dtoArray = serializeXml(); - ServerInfoResponse serverInfoResponse1 = dtoArray[0]; - ServerInfoResponse serverInfoResponse2 = dtoArray[1]; - assertThat(serverInfoResponse1.getFeatureSet(), is(serverInfoResponse2.getFeatureSet())); - } - - private void assertFields(ServerInfoResponse response) { - assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); - assertThat(response.getEdition(), is(ServerEdition.PRO)); - assertThat(response.getFeatureSet().asSet(), hasItems("Fusion", "AHD", "EXP", "DB", "AUD", "ANA", "MT")); - } - private JsonElement serializeJson() { String initialJson = mJsonResource.asString(); ServerInfoResponse response = mGson.fromJson(initialJson, ServerInfoResponse.class); return mGson.toJsonTree(response, ServerInfoResponse.class); } - private ServerInfoResponse[] serializeXml() throws Exception { - String initialXml = mXmlResource.asString(); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ServerInfoResponse serverInfoResponse1 = mSerializer.read(ServerInfoResponse.class, initialXml); - mSerializer.write(serverInfoResponse1, outputStream); - - String xml = new String(outputStream.toByteArray()); - ServerInfoResponse serverInfoResponse2 = mSerializer.read(ServerInfoResponse.class, xml); - - return new ServerInfoResponse[] {serverInfoResponse1, serverInfoResponse2}; - } } diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/json/GsonFactoryTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java similarity index 96% rename from data/src/test/java/com/jaspersoft/android/sdk/data/json/GsonFactoryTest.java rename to data/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java index 17c2f35a..bbd5ae93 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/json/GsonFactoryTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java @@ -22,11 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.data.json; +package com.jaspersoft.android.sdk.data.type; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.data.type.GsonFactory; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactoryTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactoryTest.java deleted file mode 100644 index 4c2edb34..00000000 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/type/XmlSerializerFactoryTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.data.type; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.simpleframework.xml.Serializer; -import org.simpleframework.xml.convert.AnnotationStrategy; -import org.simpleframework.xml.core.Persister; -import org.simpleframework.xml.strategy.Strategy; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.powermock.api.mockito.PowerMockito.whenNew; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(com.jaspersoft.android.sdk.data.type.XmlSerializerFactory.class) -public class XmlSerializerFactoryTest { - @Mock - Persister mPersister; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void shouldCreatePersisterWithAnnotationStrategy() throws Exception { - whenNew(Persister.class).withParameterTypes(Strategy.class).withArguments(Mockito.any(Strategy.class)).thenReturn(mPersister); - com.jaspersoft.android.sdk.data.type.XmlSerializerFactory.create(); - PowerMockito.verifyNew(Persister.class).withArguments(Mockito.any(AnnotationStrategy.class)); - } - - @Test - public void shouldCreateSerializerInstance() { - Serializer serializer = com.jaspersoft.android.sdk.data.type.XmlSerializerFactory.create(); - assertThat(serializer, is(notNullValue())); - } -} diff --git a/data/src/test/resources/xml/default_server_info.xml b/data/src/test/resources/xml/default_server_info.xml deleted file mode 100644 index b2b0bd0a..00000000 --- a/data/src/test/resources/xml/default_server_info.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - 20150527_1447 - yyyy-MM-dd - yyyy-MM-dd'T'HH:mm:ss - PRO - Enterprise for AWS - Fusion AHD EXP DB AUD ANA MT - Commercial - 6.1 - \ No newline at end of file From a713ec884fd12d19e7651d047cdca5a8cedf54d8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 15:58:02 +0300 Subject: [PATCH 015/457] Fix version parser test --- .../jaspersoft/android/sdk/data/server/ServerVersionTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java index c40739a3..7779cce6 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java @@ -62,9 +62,9 @@ public void shouldParseSemanticVersioning(String versionCode, String enumName) { "5.2, EMERALD_MR1", "5.5, EMERALD_MR2", "5.6, EMERALD_MR3", - "5.61, EMERALD_MR4", + "5.6.1, EMERALD_MR4", "6.0, AMBER", - "6.01, AMBER_MR1", + "6.0.1, AMBER_MR1", "6.1, AMBER_MR2", }) public void shouldParseCode(String versionCode, String enumName) { From 5efce3cbdb7b1bdb7e75f38df2c10edac5c1fd9f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 5 Aug 2015 16:44:15 +0300 Subject: [PATCH 016/457] Converting client layer to android module structure --- client-retrofit/build.gradle | 51 +++++++++++++++++-- client-retrofit/src/main/AndroidManifest.xml | 31 +++++++++++ .../client/retrofit/server/RestBuilder.java | 4 ++ .../client/retrofit/server/ServerRestApi.java | 5 ++ .../retrofit/server/ServerRestApiTest.java | 24 +++++++-- 5 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 client-retrofit/src/main/AndroidManifest.xml diff --git a/client-retrofit/build.gradle b/client-retrofit/build.gradle index a79f90fd..3466847d 100644 --- a/client-retrofit/build.gradle +++ b/client-retrofit/build.gradle @@ -1,14 +1,57 @@ -apply plugin: 'java' +apply plugin: 'com.android.library' -repositories { - jcenter() +android { + compileSdkVersion androidCompileSdkVersion + buildToolsVersion androidBuildToolsVersion + + defaultConfig { + minSdkVersion androidMinSdkVersion + targetSdkVersion androidTargetSdkVersion + versionCode clientModuleVersionCode + versionName version + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + encoding 'ISO-8859-1' + } + packagingOptions { + exclude 'META-INF/notice.txt' + exclude 'META-INF/license.txt' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/NOTICE.txt' + } + lintOptions { + abortOnError false + } + + buildTypes { + debug { + minifyEnabled false + } + } } dependencies { compile project(':js-android-sdk-data') compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' - compile 'com.squareup.retrofit:retrofit:1.9.0' + compile 'com.squareup.retrofit:converter-simplexml:1.9.0' testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' + + testCompile('org.robolectric:shadows-support-v4:3.0-rc3') { + exclude group: 'commons-logging', module: 'commons-logging' + exclude group: 'org.apache.httpcomponents', module: 'httpclient' + } + testCompile 'org.robolectric:shadows-httpclient:3.0-rc3' + + testCompile ('org.powermock:powermock-api-mockito:1.6.2') { + exclude module: 'hamcrest-core' + exclude module: 'objenesis' + } + testCompile ('org.powermock:powermock-module-junit4:1.6.2') { + exclude module: 'hamcrest-core' + exclude module: 'objenesis' + } } \ No newline at end of file diff --git a/client-retrofit/src/main/AndroidManifest.xml b/client-retrofit/src/main/AndroidManifest.xml new file mode 100644 index 00000000..fdd84fe6 --- /dev/null +++ b/client-retrofit/src/main/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java index f950e553..66607e47 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java @@ -24,9 +24,12 @@ package com.jaspersoft.android.sdk.client.retrofit.server; +import com.jaspersoft.android.sdk.data.json.GsonFactory; + import retrofit.Endpoint; import retrofit.Endpoints; import retrofit.RestAdapter; +import retrofit.converter.GsonConverter; /** * @author Tom Koptel @@ -46,6 +49,7 @@ public Api build() { RestAdapter.Builder builder = new RestAdapter.Builder(); builder.setEndpoint(endpoint); + builder.setConverter(new GsonConverter(GsonFactory.create())); RestAdapter restAdapter = builder.build(); return createApiService(restAdapter); diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java index a627d564..14ed2423 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java @@ -24,16 +24,21 @@ package com.jaspersoft.android.sdk.client.retrofit.server; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; import retrofit.RestAdapter; import retrofit.http.GET; +import retrofit.http.Headers; /** * @author Tom Koptel * @since 2.0 */ public interface ServerRestApi { + @NonNull + @Headers("Accept: application/json") @GET(value = "/rest_v2/serverInfo") ServerInfoResponse getServerInfo(); diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java index 34f7c1aa..aea6ba00 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java @@ -24,9 +24,17 @@ package com.jaspersoft.android.sdk.client.retrofit.server; + import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; +import org.robolectric.shadows.FakeHttp; + +import java.io.IOException; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -36,14 +44,22 @@ * @author Tom Koptel * @since 2.0 */ +@RunWith(RobolectricTestRunner.class) +@Config(manifest = Config.NONE) public class ServerRestApiTest { - String fixedEndpoint = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + + @Before + public void setup() { + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + } @Test - public void shouldRequestServerInfo() { - ServerRestApi restApi = new ServerRestApi.Builder(fixedEndpoint).build(); - ServerInfoResponse response = restApi.getServerInfo(); + public void shouldRequestServerInfo() throws IOException { + ServerRestApi api = new ServerRestApi.Builder(mobileDemo2).build(); + ServerInfoResponse response = api.getServerInfo(); assertThat(response, is(notNullValue())); } + } From 27598243285e47dcc5d96b48cc1aa991e9b11eb9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 11:38:36 +0300 Subject: [PATCH 017/457] Implementing ResourceLookup entity --- .../retrofit/server/RepositoryRestApi.java | 33 ++++++ .../sdk/data/resource/ResourceLookup.java | 104 ++++++++++++++++++ .../sdk/data/resource/ResourceType.java | 71 ++++++++++++ .../data/resource/ResourceTypeAdapter.java | 48 ++++++++ .../type/CustomizedTypeAdapterFactory.java | 87 +++++++++++++++ .../android/sdk/data/type/GsonFactory.java | 1 + .../ResourceLookupTypeAdapterFactory.java | 52 +++++++++ .../resource/ResourceLookupConvertTest.java | 66 +++++++++++ .../sdk/data/resource/ResourceTypeTest.java | 56 ++++++++++ .../test/resources/json/all_resources.json | 83 ++++++++++++++ 10 files changed, 601 insertions(+) create mode 100644 client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RepositoryRestApi.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java create mode 100644 data/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java create mode 100644 data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java create mode 100644 data/src/test/resources/json/all_resources.json diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RepositoryRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RepositoryRestApi.java new file mode 100644 index 00000000..4191e753 --- /dev/null +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RepositoryRestApi.java @@ -0,0 +1,33 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.retrofit.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RepositoryRestApi { + +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java b/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java new file mode 100644 index 00000000..81704e2b --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile SDK for Android. + * + * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.resource; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.JsonAdapter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ResourceLookup { + + @Expose + private String label; + @Expose + private String description; + @Expose + private String uri; + @Expose + @JsonAdapter(ResourceTypeAdapter.class) + private ResourceType resourceType; + + @Expose + private int version; + @Expose + private int permissionMask; + @Expose + private String creationDate; + @Expose + private String updateDate; + + //--------------------------------------------------------------------- + // Getters + //--------------------------------------------------------------------- + + public String getCreationDate() { + return creationDate; + } + + public String getDescription() { + return description; + } + + public String getLabel() { + return label; + } + + public int getPermissionMask() { + return permissionMask; + } + + public ResourceType getResourceType() { + return resourceType; + } + + public String getUpdateDate() { + return updateDate; + } + + public String getUri() { + return uri; + } + + public int getVersion() { + return version; + } + + @Override + public String toString() { + return "ResourceLookup{" + + "creationDate='" + creationDate + '\'' + + ", label='" + label + '\'' + + ", description='" + description + '\'' + + ", uri='" + uri + '\'' + + ", resourceType=" + resourceType + + ", version=" + version + + ", permissionMask=" + permissionMask + + ", updateDate='" + updateDate + '\'' + + '}'; + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java b/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java new file mode 100644 index 00000000..51946aa7 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java @@ -0,0 +1,71 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.resource; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum ResourceType { + folder, + reportUnit, + dashboard, + legacyDashboard, + file, + semanticLayerDataSource, + jndiJdbcDataSource, + unknown { + private String rawValue; + + @Override + void setRawValue(String value) { + rawValue = value; + } + + @Override + public String getRawValue() { + return rawValue; + } + }; + + static ResourceType parseRawValue(String rawValue) { + ResourceType type; + try { + type = ResourceType.valueOf(rawValue); + } catch (IllegalArgumentException ex) { + type = ResourceType.unknown; + type.setRawValue(rawValue); + } + return type; + } + + void setRawValue(String value) { + throw new UnsupportedOperationException(); + } + + public String getRawValue() { + return String.valueOf(this); + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java b/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java new file mode 100644 index 00000000..fe7cfd7d --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.resource; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ResourceTypeAdapter extends TypeAdapter { + @Override + public void write(JsonWriter out, ResourceType type) throws IOException { + out.value(type.getRawValue()); + } + + @Override + public ResourceType read(JsonReader in) throws IOException { + String rawValue = in.nextString(); + return ResourceType.parseRawValue(rawValue); + } +} diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java new file mode 100644 index 00000000..b762e7e0 --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java @@ -0,0 +1,87 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.type; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class CustomizedTypeAdapterFactory + implements TypeAdapterFactory { + private final Class customizedClass; + + public CustomizedTypeAdapterFactory(Class customizedClass) { + this.customizedClass = customizedClass; + } + + @SuppressWarnings("unchecked") // we use a runtime check to guarantee that 'C' and 'T' are equal + public final TypeAdapter create(Gson gson, TypeToken type) { + return type.getRawType() == customizedClass + ? (TypeAdapter) customizeMyClassAdapter(gson, (TypeToken) type) + : null; + } + + private TypeAdapter customizeMyClassAdapter(Gson gson, TypeToken type) { + final TypeAdapter delegate = gson.getDelegateAdapter(this, type); + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + return new TypeAdapter() { + @Override public void write(JsonWriter out, C value) throws IOException { + JsonElement tree = delegate.toJsonTree(value); + beforeWrite(value, tree); + elementAdapter.write(out, tree); + } + @Override public C read(JsonReader in) throws IOException { + JsonElement tree = elementAdapter.read(in); + tree = afterRead(tree); + return delegate.fromJsonTree(tree); + } + }; + } + + /** + * Override this to muck with {@code toSerialize} before it is written to + * the outgoing JSON stream. + */ + protected void beforeWrite(C source, JsonElement toSerialize) { + } + + /** + * Override this to muck with {@code deserialized} before it parsed into + * the application type. + */ + protected JsonElement afterRead(JsonElement deserialized) { + return deserialized; + } +} \ No newline at end of file diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java index 8b61626a..2d605d36 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java @@ -36,6 +36,7 @@ public static Gson create() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.excludeFieldsWithoutExposeAnnotation(); gsonBuilder.disableHtmlEscaping(); + gsonBuilder.registerTypeAdapterFactory(new ResourceLookupTypeAdapterFactory()); return gsonBuilder.create(); } } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java b/data/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java new file mode 100644 index 00000000..c830b35a --- /dev/null +++ b/data/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.type; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import com.jaspersoft.android.sdk.data.resource.ResourceLookup; + +import java.util.Collection; + + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { + static final TypeToken TOKEN_TYPE = new TypeToken>(){}; + + @SuppressWarnings("unchecked") + public ResourceLookupTypeAdapterFactory() { + super(TOKEN_TYPE.getRawType()); + } + + @Override + protected JsonElement afterRead(JsonElement deserialized) { + JsonObject jsonObject = deserialized.getAsJsonObject(); + return jsonObject.get("resourceLookup").getAsJsonArray(); + } +} diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java new file mode 100644 index 00000000..729e9184 --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java @@ -0,0 +1,66 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.resource; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; +import org.junit.Test; + +import java.lang.reflect.Type; +import java.util.Collection; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ResourceLookupConvertTest { + @ResourceFile("json/all_resources.json") + TestResource mJsonResources; + + Gson mGson = GsonFactory.create(); + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + + @Test + public void shouldDeserializeCollectionFromJson() { + Type type = new TypeToken>(){}.getType(); + Collection resourceLookups = mGson.fromJson(mJsonResources.asString(), type); + assertThat(resourceLookups.size(), is(not(0))); + } + +} diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java b/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java new file mode 100644 index 00000000..7bdda44f --- /dev/null +++ b/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java @@ -0,0 +1,56 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.data.resource; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ResourceTypeTest { + @Test + @Parameters({"folder", "reportUnit", "dashboard", "legacyDashboard", "file", "semanticLayerDataSource", "jndiJdbcDataSource"}) + public void shouldProvideTypeForKnownResourceTypes(String type) { + ResourceType resourceType = ResourceType.valueOf(type); + assertThat(ResourceType.parseRawValue(type), is(resourceType)); + } + + @Test + public void shouldReturnUnkownTypeForMissingMapping() { + ResourceType resourceType = ResourceType.parseRawValue("someStrangeType"); + assertThat(resourceType, is(notNullValue())); + assertThat(resourceType.getRawValue(), is("someStrangeType")); + } +} diff --git a/data/src/test/resources/json/all_resources.json b/data/src/test/resources/json/all_resources.json new file mode 100644 index 00000000..7cc3df21 --- /dev/null +++ b/data/src/test/resources/json/all_resources.json @@ -0,0 +1,83 @@ +{ + "resourceLookup": [ + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:11", + "updateDate": "2014-05-14T17:38:49", + "label": "01. Geographic Results by Segment", + "description": "Sample HTML5 multi-axis column chart from Domain showing Sales, Units, and $ Per Square Foot by Country and Store Type with various filters", + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment", + "resourceType": "adhocDataView" + }, + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:12", + "updateDate": "2014-04-25T16:06:57", + "label": "03. Store Segment Performance Report", + "description": "Sample OLAP chart with HTML5 Grouped Bar chart and Filter. Created from an Ad Hoc View.", + "uri": "/public/Samples/Reports/03._Store_Segment_Performance_Report", + "resourceType": "reportUnit" + }, + { + "version": 1, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:37", + "updateDate": "2015-05-04T21:05:55", + "label": "1. Supermart Dashboard", + "description": "Sample containing 5 Dashlets and Filter wiring. One Dashlet is a report with hyperlinks, the other Dashlets are defined as part of the Dashboard.", + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard", + "resourceType": "dashboard" + }, + { + "version": 1, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:39", + "updateDate": "2015-04-20T20:46:58", + "label": "3.1 Sales Metrics", + "description": "Sample containing Sales related data, hyperlinks, and a hidden filter for embedded Visualize.js demo.", + "uri": "/public/Samples/Dashboards/3.1_Sales_Metrics", + "resourceType": "legacyDashboard" + }, + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-04T13:26:23", + "updateDate": "2015-05-27T22:03:29", + "label": "A4 Landscape", + "uri": "/public/templates/a4_landscape.510.jrxml", + "resourceType": "file" + }, + { + "version": 0, + "permissionMask": 1, + "creationDate": "2015-01-13T01:00:33", + "updateDate": "2014-12-18T09:59:47", + "label": "Ad Hoc Components", + "description": "Ad Hoc Components", + "uri": "/public/adhoc", + "resourceType": "folder" + }, + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-04T13:26:25", + "updateDate": "2015-05-27T22:03:38", + "label": "Audit Archive Domain", + "description": "Use this domain to build audit archive reports", + "uri": "/public/audit/domains/AuditArchiveDomain", + "resourceType": "semanticLayerDataSource" + }, + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-04T13:26:24", + "updateDate": "2015-05-27T22:03:36", + "label": "Audit Data Source", + "description": "Audit Data Source", + "uri": "/public/audit/datasources/AuditDataSource", + "resourceType": "jndiJdbcDataSource" + } + ] +} \ No newline at end of file From aad5e93c7c7182ef4f20dcbe247278a10d87ce33 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 11:47:19 +0300 Subject: [PATCH 018/457] Grouping interfaces into rest package --- .../v2/repository}/RepositoryRestApi.java | 2 +- .../{ => rest/v2}/server/ServerRestApi.java | 22 +++++-- .../client/retrofit/server/RestBuilder.java | 57 ------------------- .../v2}/server/ServerRestApiTest.java | 2 +- 4 files changed, 19 insertions(+), 64 deletions(-) rename client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/{server => rest/v2/repository}/RepositoryRestApi.java (93%) rename client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/{ => rest/v2}/server/ServerRestApi.java (70%) delete mode 100644 client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java rename client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/{ => rest/v2}/server/ServerRestApiTest.java (96%) diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RepositoryRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java similarity index 93% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RepositoryRestApi.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java index 4191e753..a98a91a4 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RepositoryRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.client.retrofit.server; +package com.jaspersoft.android.sdk.client.retrofit.rest.v2.repository; /** * @author Tom Koptel diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java similarity index 70% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java index 14ed2423..a3cdfd5a 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java @@ -22,13 +22,17 @@ * . */ -package com.jaspersoft.android.sdk.client.retrofit.server; +package com.jaspersoft.android.sdk.client.retrofit.rest.v2.server; import android.support.annotation.NonNull; +import com.jaspersoft.android.sdk.data.json.GsonFactory; import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; +import retrofit.Endpoint; +import retrofit.Endpoints; import retrofit.RestAdapter; +import retrofit.converter.GsonConverter; import retrofit.http.GET; import retrofit.http.Headers; @@ -42,13 +46,21 @@ public interface ServerRestApi { @GET(value = "/rest_v2/serverInfo") ServerInfoResponse getServerInfo(); - class Builder extends RestBuilder { + class Builder { + private final String mBaseUrl; + public Builder(String baseUrl) { - super(baseUrl); + mBaseUrl = baseUrl; } - @Override - protected ServerRestApi createApiService(RestAdapter restAdapter) { + public ServerRestApi build() { + Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); + + RestAdapter.Builder builder = new RestAdapter.Builder(); + builder.setEndpoint(endpoint); + builder.setConverter(new GsonConverter(GsonFactory.create())); + RestAdapter restAdapter = builder.build(); + return restAdapter.create(ServerRestApi.class); } } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java deleted file mode 100644 index 66607e47..00000000 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/server/RestBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.retrofit.server; - -import com.jaspersoft.android.sdk.data.json.GsonFactory; - -import retrofit.Endpoint; -import retrofit.Endpoints; -import retrofit.RestAdapter; -import retrofit.converter.GsonConverter; - -/** - * @author Tom Koptel - * @since 2.0 - */ -abstract class RestBuilder { - private final String mBaseUrl; - - public RestBuilder(String baseUrl) { - mBaseUrl = baseUrl; - } - - protected abstract Api createApiService(RestAdapter restAdapter); - - public Api build() { - Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); - - RestAdapter.Builder builder = new RestAdapter.Builder(); - builder.setEndpoint(endpoint); - builder.setConverter(new GsonConverter(GsonFactory.create())); - RestAdapter restAdapter = builder.build(); - - return createApiService(restAdapter); - } -} diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApiTest.java similarity index 96% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApiTest.java index aea6ba00..57b762ce 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/server/ServerRestApiTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApiTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.client.retrofit.server; +package com.jaspersoft.android.sdk.client.retrofit.rest.v2.server; import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; From 6f992210b7c1542f0611c49ab7f0c67985cdc292 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 11:53:20 +0300 Subject: [PATCH 019/457] Add api for resources search --- .../rest/v2/repository/RepositoryRestApi.java | 39 +++++++++++ .../sdk/data/resource/ResourceLookup.java | 4 +- .../sdk/data/resource/ResourceType.java | 8 +-- .../data/resource/ResourceTypeAdapter.java | 1 + .../sdk/data/server/DefaultVersionParser.java | 2 + .../android/sdk/data/server/FeatureSet.java | 6 +- .../sdk/data/server/FeaturesAdapter.java | 9 +-- .../sdk/data/server/ServerEdition.java | 0 .../sdk/data/server/ServerInfoResponse.java | 5 +- .../sdk/data/server/ServerVersion.java | 6 +- .../sdk/data/server/ServerVersionAdapter.java | 7 +- .../type/CustomizedTypeAdapterFactory.java | 0 .../android/sdk/data/type/GsonFactory.java | 0 .../ResourceLookupTypeAdapterFactory.java | 5 +- .../v2/repository/RepositoryRestApiTest.java | 67 +++++++++++++++++++ .../resource/ResourceLookupConvertTest.java | 7 +- .../sdk/data/resource/ResourceTypeTest.java | 0 .../data/server/DefaultVersionParserTest.java | 0 .../data/server/ServerInfoResponseTest.java | 7 +- .../sdk/data/server/ServerVersionTest.java | 0 .../sdk/data/type/GsonFactoryTest.java | 0 .../sdk/test/resource/ResourceFile.java | 0 .../sdk/test/resource/TestResource.java | 0 .../resource/inject/TestResourceInjector.java | 0 .../test/resources/json/all_resources.json | 0 .../resources/json/default_server_info.json | 0 data/build.gradle | 23 ------- 27 files changed, 145 insertions(+), 51 deletions(-) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java (92%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java (84%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java (96%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java (97%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java (86%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java (74%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java (100%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java (91%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java (88%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java (78%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java (100%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java (100%) rename {data => client-retrofit}/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java (91%) create mode 100644 client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApiTest.java rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java (91%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java (100%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java (100%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java (94%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java (100%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java (100%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java (100%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java (100%) rename {data => client-retrofit}/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java (100%) rename {data => client-retrofit}/src/test/resources/json/all_resources.json (100%) rename {data => client-retrofit}/src/test/resources/json/default_server_info.json (100%) delete mode 100644 data/build.gradle diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java index a98a91a4..2c0b797e 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java @@ -24,10 +24,49 @@ package com.jaspersoft.android.sdk.client.retrofit.rest.v2.repository; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.data.json.GsonFactory; +import com.jaspersoft.android.sdk.data.resource.ResourceLookup; + +import java.util.Collection; +import java.util.Map; + +import retrofit.Endpoint; +import retrofit.Endpoints; +import retrofit.RestAdapter; +import retrofit.converter.GsonConverter; +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.QueryMap; + /** * @author Tom Koptel * @since 2.0 */ public interface RepositoryRestApi { + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/resources") + Collection searchResources(@Nullable @QueryMap Map searchParams); + + class Builder { + private final String mBaseUrl; + + public Builder(String baseUrl) { + mBaseUrl = baseUrl; + } + + public RepositoryRestApi build() { + Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); + + RestAdapter.Builder builder = new RestAdapter.Builder(); + builder.setEndpoint(endpoint); + builder.setConverter(new GsonConverter(GsonFactory.create())); + RestAdapter restAdapter = builder.build(); + return restAdapter.create(RepositoryRestApi.class); + } + } } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java similarity index 92% rename from data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java index 81704e2b..dccd490e 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java @@ -26,6 +26,8 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.JsonAdapter; +import com.jaspersoft.android.sdk.data.resource.ResourceType; +import com.jaspersoft.android.sdk.data.resource.ResourceTypeAdapter; /** * @author Tom Koptel @@ -40,7 +42,7 @@ public final class ResourceLookup { @Expose private String uri; @Expose - @JsonAdapter(ResourceTypeAdapter.class) + @JsonAdapter(com.jaspersoft.android.sdk.data.resource.ResourceTypeAdapter.class) private ResourceType resourceType; @Expose diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java similarity index 84% rename from data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java index 51946aa7..0642db03 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java @@ -50,12 +50,12 @@ public String getRawValue() { } }; - static ResourceType parseRawValue(String rawValue) { - ResourceType type; + static com.jaspersoft.android.sdk.data.resource.ResourceType parseRawValue(String rawValue) { + com.jaspersoft.android.sdk.data.resource.ResourceType type; try { - type = ResourceType.valueOf(rawValue); + type = com.jaspersoft.android.sdk.data.resource.ResourceType.valueOf(rawValue); } catch (IllegalArgumentException ex) { - type = ResourceType.unknown; + type = com.jaspersoft.android.sdk.data.resource.ResourceType.unknown; type.setRawValue(rawValue); } return type; diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java similarity index 96% rename from data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java index fe7cfd7d..fba74e57 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java @@ -27,6 +27,7 @@ import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.jaspersoft.android.sdk.data.resource.ResourceType; import java.io.IOException; diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java similarity index 97% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java index 1028a96d..b8a943b4 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.data.server; +import com.jaspersoft.android.sdk.data.server.ServerVersion; + import java.math.BigDecimal; /** diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java similarity index 86% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java index 1e2ca583..77eac435 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java @@ -48,8 +48,8 @@ public String asString() { return mRawData; } - public static FeatureSet create(String rawString) { - return new FeatureSet(rawString); + public static com.jaspersoft.android.sdk.data.server.FeatureSet create(String rawString) { + return new com.jaspersoft.android.sdk.data.server.FeatureSet(rawString); } @Override @@ -57,7 +57,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - FeatureSet that = (FeatureSet) o; + com.jaspersoft.android.sdk.data.server.FeatureSet that = (com.jaspersoft.android.sdk.data.server.FeatureSet) o; return !(mRawData != null ? !mRawData.equals(that.mRawData) : that.mRawData != null); diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java similarity index 74% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java index e2fa73f1..facac1f0 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java @@ -27,6 +27,7 @@ import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.jaspersoft.android.sdk.data.server.FeatureSet; import java.io.IOException; @@ -34,15 +35,15 @@ * @author Tom Koptel * @since 2.0 */ -final class FeaturesAdapter extends TypeAdapter { +final class FeaturesAdapter extends TypeAdapter { @Override - public void write(JsonWriter out, FeatureSet value) throws IOException { + public void write(JsonWriter out, com.jaspersoft.android.sdk.data.server.FeatureSet value) throws IOException { out.value(value.asString()); } @Override - public FeatureSet read(JsonReader in) throws IOException { + public com.jaspersoft.android.sdk.data.server.FeatureSet read(JsonReader in) throws IOException { String rawFeatures = in.nextString(); - return FeatureSet.create(rawFeatures); + return com.jaspersoft.android.sdk.data.server.FeatureSet.create(rawFeatures); } } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java similarity index 100% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java similarity index 91% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java index 6c9ec6aa..ec17c43b 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java @@ -23,6 +23,7 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.JsonAdapter; +import com.jaspersoft.android.sdk.data.server.ServerEdition; /** * @author Tom Koptel @@ -41,7 +42,7 @@ public final class ServerInfoResponse { private ServerVersion version; @Expose - private ServerEdition edition; + private com.jaspersoft.android.sdk.data.server.ServerEdition edition; @Expose private String licenseType; @@ -72,7 +73,7 @@ public String getDatetimeFormatPattern() { return datetimeFormatPattern; } - public ServerEdition getEdition() { + public com.jaspersoft.android.sdk.data.server.ServerEdition getEdition() { return edition; } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java similarity index 88% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java index c832888c..549f8872 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.data.server; +import com.jaspersoft.android.sdk.data.server.DefaultVersionParser; + /** * @author Tom Koptel * @since 2.0 @@ -63,10 +65,10 @@ void setRawValue(String rawValue) { } public static Parser defaultParser() { - return DefaultVersionParser.INSTANCE; + return com.jaspersoft.android.sdk.data.server.DefaultVersionParser.INSTANCE; } public interface Parser { - ServerVersion parse(String rawVersion); + com.jaspersoft.android.sdk.data.server.ServerVersion parse(String rawVersion); } } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java similarity index 78% rename from data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java index d02ab936..adbfafd1 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java @@ -27,6 +27,7 @@ import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.jaspersoft.android.sdk.data.server.ServerVersion; import java.io.IOException; @@ -34,14 +35,14 @@ * @author Tom Koptel * @since 2.0 */ -final class ServerVersionAdapter extends TypeAdapter { +final class ServerVersionAdapter extends TypeAdapter { @Override - public void write(JsonWriter out, ServerVersion value) throws IOException { + public void write(JsonWriter out, com.jaspersoft.android.sdk.data.server.ServerVersion value) throws IOException { out.value(value.getRawValue()); } @Override - public ServerVersion read(JsonReader in) throws IOException { + public com.jaspersoft.android.sdk.data.server.ServerVersion read(JsonReader in) throws IOException { String rawValue = in.nextString(); return ServerVersion.defaultParser().parse(rawValue); } diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java similarity index 100% rename from data/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java similarity index 100% rename from data/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java diff --git a/data/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java similarity index 91% rename from data/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java rename to client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java index c830b35a..48aedd44 100644 --- a/data/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java @@ -27,7 +27,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.data.resource.ResourceLookup; import java.util.Collection; @@ -36,8 +35,8 @@ * @author Tom Koptel * @since 2.0 */ -final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { - static final TypeToken TOKEN_TYPE = new TypeToken>(){}; +final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { + static final TypeToken TOKEN_TYPE = new TypeToken>(){}; @SuppressWarnings("unchecked") public ResourceLookupTypeAdapterFactory() { diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApiTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApiTest.java new file mode 100644 index 00000000..6b28002b --- /dev/null +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApiTest.java @@ -0,0 +1,67 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.client.retrofit.rest.v2.repository; + +import com.jaspersoft.android.sdk.data.resource.ResourceLookup; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; +import org.robolectric.shadows.FakeHttp; + +import java.io.IOException; +import java.util.Collection; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.2 + */ +@RunWith(RobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class RepositoryRestApiTest { + + String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + + @Before + public void setup() { + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + } + + @Test + public void shouldRequestServerInfo() throws IOException { + RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2).build(); + Collection resourceLookups = api.searchResources(null); + assertThat(resourceLookups, is(notNullValue())); + assertThat(resourceLookups.size(), is(not(0))); + } + +} \ No newline at end of file diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java similarity index 91% rename from data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java index 729e9184..94d4f4ea 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java @@ -27,9 +27,6 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.jaspersoft.android.sdk.data.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import org.junit.Before; import org.junit.Test; @@ -37,6 +34,10 @@ import java.lang.reflect.Type; import java.util.Collection; +import sdk.test.resource.ResourceFile; +import sdk.test.resource.TestResource; +import sdk.test.resource.inject.TestResourceInjector; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java similarity index 100% rename from data/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java similarity index 100% rename from data/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java similarity index 94% rename from data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java index cd05c1cf..ce9a0a20 100644 --- a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -26,13 +26,14 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.jaspersoft.android.sdk.data.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import org.junit.Before; import org.junit.Test; +import sdk.test.resource.ResourceFile; +import sdk.test.resource.TestResource; +import sdk.test.resource.inject.TestResourceInjector; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsCollectionContaining.hasItems; diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java similarity index 100% rename from data/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java diff --git a/data/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java similarity index 100% rename from data/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java diff --git a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java similarity index 100% rename from data/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java diff --git a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java similarity index 100% rename from data/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java diff --git a/data/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java similarity index 100% rename from data/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java rename to client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java diff --git a/data/src/test/resources/json/all_resources.json b/client-retrofit/src/test/resources/json/all_resources.json similarity index 100% rename from data/src/test/resources/json/all_resources.json rename to client-retrofit/src/test/resources/json/all_resources.json diff --git a/data/src/test/resources/json/default_server_info.json b/client-retrofit/src/test/resources/json/default_server_info.json similarity index 100% rename from data/src/test/resources/json/default_server_info.json rename to client-retrofit/src/test/resources/json/default_server_info.json diff --git a/data/build.gradle b/data/build.gradle deleted file mode 100644 index a6f28d78..00000000 --- a/data/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -apply plugin: 'java' - -repositories { - jcenter() -} - -dependencies { - compile 'com.google.code.gson:gson:2.3.1' - - testCompile 'junit:junit:4.12' - testCompile('pl.pragmatists:JUnitParams:1.0.4') { - exclude group: 'org.hamcrest' - } - testCompile 'org.mockito:mockito-core:1.10.19' - testCompile ('org.powermock:powermock-api-mockito:1.6.2') { - exclude module: 'hamcrest-core' - exclude module: 'objenesis' - } - testCompile ('org.powermock:powermock-module-junit4:1.6.2') { - exclude module: 'hamcrest-core' - exclude module: 'objenesis' - } -} \ No newline at end of file From 7b0b23efed0cfbe154f729e7e0508ef2f36185db Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 13:12:56 +0300 Subject: [PATCH 020/457] Removing data layer --- client-retrofit/build.gradle | 35 ++++++++++++++----- .../rest/v2/repository/RepositoryRestApi.java | 2 +- .../rest/v2/server/ServerRestApi.java | 2 +- .../sdk/data/resource/ResourceLookup.java | 4 +-- .../sdk/data/resource/ResourceType.java | 8 ++--- .../data/resource/ResourceTypeAdapter.java | 1 - .../sdk/data/server/DefaultVersionParser.java | 2 -- .../sdk/data/server/FeaturesAdapter.java | 9 +++-- .../sdk/data/server/ServerInfoResponse.java | 5 ++- .../sdk/data/server/ServerVersion.java | 5 ++- .../sdk/data/server/ServerVersionAdapter.java | 7 ++-- .../ResourceLookupTypeAdapterFactory.java | 5 +-- .../resource/ResourceLookupConvertTest.java | 7 ++-- .../data/server/ServerInfoResponseTest.java | 7 ++-- .../sdk/test/resource/TestResource.java | 9 ++--- settings.gradle | 2 -- 16 files changed, 56 insertions(+), 54 deletions(-) diff --git a/client-retrofit/build.gradle b/client-retrofit/build.gradle index 3466847d..5e3bb726 100644 --- a/client-retrofit/build.gradle +++ b/client-retrofit/build.gradle @@ -33,25 +33,44 @@ android { } dependencies { - compile project(':js-android-sdk-data') + compile 'com.android.support:support-annotations:22.2.0' compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' - compile 'com.squareup.retrofit:converter-simplexml:1.9.0' + compile 'com.squareup.retrofit:retrofit:1.9.0' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + // Hamcrest Matchers for Junit + testCompile('org.hamcrest:hamcrest-integration:1.3') + + testCompile('junit:junit:4.12') { + transitive = false + } + // JunitParams + testCompile('pl.pragmatists:JUnitParams:1.0.4') { + transitive = false + } + + // Mockito + testCompile("org.mockito:mockito-core:1.10.19") { + exclude group: 'org.hamcrest' + } + // Robolectric + Support v4 testCompile('org.robolectric:shadows-support-v4:3.0-rc3') { + exclude group: 'junit' exclude group: 'commons-logging', module: 'commons-logging' exclude group: 'org.apache.httpcomponents', module: 'httpclient' } - testCompile 'org.robolectric:shadows-httpclient:3.0-rc3' - - testCompile ('org.powermock:powermock-api-mockito:1.6.2') { + testCompile('org.robolectric:shadows-httpclient:3.0-rc3') { + exclude group: 'org.robolectric' + } + + testCompile('org.powermock:powermock-api-mockito:1.6.2') { exclude module: 'hamcrest-core' exclude module: 'objenesis' } - testCompile ('org.powermock:powermock-module-junit4:1.6.2') { + testCompile('org.powermock:powermock-module-junit4:1.6.2') { + exclude group: 'junit' exclude module: 'hamcrest-core' exclude module: 'objenesis' + exclude module: 'powermock-core' } } \ No newline at end of file diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java index 2c0b797e..39f57bbb 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java @@ -27,7 +27,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.data.json.GsonFactory; +import com.jaspersoft.android.sdk.data.type.GsonFactory; import com.jaspersoft.android.sdk.data.resource.ResourceLookup; import java.util.Collection; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java index a3cdfd5a..eb62f8c2 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.data.json.GsonFactory; +import com.jaspersoft.android.sdk.data.type.GsonFactory; import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; import retrofit.Endpoint; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java index dccd490e..81704e2b 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java @@ -26,8 +26,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.JsonAdapter; -import com.jaspersoft.android.sdk.data.resource.ResourceType; -import com.jaspersoft.android.sdk.data.resource.ResourceTypeAdapter; /** * @author Tom Koptel @@ -42,7 +40,7 @@ public final class ResourceLookup { @Expose private String uri; @Expose - @JsonAdapter(com.jaspersoft.android.sdk.data.resource.ResourceTypeAdapter.class) + @JsonAdapter(ResourceTypeAdapter.class) private ResourceType resourceType; @Expose diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java index 0642db03..51946aa7 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java @@ -50,12 +50,12 @@ public String getRawValue() { } }; - static com.jaspersoft.android.sdk.data.resource.ResourceType parseRawValue(String rawValue) { - com.jaspersoft.android.sdk.data.resource.ResourceType type; + static ResourceType parseRawValue(String rawValue) { + ResourceType type; try { - type = com.jaspersoft.android.sdk.data.resource.ResourceType.valueOf(rawValue); + type = ResourceType.valueOf(rawValue); } catch (IllegalArgumentException ex) { - type = com.jaspersoft.android.sdk.data.resource.ResourceType.unknown; + type = ResourceType.unknown; type.setRawValue(rawValue); } return type; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java index fba74e57..fe7cfd7d 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java @@ -27,7 +27,6 @@ import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.jaspersoft.android.sdk.data.resource.ResourceType; import java.io.IOException; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java index b8a943b4..1028a96d 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.data.server; -import com.jaspersoft.android.sdk.data.server.ServerVersion; - import java.math.BigDecimal; /** diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java index facac1f0..e2fa73f1 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java @@ -27,7 +27,6 @@ import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.jaspersoft.android.sdk.data.server.FeatureSet; import java.io.IOException; @@ -35,15 +34,15 @@ * @author Tom Koptel * @since 2.0 */ -final class FeaturesAdapter extends TypeAdapter { +final class FeaturesAdapter extends TypeAdapter { @Override - public void write(JsonWriter out, com.jaspersoft.android.sdk.data.server.FeatureSet value) throws IOException { + public void write(JsonWriter out, FeatureSet value) throws IOException { out.value(value.asString()); } @Override - public com.jaspersoft.android.sdk.data.server.FeatureSet read(JsonReader in) throws IOException { + public FeatureSet read(JsonReader in) throws IOException { String rawFeatures = in.nextString(); - return com.jaspersoft.android.sdk.data.server.FeatureSet.create(rawFeatures); + return FeatureSet.create(rawFeatures); } } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java index ec17c43b..6c9ec6aa 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java @@ -23,7 +23,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.JsonAdapter; -import com.jaspersoft.android.sdk.data.server.ServerEdition; /** * @author Tom Koptel @@ -42,7 +41,7 @@ public final class ServerInfoResponse { private ServerVersion version; @Expose - private com.jaspersoft.android.sdk.data.server.ServerEdition edition; + private ServerEdition edition; @Expose private String licenseType; @@ -73,7 +72,7 @@ public String getDatetimeFormatPattern() { return datetimeFormatPattern; } - public com.jaspersoft.android.sdk.data.server.ServerEdition getEdition() { + public ServerEdition getEdition() { return edition; } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java index 549f8872..4617412b 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.data.server; -import com.jaspersoft.android.sdk.data.server.DefaultVersionParser; /** * @author Tom Koptel @@ -65,10 +64,10 @@ void setRawValue(String rawValue) { } public static Parser defaultParser() { - return com.jaspersoft.android.sdk.data.server.DefaultVersionParser.INSTANCE; + return DefaultVersionParser.INSTANCE; } public interface Parser { - com.jaspersoft.android.sdk.data.server.ServerVersion parse(String rawVersion); + ServerVersion parse(String rawVersion); } } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java index adbfafd1..d02ab936 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java @@ -27,7 +27,6 @@ import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import com.jaspersoft.android.sdk.data.server.ServerVersion; import java.io.IOException; @@ -35,14 +34,14 @@ * @author Tom Koptel * @since 2.0 */ -final class ServerVersionAdapter extends TypeAdapter { +final class ServerVersionAdapter extends TypeAdapter { @Override - public void write(JsonWriter out, com.jaspersoft.android.sdk.data.server.ServerVersion value) throws IOException { + public void write(JsonWriter out, ServerVersion value) throws IOException { out.value(value.getRawValue()); } @Override - public com.jaspersoft.android.sdk.data.server.ServerVersion read(JsonReader in) throws IOException { + public ServerVersion read(JsonReader in) throws IOException { String rawValue = in.nextString(); return ServerVersion.defaultParser().parse(rawValue); } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java index 48aedd44..c830b35a 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java +++ b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java @@ -27,6 +27,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; +import com.jaspersoft.android.sdk.data.resource.ResourceLookup; import java.util.Collection; @@ -35,8 +36,8 @@ * @author Tom Koptel * @since 2.0 */ -final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { - static final TypeToken TOKEN_TYPE = new TypeToken>(){}; +final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { + static final TypeToken TOKEN_TYPE = new TypeToken>(){}; @SuppressWarnings("unchecked") public ResourceLookupTypeAdapterFactory() { diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java index 94d4f4ea..729e9184 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java @@ -27,6 +27,9 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import org.junit.Before; import org.junit.Test; @@ -34,10 +37,6 @@ import java.lang.reflect.Type; import java.util.Collection; -import sdk.test.resource.ResourceFile; -import sdk.test.resource.TestResource; -import sdk.test.resource.inject.TestResourceInjector; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java index ce9a0a20..cd05c1cf 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java @@ -26,14 +26,13 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import org.junit.Before; import org.junit.Test; -import sdk.test.resource.ResourceFile; -import sdk.test.resource.TestResource; -import sdk.test.resource.inject.TestResourceInjector; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsCollectionContaining.hasItems; diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java index bb32619e..e4a55a54 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java +++ b/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java @@ -45,13 +45,8 @@ private TestResource(String fileName) { throw new IllegalArgumentException("Resource name should not be null"); } ClassLoader classLoader = getClass().getClassLoader(); - URL url = classLoader.getResource("."); - File classesFolder = new File(url.getFile()); - File resourcesFolder = new File( - new File(classesFolder.getParent()).getParent() + "/resources/test" - ); - - File file = new File(resourcesFolder, fileName); + URL url = classLoader.getResource(fileName); + File file = new File(url.getFile()); if (!file.exists()) { throw new RuntimeException( new FileNotFoundException("Resource on path: " + file.getPath() + " not found") diff --git a/settings.gradle b/settings.gradle index 67852d56..a768e251 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,7 @@ include ':js-android-sdk-client' include ':js-android-sdk-ui' -include ':js-android-sdk-data' include ':js-android-sdk-client-retrofit' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File -project(':js-android-sdk-data').projectDir = "$rootDir/data" as File project(':js-android-sdk-client-retrofit').projectDir = "$rootDir/client-retrofit" as File From 383b39d5a8035dd43fb9e56886deffd05ddb3542 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 13:56:18 +0300 Subject: [PATCH 021/457] Introducing 2 layers network and service --- .../build.gradle | 0 .../src/main/AndroidManifest.xml | 2 +- .../resource/ResourceLookupResponse.java | 18 +++---- .../v2/entity}/server/ServerInfoResponse.java | 35 +++++++----- .../type/CustomizedTypeAdapterFactory.java | 2 +- .../rest/v2/entity}/type/GsonFactory.java | 2 +- .../ResourceLookupTypeAdapterFactory.java | 8 +-- .../rest/v2/repository/RepositoryRestApi.java | 8 +-- .../rest/v2/server/ServerRestApi.java | 6 +-- .../ResourceLookupResponseConvertTest.java | 13 +++-- .../server/ServerInfoResponseTest.java | 37 +------------ .../rest/v2/entity}/type/GsonFactoryTest.java | 2 +- .../v2/repository/RepositoryRestApiTest.java | 15 +++--- .../rest/v2/server/ServerRestApiTest.java | 5 +- .../sdk/test/resource/ResourceFile.java | 0 .../sdk/test/resource/TestResource.java | 0 .../resource/inject/TestResourceInjector.java | 0 .../test/resources/json/all_resources.json | 0 .../resources/json/default_server_info.json | 0 .../sdk/data/server/ServerVersionAdapter.java | 48 ----------------- client-service/build.gradle | 54 +++++++++++++++++++ client-service/src/main/AndroidManifest.xml | 31 +++++++++++ .../service/data/resource/ResourceLookup.java | 29 +++++----- .../service}/data/resource/ResourceType.java | 4 +- .../data/server/DefaultVersionParser.java | 2 +- .../sdk/service}/data/server/FeatureSet.java | 8 +-- .../service}/data/server/ServerEdition.java | 4 +- .../sdk/service/data/server/ServerInfo.java | 30 ++++------- .../service}/data/server/ServerVersion.java | 2 +- .../service/repository/RepositoryService.java | 13 +++++ .../sdk/service/server/ServerService.java | 11 ++++ .../data/resource/ResourceLookupTest.java | 9 ++++ .../data/resource/ResourceTypeTest.java | 4 +- .../data/server/DefaultVersionParserTest.java | 2 +- .../service/data/server/FeatureSetTest.java | 9 ++++ .../service/data/server/ServerInfoTest.java | 9 ++++ .../data/server/ServerVersionTest.java | 4 +- .../repository/RepositoryServiceTest.java | 9 ++++ .../sdk/service/server/ServerServiceTest.java | 9 ++++ .../sdk/client/api/v2/ConverterFactory.java | 2 +- .../android/sdk/client/api/v2/DataType.java | 2 +- .../client/api/v2/ConverterFactoryTest.java | 2 +- settings.gradle | 6 ++- 43 files changed, 258 insertions(+), 198 deletions(-) rename {client-retrofit => client-network}/build.gradle (100%) rename {client-retrofit => client-network}/src/main/AndroidManifest.xml (95%) rename client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java => client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java (82%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk/data => client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity}/server/ServerInfoResponse.java (68%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk/data => client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity}/type/CustomizedTypeAdapterFactory.java (98%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk/data => client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity}/type/GsonFactory.java (95%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk/data => client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity}/type/ResourceLookupTypeAdapterFactory.java (87%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit => client-network/src/main/java/com/jaspersoft/android/sdk/network}/rest/v2/repository/RepositoryRestApi.java (86%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit => client-network/src/main/java/com/jaspersoft/android/sdk/network}/rest/v2/server/ServerRestApi.java (90%) rename client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java => client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java (80%) rename {client-retrofit/src/test/java/com/jaspersoft/android/sdk/data => client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity}/server/ServerInfoResponseTest.java (56%) rename {client-retrofit/src/test/java/com/jaspersoft/android/sdk/data => client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity}/type/GsonFactoryTest.java (97%) rename {client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit => client-network/src/test/java/com/jaspersoft/android/sdk/network}/rest/v2/repository/RepositoryRestApiTest.java (80%) rename {client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit => client-network/src/test/java/com/jaspersoft/android/sdk/network}/rest/v2/server/ServerRestApiTest.java (93%) rename {client-retrofit => client-network}/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java (100%) rename {client-retrofit => client-network}/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java (100%) rename {client-retrofit => client-network}/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java (100%) rename {client-retrofit => client-network}/src/test/resources/json/all_resources.json (100%) rename {client-retrofit => client-network}/src/test/resources/json/default_server_info.json (100%) delete mode 100644 client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java create mode 100644 client-service/build.gradle create mode 100644 client-service/src/main/AndroidManifest.xml rename client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java => client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookup.java (65%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk => client-service/src/main/java/com/jaspersoft/android/sdk/service}/data/resource/ResourceType.java (93%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk => client-service/src/main/java/com/jaspersoft/android/sdk/service}/data/server/DefaultVersionParser.java (98%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk => client-service/src/main/java/com/jaspersoft/android/sdk/service}/data/server/FeatureSet.java (84%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk => client-service/src/main/java/com/jaspersoft/android/sdk/service}/data/server/ServerEdition.java (89%) rename client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java => client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java (60%) rename {client-retrofit/src/main/java/com/jaspersoft/android/sdk => client-service/src/main/java/com/jaspersoft/android/sdk/service}/data/server/ServerVersion.java (97%) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java rename {client-retrofit/src/test/java/com/jaspersoft/android/sdk => client-service/src/test/java/com/jaspersoft/android/sdk/service}/data/resource/ResourceTypeTest.java (94%) rename {client-retrofit/src/test/java/com/jaspersoft/android/sdk => client-service/src/test/java/com/jaspersoft/android/sdk/service}/data/server/DefaultVersionParserTest.java (97%) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java rename {client-retrofit/src/test/java/com/jaspersoft/android/sdk => client-service/src/test/java/com/jaspersoft/android/sdk/service}/data/server/ServerVersionTest.java (95%) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java diff --git a/client-retrofit/build.gradle b/client-network/build.gradle similarity index 100% rename from client-retrofit/build.gradle rename to client-network/build.gradle diff --git a/client-retrofit/src/main/AndroidManifest.xml b/client-network/src/main/AndroidManifest.xml similarity index 95% rename from client-retrofit/src/main/AndroidManifest.xml rename to client-network/src/main/AndroidManifest.xml index fdd84fe6..8f4606a4 100644 --- a/client-retrofit/src/main/AndroidManifest.xml +++ b/client-network/src/main/AndroidManifest.xml @@ -24,7 +24,7 @@ --> + package="com.jaspersoft.android.sdk.network" > diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java similarity index 82% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java index 81704e2b..bc488f44 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceLookup.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java @@ -22,16 +22,15 @@ * . */ -package com.jaspersoft.android.sdk.data.resource; +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; import com.google.gson.annotations.Expose; -import com.google.gson.annotations.JsonAdapter; /** * @author Tom Koptel * @since 2.0 */ -public final class ResourceLookup { +public final class ResourceLookupResponse { @Expose private String label; @@ -40,8 +39,7 @@ public final class ResourceLookup { @Expose private String uri; @Expose - @JsonAdapter(ResourceTypeAdapter.class) - private ResourceType resourceType; + private String resourceType; @Expose private int version; @@ -52,10 +50,6 @@ public final class ResourceLookup { @Expose private String updateDate; - //--------------------------------------------------------------------- - // Getters - //--------------------------------------------------------------------- - public String getCreationDate() { return creationDate; } @@ -72,7 +66,7 @@ public int getPermissionMask() { return permissionMask; } - public ResourceType getResourceType() { + public String getResourceType() { return resourceType; } @@ -90,12 +84,12 @@ public int getVersion() { @Override public String toString() { - return "ResourceLookup{" + + return "ResourceLookupResponse{" + "creationDate='" + creationDate + '\'' + ", label='" + label + '\'' + ", description='" + description + '\'' + ", uri='" + uri + '\'' + - ", resourceType=" + resourceType + + ", resourceType='" + resourceType + '\'' + ", version=" + version + ", permissionMask=" + permissionMask + ", updateDate='" + updateDate + '\'' + diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponse.java similarity index 68% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponse.java index 6c9ec6aa..5cbade49 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponse.java @@ -19,10 +19,9 @@ * along with this program. If not, see . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.network.rest.v2.entity.server; import com.google.gson.annotations.Expose; -import com.google.gson.annotations.JsonAdapter; /** * @author Tom Koptel @@ -37,11 +36,10 @@ public final class ServerInfoResponse { private String datetimeFormatPattern; @Expose - @JsonAdapter(ServerVersionAdapter.class) - private ServerVersion version; + private String version; @Expose - private ServerEdition edition; + private String edition; @Expose private String licenseType; @@ -53,12 +51,7 @@ public final class ServerInfoResponse { private String editionName; @Expose - @JsonAdapter(FeaturesAdapter.class) - private FeatureSet features; - - //--------------------------------------------------------------------- - // Getters - //--------------------------------------------------------------------- + private String features; public String getBuild() { return build; @@ -72,7 +65,7 @@ public String getDatetimeFormatPattern() { return datetimeFormatPattern; } - public ServerEdition getEdition() { + public String getEdition() { return edition; } @@ -80,7 +73,7 @@ public String getEditionName() { return editionName; } - public FeatureSet getFeatureSet() { + public String getFeatures() { return features; } @@ -88,7 +81,21 @@ public String getLicenseType() { return licenseType; } - public ServerVersion getVersion() { + public String getVersion() { return version; } + + @Override + public String toString() { + return "ServerInfoResponse{" + + "build='" + build + '\'' + + ", dateFormatPattern='" + dateFormatPattern + '\'' + + ", datetimeFormatPattern='" + datetimeFormatPattern + '\'' + + ", version='" + version + '\'' + + ", edition='" + edition + '\'' + + ", licenseType='" + licenseType + '\'' + + ", editionName='" + editionName + '\'' + + ", features='" + features + '\'' + + '}'; + } } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/CustomizedTypeAdapterFactory.java similarity index 98% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/CustomizedTypeAdapterFactory.java index b762e7e0..a70c7198 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/CustomizedTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/CustomizedTypeAdapterFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.type; +package com.jaspersoft.android.sdk.network.rest.v2.entity.type; import com.google.gson.Gson; import com.google.gson.JsonElement; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java similarity index 95% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java index 2d605d36..4fbbe81b 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/GsonFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.type; +package com.jaspersoft.android.sdk.network.rest.v2.entity.type; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ResourceLookupTypeAdapterFactory.java similarity index 87% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ResourceLookupTypeAdapterFactory.java index c830b35a..be85190f 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/type/ResourceLookupTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ResourceLookupTypeAdapterFactory.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.data.type; +package com.jaspersoft.android.sdk.network.rest.v2.entity.type; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.data.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import java.util.Collection; @@ -36,8 +36,8 @@ * @author Tom Koptel * @since 2.0 */ -final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { - static final TypeToken TOKEN_TYPE = new TypeToken>(){}; +final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { + static final TypeToken TOKEN_TYPE = new TypeToken>(){}; @SuppressWarnings("unchecked") public ResourceLookupTypeAdapterFactory() { diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java similarity index 86% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java index 39f57bbb..48604530 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java @@ -22,13 +22,13 @@ * . */ -package com.jaspersoft.android.sdk.client.retrofit.rest.v2.repository; +package com.jaspersoft.android.sdk.network.rest.v2.repository; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.data.type.GsonFactory; -import com.jaspersoft.android.sdk.data.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import java.util.Collection; import java.util.Map; @@ -49,7 +49,7 @@ public interface RepositoryRestApi { @NonNull @Headers("Accept: application/json") @GET("/rest_v2/resources") - Collection searchResources(@Nullable @QueryMap Map searchParams); + Collection searchResources(@Nullable @QueryMap Map searchParams); class Builder { private final String mBaseUrl; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java similarity index 90% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java index eb62f8c2..e1fb4f22 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.client.retrofit.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.server; import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.data.type.GsonFactory; -import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; import retrofit.Endpoint; import retrofit.Endpoints; diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java similarity index 80% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java index 729e9184..6efcee34 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceLookupConvertTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java @@ -22,11 +22,11 @@ * . */ -package com.jaspersoft.android.sdk.data.resource; +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; @@ -45,7 +45,7 @@ * @author Tom Koptel * @since 2.0 */ -public class ResourceLookupConvertTest { +public class ResourceLookupResponseConvertTest { @ResourceFile("json/all_resources.json") TestResource mJsonResources; @@ -58,9 +58,8 @@ public void setup() { @Test public void shouldDeserializeCollectionFromJson() { - Type type = new TypeToken>(){}.getType(); - Collection resourceLookups = mGson.fromJson(mJsonResources.asString(), type); - assertThat(resourceLookups.size(), is(not(0))); + Type type = new TypeToken>(){}.getType(); + Collection resourceLookupResponses = mGson.fromJson(mJsonResources.asString(), type); + assertThat(resourceLookupResponses.size(), is(not(0))); } - } diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java similarity index 56% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java index cd05c1cf..7308a4ed 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerInfoResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.network.rest.v2.entity.server; /* * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android @@ -24,8 +24,7 @@ */ import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.jaspersoft.android.sdk.data.type.GsonFactory; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; @@ -35,7 +34,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsCollectionContaining.hasItems; import static org.hamcrest.core.IsNull.notNullValue; /** @@ -57,36 +55,5 @@ public void setup() { public void shouldParseDefaultJsonResponse() { ServerInfoResponse response = mGson.fromJson(mJsonResource.asString(), ServerInfoResponse.class); assertThat(response, is(notNullValue())); - assertThat(response.getVersion(), is(ServerVersion.AMBER_MR2)); - assertThat(response.getEdition(), is(ServerEdition.PRO)); - assertThat(response.getFeatureSet().asSet(), hasItems("Fusion", "AHD", "EXP", "DB", "AUD", "ANA", "MT")); } - - @Test - public void shouldSerializeServerVersionToJson() { - JsonElement element = serializeJson(); - String serializedVersion = element.getAsJsonObject().get("version").getAsString(); - assertThat(serializedVersion, is("6.1")); - } - - @Test - public void shouldSerializeServerEditionToJson() { - JsonElement element = serializeJson(); - String serializedVersion = element.getAsJsonObject().get("edition").getAsString(); - assertThat(serializedVersion, is("PRO")); - } - - @Test - public void shouldSerializeFeaturesToJson() { - JsonElement element = serializeJson(); - String serializedVersion = element.getAsJsonObject().get("features").getAsString(); - assertThat(serializedVersion, is("Fusion AHD EXP DB AUD ANA MT ")); - } - - private JsonElement serializeJson() { - String initialJson = mJsonResource.asString(); - ServerInfoResponse response = mGson.fromJson(initialJson, ServerInfoResponse.class); - return mGson.toJsonTree(response, ServerInfoResponse.class); - } - } diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactoryTest.java similarity index 97% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactoryTest.java index bbd5ae93..ee7f6a51 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/type/GsonFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactoryTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.type; +package com.jaspersoft.android.sdk.network.rest.v2.entity.type; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java similarity index 80% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java index 6b28002b..93005f9a 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/repository/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,9 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.client.retrofit.rest.v2.repository; +package com.jaspersoft.android.sdk.network.rest.v2.repository; -import com.jaspersoft.android.sdk.data.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import org.junit.Before; import org.junit.Test; @@ -43,7 +43,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) @@ -59,9 +59,8 @@ public void setup() { @Test public void shouldRequestServerInfo() throws IOException { RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2).build(); - Collection resourceLookups = api.searchResources(null); - assertThat(resourceLookups, is(notNullValue())); - assertThat(resourceLookups.size(), is(not(0))); + Collection resourceLookupResponses = api.searchResources(null); + assertThat(resourceLookupResponses, is(notNullValue())); + assertThat(resourceLookupResponses.size(), is(not(0))); } - } \ No newline at end of file diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java similarity index 93% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java index 57b762ce..591a4c36 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/client/retrofit/rest/v2/server/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java @@ -22,10 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.client.retrofit.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.server; -import com.jaspersoft.android.sdk.data.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; import org.junit.Before; import org.junit.Test; @@ -61,5 +61,4 @@ public void shouldRequestServerInfo() throws IOException { ServerInfoResponse response = api.getServerInfo(); assertThat(response, is(notNullValue())); } - } diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java similarity index 100% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java similarity index 100% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java similarity index 100% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java diff --git a/client-retrofit/src/test/resources/json/all_resources.json b/client-network/src/test/resources/json/all_resources.json similarity index 100% rename from client-retrofit/src/test/resources/json/all_resources.json rename to client-network/src/test/resources/json/all_resources.json diff --git a/client-retrofit/src/test/resources/json/default_server_info.json b/client-network/src/test/resources/json/default_server_info.json similarity index 100% rename from client-retrofit/src/test/resources/json/default_server_info.json rename to client-network/src/test/resources/json/default_server_info.json diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java b/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java deleted file mode 100644 index d02ab936..00000000 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersionAdapter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.data.server; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ServerVersionAdapter extends TypeAdapter { - @Override - public void write(JsonWriter out, ServerVersion value) throws IOException { - out.value(value.getRawValue()); - } - - @Override - public ServerVersion read(JsonReader in) throws IOException { - String rawValue = in.nextString(); - return ServerVersion.defaultParser().parse(rawValue); - } -} diff --git a/client-service/build.gradle b/client-service/build.gradle new file mode 100644 index 00000000..245aa2e3 --- /dev/null +++ b/client-service/build.gradle @@ -0,0 +1,54 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion androidCompileSdkVersion + buildToolsVersion androidBuildToolsVersion + + defaultConfig { + minSdkVersion androidMinSdkVersion + targetSdkVersion androidTargetSdkVersion + versionCode clientModuleVersionCode + versionName version + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + encoding 'ISO-8859-1' + } + packagingOptions { + exclude 'META-INF/notice.txt' + exclude 'META-INF/license.txt' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/NOTICE.txt' + } + lintOptions { + abortOnError false + } + + buildTypes { + debug { + minifyEnabled false + } + } +} + +dependencies { + compile project(':js-android-sdk-client-network') + compile 'com.android.support:support-annotations:22.2.0' + + // Hamcrest Matchers for Junit + testCompile('org.hamcrest:hamcrest-integration:1.3') + + testCompile('junit:junit:4.12') { + transitive = false + } + // JunitParams + testCompile('pl.pragmatists:JUnitParams:1.0.4') { + transitive = false + } + + // Mockito + testCompile("org.mockito:mockito-core:1.10.19") { + exclude group: 'org.hamcrest' + } +} \ No newline at end of file diff --git a/client-service/src/main/AndroidManifest.xml b/client-service/src/main/AndroidManifest.xml new file mode 100644 index 00000000..2f3d5c6f --- /dev/null +++ b/client-service/src/main/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookup.java similarity index 65% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookup.java index e2fa73f1..d62d5fef 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeaturesAdapter.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookup.java @@ -22,27 +22,22 @@ * . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.service.data.resource; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +import java.net.URI; +import java.util.Date; /** * @author Tom Koptel * @since 2.0 */ -final class FeaturesAdapter extends TypeAdapter { - @Override - public void write(JsonWriter out, FeatureSet value) throws IOException { - out.value(value.asString()); - } - - @Override - public FeatureSet read(JsonReader in) throws IOException { - String rawFeatures = in.nextString(); - return FeatureSet.create(rawFeatures); - } +public final class ResourceLookup { + private String label; + private String description; + private URI uri; + private ResourceType resourceType; + private int version; + private int permissionMask; + private Date creationDate; + private Date updateDate; } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceType.java similarity index 93% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceType.java index 51946aa7..74b6073a 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceType.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceType.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.resource; +package com.jaspersoft.android.sdk.service.data.resource; /** * @author Tom Koptel diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java similarity index 98% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java index 1028a96d..61ab836b 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParser.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.service.data.server; import java.math.BigDecimal; diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java similarity index 84% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java index 77eac435..4606771e 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/FeatureSet.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.service.data.server; import java.util.Arrays; import java.util.HashSet; @@ -48,8 +48,8 @@ public String asString() { return mRawData; } - public static com.jaspersoft.android.sdk.data.server.FeatureSet create(String rawString) { - return new com.jaspersoft.android.sdk.data.server.FeatureSet(rawString); + public static FeatureSet create(String rawString) { + return new FeatureSet(rawString); } @Override @@ -57,7 +57,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - com.jaspersoft.android.sdk.data.server.FeatureSet that = (com.jaspersoft.android.sdk.data.server.FeatureSet) o; + FeatureSet that = (FeatureSet) o; return !(mRawData != null ? !mRawData.equals(that.mRawData) : that.mRawData != null); diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java similarity index 89% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java index 64a73263..b6571ad7 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerEdition.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.service.data.server; /** * @author Tom Koptel diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java similarity index 60% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index fe7cfd7d..67a177ad 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeAdapter.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -1,5 +1,5 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,27 +22,19 @@ * . */ -package com.jaspersoft.android.sdk.data.resource; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; +package com.jaspersoft.android.sdk.service.data.server; /** * @author Tom Koptel * @since 2.0 */ -final class ResourceTypeAdapter extends TypeAdapter { - @Override - public void write(JsonWriter out, ResourceType type) throws IOException { - out.value(type.getRawValue()); - } - - @Override - public ResourceType read(JsonReader in) throws IOException { - String rawValue = in.nextString(); - return ResourceType.parseRawValue(rawValue); - } +public final class ServerInfo { + private String dateFormatPattern; + private String datetimeFormatPattern; + private ServerVersion version; + private ServerEdition edition; + private String licenseType; + private String build; + private String editionName; + private FeatureSet features; } diff --git a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java similarity index 97% rename from client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java index 4617412b..93f7bac8 100644 --- a/client-retrofit/src/main/java/com/jaspersoft/android/sdk/data/server/ServerVersion.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.service.data.server; /** diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java new file mode 100644 index 00000000..c01b7eb5 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -0,0 +1,13 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.service.data.resource.ResourceLookup; + +import java.util.Collection; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RepositoryService { + Collection searchResources(); +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java new file mode 100644 index 00000000..fc3c0ac0 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java @@ -0,0 +1,11 @@ +package com.jaspersoft.android.sdk.service.server; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ServerService { + ServerInfo getServerInfo(); +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java new file mode 100644 index 00000000..a35056ed --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.data.resource; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ResourceLookupTest { + +} \ No newline at end of file diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceTypeTest.java similarity index 94% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceTypeTest.java index 7bdda44f..fe173054 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/resource/ResourceTypeTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.resource; +package com.jaspersoft.android.sdk.service.data.resource; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java similarity index 97% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java index b1a72ead..32be5cb4 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/DefaultVersionParserTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.service.data.server; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java new file mode 100644 index 00000000..201f29ac --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.data.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class FeatureSetTest { + +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java new file mode 100644 index 00000000..b7a81caf --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.data.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerInfoTest { + +} \ No newline at end of file diff --git a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java similarity index 95% rename from client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java index 7779cce6..60858e12 100644 --- a/client-retrofit/src/test/java/com/jaspersoft/android/sdk/data/server/ServerVersionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.data.server; +package com.jaspersoft.android.sdk.service.data.server; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java new file mode 100644 index 00000000..f002becb --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.repository; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RepositoryServiceTest { + +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java new file mode 100644 index 00000000..7d3c29d4 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerServiceTest { + +} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java index df03eb17..3d8fd372 100644 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java @@ -40,7 +40,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ final class ConverterFactory { diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java index 378cea21..8f9f5201 100644 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java @@ -2,7 +2,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ public enum DataType { XML, JSON diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java index ff75f498..922caf62 100644 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java @@ -34,7 +34,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ public class ConverterFactoryTest { diff --git a/settings.gradle b/settings.gradle index a768e251..a8972f7e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,9 @@ include ':js-android-sdk-client' include ':js-android-sdk-ui' -include ':js-android-sdk-client-retrofit' +include ':js-android-sdk-client-network' +include ':js-android-sdk-client-service' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File -project(':js-android-sdk-client-retrofit').projectDir = "$rootDir/client-retrofit" as File +project(':js-android-sdk-client-network').projectDir = "$rootDir/client-network" as File +project(':js-android-sdk-client-service').projectDir = "$rootDir/client-service" as File From fa7cf705041ecd297abfb0da1e4bfebd712170a5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 14:46:25 +0300 Subject: [PATCH 022/457] Add deserialize parse conditions for ServerInfoResponse --- .../ServerInfoResponseJsonConvertTest.java | 111 ++++++++++++++++++ .../entity/server/ServerInfoResponseTest.java | 59 ---------- 2 files changed, 111 insertions(+), 59 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java new file mode 100644 index 00000000..57855635 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java @@ -0,0 +1,111 @@ +package com.jaspersoft.android.sdk.network.rest.v2.entity.server; +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerInfoResponseJsonConvertTest { + @ResourceFile("json/default_server_info.json") + TestResource mJsonResource; + + Gson mGson = GsonFactory.create(); + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + + @Test + public void shouldDeserializeDefaultJsonResponse() { + ServerInfoResponse response = deserialize(mJsonResource.asString()); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldDeserializeDateFormatPattern() { + ServerInfoResponse response = deserialize("{\"dateFormatPattern\": \"yyyy-MM-dd\"}"); + assertThat(response.getDateFormatPattern(), is("yyyy-MM-dd")); + } + + @Test + public void shouldDeserializeDateTimeFormatPattern() { + ServerInfoResponse response = deserialize("{\"datetimeFormatPattern\": \"yyyy-MM-dd'T'HH:mm:ss\"}"); + assertThat(response.getDatetimeFormatPattern(), is("yyyy-MM-dd'T'HH:mm:ss")); + } + + @Test + public void shouldDeserializeVersion() { + ServerInfoResponse response = deserialize("{\"version\": \"6.1\"}"); + assertThat(response.getVersion(), is("6.1")); + } + + @Test + public void shouldDeserializeEdition() { + ServerInfoResponse response = deserialize("{\"edition\": \"PRO\"}"); + assertThat(response.getEdition(), is("PRO")); + } + + @Test + public void shouldDeserializeEditionName() { + ServerInfoResponse response = deserialize("{\"editionName\": \"Enterprise for AWS\"}"); + assertThat(response.getEditionName(), is("Enterprise for AWS")); + } + + @Test + public void shouldDeserializeLicenseType() { + ServerInfoResponse response = deserialize("{\"licenseType\": \"Commercial\"}"); + assertThat(response.getLicenseType(), is("Commercial")); + } + + @Test + public void shouldDeserializeBuild() { + ServerInfoResponse response = deserialize("{\"build\": \"20150527_1447\"}"); + assertThat(response.getBuild(), is("20150527_1447")); + } + + @Test + public void shouldDeserializeFeatures() { + ServerInfoResponse response = deserialize("{\"features\": \"Fusion AHD EXP DB AUD ANA MT \"}"); + assertThat(response.getFeatures(), is("Fusion AHD EXP DB AUD ANA MT ")); + } + + private ServerInfoResponse deserialize(String json) { + return mGson.fromJson(json, ServerInfoResponse.class); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java deleted file mode 100644 index 7308a4ed..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.jaspersoft.android.sdk.network.rest.v2.entity.server; -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; - -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ServerInfoResponseTest { - @ResourceFile("json/default_server_info.json") - TestResource mJsonResource; - - Gson mGson = GsonFactory.create(); - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - - @Test - public void shouldParseDefaultJsonResponse() { - ServerInfoResponse response = mGson.fromJson(mJsonResource.asString(), ServerInfoResponse.class); - assertThat(response, is(notNullValue())); - } -} From b708a45510567035dd1a8879d6b6208724600a54 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 15:06:20 +0300 Subject: [PATCH 023/457] Add additional test cases for ResourceLookupResponse --- .../ResourceLookupResponseConvertTest.java | 65 --------- ...ResourceLookupResponseJsonConvertTest.java | 131 ++++++++++++++++++ .../resources/json/resource_lookup_item.json | 10 ++ 3 files changed, 141 insertions(+), 65 deletions(-) delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java create mode 100644 client-network/src/test/resources/json/resource_lookup_item.json diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java deleted file mode 100644 index 6efcee34..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseConvertTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; - -import org.junit.Before; -import org.junit.Test; - -import java.lang.reflect.Type; -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ResourceLookupResponseConvertTest { - @ResourceFile("json/all_resources.json") - TestResource mJsonResources; - - Gson mGson = GsonFactory.create(); - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - - @Test - public void shouldDeserializeCollectionFromJson() { - Type type = new TypeToken>(){}.getType(); - Collection resourceLookupResponses = mGson.fromJson(mJsonResources.asString(), type); - assertThat(resourceLookupResponses.size(), is(not(0))); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java new file mode 100644 index 00000000..bbd093e5 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java @@ -0,0 +1,131 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; +import org.junit.Test; + +import java.lang.reflect.Type; +import java.util.Collection; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; + +/** + * { + * "version": 2, + * "permissionMask": 1, + * "creationDate": "2015-06-05T07:21:11", + * "updateDate": "2014-05-14T17:38:49", + * "label": "01. Geographic Results by Segment", + * "description": "Sample HTML5 multi-axis column chart from Domain showing Sales, Units, and $ Per Square Foot by Country and Store Type with various filters", + * "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment", + * "resourceType": "adhocDataView" + * } + * + * @author Tom Koptel + * @since 2.0 + */ +public class ResourceLookupResponseJsonConvertTest { + @ResourceFile("json/all_resources.json") + TestResource mJsonResources; + @ResourceFile("json/resource_lookup_item.json") + TestResource mJsonResource; + + Gson mGson = GsonFactory.create(); + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + + @Test + public void shouldDeserializeCollectionFromJson() { + Type type = new TypeToken>() { + }.getType(); + Collection resourceLookupResponses = mGson.fromJson(mJsonResources.asString(), type); + assertThat(resourceLookupResponses.size(), is(not(0))); + } + + @Test + public void shouldDeserializeVersion() { + ResourceLookupResponse response = deserialize("{\"version\": 2}"); + assertThat(response.getVersion(), is(2)); + } + + @Test + public void shouldDeserializePermissionMask() { + ResourceLookupResponse response = deserialize("{\"permissionMask\": 1}"); + assertThat(response.getPermissionMask(), is(1)); + } + + @Test + public void shouldDeserializeCreationDate() { + ResourceLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); + assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); + } + + @Test + public void shouldDeserializeUpdateDate() { + ResourceLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); + assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); + } + + @Test + public void shouldDeserializeLabel() { + ResourceLookupResponse response = deserialize("{\"label\": \"01. Geographic Results by Segment\"}"); + assertThat(response.getLabel(), is("01. Geographic Results by Segment")); + } + + @Test + public void shouldDeserializeDescription() { + ResourceLookupResponse response = deserialize("{\"description\": \"Sample HTML5 multi-axis column chart\"}"); + assertThat(response.getDescription(), is("Sample HTML5 multi-axis column chart")); + } + + @Test + public void shouldDeserializeUri() { + ResourceLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment\"}"); + assertThat(response.getUri(), is("/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment")); + } + + @Test + public void shouldDeserializeResourceType() { + ResourceLookupResponse response = deserialize("{\"resourceType\": \"adhocDataView\"}"); + assertThat(response.getResourceType(), is("adhocDataView")); + } + + private ResourceLookupResponse deserialize(String json) { + return mGson.fromJson(json, ResourceLookupResponse.class); + } +} diff --git a/client-network/src/test/resources/json/resource_lookup_item.json b/client-network/src/test/resources/json/resource_lookup_item.json new file mode 100644 index 00000000..c09c75ca --- /dev/null +++ b/client-network/src/test/resources/json/resource_lookup_item.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:11", + "updateDate": "2014-05-14T17:38:49", + "label": "01. Geographic Results by Segment", + "description": "Sample HTML5 multi-axis column chart", + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment", + "resourceType": "adhocDataView" +} \ No newline at end of file From b1a0510bcef55e198950bf1d967fb8934f8dda5d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 6 Aug 2015 16:02:33 +0300 Subject: [PATCH 024/457] Resolving hamcrest dependency issue --- client-network/build.gradle | 36 ++++--------------- .../v2/repository/RepositoryRestApiTest.java | 2 +- .../rest/v2/server/ServerRestApiTest.java | 2 +- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/client-network/build.gradle b/client-network/build.gradle index 5e3bb726..bee73763 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -38,39 +38,17 @@ dependencies { compile 'com.squareup.retrofit:retrofit:1.9.0' - // Hamcrest Matchers for Junit - testCompile('org.hamcrest:hamcrest-integration:1.3') - - testCompile('junit:junit:4.12') { - transitive = false - } - // JunitParams - testCompile('pl.pragmatists:JUnitParams:1.0.4') { - transitive = false - } - - // Mockito testCompile("org.mockito:mockito-core:1.10.19") { exclude group: 'org.hamcrest' - } - // Robolectric + Support v4 - testCompile('org.robolectric:shadows-support-v4:3.0-rc3') { - exclude group: 'junit' - exclude group: 'commons-logging', module: 'commons-logging' - exclude group: 'org.apache.httpcomponents', module: 'httpclient' - } - testCompile('org.robolectric:shadows-httpclient:3.0-rc3') { - exclude group: 'org.robolectric' + exclude group: 'org.objenesis' } testCompile('org.powermock:powermock-api-mockito:1.6.2') { - exclude module: 'hamcrest-core' - exclude module: 'objenesis' - } - testCompile('org.powermock:powermock-module-junit4:1.6.2') { - exclude group: 'junit' - exclude module: 'hamcrest-core' - exclude module: 'objenesis' - exclude module: 'powermock-core' + exclude group: 'org.mockito' } + testCompile('org.powermock:powermock-module-junit4:1.6.2') + + testCompile('org.robolectric:shadows-support-v4:3.0') + testCompile('org.robolectric:shadows-httpclient:3.0') + } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java index 93005f9a..11679e02 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java @@ -31,7 +31,7 @@ import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -import org.robolectric.shadows.FakeHttp; +import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; import java.util.Collection; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java index 591a4c36..65e4d0c3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java @@ -32,7 +32,7 @@ import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; -import org.robolectric.shadows.FakeHttp; +import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; From ee477736ca3f51b70c5274f9df9d6bd435815dba Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:02:20 +0300 Subject: [PATCH 025/457] Implementing AuthenticationRestApi --- client-network/build.gradle | 1 + .../rest/v2/entity/server/AuthResponse.java | 41 +++++ .../rest/v2/exception/ErrorHandler.java | 11 ++ .../network/rest/v2/exception/RestError.java | 63 ++++++++ .../v2/exception/RetrofitErrorHandler.java | 47 ++++++ .../rest/v2/server/AuthResponseFactory.java | 76 +++++++++ .../rest/v2/server/AuthenticationRestApi.java | 56 +++++++ .../v2/server/AuthenticationRestApiImpl.java | 151 ++++++++++++++++++ .../v2/server/AuthResponseFactoryTest.java | 70 ++++++++ .../v2/server/AuthenticationRestApiTest.java | 113 +++++++++++++ .../android/sdk/test/WebMockRule.java | 85 ++++++++++ .../repository/RepositoryRestApiTest.java | 3 +- .../server/AuthenticationRestApiTest.java | 58 +++++++ .../integration/server/ServerRestTest.java} | 7 +- 14 files changed, 778 insertions(+), 4 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/ErrorHandler.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RestError.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RetrofitErrorHandler.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactory.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactoryTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java rename client-network/src/test/java/com/jaspersoft/android/sdk/{network/rest/v2 => test/integration}/repository/RepositoryRestApiTest.java (94%) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/AuthenticationRestApiTest.java rename client-network/src/test/java/com/jaspersoft/android/sdk/{network/rest/v2/server/ServerRestApiTest.java => test/integration/server/ServerRestTest.java} (89%) diff --git a/client-network/build.gradle b/client-network/build.gradle index bee73763..f8be1c10 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -50,5 +50,6 @@ dependencies { testCompile('org.robolectric:shadows-support-v4:3.0') testCompile('org.robolectric:shadows-httpclient:3.0') + testCompile('com.squareup.okhttp:mockwebserver:2.4.0') } \ No newline at end of file diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java new file mode 100644 index 00000000..066dec89 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java @@ -0,0 +1,41 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class AuthResponse { + private final String mToken; + + public AuthResponse(String token) { + mToken = token; + } + + public String getToken() { + return mToken; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/ErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/ErrorHandler.java new file mode 100644 index 00000000..852563cf --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/ErrorHandler.java @@ -0,0 +1,11 @@ +package com.jaspersoft.android.sdk.network.rest.v2.exception; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ErrorHandler { + ErrorHandler DEFAULT = new RetrofitErrorHandler(); + + Throwable handleError(ERROR cause); +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RestError.java new file mode 100644 index 00000000..508925f2 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RestError.java @@ -0,0 +1,63 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.exception; + + +import retrofit.RetrofitError; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class RestError extends RuntimeException { + private final Kind mKind; + + RestError(String message, RetrofitError error, Kind kind) { + super(message, error); + mKind = kind; + } + + static RestError createNetworkError(RetrofitError error) { + return new RestError(error.getMessage(), error, Kind.NETWORK); + } + + static RestError createHttpError(RetrofitError error) { + return new RestError(error.getMessage(), error, Kind.HTTP); + } + + static RestError createUnexpectedError(RetrofitError error) { + return new RestError(error.getMessage(), error, Kind.UNEXPECTED); + } + + public Kind getKind() { + return mKind; + } + + public enum Kind { + NETWORK, + HTTP, + UNEXPECTED + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RetrofitErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RetrofitErrorHandler.java new file mode 100644 index 00000000..3489e950 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RetrofitErrorHandler.java @@ -0,0 +1,47 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.exception; + +import retrofit.*; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RetrofitErrorHandler implements ErrorHandler { + @Override + public Throwable handleError(RetrofitError error) { + switch (error.getKind()) { + case HTTP: + return RestError.createHttpError(error); + case NETWORK: + return RestError.createNetworkError(error); + case UNEXPECTED: + return RestError.createUnexpectedError(error); + default: + throw error; + } + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactory.java new file mode 100644 index 00000000..7315e15c --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactory.java @@ -0,0 +1,76 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.server; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import retrofit.client.Header; +import retrofit.client.Response; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class AuthResponseFactory { + private final List mCookieParts; + + AuthResponseFactory(List parts) { + mCookieParts = parts; + } + + public static AuthResponse create(Response response) { + List
headers = response.getHeaders(); + List parts = new ArrayList<>(); + for (Header header : headers) { + if (header.getName().equals("Set-Cookie")) { + parts.add(header.getValue()); + } + } + AuthResponseFactory responseFactory = new AuthResponseFactory(parts); + return responseFactory.create(); + } + + private AuthResponse create() { + String cookie = joinCookieParts().toString(); + return new AuthResponse(cookie); + } + + private StringBuilder joinCookieParts() { + StringBuilder stringBuilder = new StringBuilder(); + Iterator iterator = mCookieParts.iterator(); + while (iterator.hasNext()) { + String cookie = iterator.next(); + stringBuilder.append(cookie); + if (iterator.hasNext()) { + stringBuilder.append(";"); + } + } + return stringBuilder; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java new file mode 100644 index 00000000..6b1bb605 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java @@ -0,0 +1,56 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.server; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; + +import java.util.Map; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface AuthenticationRestApi { + @NonNull + AuthResponse authenticate(@NonNull String username, + @NonNull String password, + @Nullable String organization, + @Nullable Map params); + + class Builder { + private final String mBaseUrl; + + public Builder(String baseUrl) { + mBaseUrl = baseUrl; + } + + public AuthenticationRestApi build() { + return new AuthenticationRestApiImpl(mBaseUrl); + } + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java new file mode 100644 index 00000000..dbf0024f --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java @@ -0,0 +1,151 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.server; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; +import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.OkHttpClient; + +import java.util.List; +import java.util.Map; + +import retrofit.Endpoint; +import retrofit.Endpoints; +import retrofit.RestAdapter; +import retrofit.RetrofitError; +import retrofit.client.Header; +import retrofit.client.OkClient; +import retrofit.client.Response; +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.Query; +import retrofit.http.QueryMap; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class AuthenticationRestApiImpl implements AuthenticationRestApi { + private final RestApi mRestApi; + + AuthenticationRestApiImpl(String serverUrl) { + RestAdapter restAdapter = createRestAdapter(serverUrl); + mRestApi = restAdapter.create(RestApi.class); + } + + private RestAdapter createRestAdapter(String serverUrl) { + Endpoint endpoint = Endpoints.newFixedEndpoint(serverUrl); + + OkHttpClient httpClient = new OkHttpClient(); + httpClient.setFollowRedirects(false); + + RestAdapter.Builder builder = new RestAdapter.Builder(); + builder.setClient(new OkClient(httpClient)); + builder.setEndpoint(endpoint); + builder.setErrorHandler(new retrofit.ErrorHandler() { + @Override + @SuppressWarnings("unchecked") + public Throwable handleError(RetrofitError cause) { + return ErrorHandler.DEFAULT.handleError(cause); + } + }); + + return builder.build(); + } + + @NonNull + @Override + public AuthResponse authenticate(@NonNull String username, + @NonNull String password, + String organization, + Map params) { + try { + Response response = mRestApi.authenticate(username, password, organization, params); + return createAuthResponse(response); + } catch (RestError error) { + RetrofitError retrofitError = extractRetrofitError(error); + if (retrofitError.getKind() == RetrofitError.Kind.HTTP) { + Response response = retrofitError.getResponse(); + if (containsRedirect(response)) { + String location = retrieveLocation(response); + + if (locationPointsToSuccess(location)) { + return createAuthResponse(response); + } else { + throw error; + } + } else { + throw error; + } + } else { + throw error; + } + } + } + + private RetrofitError extractRetrofitError(RestError error) { + return (RetrofitError) error.getCause(); + } + + private boolean locationPointsToSuccess(String location) { + HttpUrl url = HttpUrl.parse(location); + String errorQueryParameter = url.queryParameter("error"); + return errorQueryParameter == null; + } + + @NonNull + private String retrieveLocation(Response response) { + List
headers = response.getHeaders(); + for (Header header : headers) { + if (header.getName().equals("Location")) { + return header.getValue(); + } + } + throw new IllegalStateException("Missing 'Location' header"); + } + + private boolean containsRedirect(Response response) { + int status = response.getStatus(); + return status >= 300 && status < 400; + } + + private AuthResponse createAuthResponse(Response response) { + return AuthResponseFactory.create(response); + } + + interface RestApi { + @NonNull + @Headers({"Accept:application/json"}) + @GET(value = "/j_spring_security_check") + Response authenticate(@Query(value = "j_username", encodeValue = false) String username, + @Query(value = "j_password", encodeValue = false) String password, + @Query(value = "orgId ", encodeValue = false) String organization, + @QueryMap Map params); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactoryTest.java new file mode 100644 index 00000000..064d1be0 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactoryTest.java @@ -0,0 +1,70 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.server; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; + +import retrofit.client.Header; +import retrofit.client.Response; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({Response.class}) +public class AuthResponseFactoryTest { + @Mock + Response mResponse; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void shouldExtractTokenFromNetworkResponse() { + when(mResponse.getHeaders()).thenReturn(new ArrayList
() {{ + add(new Header("Set-Cookie", "cookie1")); + add(new Header("Set-Cookie", "cookie2")); + }}); + AuthResponse response = AuthResponseFactory.create(mResponse); + assertThat(response.getToken(), is("cookie1;cookie2")); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java new file mode 100644 index 00000000..39f6f6cb --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java @@ -0,0 +1,113 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.server; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.test.WebMockRule; +import com.squareup.okhttp.mockwebserver.MockResponse; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public class AuthenticationRestApiTest { + private final String LOCATION_SUCCESS = "/scripts/bower_components/js-sdk/src/common/auth/loginSuccess.json;jsessionid=7D86AE28407432B728694DF649DB5E8F"; + private final String LOCATION_ERROR = "login.html;jsessionid=395364A98787A1C42D5FEB0E9F58CF9F?error=1"; + + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + + private AuthenticationRestApi mRestApi; + + @Before + public void setup() { + mRestApi = new AuthenticationRestApi.Builder(mWebMockRule.getRootUrl()).build(); + } + + @Test + public void shouldReturnResponseForSuccessRedirect() { + MockResponse mockResponse = create302Response(); + mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); + mWebMockRule.enqueue(mockResponse); + + AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", "null", null); + assertThat(response.getToken(), is(notNullValue())); + } + + @Test + public void shouldRiseErrorForErrorRedirect() { + mExpectedException.expect(RestError.class); + + MockResponse mockResponse = create302Response(); + mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_ERROR); + mWebMockRule.enqueue(mockResponse); + + mRestApi.authenticate("joeuser", "joeuser", "null", null); + } + + @Test + public void shouldRiseErrorForHttpException() { + mExpectedException.expect(RestError.class); + + MockResponse mockResponse = create500Response(); + mWebMockRule.enqueue(mockResponse); + + mRestApi.authenticate("joeuser", "joeuser", "null", null); + } + + @Test + public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() { + mExpectedException.expect(IllegalStateException.class); + mExpectedException.expectMessage("Missing 'Location' header"); + + MockResponse mockResponse = create302Response(); + mWebMockRule.enqueue(mockResponse); + + mRestApi.authenticate("joeuser", "joeuser", "null", null); + } + + private MockResponse create302Response() { + return new MockResponse() + .addHeader("Set-Cookie", "cookie1") + .setStatus("HTTP/1.1 302 Found"); + } + + private MockResponse create500Response() { + return new MockResponse() + .setStatus("HTTP/1.1 500 Internal Server Error"); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java new file mode 100644 index 00000000..90d3e744 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java @@ -0,0 +1,85 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; + +import org.junit.Before; +import org.junit.rules.ExternalResource; +import org.robolectric.shadows.httpclient.FakeHttp; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class WebMockRule extends ExternalResource { + private MockWebServer server; + + private Logger logger = Logger.getLogger(WebMockRule.class.getName()); + + @Before + public void before() throws Throwable { + super.before(); + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + + // Create a MockWebServer. These are lean enough that you can create a new + // instance for every unit test. + server = new MockWebServer(); + try { + server.start(); + } catch (IOException e) { + logger.log(Level.INFO, "Failed to start MockWebServer"); + throw new RuntimeException(e); + } + } + + @Override + protected void after() { + super.after(); + try { + server.shutdown(); + } catch (IOException e) { + logger.log(Level.INFO, "Failed to shutdown MockWebServer", e); + } + FakeHttp.getFakeHttpLayer().interceptHttpRequests(true); + } + + public MockWebServer get() { + return server; + } + + public String getRootUrl() { + return server.getUrl("/").toExternalForm(); + } + + public void enqueue(MockResponse mockResponse) { + server.enqueue(mockResponse); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java index 11679e02..7de9b9a2 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java @@ -22,9 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.repository; +package com.jaspersoft.android.sdk.test.integration.repository; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.repository.RepositoryRestApi; import org.junit.Before; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/AuthenticationRestApiTest.java new file mode 100644 index 00000000..18f5a12d --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/AuthenticationRestApiTest.java @@ -0,0 +1,58 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.server; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.rest.v2.server.AuthenticationRestApi; + +import org.junit.Before; +import org.junit.Test; +import org.robolectric.shadows.httpclient.FakeHttp; + +import java.io.IOException; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class AuthenticationRestApiTest { + String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + + @Before + public void setup() { + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + } + + @Test + public void shouldReturnResponseForSpringRequest() throws IOException { + AuthenticationRestApi authApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + AuthResponse response = authApi.authenticate("joeuser", "joeuser", "null", null); + assertThat(response.getToken(), is(notNullValue())); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/ServerRestTest.java similarity index 89% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/ServerRestTest.java index 65e4d0c3..69042c72 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/ServerRestTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,10 +22,11 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.test.integration.server; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.rest.v2.server.ServerRestApi; import org.junit.Before; import org.junit.Test; @@ -46,7 +47,7 @@ */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE) -public class ServerRestApiTest { +public class ServerRestTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; From 1cde80ec18b2d1513ba3094a5ee2d1419674b85c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:09:17 +0300 Subject: [PATCH 026/457] Add cookie parameter for RepositoryRestApi --- .../network/rest/v2/entity/server/AuthResponse.java | 7 +++++++ .../rest/v2/repository/RepositoryRestApi.java | 13 +++++++++++-- .../repository/RepositoryRestApiTest.java | 7 ++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java index 066dec89..65616a83 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java @@ -38,4 +38,11 @@ public AuthResponse(String token) { public String getToken() { return mToken; } + + @Override + public String toString() { + return "AuthResponse{" + + "mToken='" + mToken + '\'' + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java index 48604530..ae02a8ce 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -35,6 +35,7 @@ import retrofit.Endpoint; import retrofit.Endpoints; +import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.GsonConverter; import retrofit.http.GET; @@ -53,9 +54,11 @@ public interface RepositoryRestApi { class Builder { private final String mBaseUrl; + private final String mCookie; - public Builder(String baseUrl) { + public Builder(String baseUrl, String cookie) { mBaseUrl = baseUrl; + mCookie = cookie; } public RepositoryRestApi build() { @@ -64,6 +67,12 @@ public RepositoryRestApi build() { RestAdapter.Builder builder = new RestAdapter.Builder(); builder.setEndpoint(endpoint); builder.setConverter(new GsonConverter(GsonFactory.create())); + builder.setRequestInterceptor(new RequestInterceptor() { + @Override + public void intercept(RequestFacade request) { + request.addHeader("Cookie", mCookie); + } + }); RestAdapter restAdapter = builder.build(); return restAdapter.create(RepositoryRestApi.class); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java index 7de9b9a2..de7b5275 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java @@ -25,7 +25,9 @@ package com.jaspersoft.android.sdk.test.integration.repository; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.rest.v2.repository.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.server.AuthenticationRestApi; import org.junit.Before; import org.junit.Test; @@ -59,7 +61,10 @@ public void setup() { @Test public void shouldRequestServerInfo() throws IOException { - RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2).build(); + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + AuthResponse response = restApi.authenticate("joeuser", "joeuser", null, null); + + RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, response.getToken()).build(); Collection resourceLookupResponses = api.searchResources(null); assertThat(resourceLookupResponses, is(notNullValue())); assertThat(resourceLookupResponses.size(), is(not(0))); From fc78625426007a715410fdd53199a2928094e7af Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:13:53 +0300 Subject: [PATCH 027/457] Replace GET with POST for auth requests --- .../v2/server/AuthenticationRestApiImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java index dbf0024f..a1de61ea 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java @@ -42,10 +42,11 @@ import retrofit.client.Header; import retrofit.client.OkClient; import retrofit.client.Response; -import retrofit.http.GET; import retrofit.http.Headers; -import retrofit.http.Query; -import retrofit.http.QueryMap; +import retrofit.http.Multipart; +import retrofit.http.POST; +import retrofit.http.Part; +import retrofit.http.PartMap; /** * @author Tom Koptel @@ -140,12 +141,12 @@ private AuthResponse createAuthResponse(Response response) { } interface RestApi { - @NonNull + @Multipart @Headers({"Accept:application/json"}) - @GET(value = "/j_spring_security_check") - Response authenticate(@Query(value = "j_username", encodeValue = false) String username, - @Query(value = "j_password", encodeValue = false) String password, - @Query(value = "orgId ", encodeValue = false) String organization, - @QueryMap Map params); + @POST(value = "/j_spring_security_check") + Response authenticate(@Part(value = "j_username") String username, + @Part(value = "j_password") String password, + @Part(value = "orgId ") String organization, + @PartMap Map params); } } From 43e8c041474cd067d25a4a81d02783553a74b34a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:25:43 +0300 Subject: [PATCH 028/457] Add RepositoryRestApiTest for illegal states --- .../rest/v2/repository/RepositoryRestApi.java | 15 ++++ .../network/rest/v2/server/ServerRestApi.java | 9 +++ .../v2/repository/RepositoryRestApiTEst.java | 73 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTEst.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java index ae02a8ce..d572aa3d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; import java.util.Collection; import java.util.Map; @@ -37,6 +38,7 @@ import retrofit.Endpoints; import retrofit.RequestInterceptor; import retrofit.RestAdapter; +import retrofit.RetrofitError; import retrofit.converter.GsonConverter; import retrofit.http.GET; import retrofit.http.Headers; @@ -57,6 +59,12 @@ class Builder { private final String mCookie; public Builder(String baseUrl, String cookie) { + if (baseUrl == null || baseUrl.length() == 0) { + throw new IllegalArgumentException("Base url should not be null or empty"); + } + if (cookie == null || cookie.length() == 0) { + throw new IllegalArgumentException("Cookie should not be null or empty"); + } mBaseUrl = baseUrl; mCookie = cookie; } @@ -73,6 +81,13 @@ public void intercept(RequestFacade request) { request.addHeader("Cookie", mCookie); } }); + builder.setErrorHandler(new retrofit.ErrorHandler() { + @Override + @SuppressWarnings("unchecked") + public Throwable handleError(RetrofitError cause) { + return ErrorHandler.DEFAULT.handleError(cause); + } + }); RestAdapter restAdapter = builder.build(); return restAdapter.create(RepositoryRestApi.class); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java index e1fb4f22..6a28d855 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java @@ -28,10 +28,12 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; import retrofit.Endpoint; import retrofit.Endpoints; import retrofit.RestAdapter; +import retrofit.RetrofitError; import retrofit.converter.GsonConverter; import retrofit.http.GET; import retrofit.http.Headers; @@ -59,6 +61,13 @@ public ServerRestApi build() { RestAdapter.Builder builder = new RestAdapter.Builder(); builder.setEndpoint(endpoint); builder.setConverter(new GsonConverter(GsonFactory.create())); + builder.setErrorHandler(new retrofit.ErrorHandler() { + @Override + @SuppressWarnings("unchecked") + public Throwable handleError(RetrofitError cause) { + return ErrorHandler.DEFAULT.handleError(cause); + } + }); RestAdapter restAdapter = builder.build(); return restAdapter.create(ServerRestApi.class); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTEst.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTEst.java new file mode 100644 index 00000000..b8403409 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTEst.java @@ -0,0 +1,73 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.repository; + +import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.test.WebMockRule; +import com.squareup.okhttp.mockwebserver.MockResponse; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RepositoryRestApiTest { + + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + + + @Test + public void shouldThroughRestErrorForHttpError() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(create500Response()); + + RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + restApi.searchResources(null); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { + mExpectedException.expect(IllegalArgumentException.class); + new RepositoryRestApi.Builder(null, "cookie").build(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullCookie() { + mExpectedException.expect(IllegalArgumentException.class); + RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); + } + + private MockResponse create500Response() { + return new MockResponse() + .setStatus("HTTP/1.1 500 Internal Server Error"); + } +} From bacbe304fda583f033917a94b275bb2048878394 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:28:27 +0300 Subject: [PATCH 029/457] Add ServerRestApi for illegal states --- .../network/rest/v2/server/ServerRestApi.java | 3 + .../rest/v2/server/ServerRestApiTest.java | 66 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java index 6a28d855..7aabe222 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java @@ -52,6 +52,9 @@ class Builder { private final String mBaseUrl; public Builder(String baseUrl) { + if (baseUrl == null || baseUrl.length() == 0) { + throw new IllegalArgumentException("Base url should not be null or empty"); + } mBaseUrl = baseUrl; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java new file mode 100644 index 00000000..e889f1af --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java @@ -0,0 +1,66 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.server; + +import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.test.WebMockRule; +import com.squareup.okhttp.mockwebserver.MockResponse; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerRestApiTest { + + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + + @Test + public void shouldThroughRestErrorForHttpError() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(create500Response()); + + ServerRestApi restApi = new ServerRestApi.Builder(mWebMockRule.getRootUrl()).build(); + restApi.getServerInfo(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { + mExpectedException.expect(IllegalArgumentException.class); + new ServerRestApi.Builder(null).build(); + } + + private MockResponse create500Response() { + return new MockResponse() + .setStatus("HTTP/1.1 500 Internal Server Error"); + } +} From d466015b876c98b434189cd77e3f3e07736a17b0 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:30:12 +0300 Subject: [PATCH 030/457] Add test for IllegalArgument on AuthenticationRestApi --- .../sdk/network/rest/v2/server/AuthenticationRestApi.java | 3 +++ .../network/rest/v2/server/AuthenticationRestApiTest.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java index 6b1bb605..aab90238 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java @@ -46,6 +46,9 @@ class Builder { private final String mBaseUrl; public Builder(String baseUrl) { + if (baseUrl == null || baseUrl.length() == 0) { + throw new IllegalArgumentException("Base url should not be null or empty"); + } mBaseUrl = baseUrl; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java index 39f6f6cb..93652c2b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java @@ -58,6 +58,12 @@ public void setup() { mRestApi = new AuthenticationRestApi.Builder(mWebMockRule.getRootUrl()).build(); } + @Test + public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { + mExpectedException.expect(IllegalArgumentException.class); + new AuthenticationRestApi.Builder(null).build(); + } + @Test public void shouldReturnResponseForSuccessRedirect() { MockResponse mockResponse = create302Response(); From 8c432a4af4220097b93928f2b25608e7cfac2f22 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:37:13 +0300 Subject: [PATCH 031/457] Refactor packages --- .../rest/v2/{server => api}/AuthResponseFactory.java | 2 +- .../rest/v2/{server => api}/AuthenticationRestApi.java | 2 +- .../rest/v2/{server => api}/AuthenticationRestApiImpl.java | 2 +- .../rest/v2/{repository => api}/RepositoryRestApi.java | 2 +- .../sdk/network/rest/v2/{server => api}/ServerRestApi.java | 2 +- .../rest/v2/{server => api}/AuthResponseFactoryTest.java | 3 ++- .../rest/v2/{server => api}/AuthenticationRestApiTest.java | 2 +- .../RepositoryRestApiTest.java} | 3 ++- .../network/rest/v2/{server => api}/ServerRestApiTest.java | 3 ++- .../{server => api}/AuthenticationRestApiTest.java | 4 ++-- .../{repository => api}/RepositoryRestApiTest.java | 6 +++--- .../test/integration/{server => api}/ServerRestTest.java | 4 ++-- 12 files changed, 19 insertions(+), 16 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/{server => api}/AuthResponseFactory.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/{server => api}/AuthenticationRestApi.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/{server => api}/AuthenticationRestApiImpl.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/{repository => api}/RepositoryRestApi.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/{server => api}/ServerRestApi.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/{server => api}/AuthResponseFactoryTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/{server => api}/AuthenticationRestApiTest.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/{repository/RepositoryRestApiTEst.java => api/RepositoryRestApiTest.java} (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/{server => api}/ServerRestApiTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/{server => api}/AuthenticationRestApiTest.java (93%) rename client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/{repository => api}/RepositoryRestApiTest.java (92%) rename client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/{server => api}/ServerRestTest.java (94%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactory.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactory.java index 7315e15c..287bb3aa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java index aab90238..f7182077 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.api; import android.support.annotation.NonNull; import android.support.annotation.Nullable; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java index a1de61ea..9feb23c9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.api; import android.support.annotation.NonNull; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index d572aa3d..682dcf75 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.repository; +package com.jaspersoft.android.sdk.network.rest.v2.api; import android.support.annotation.NonNull; import android.support.annotation.Nullable; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java index 7aabe222..179b98f8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.api; import android.support.annotation.NonNull; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactoryTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactoryTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactoryTest.java index 064d1be0..cb581a55 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthResponseFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactoryTest.java @@ -22,8 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.api; +import com.jaspersoft.android.sdk.network.rest.v2.api.AuthResponseFactory; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import org.junit.Before; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java index 93652c2b..f01b9174 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTEst.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTEst.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java index b8403409..6363e701 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/repository/RepositoryRestApiTEst.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java @@ -22,8 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.repository; +package com.jaspersoft.android.sdk.network.rest.v2.api; +import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApiTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApiTest.java index e889f1af..b87210fd 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/server/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApiTest.java @@ -22,8 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.server; +package com.jaspersoft.android.sdk.network.rest.v2.api; +import com.jaspersoft.android.sdk.network.rest.v2.api.ServerRestApi; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java similarity index 93% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/AuthenticationRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 18f5a12d..c3c1abff 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -22,10 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.server; +package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.rest.v2.server.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import org.junit.Before; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java similarity index 92% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index de7b5275..ec087fb5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/repository/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.repository; +package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.rest.v2.repository.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.server.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import org.junit.Before; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/ServerRestTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 69042c72..624c0ddb 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/server/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -22,11 +22,11 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.server; +package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; -import com.jaspersoft.android.sdk.network.rest.v2.server.ServerRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.ServerRestApi; import org.junit.Before; import org.junit.Test; From ad28e06fe87dd72b878bd222eee23d66aa383d8b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 7 Aug 2015 16:47:00 +0300 Subject: [PATCH 032/457] Refactor rest builder related code --- .../rest/v2/api/AuthenticationRestApi.java | 21 ++++--- .../v2/api/AuthenticationRestApiImpl.java | 23 +------ .../sdk/network/rest/v2/api/BaseBuilder.java | 61 +++++++++++++++++++ .../rest/v2/api/RepositoryRestApi.java | 20 +----- .../network/rest/v2/api/ServerRestApi.java | 27 ++------ 5 files changed, 82 insertions(+), 70 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java index f7182077..6e87628c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java @@ -28,9 +28,13 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.squareup.okhttp.OkHttpClient; import java.util.Map; +import retrofit.RestAdapter; +import retrofit.client.OkClient; + /** * @author Tom Koptel * @since 2.0 @@ -42,18 +46,19 @@ AuthResponse authenticate(@NonNull String username, @Nullable String organization, @Nullable Map params); - class Builder { - private final String mBaseUrl; - + class Builder extends BaseBuilder { public Builder(String baseUrl) { - if (baseUrl == null || baseUrl.length() == 0) { - throw new IllegalArgumentException("Base url should not be null or empty"); - } - mBaseUrl = baseUrl; + super(baseUrl); } public AuthenticationRestApi build() { - return new AuthenticationRestApiImpl(mBaseUrl); + RestAdapter.Builder builder = getDefaultBuilder(); + + OkHttpClient httpClient = new OkHttpClient(); + httpClient.setFollowRedirects(false); + builder.setClient(new OkClient(httpClient)); + + return new AuthenticationRestApiImpl(builder.build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java index 9feb23c9..b167b868 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java @@ -55,31 +55,10 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { private final RestApi mRestApi; - AuthenticationRestApiImpl(String serverUrl) { - RestAdapter restAdapter = createRestAdapter(serverUrl); + AuthenticationRestApiImpl(RestAdapter restAdapter) { mRestApi = restAdapter.create(RestApi.class); } - private RestAdapter createRestAdapter(String serverUrl) { - Endpoint endpoint = Endpoints.newFixedEndpoint(serverUrl); - - OkHttpClient httpClient = new OkHttpClient(); - httpClient.setFollowRedirects(false); - - RestAdapter.Builder builder = new RestAdapter.Builder(); - builder.setClient(new OkClient(httpClient)); - builder.setEndpoint(endpoint); - builder.setErrorHandler(new retrofit.ErrorHandler() { - @Override - @SuppressWarnings("unchecked") - public Throwable handleError(RetrofitError cause) { - return ErrorHandler.DEFAULT.handleError(cause); - } - }); - - return builder.build(); - } - @NonNull @Override public AuthResponse authenticate(@NonNull String username, diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java new file mode 100644 index 00000000..e5de6b41 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java @@ -0,0 +1,61 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; + +import retrofit.RestAdapter; +import retrofit.RetrofitError; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class BaseBuilder { + private final String mBaseUrl; + private final RestAdapter.Builder mRestAdapterBuilder; + + public BaseBuilder(String baseUrl){ + if (baseUrl == null || baseUrl.length() == 0) { + throw new IllegalArgumentException("Base url should not be null or empty"); + } + mBaseUrl = baseUrl; + mRestAdapterBuilder = new RestAdapter.Builder(); + mRestAdapterBuilder.setEndpoint(mBaseUrl); + mRestAdapterBuilder.setErrorHandler(new retrofit.ErrorHandler() { + @Override + @SuppressWarnings("unchecked") + public Throwable handleError(RetrofitError cause) { + return ErrorHandler.DEFAULT.handleError(cause); + } + }); + } + + protected RestAdapter.Builder getDefaultBuilder() { + return mRestAdapterBuilder; + } + + public abstract API build(); +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index 682dcf75..6f6a5214 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -54,26 +54,19 @@ public interface RepositoryRestApi { @GET("/rest_v2/resources") Collection searchResources(@Nullable @QueryMap Map searchParams); - class Builder { - private final String mBaseUrl; + class Builder extends BaseBuilder { private final String mCookie; public Builder(String baseUrl, String cookie) { - if (baseUrl == null || baseUrl.length() == 0) { - throw new IllegalArgumentException("Base url should not be null or empty"); - } + super(baseUrl); if (cookie == null || cookie.length() == 0) { throw new IllegalArgumentException("Cookie should not be null or empty"); } - mBaseUrl = baseUrl; mCookie = cookie; } public RepositoryRestApi build() { - Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); - - RestAdapter.Builder builder = new RestAdapter.Builder(); - builder.setEndpoint(endpoint); + RestAdapter.Builder builder = getDefaultBuilder(); builder.setConverter(new GsonConverter(GsonFactory.create())); builder.setRequestInterceptor(new RequestInterceptor() { @Override @@ -81,13 +74,6 @@ public void intercept(RequestFacade request) { request.addHeader("Cookie", mCookie); } }); - builder.setErrorHandler(new retrofit.ErrorHandler() { - @Override - @SuppressWarnings("unchecked") - public Throwable handleError(RetrofitError cause) { - return ErrorHandler.DEFAULT.handleError(cause); - } - }); RestAdapter restAdapter = builder.build(); return restAdapter.create(RepositoryRestApi.class); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java index 179b98f8..633d285d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java @@ -26,14 +26,10 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; -import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import retrofit.Endpoint; -import retrofit.Endpoints; import retrofit.RestAdapter; -import retrofit.RetrofitError; import retrofit.converter.GsonConverter; import retrofit.http.GET; import retrofit.http.Headers; @@ -48,29 +44,14 @@ public interface ServerRestApi { @GET(value = "/rest_v2/serverInfo") ServerInfoResponse getServerInfo(); - class Builder { - private final String mBaseUrl; - + class Builder extends BaseBuilder { public Builder(String baseUrl) { - if (baseUrl == null || baseUrl.length() == 0) { - throw new IllegalArgumentException("Base url should not be null or empty"); - } - mBaseUrl = baseUrl; + super(baseUrl); } public ServerRestApi build() { - Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); - - RestAdapter.Builder builder = new RestAdapter.Builder(); - builder.setEndpoint(endpoint); + RestAdapter.Builder builder = getDefaultBuilder(); builder.setConverter(new GsonConverter(GsonFactory.create())); - builder.setErrorHandler(new retrofit.ErrorHandler() { - @Override - @SuppressWarnings("unchecked") - public Throwable handleError(RetrofitError cause) { - return ErrorHandler.DEFAULT.handleError(cause); - } - }); RestAdapter restAdapter = builder.build(); return restAdapter.create(ServerRestApi.class); From 219676cc9d6bd8a3d2add50dfebde5740189850a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 10 Aug 2015 14:14:55 +0300 Subject: [PATCH 033/457] Add api 'requestReportResource' for repository module --- .../rest/v2/api/RepositoryRestApi.java | 13 +- .../rest/v2/entity/resource/DataSource.java | 40 +++++ .../entity/resource/DataSourceReference.java | 40 +++++ .../rest/v2/entity/resource/JRXml.java | 41 +++++ .../entity/resource/JRXmlFileReference.java | 41 +++++ .../entity/resource/ReportLookupResponse.java | 84 +++++++++ .../v2/entity/resource/ReportResource.java | 47 +++++ .../rest/v2/entity/resource/ResourceFile.java | 41 +++++ .../resource/ResourceFileReference.java | 41 +++++ .../resource/ResourceLookupResponse.java | 16 +- .../rest/v2/entity/type/GsonFactory.java | 1 + .../ReportResourcesTypeAdapterFactory.java | 52 ++++++ .../resource/ReportLookupResponseTest.java | 162 ++++++++++++++++++ .../api/RepositoryRestApiTest.java | 25 ++- .../resources/json/report_unit_resource1.json | 24 +++ .../resources/json/report_unit_resource2.json | 89 ++++++++++ 16 files changed, 739 insertions(+), 18 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFileReference.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportResourcesTypeAdapterFactory.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java create mode 100644 client-network/src/test/resources/json/report_unit_resource1.json create mode 100644 client-network/src/test/resources/json/report_unit_resource2.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index 6f6a5214..3f20dd58 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -27,21 +27,19 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import java.util.Collection; import java.util.Map; -import retrofit.Endpoint; -import retrofit.Endpoints; import retrofit.RequestInterceptor; import retrofit.RestAdapter; -import retrofit.RetrofitError; import retrofit.converter.GsonConverter; import retrofit.http.GET; import retrofit.http.Headers; +import retrofit.http.Path; import retrofit.http.QueryMap; /** @@ -54,6 +52,11 @@ public interface RepositoryRestApi { @GET("/rest_v2/resources") Collection searchResources(@Nullable @QueryMap Map searchParams); + @NonNull + @Headers("Accept: application/repository.reportUnit+json") + @GET("/rest_v2/resources{resourceUri}") + ReportLookupResponse requestReportResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + class Builder extends BaseBuilder { private final String mCookie; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java new file mode 100644 index 00000000..7afabef1 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java @@ -0,0 +1,40 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DataSource { + @Expose + private DataSourceReference dataSourceReference; + + public DataSourceReference getDataSourceReference() { + return dataSourceReference; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java new file mode 100644 index 00000000..f4137d0c --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java @@ -0,0 +1,40 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DataSourceReference { + @Expose + private String uri; + + public String getUri() { + return uri; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java new file mode 100644 index 00000000..bd5e37fe --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class JRXml { + + @Expose + private JRXmlFileReference jrxmlFileReference; + + public JRXmlFileReference getJrxmlFileReference() { + return jrxmlFileReference; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java new file mode 100644 index 00000000..c3f2ab18 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class JRXmlFileReference { + + @Expose + private String uri; + + public String getUri() { + return uri; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java new file mode 100644 index 00000000..54b75567 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java @@ -0,0 +1,84 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportLookupResponse extends ResourceLookupResponse { + + @Expose + private DataSource dataSource; + @Expose + private JRXml jrxml; + @Expose + private String inputControlRenderingView; + @Expose + private String reportRenderingView; + @Expose + private boolean alwaysPromptControls; + @Expose + private String controlsLayout; + @Expose + private List resources; + + @Override + public String getResourceType() { + return "reportUnit"; + } + + public boolean isAlwaysPromptControls() { + return alwaysPromptControls; + } + + public String getControlsLayout() { + return controlsLayout; + } + + public DataSource getDataSource() { + return dataSource; + } + + public String getInputControlRenderingView() { + return inputControlRenderingView; + } + + public JRXml getJrxml() { + return jrxml; + } + + public String getReportRenderingView() { + return reportRenderingView; + } + + public List getResources() { + return resources; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java new file mode 100644 index 00000000..c882edea --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportResource { + + @Expose + private String name; + @Expose + private ResourceFile file; + + public ResourceFile getFile() { + return file; + } + + public String getName() { + return name; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java new file mode 100644 index 00000000..d662f63e --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ResourceFile { + + @Expose + private ResourceFileReference fileReference; + + public ResourceFileReference getFileReference() { + return fileReference; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFileReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFileReference.java new file mode 100644 index 00000000..4fd8caf1 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFileReference.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ResourceFileReference { + + @Expose + private String uri; + + public String getUri() { + return uri; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java index bc488f44..dcfe8177 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java @@ -30,25 +30,25 @@ * @author Tom Koptel * @since 2.0 */ -public final class ResourceLookupResponse { +public class ResourceLookupResponse { @Expose - private String label; + protected String label; @Expose - private String description; + protected String description; @Expose - private String uri; + protected String uri; @Expose private String resourceType; @Expose - private int version; + protected int version; @Expose - private int permissionMask; + protected int permissionMask; @Expose - private String creationDate; + protected String creationDate; @Expose - private String updateDate; + protected String updateDate; public String getCreationDate() { return creationDate; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java index 4fbbe81b..96e04093 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java @@ -37,6 +37,7 @@ public static Gson create() { gsonBuilder.excludeFieldsWithoutExposeAnnotation(); gsonBuilder.disableHtmlEscaping(); gsonBuilder.registerTypeAdapterFactory(new ResourceLookupTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ReportResourcesTypeAdapterFactory()); return gsonBuilder.create(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportResourcesTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportResourcesTypeAdapterFactory.java new file mode 100644 index 00000000..819b88d8 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportResourcesTypeAdapterFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.type; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportResource; + +import java.util.List; + + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportResourcesTypeAdapterFactory extends CustomizedTypeAdapterFactory> { + static final TypeToken TOKEN_TYPE = new TypeToken>(){}; + + @SuppressWarnings("unchecked") + public ReportResourcesTypeAdapterFactory() { + super(TOKEN_TYPE.getRawType()); + } + + @Override + protected JsonElement afterRead(JsonElement deserialized) { + JsonObject jsonObject = deserialized.getAsJsonObject(); + return jsonObject.getAsJsonArray("resource"); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java new file mode 100644 index 00000000..9e7cf906 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java @@ -0,0 +1,162 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportLookupResponseTest { + @com.jaspersoft.android.sdk.test.resource.ResourceFile("json/report_unit_resource1.json") + TestResource reportResponse1; + @com.jaspersoft.android.sdk.test.resource.ResourceFile("json/report_unit_resource2.json") + TestResource reportResponse2; + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + + @Test + public void shouldDeserializeResponse1FromWholeJson() { + ReportLookupResponse response1 = deserialize(reportResponse1.asString()); + assertThat(response1, is(notNullValue())); + } + + @Test + public void shouldDeserializeResponse2FromWholeJson() { + ReportLookupResponse response2 = deserialize(reportResponse2.asString()); + assertThat(response2, is(notNullValue())); + } + + @Test + public void shouldAlwaysReturnReportUnitUriAsType() { + ReportLookupResponse response = deserialize("{}"); + assertThat(response.getResourceType(), is("reportUnit")); + } + + @Test + public void shouldDeserializeVersion() { + ReportLookupResponse response = deserialize("{\"version\": 2}"); + assertThat(response.getVersion(), is(2)); + } + + @Test + public void shouldDeserializePermissionMask() { + ReportLookupResponse response = deserialize("{\"permissionMask\": 1}"); + assertThat(response.getPermissionMask(), is(1)); + } + + @Test + public void shouldDeserializeCreationDate() { + ReportLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); + assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); + } + + @Test + public void shouldDeserializeUpdateDate() { + ReportLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); + assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); + } + + @Test + public void shouldDeserializeLabel() { + ReportLookupResponse response = deserialize("{\"label\": \"01. Geographic Results by Segment\"}"); + assertThat(response.getLabel(), is("01. Geographic Results by Segment")); + } + + @Test + public void shouldDeserializeDescription() { + ReportLookupResponse response = deserialize("{\"description\": \"Sample HTML5 multi-axis column chart\"}"); + assertThat(response.getDescription(), is("Sample HTML5 multi-axis column chart")); + } + + @Test + public void shouldDeserializeUri() { + ReportLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment\"}"); + assertThat(response.getUri(), is("/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment")); + } + + @Test + public void shouldDeserializeDataSource() { + ReportLookupResponse response = deserialize("{\"dataSource\": {\"dataSourceReference\": {\"uri\": \"/public/Samples/Data_Sources/JServerJNDIDS\"}}}"); + assertThat(response.getDataSource().getDataSourceReference().getUri(), is("/public/Samples/Data_Sources/JServerJNDIDS")); + } + + @Test + public void shouldDeserializeJrxml() { + ReportLookupResponse response = deserialize("{\"jrxml\": {\"jrxmlFileReference\": {\"uri\": \"/public/Samples/Reports/AllAccounts_files/main_jrxml\"}}}"); + assertThat(response.getJrxml().getJrxmlFileReference().getUri(), is("/public/Samples/Reports/AllAccounts_files/main_jrxml")); + } + + @Test + public void shouldDeserializeInputControlRenderingView() { + ReportLookupResponse response = deserialize("{\"inputControlRenderingView\": \"any view\"}"); + assertThat(response.getInputControlRenderingView(), is("any view")); + } + + @Test + public void shouldDeserializeReportRenderingView() { + ReportLookupResponse response = deserialize("{\"reportRenderingView\": \"any view\"}"); + assertThat(response.getReportRenderingView(), is("any view")); + } + + @Test + public void shouldDeserializeAlwaysPrompt() { + ReportLookupResponse response = deserialize("{\"alwaysPromptControls\": \"true\"}"); + assertThat(response.isAlwaysPromptControls(), is(true)); + } + + @Test + public void shouldDeserializeControlsLayout() { + ReportLookupResponse response = deserialize("{\"controlsLayout\": \"any layout\"}"); + assertThat(response.getControlsLayout(), is("any layout")); + } + + @Test + public void shouldDeserializeResources() { + ReportLookupResponse response = deserialize("{\"resources\": {\"resource\": [{\"name\": \"SampleReportsStyles.jrtx\",\"file\": {\"fileReference\": {\"uri\": \"/public/Samples/Resources/Extras/SampleReportStyles.jrtx\"}}}]}}"); + + ReportResource reportResource = response.getResources().get(0); + ResourceFile file = reportResource.getFile(); + assertThat(file.getFileReference().getUri(), is("/public/Samples/Resources/Extras/SampleReportStyles.jrtx")); + assertThat(reportResource.getName(), is("SampleReportsStyles.jrtx")); + } + + private ReportLookupResponse deserialize(String json) { + return GsonFactory.create().fromJson(json, ReportLookupResponse.class); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index ec087fb5..26e77c36 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; @@ -53,6 +54,7 @@ public class RepositoryRestApiTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + AuthResponse mAuthResponse; @Before public void setup() { @@ -60,13 +62,26 @@ public void setup() { } @Test - public void shouldRequestServerInfo() throws IOException { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); - AuthResponse response = restApi.authenticate("joeuser", "joeuser", null, null); - - RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, response.getToken()).build(); + public void shouldRequestListOfResources() throws IOException { + RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); Collection resourceLookupResponses = api.searchResources(null); assertThat(resourceLookupResponses, is(notNullValue())); assertThat(resourceLookupResponses.size(), is(not(0))); } + + @Test + public void shouldRequestReport() throws IOException { + RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); + ReportLookupResponse report = api.requestReportResource("/public/Samples/Reports/AllAccounts"); + assertThat(report, is(notNullValue())); + assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); + } + + private AuthResponse getAuthResponse() { + if (mAuthResponse == null) { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", null, null); + } + return mAuthResponse; + } } \ No newline at end of file diff --git a/client-network/src/test/resources/json/report_unit_resource1.json b/client-network/src/test/resources/json/report_unit_resource1.json new file mode 100644 index 00000000..f2120624 --- /dev/null +++ b/client-network/src/test/resources/json/report_unit_resource1.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "permissionMask": 2, + "creationDate": "2015-06-05T07:21:20", + "updateDate": "2014-04-17T17:07:12", + "label": "05. Accounts Report", + "description": "Basic interactive Table Component report with Bookmarks Panel", + "uri": "/public/Samples/Reports/AllAccounts", + "dataSource": { + "dataSourceReference": { + "uri": "/public/Samples/Data_Sources/JServerJNDIDS" + } + }, + "jrxml": { + "jrxmlFileReference": { + "uri": "/public/Samples/Reports/AllAccounts_files/main_jrxml" + } + }, + "inputControlRenderingView": "", + "reportRenderingView": "", + "alwaysPromptControls": true, + "controlsLayout": "popupScreen", + "resources": {"resource": [{"name": "SampleReportsStyles.jrtx","file": {"fileReference": {"uri": "/public/Samples/Resources/Extras/SampleReportStyles.jrtx"}}}]} +} \ No newline at end of file diff --git a/client-network/src/test/resources/json/report_unit_resource2.json b/client-network/src/test/resources/json/report_unit_resource2.json new file mode 100644 index 00000000..58eb43f8 --- /dev/null +++ b/client-network/src/test/resources/json/report_unit_resource2.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "permissionMask": 2, + "creationDate": "2015-06-05T07:21:12", + "updateDate": "2014-05-14T17:46:00", + "label": "01. Geographic Results by Segment Report", + "description": "Sample HTML5 multi-axis column chart from Domain showing Sales, Units, and $ Per Square Foot by Country and Store Type with various filters. Created from an Ad Hoc View.", + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report", + "dataSource": { + "dataSourceReference": { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment" + } + }, + "jrxml": { + "jrxmlFileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/mainReportJrxml" + } + }, + "alwaysPromptControls": false, + "controlsLayout": "popupScreen", + "resources": { + "resource": [ + { + "name": "supermart_domain_de.properties", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/supermart_domain_de.properties" + } + } + }, + { + "name": "stateXML", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/stateXML" + } + } + }, + { + "name": "supermart_domain_zh_CN.properties", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/supermart_domain_zh_CN.properties" + } + } + }, + { + "name": "supermart_domain_ja.properties", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/supermart_domain_ja.properties" + } + } + }, + { + "name": "supermart_domain_en_US.properties", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/supermart_domain_en_US.properties" + } + } + }, + { + "name": "supermart_domain.properties", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/supermart_domain.properties" + } + } + }, + { + "name": "supermart_domain_es.properties", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/supermart_domain_es.properties" + } + } + }, + { + "name": "supermart_domain_fr.properties", + "file": { + "fileReference": { + "uri": "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report_files/supermart_domain_fr.properties" + } + } + } + ] + } +} \ No newline at end of file From 9dcb1af8d72b50787eb1d27941567becb6373e4a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 10 Aug 2015 15:06:19 +0300 Subject: [PATCH 034/457] Add api 'requestDashboardResource' for repository module --- .../rest/v2/api/RepositoryRestApi.java | 6 + .../entity/resource/DashboardFoundation.java | 59 ++++++++ .../resource/DashboardLookupResponse.java | 60 ++++++++ .../v2/entity/resource/DashboardResource.java | 53 ++++++++ .../resource/DashboardResourceInfo.java | 41 ++++++ .../rest/v2/entity/resource/ResourceFile.java | 4 +- ...eReference.java => ResourceReference.java} | 2 +- .../rest/v2/entity/type/GsonFactory.java | 2 +- ...portLookupResponseTypeAdapterFactory.java} | 23 ++-- .../resource/DashboardLookupResponseTest.java | 128 ++++++++++++++++++ .../api/RepositoryRestApiTest.java | 9 ++ .../json/dashboard_unit_resource.json | 101 ++++++++++++++ 12 files changed, 473 insertions(+), 15 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/{ResourceFileReference.java => ResourceReference.java} (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/{ReportResourcesTypeAdapterFactory.java => ReportLookupResponseTypeAdapterFactory.java} (70%) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java create mode 100644 client-network/src/test/resources/json/dashboard_unit_resource.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index 3f20dd58..c0b17b46 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; @@ -57,6 +58,11 @@ public interface RepositoryRestApi { @GET("/rest_v2/resources{resourceUri}") ReportLookupResponse requestReportResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + @NonNull + @Headers("Accept: application/repository.dashboard+json") + @GET("/rest_v2/resources{resourceUri}") + DashboardLookupResponse requestDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + class Builder extends BaseBuilder { private final String mCookie; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java new file mode 100644 index 00000000..4237f5d7 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DashboardFoundation { + + @Expose + private String id; + @Expose + private String layout; + @Expose + private String wiring; + @Expose + private String components; + + public String getComponents() { + return components; + } + + public String getId() { + return id; + } + + public String getLayout() { + return layout; + } + + public String getWiring() { + return wiring; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java new file mode 100644 index 00000000..1ff18b85 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java @@ -0,0 +1,60 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DashboardLookupResponse extends ResourceLookupResponse { + + @Expose + private List foundations; + @Expose + private List resources; + @Expose + private String defaultFoundation; + + @Override + public String getResourceType() { + return "dashboard"; + } + + public String getDefaultFoundation() { + return defaultFoundation; + } + + public List getFoundations() { + return foundations; + } + + public List getResources() { + return resources; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java new file mode 100644 index 00000000..4cae1b4d --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DashboardResource { + + @Expose + private String name; + @Expose + private String type; + @Expose + private DashboardResourceInfo resource; + + public DashboardResourceInfo getResource() { + return resource; + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java new file mode 100644 index 00000000..ccb9502f --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DashboardResourceInfo { + + @Expose + private ResourceReference resourceReference; + + public ResourceReference getResourceReference() { + return resourceReference; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java index d662f63e..b474e33d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java @@ -33,9 +33,9 @@ public final class ResourceFile { @Expose - private ResourceFileReference fileReference; + private ResourceReference fileReference; - public ResourceFileReference getFileReference() { + public ResourceReference getFileReference() { return fileReference; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFileReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFileReference.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java index 4fd8caf1..93fedfa7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFileReference.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java @@ -30,7 +30,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ResourceFileReference { +public final class ResourceReference { @Expose private String uri; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java index 96e04093..e45fdbb2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java @@ -37,7 +37,7 @@ public static Gson create() { gsonBuilder.excludeFieldsWithoutExposeAnnotation(); gsonBuilder.disableHtmlEscaping(); gsonBuilder.registerTypeAdapterFactory(new ResourceLookupTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ReportResourcesTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ReportLookupResponseTypeAdapterFactory()); return gsonBuilder.create(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportResourcesTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportLookupResponseTypeAdapterFactory.java similarity index 70% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportResourcesTypeAdapterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportLookupResponseTypeAdapterFactory.java index 819b88d8..5110f6d9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportResourcesTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportLookupResponseTypeAdapterFactory.java @@ -24,29 +24,30 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.type; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportResource; - -import java.util.List; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; /** * @author Tom Koptel * @since 2.0 */ -final class ReportResourcesTypeAdapterFactory extends CustomizedTypeAdapterFactory> { - static final TypeToken TOKEN_TYPE = new TypeToken>(){}; - - @SuppressWarnings("unchecked") - public ReportResourcesTypeAdapterFactory() { - super(TOKEN_TYPE.getRawType()); +final class ReportLookupResponseTypeAdapterFactory extends CustomizedTypeAdapterFactory { + public ReportLookupResponseTypeAdapterFactory() { + super(ReportLookupResponse.class); } @Override protected JsonElement afterRead(JsonElement deserialized) { JsonObject jsonObject = deserialized.getAsJsonObject(); - return jsonObject.getAsJsonArray("resource"); + JsonObject resources = jsonObject.getAsJsonObject("resources"); + if (resources != null) { + JsonArray resourceArray = resources.getAsJsonArray("resource"); + jsonObject.remove("resources"); + jsonObject.add("resources", resourceArray); + } + return jsonObject; } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java new file mode 100644 index 00000000..79d4f8ff --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java @@ -0,0 +1,128 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class DashboardLookupResponseTest { + @com.jaspersoft.android.sdk.test.resource.ResourceFile("json/dashboard_unit_resource.json") + TestResource dashboardResponse1; + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + + @Test + public void shouldDeserializeResponse1FromWholeJson() { + DashboardLookupResponse response1 = deserialize(dashboardResponse1.asString()); + assertThat(response1, is(notNullValue())); + } + + @Test + public void shouldDeserializeVersion() { + DashboardLookupResponse response = deserialize("{\"version\": 2}"); + assertThat(response.getVersion(), is(2)); + } + + @Test + public void shouldDeserializePermissionMask() { + DashboardLookupResponse response = deserialize("{\"permissionMask\": 1}"); + assertThat(response.getPermissionMask(), is(1)); + } + + @Test + public void shouldDeserializeCreationDate() { + DashboardLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); + assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); + } + + @Test + public void shouldDeserializeUpdateDate() { + DashboardLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); + assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); + } + + @Test + public void shouldDeserializeLabel() { + DashboardLookupResponse response = deserialize("{\"label\": \"01. Geographic Results by Segment\"}"); + assertThat(response.getLabel(), is("01. Geographic Results by Segment")); + } + + @Test + public void shouldDeserializeDescription() { + DashboardLookupResponse response = deserialize("{\"description\": \"Sample HTML5 multi-axis column chart\"}"); + assertThat(response.getDescription(), is("Sample HTML5 multi-axis column chart")); + } + + @Test + public void shouldDeserializeUri() { + DashboardLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment\"}"); + assertThat(response.getUri(), is("/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment")); + } + + @Test + public void shouldDeserializeFoundations() { + DashboardLookupResponse response = deserialize("{\"foundations\": [{\"id\": \"default\",\"layout\": \"layout\",\"wiring\": \"wiring\",\"components\": \"components\"}]}"); + DashboardFoundation foundation = response.getFoundations().get(0); + assertThat(foundation.getId(), is("default")); + assertThat(foundation.getLayout(), is("layout")); + assertThat(foundation.getWiring(), is("wiring")); + assertThat(foundation.getComponents(), is("components")); + } + + @Test + public void shouldDeserializeDefaultFoundation() { + DashboardLookupResponse response = deserialize("{\"defaultFoundation\": \"default\"}"); + assertThat(response.getDefaultFoundation(), is("default")); + } + + @Test + public void shouldDeserializeResources() { + DashboardLookupResponse response = deserialize("{\"resources\": [{\"name\": \"wiring\",\"type\": \"wiring\",\"resource\": {\"resourceReference\": {\"uri\": \"/public/Samples/Dashboards/1._Supermart_Dashboard_files/wiring\"}}}]}"); + DashboardResource resource = response.getResources().get(0); + DashboardResourceInfo info = resource.getResource(); + assertThat(resource.getName(), is("wiring")); + assertThat(resource.getType(), is("wiring")); + assertThat(info.getResourceReference().getUri(), is("/public/Samples/Dashboards/1._Supermart_Dashboard_files/wiring")); + } + + private DashboardLookupResponse deserialize(String json) { + return GsonFactory.create().fromJson(json, DashboardLookupResponse.class); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 26e77c36..c5e63534 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; @@ -77,6 +78,14 @@ public void shouldRequestReport() throws IOException { assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } + @Test + public void shouldRequestDashboard() throws IOException { + RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); + DashboardLookupResponse dashboard = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); + assertThat(dashboard, is(notNullValue())); + assertThat(dashboard.getFoundations().size(), is(not(0))); + } + private AuthResponse getAuthResponse() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); diff --git a/client-network/src/test/resources/json/dashboard_unit_resource.json b/client-network/src/test/resources/json/dashboard_unit_resource.json new file mode 100644 index 00000000..281d98e7 --- /dev/null +++ b/client-network/src/test/resources/json/dashboard_unit_resource.json @@ -0,0 +1,101 @@ +{ + "version": 1, + "permissionMask": 2, + "creationDate": "2015-06-05T07:21:37", + "updateDate": "2015-05-04T21:05:55", + "label": "1. Supermart Dashboard", + "description": "Sample containing 5 Dashlets and Filter wiring. One Dashlet is a report with hyperlinks, the other Dashlets are defined as part of the Dashboard.", + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard", + "foundations": [ + { + "id": "default", + "layout": "layout", + "wiring": "wiring", + "components": "components" + } + ], + "resources": [ + { + "name": "wiring", + "type": "wiring", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/wiring" + } + } + }, + { + "name": "layout", + "type": "layout", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/layout" + } + } + }, + { + "name": "components", + "type": "components", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/components" + } + } + }, + { + "name": "/public/Samples/Reports/TopFivesReport", + "type": "reportUnit", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Reports/TopFivesReport" + } + } + }, + { + "name": "/temp/tmpAdv_1414686450998_tqqd", + "type": "adhocDataView", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/tmpAdv_1414686450998_tqqd" + } + } + }, + { + "name": "/temp/tmpAdv_1414686673912_uhun", + "type": "adhocDataView", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/tmpAdv_1414686673912_uhun" + } + } + }, + { + "name": "/temp/tmpAdv_1414687065368_jiwe", + "type": "adhocDataView", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/tmpAdv_1414687065368_jiwe" + } + } + }, + { + "name": "/temp/tmpAdv_1414696815261_ulel", + "type": "adhocDataView", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/tmpAdv_1414696815261_ulel" + } + } + }, + { + "name": "/public/AAT1_files/tmpAdv_1414686450998_tqqd_files/store_country_1", + "type": "inputControl", + "resource": { + "resourceReference": { + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard_files/store_country_1" + } + } + } + ], + "defaultFoundation": "default" +} \ No newline at end of file From 21a492d1a9d386594bbd07927640a18d38768f99 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 10 Aug 2015 15:10:52 +0300 Subject: [PATCH 035/457] Add api 'requestLegacyDashboardResource' for repository module --- .../rest/v2/api/RepositoryRestApi.java | 6 +++ .../LegacyDashboardLookupResponse.java | 37 ++++++++++++++ .../resource/DashboardLookupResponseTest.java | 12 +++-- .../LegacyDashboardLookupResponseTest.java | 49 +++++++++++++++++++ 4 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponse.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index c0b17b46..9146174d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -28,6 +28,7 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; @@ -63,6 +64,11 @@ public interface RepositoryRestApi { @GET("/rest_v2/resources{resourceUri}") DashboardLookupResponse requestDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + @NonNull + @Headers("Accept: application/repository.legacyDashboard+json") + @GET("/rest_v2/resources{resourceUri}") + LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + class Builder extends BaseBuilder { private final String mCookie; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponse.java new file mode 100644 index 00000000..f9d553bf --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class LegacyDashboardLookupResponse extends ResourceLookupResponse { + + @Override + public String getResourceType() { + return "legacyDashboard"; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java index 79d4f8ff..b60b897a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java @@ -54,6 +54,12 @@ public void shouldDeserializeResponse1FromWholeJson() { assertThat(response1, is(notNullValue())); } + @Test + public void shouldAlwaysReturnReportUnitUriAsType() { + DashboardLookupResponse response = deserialize("{}"); + assertThat(response.getResourceType(), is("dashboard")); + } + @Test public void shouldDeserializeVersion() { DashboardLookupResponse response = deserialize("{\"version\": 2}"); @@ -80,19 +86,19 @@ public void shouldDeserializeUpdateDate() { @Test public void shouldDeserializeLabel() { - DashboardLookupResponse response = deserialize("{\"label\": \"01. Geographic Results by Segment\"}"); + DashboardLookupResponse response = deserialize("{\"label\": \"1. Supermart Dashboard\"}"); assertThat(response.getLabel(), is("01. Geographic Results by Segment")); } @Test public void shouldDeserializeDescription() { - DashboardLookupResponse response = deserialize("{\"description\": \"Sample HTML5 multi-axis column chart\"}"); + DashboardLookupResponse response = deserialize("{\"description\": \"ample containing 5 Dashlets\"}"); assertThat(response.getDescription(), is("Sample HTML5 multi-axis column chart")); } @Test public void shouldDeserializeUri() { - DashboardLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment\"}"); + DashboardLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Dashboards/1._Supermart_Dashboard\"}"); assertThat(response.getUri(), is("/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment")); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java new file mode 100644 index 00000000..7d79fd13 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class LegacyDashboardLookupResponseTest { + + @Test + public void shouldAlwaysReturnReportUnitUriAsType() { + LegacyDashboardLookupResponse response = deserialize("{}"); + assertThat(response.getResourceType(), is("legacyDashboard")); + } + + private LegacyDashboardLookupResponse deserialize(String json) { + return GsonFactory.create().fromJson(json, LegacyDashboardLookupResponse.class); + } +} From 49b6c612a9f12a82412ad0ce19bb86461d21269b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 10 Aug 2015 15:15:41 +0300 Subject: [PATCH 036/457] Add toString implementation for entity objects --- .../entity/resource/DashboardFoundation.java | 10 ++++++++++ .../resource/DashboardLookupResponse.java | 18 ++++++++++++++++++ .../v2/entity/resource/DashboardResource.java | 9 +++++++++ .../entity/resource/DashboardResourceInfo.java | 7 +++++++ .../rest/v2/entity/resource/DataSource.java | 7 +++++++ .../entity/resource/DataSourceReference.java | 7 +++++++ .../network/rest/v2/entity/resource/JRXml.java | 7 +++++++ .../v2/entity/resource/JRXmlFileReference.java | 7 +++++++ .../entity/resource/ReportLookupResponse.java | 14 ++++++++++++++ .../v2/entity/resource/ReportResource.java | 8 ++++++++ .../rest/v2/entity/resource/ResourceFile.java | 7 +++++++ .../v2/entity/resource/ResourceReference.java | 7 +++++++ 12 files changed, 108 insertions(+) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java index 4237f5d7..95028e59 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java @@ -56,4 +56,14 @@ public String getLayout() { public String getWiring() { return wiring; } + + @Override + public String toString() { + return "DashboardFoundation{" + + "components='" + components + '\'' + + ", id='" + id + '\'' + + ", layout='" + layout + '\'' + + ", wiring='" + wiring + '\'' + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java index 1ff18b85..9048d950 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java @@ -26,6 +26,7 @@ import com.google.gson.annotations.Expose; +import java.util.Arrays; import java.util.List; /** @@ -57,4 +58,21 @@ public List getFoundations() { public List getResources() { return resources; } + + @Override + public String toString() { + return "DashboardLookupResponse{" + + "creationDate='" + creationDate + '\'' + + ", label='" + label + '\'' + + ", description='" + description + '\'' + + ", uri='" + uri + '\'' + + ", resourceType='dashboard'" + + ", version=" + version + + ", permissionMask=" + permissionMask + + ", updateDate='" + updateDate + '\'' + + ", defaultFoundation='" + defaultFoundation + '\'' + + ", foundations=" + Arrays.toString(foundations.toArray()) + + ", resources=" + Arrays.toString(resources.toArray()) + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java index 4cae1b4d..e1597854 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java @@ -50,4 +50,13 @@ public String getName() { public String getType() { return type; } + + @Override + public String toString() { + return "DashboardResource{" + + "name='" + name + '\'' + + ", type='" + type + '\'' + + ", resource=" + resource + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java index ccb9502f..714614ab 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java @@ -38,4 +38,11 @@ public final class DashboardResourceInfo { public ResourceReference getResourceReference() { return resourceReference; } + + @Override + public String toString() { + return "DashboardResourceInfo{" + + "resourceReference=" + resourceReference + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java index 7afabef1..7f63a5c4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java @@ -37,4 +37,11 @@ public final class DataSource { public DataSourceReference getDataSourceReference() { return dataSourceReference; } + + @Override + public String toString() { + return "DataSource{" + + "dataSourceReference=" + dataSourceReference + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java index f4137d0c..cf1c3569 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java @@ -37,4 +37,11 @@ public final class DataSourceReference { public String getUri() { return uri; } + + @Override + public String toString() { + return "DataSourceReference{" + + "uri='" + uri + '\'' + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java index bd5e37fe..e06d6afb 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java @@ -38,4 +38,11 @@ public final class JRXml { public JRXmlFileReference getJrxmlFileReference() { return jrxmlFileReference; } + + @Override + public String toString() { + return "JRXml{" + + "jrxmlFileReference=" + jrxmlFileReference + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java index c3f2ab18..27dc1348 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java @@ -38,4 +38,11 @@ public final class JRXmlFileReference { public String getUri() { return uri; } + + @Override + public String toString() { + return "JRXmlFileReference{" + + "uri='" + uri + '\'' + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java index 54b75567..d6317ebe 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java @@ -26,6 +26,7 @@ import com.google.gson.annotations.Expose; +import java.util.Arrays; import java.util.List; /** @@ -81,4 +82,17 @@ public String getReportRenderingView() { public List getResources() { return resources; } + + @Override + public String toString() { + return "ReportLookupResponse{" + + "alwaysPromptControls=" + alwaysPromptControls + + ", dataSource=" + dataSource + + ", jrxml=" + jrxml + + ", inputControlRenderingView='" + inputControlRenderingView + '\'' + + ", reportRenderingView='" + reportRenderingView + '\'' + + ", controlsLayout='" + controlsLayout + '\'' + + ", resources=" + Arrays.toString(resources.toArray()) + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java index c882edea..ca817aea 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java @@ -44,4 +44,12 @@ public ResourceFile getFile() { public String getName() { return name; } + + @Override + public String toString() { + return "ReportResource{" + + "file=" + file + + ", name='" + name + '\'' + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java index b474e33d..afe6d06a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java @@ -38,4 +38,11 @@ public final class ResourceFile { public ResourceReference getFileReference() { return fileReference; } + + @Override + public String toString() { + return "ResourceFile{" + + "fileReference=" + fileReference + + '}'; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java index 93fedfa7..065cc967 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java @@ -38,4 +38,11 @@ public final class ResourceReference { public String getUri() { return uri; } + + @Override + public String toString() { + return "ResourceReference{" + + "uri='" + uri + '\'' + + '}'; + } } From 4e962206baec45e7ae9392561ff2c78a98b477cb Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 10:19:32 +0300 Subject: [PATCH 037/457] Add headers support for repository search API --- client-network/build.gradle | 1 + .../rest/v2/api/RepositoryRestApi.java | 25 +-- .../rest/v2/api/RepositoryRestApiImpl.java | 106 +++++++++++++ .../v2/api/ResourceSearchResponseAdapter.java | 76 ++++++++++ .../network/rest/v2/api/ResponseWrapper.java | 102 +++++++++++++ .../resource/ResourceSearchResponse.java | 93 ++++++++++++ .../rest/v2/entity/type/GsonFactory.java | 1 - .../ResourceLookupTypeAdapterFactory.java | 52 ------- .../v2/api/AuthenticationRestApiTest.java | 2 +- .../rest/v2/api/RepositoryRestApiTest.java | 32 +++- ...urceResourceSearchResponseAdapterTest.java | 143 ++++++++++++++++++ .../resource/DashboardLookupResponseTest.java | 8 +- ...ResourceLookupResponseJsonConvertTest.java | 22 +-- .../api/RepositoryRestApiTest.java | 13 +- 14 files changed, 569 insertions(+), 107 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ResourceLookupTypeAdapterFactory.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceResourceSearchResponseAdapterTest.java diff --git a/client-network/build.gradle b/client-network/build.gradle index f8be1c10..4b93a1cf 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -38,6 +38,7 @@ dependencies { compile 'com.squareup.retrofit:retrofit:1.9.0' + testCompile 'org.hamcrest:hamcrest-integration:1.3' testCompile("org.mockito:mockito-core:1.10.19") { exclude group: 'org.hamcrest' exclude group: 'org.objenesis' diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index 9146174d..ce861dcc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -30,19 +30,14 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import java.util.Collection; import java.util.Map; import retrofit.RequestInterceptor; import retrofit.RestAdapter; import retrofit.converter.GsonConverter; -import retrofit.http.GET; -import retrofit.http.Headers; -import retrofit.http.Path; -import retrofit.http.QueryMap; /** * @author Tom Koptel @@ -50,24 +45,16 @@ */ public interface RepositoryRestApi { @NonNull - @Headers("Accept: application/json") - @GET("/rest_v2/resources") - Collection searchResources(@Nullable @QueryMap Map searchParams); + ResourceSearchResponse searchResources(@Nullable Map searchParams); @NonNull - @Headers("Accept: application/repository.reportUnit+json") - @GET("/rest_v2/resources{resourceUri}") - ReportLookupResponse requestReportResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + ReportLookupResponse requestReportResource(@NonNull String resourceUri); @NonNull - @Headers("Accept: application/repository.dashboard+json") - @GET("/rest_v2/resources{resourceUri}") - DashboardLookupResponse requestDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + DashboardLookupResponse requestDashboardResource(@NonNull String resourceUri); @NonNull - @Headers("Accept: application/repository.legacyDashboard+json") - @GET("/rest_v2/resources{resourceUri}") - LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull String resourceUri); class Builder extends BaseBuilder { private final String mCookie; @@ -91,7 +78,7 @@ public void intercept(RequestFacade request) { }); RestAdapter restAdapter = builder.build(); - return restAdapter.create(RepositoryRestApi.class); + return new RepositoryRestApiImpl(restAdapter); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java new file mode 100644 index 00000000..37f11ea0 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java @@ -0,0 +1,106 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; + +import java.util.Map; + +import retrofit.RestAdapter; +import retrofit.client.Response; +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.Path; +import retrofit.http.QueryMap; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RepositoryRestApiImpl implements RepositoryRestApi { + private final RestApi mRestApi; + + RepositoryRestApiImpl(RestAdapter restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } + + @NonNull + @Override + public ResourceSearchResponse searchResources(@Nullable Map searchParams) { + Response response = mRestApi.searchResources(searchParams); + int status = response.getStatus(); + if (status == 204) { + return ResourceSearchResponseAdapter.emptyResponse(); + } else { + return ResourceSearchResponseAdapter.adapt(response); + } + } + + @NonNull + @Override + public ReportLookupResponse requestReportResource(@NonNull String resourceUri) { + return mRestApi.requestReportResource(resourceUri); + } + + @NonNull + @Override + public DashboardLookupResponse requestDashboardResource(@NonNull String resourceUri) { + return mRestApi.requestDashboardResource(resourceUri); + } + + @NonNull + @Override + public LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull String resourceUri) { + return mRestApi.requestLegacyDashboardResource(resourceUri); + } + + private interface RestApi { + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/resources") + Response searchResources(@Nullable @QueryMap Map searchParams); + + @NonNull + @Headers("Accept: application/repository.reportUnit+json") + @GET("/rest_v2/resources{resourceUri}") + ReportLookupResponse requestReportResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + + @NonNull + @Headers("Accept: application/repository.dashboard+json") + @GET("/rest_v2/resources{resourceUri}") + DashboardLookupResponse requestDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + + @NonNull + @Headers("Accept: application/repository.legacyDashboard+json") + @GET("/rest_v2/resources{resourceUri}") + LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java new file mode 100644 index 00000000..0ff86e00 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java @@ -0,0 +1,76 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; + +import retrofit.client.Header; +import retrofit.client.Response; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ResourceSearchResponseAdapter { + + private ResourceSearchResponseAdapter() {} + + public static ResourceSearchResponse adapt(Response response) { + ResponseWrapper wrapper = ResponseWrapper.wrap(response, ResourceSearchResponse.class); + Header resultCountHeader = wrapper.getFirstHeader("Result-Count"); + Header totalCountHeader = wrapper.getFirstHeader("Total-Count"); + Header startIndexHeader = wrapper.getFirstHeader("Start-Index"); + Header nextOffsetHeader = wrapper.getFirstHeader("Next-Offset"); + + int resultCount = asInt(resultCountHeader); + int totalCount = asInt(totalCountHeader); + int startIndex = asInt(startIndexHeader); + int nextOffset = asInt(nextOffsetHeader); + + ResourceSearchResponse resourceSearchResponse = wrapper.parseResponse(); + resourceSearchResponse.setResultCount(resultCount); + resourceSearchResponse.setTotalCount(totalCount); + resourceSearchResponse.setStartIndex(startIndex); + resourceSearchResponse.setNextOffset(nextOffset); + return resourceSearchResponse; + } + + public static ResourceSearchResponse emptyResponse() { + return new ResourceSearchResponse(); + } + + static int asInt(Header header) { + if (header == null) { + return 0; + } + String value = header.getValue(); + try { + return Integer.parseInt(value); + } catch (NumberFormatException ex) { + return 0; + } + } + +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java new file mode 100644 index 00000000..39986441 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java @@ -0,0 +1,102 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +import retrofit.client.Header; +import retrofit.mime.TypedInput; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ResponseWrapper { + + private final retrofit.client.Response mResponse; + private final Type mType; + private final Gson mGson; + + private ResponseWrapper(retrofit.client.Response response, Type type) { + mResponse = response; + mType = type; + mGson = GsonFactory.create(); + } + + @SuppressWarnings("unchecked") + public static ResponseWrapper wrap(retrofit.client.Response response, Type type) { + return new ResponseWrapper(response, type); + } + + @NonNull + public Response parseResponse() { + TypedInput typedInput = mResponse.getBody(); + Reader reader = null; + try { + reader = new InputStreamReader(typedInput.in()); + } catch (IOException e) { + // TODO it is no good idea to rethrow it here. Better solution to wrap with RestError + throw new RuntimeException(e); + } + return mGson.fromJson(reader, mType); + } + + @Nullable + public Header getFirstHeader(String name) { + List
headers = findHeaders(name); + if (headers.isEmpty()) { + return null; + } else { + Header header = headers.get(0); + if (header == null) { + return null; + } + return header; + } + } + + private List
findHeaders(String name) { + List
result = new ArrayList<>(); + List
headers = mResponse.getHeaders(); + for (Header header : headers) { + if (header.getName().equals(name)) { + result.add(header); + } + } + return result; + } + +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java new file mode 100644 index 00000000..1d5a9988 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java @@ -0,0 +1,93 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.Collections; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ResourceSearchResponse { + + @Expose + @SerializedName("resourceLookup") + private List mResources = Collections.emptyList(); + private int mResultCount; + private int mTotalCount; + private int mStartIndex; + private int mNextOffset; + + public int getNextOffset() { + return mNextOffset; + } + + public List getResources() { + return mResources; + } + + public int getResultCount() { + return mResultCount; + } + + public int getStartIndex() { + return mStartIndex; + } + + public int getTotalCount() { + return mTotalCount; + } + + @Override + public String toString() { + return "ResourceSearchResponse{" + + "mNextOffset=" + mNextOffset + + ", mResourcesCount=" + mResources.size() + + ", mResultCount=" + mResultCount + + ", mStartIndex=" + mStartIndex + + ", mTotalCount=" + mTotalCount + + '}'; + } + + public void setResultCount(int resultCount) { + mResultCount = resultCount; + } + + public void setTotalCount(int totalCount) { + mTotalCount = totalCount; + } + + public void setStartIndex(int startIndex) { + mStartIndex = startIndex; + } + + public void setNextOffset(int nextOffset) { + mNextOffset = nextOffset; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java index e45fdbb2..e2bb09f8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java @@ -36,7 +36,6 @@ public static Gson create() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.excludeFieldsWithoutExposeAnnotation(); gsonBuilder.disableHtmlEscaping(); - gsonBuilder.registerTypeAdapterFactory(new ResourceLookupTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ReportLookupResponseTypeAdapterFactory()); return gsonBuilder.create(); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ResourceLookupTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ResourceLookupTypeAdapterFactory.java deleted file mode 100644 index be85190f..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ResourceLookupTypeAdapterFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.rest.v2.entity.type; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; - -import java.util.Collection; - - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ResourceLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory> { - static final TypeToken TOKEN_TYPE = new TypeToken>(){}; - - @SuppressWarnings("unchecked") - public ResourceLookupTypeAdapterFactory() { - super(TOKEN_TYPE.getRawType()); - } - - @Override - protected JsonElement afterRead(JsonElement deserialized) { - JsonObject jsonObject = deserialized.getAsJsonObject(); - return jsonObject.get("resourceLookup").getAsJsonArray(); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java index f01b9174..2da32aa7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java @@ -40,7 +40,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ public class AuthenticationRestApiTest { private final String LOCATION_SUCCESS = "/scripts/bower_components/js-sdk/src/common/auth/loginSuccess.json;jsessionid=7D86AE28407432B728694DF649DB5E8F"; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java index 6363e701..acc6bd52 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java @@ -24,15 +24,20 @@ package com.jaspersoft.android.sdk.network.rest.v2.api; -import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + /** * @author Tom Koptel * @since 2.0 @@ -44,15 +49,29 @@ public class RepositoryRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); + private RepositoryRestApi restApiUnderTest; + + @Before + public void setup() { + restApiUnderTest = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + } @Test - public void shouldThroughRestErrorForHttpError() { + public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(create500Response()); - RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); - restApi.searchResources(null); + restApiUnderTest.searchResources(null); + } + + @Test + public void shouldReturnEmptyResponseForNoContentResponse() { + mWebMockRule.enqueue(create204Response()); + + ResourceSearchResponse response = restApiUnderTest.searchResources(null); + + assertThat(response.getResources(), is(empty())); } @Test @@ -67,6 +86,11 @@ public void shouldThrowIllegalArgumentExceptionForNullCookie() { RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); } + private MockResponse create204Response() { + return new MockResponse() + .setStatus("HTTP/1.1 204 No Content"); + } + private MockResponse create500Response() { return new MockResponse() .setStatus("HTTP/1.1 500 Internal Server Error"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceResourceSearchResponseAdapterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceResourceSearchResponseAdapterTest.java new file mode 100644 index 00000000..e3444c04 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceResourceSearchResponseAdapterTest.java @@ -0,0 +1,143 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; + +import retrofit.client.Header; +import retrofit.client.Response; +import retrofit.mime.TypedInput; +import retrofit.mime.TypedString; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({Response.class}) +public class ResourceResourceSearchResponseAdapterTest { + + @ResourceFile("json/all_resources.json") + TestResource searchResponse; + @Mock + Response mockResponse; + + @Before + public void setup() { + TestResourceInjector.inject(this); + MockitoAnnotations.initMocks(this); + + TypedInput emptyJsonInput = new TypedString("{}"); + when(mockResponse.getBody()).thenReturn(emptyJsonInput); + } + + @Test + public void shouldAssignDefaultValueToResultCountIfHeaderMissing() { + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getResultCount(), is(0)); + } + + @Test + public void shouldAssignDefaultValueToTotalCountIfHeaderMissing() { + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getTotalCount(), is(0)); + } + + @Test + public void shouldAssignDefaultValueToValueStartIndexIfHeaderMissing() { + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getStartIndex(), is(0)); + } + + @Test + public void shouldAssignDefaultValueToValueNextOffsetIfHeaderMissing() { + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getNextOffset(), is(0)); + } + + @Test + public void shouldExtractResultCountFromHeaders() { + when(mockResponse.getHeaders()).thenReturn(new ArrayList
() {{ + add(new Header("Result-Count", String.valueOf(2))); + }}); + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getResultCount(), is(2)); + } + + @Test + public void shouldExtractTotalCountFromHeaders() { + when(mockResponse.getHeaders()).thenReturn(new ArrayList
(){{ + add(new Header("Total-Count", String.valueOf(3))); + }}); + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getTotalCount(), is(3)); + } + + @Test + public void shouldExtractStartIndexFromHeaders() { + when(mockResponse.getHeaders()).thenReturn(new ArrayList
(){{ + add(new Header("Start-Index", String.valueOf(3))); + }}); + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getStartIndex(), is(3)); + } + + @Test + public void shouldExtractNextOffsetFromHeaders() { + when(mockResponse.getHeaders()).thenReturn(new ArrayList
(){{ + add(new Header("Next-Offset", String.valueOf(4))); + }}); + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getNextOffset(), is(4)); + } + + @Test + public void shouldParseJsonResponseFromBody() { + TypedInput typedInput = new TypedString(searchResponse.asString()); + when(mockResponse.getBody()).thenReturn(typedInput); + + ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); + assertThat(response.getResources(), is(not(empty()))); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java index b60b897a..81256010 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java @@ -87,19 +87,19 @@ public void shouldDeserializeUpdateDate() { @Test public void shouldDeserializeLabel() { DashboardLookupResponse response = deserialize("{\"label\": \"1. Supermart Dashboard\"}"); - assertThat(response.getLabel(), is("01. Geographic Results by Segment")); + assertThat(response.getLabel(), is("1. Supermart Dashboard")); } @Test public void shouldDeserializeDescription() { - DashboardLookupResponse response = deserialize("{\"description\": \"ample containing 5 Dashlets\"}"); - assertThat(response.getDescription(), is("Sample HTML5 multi-axis column chart")); + DashboardLookupResponse response = deserialize("{\"description\": \"Sample containing 5 Dashlets\"}"); + assertThat(response.getDescription(), is("Sample containing 5 Dashlets")); } @Test public void shouldDeserializeUri() { DashboardLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Dashboards/1._Supermart_Dashboard\"}"); - assertThat(response.getUri(), is("/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment")); + assertThat(response.getUri(), is("/public/Samples/Dashboards/1._Supermart_Dashboard")); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java index bbd093e5..c36585f8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; @@ -34,25 +33,12 @@ import org.junit.Before; import org.junit.Test; -import java.lang.reflect.Type; -import java.util.Collection; - import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; /** - * { - * "version": 2, - * "permissionMask": 1, - * "creationDate": "2015-06-05T07:21:11", - * "updateDate": "2014-05-14T17:38:49", - * "label": "01. Geographic Results by Segment", - * "description": "Sample HTML5 multi-axis column chart from Domain showing Sales, Units, and $ Per Square Foot by Country and Store Type with various filters", - * "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment", - * "resourceType": "adhocDataView" - * } - * * @author Tom Koptel * @since 2.0 */ @@ -71,10 +57,8 @@ public void setup() { @Test public void shouldDeserializeCollectionFromJson() { - Type type = new TypeToken>() { - }.getType(); - Collection resourceLookupResponses = mGson.fromJson(mJsonResources.asString(), type); - assertThat(resourceLookupResponses.size(), is(not(0))); + ResourceSearchResponse resourceSearchResponse = mGson.fromJson(mJsonResources.asString(), ResourceSearchResponse.class); + assertThat(resourceSearchResponse.getResources(), is(not(empty()))); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index c5e63534..3c117dfb 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,12 +24,12 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import org.junit.Before; import org.junit.Test; @@ -39,7 +39,6 @@ import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; -import java.util.Collection; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -65,9 +64,9 @@ public void setup() { @Test public void shouldRequestListOfResources() throws IOException { RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); - Collection resourceLookupResponses = api.searchResources(null); - assertThat(resourceLookupResponses, is(notNullValue())); - assertThat(resourceLookupResponses.size(), is(not(0))); + ResourceSearchResponse resourceSearchResponse = api.searchResources(null); + assertThat(resourceSearchResponse, is(notNullValue())); + assertThat(resourceSearchResponse.getResources().isEmpty(), is(false)); } @Test From 9a16491c11581b28e5108e03ca7cf84a828ed6c4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 10:34:06 +0300 Subject: [PATCH 038/457] Add 'request folder' resource API --- .../rest/v2/api/RepositoryRestApi.java | 4 + .../rest/v2/api/RepositoryRestApiImpl.java | 12 ++ .../entity/resource/FolderLookupResponse.java | 37 ++++++ .../resource/FolderLookupResponseTest.java | 112 ++++++++++++++++++ .../api/RepositoryRestApiTest.java | 23 +++- .../src/test/resources/json/root_folder.json | 9 ++ 6 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponse.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java create mode 100644 client-network/src/test/resources/json/root_folder.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index ce861dcc..dea89a78 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -28,6 +28,7 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; @@ -56,6 +57,9 @@ public interface RepositoryRestApi { @NonNull LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull String resourceUri); + @NonNull + FolderLookupResponse requestFolderResource(@NonNull String resourceUri); + class Builder extends BaseBuilder { private final String mCookie; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java index 37f11ea0..961850a7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java @@ -28,6 +28,7 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; @@ -82,6 +83,12 @@ public LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull Str return mRestApi.requestLegacyDashboardResource(resourceUri); } + @NonNull + @Override + public FolderLookupResponse requestFolderResource(@NonNull String resourceUri) { + return mRestApi.requestFolderResource(resourceUri); + } + private interface RestApi { @NonNull @Headers("Accept: application/json") @@ -102,5 +109,10 @@ private interface RestApi { @Headers("Accept: application/repository.legacyDashboard+json") @GET("/rest_v2/resources{resourceUri}") LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + + @NonNull + @Headers("Accept: application/repository.folder+json") + @GET("/rest_v2/resources{resourceUri}") + FolderLookupResponse requestFolderResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponse.java new file mode 100644 index 00000000..8b4fa17f --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponse.java @@ -0,0 +1,37 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class FolderLookupResponse extends ResourceLookupResponse { + + @Override + public String getResourceType() { + return "folder"; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java new file mode 100644 index 00000000..58e915a1 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java @@ -0,0 +1,112 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * + * @author Tom Koptel + * @since 2.0 + */ +public class FolderLookupResponseTest { + + @ResourceFile("json/root_folder.json") + TestResource rootFolderResponse; + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + + @Test + public void shouldDeserializeResponse1FromWholeJson() { + FolderLookupResponse response1 = deserialize(rootFolderResponse.asString()); + assertThat(response1, is(notNullValue())); + } + + @Test + public void shouldAlwaysReturnReportUnitUriAsType() { + FolderLookupResponse response = deserialize("{}"); + assertThat(response.getResourceType(), is("folder")); + } + + @Test + public void shouldDeserializeVersion() { + FolderLookupResponse response = deserialize("{\"version\": 0}"); + assertThat(response.getVersion(), is(0)); + } + + @Test + public void shouldDeserializePermissionMask() { + FolderLookupResponse response = deserialize("{\"permissionMask\": 2}"); + assertThat(response.getPermissionMask(), is(2)); + } + + @Test + public void shouldDeserializeCreationDate() { + FolderLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); + assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); + } + + @Test + public void shouldDeserializeUpdateDate() { + FolderLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); + assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); + } + + @Test + public void shouldDeserializeLabel() { + FolderLookupResponse response = deserialize("{\"label\": \"Organization\"}"); + assertThat(response.getLabel(), is("Organization")); + } + + @Test + public void shouldDeserializeDescription() { + FolderLookupResponse response = deserialize("{\"description\": \"Organization\"}"); + assertThat(response.getDescription(), is("Organization")); + } + + @Test + public void shouldDeserializeUri() { + FolderLookupResponse response = deserialize("{\"uri\": \"/\"}"); + assertThat(response.getUri(), is("/")); + } + + private FolderLookupResponse deserialize(String json) { + return GsonFactory.create().fromJson(json, FolderLookupResponse.class); + } + +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 3c117dfb..aea337ef 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; @@ -40,6 +41,7 @@ import java.io.IOException; +import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.notNullValue; @@ -63,15 +65,15 @@ public void setup() { @Test public void shouldRequestListOfResources() throws IOException { - RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); + RepositoryRestApi api = createApi(); ResourceSearchResponse resourceSearchResponse = api.searchResources(null); assertThat(resourceSearchResponse, is(notNullValue())); - assertThat(resourceSearchResponse.getResources().isEmpty(), is(false)); + assertThat(resourceSearchResponse.getResources(), is(not(empty()))); } @Test public void shouldRequestReport() throws IOException { - RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); + RepositoryRestApi api = createApi(); ReportLookupResponse report = api.requestReportResource("/public/Samples/Reports/AllAccounts"); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); @@ -79,10 +81,21 @@ public void shouldRequestReport() throws IOException { @Test public void shouldRequestDashboard() throws IOException { - RepositoryRestApi api = new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); + RepositoryRestApi api = createApi(); DashboardLookupResponse dashboard = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); assertThat(dashboard, is(notNullValue())); - assertThat(dashboard.getFoundations().size(), is(not(0))); + assertThat(dashboard.getFoundations(), is(not(empty()))); + } + + @Test + public void shouldRequestRootFolder() throws IOException { + RepositoryRestApi api = createApi(); + FolderLookupResponse folder = api.requestFolderResource("/"); + assertThat(folder, is(notNullValue())); + } + + private RepositoryRestApi createApi() { + return new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); } private AuthResponse getAuthResponse() { diff --git a/client-network/src/test/resources/json/root_folder.json b/client-network/src/test/resources/json/root_folder.json new file mode 100644 index 00000000..b42c9b3e --- /dev/null +++ b/client-network/src/test/resources/json/root_folder.json @@ -0,0 +1,9 @@ +{ + "version": 0, + "permissionMask": 2, + "creationDate": "2015-01-13T01:00:33", + "updateDate": "2014-12-18T09:59:44", + "label": "Organization", + "description": "Organization", + "uri": "/" +} \ No newline at end of file From 2354cd91268fb90cc8527518816c72a09b17037f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 12:00:36 +0300 Subject: [PATCH 039/457] Add base pojo objects for report execution task --- .../rest/v2/api/ReportExecutionRestApi.java | 46 ++++ .../v2/entity/execution/ErrorDescriptor.java | 65 ++++++ .../v2/entity/execution/ExecutionRequest.java | 210 ++++++++++++++++++ .../v2/entity/execution/ExportExecution.java | 105 +++++++++ .../execution/ReportExecutionResponse.java | 93 ++++++++ .../execution/ReportOutputResource.java | 74 ++++++ .../v2/entity/execution/ReportParameter.java | 65 ++++++ .../execution/ReportParametersList.java | 58 +++++ .../json/report_execution_request.json | 29 +++ .../json/report_execution_response.json | 17 ++ .../client/oxm/report/ExecutionRequest.java | 30 ++- 11 files changed, 776 insertions(+), 16 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptor.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResource.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java create mode 100644 client-network/src/test/resources/json/report_execution_request.json create mode 100644 client-network/src/test/resources/json/report_execution_response.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java new file mode 100644 index 00000000..7452805a --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -0,0 +1,46 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequest; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; + +import retrofit.http.Headers; +import retrofit.http.POST; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ReportExecutionRestApi { + + @NonNull + @Headers("Accept: application/json") + @POST("/rest_v2/reportExecutions") + ReportExecutionResponse runReportExecution(@NonNull ExecutionRequest reportExecutionRequest); + +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptor.java new file mode 100644 index 00000000..0a904f6e --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptor.java @@ -0,0 +1,65 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ErrorDescriptor { + @Expose + private String errorCode; + @Expose + private String message; + @Expose + private Set parameters = Collections.emptySet(); + + public String getErrorCode() { + return errorCode; + } + + public String getMessage() { + return message; + } + + public Set getParameters() { + return parameters; + } + + @Override + public String toString() { + return "ErrorDescriptor{" + + "errorCode='" + errorCode + '\'' + + ", message='" + message + '\'' + + ", parameters=" + Arrays.toString(parameters.toArray()) + + '}'; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java new file mode 100644 index 00000000..e86a6e07 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java @@ -0,0 +1,210 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExecutionRequest { + + @Expose + protected final String reportUnitUri; + @Expose + protected Boolean async; + @Expose + protected Boolean freshData; + @Expose + protected Boolean saveDataSnapshot; + @Expose + protected String outputFormat; + @Expose + protected Boolean interactive; + @Expose + protected Boolean ignorePagination; + @Expose + protected Boolean allowInlineScripts; + @Expose + protected String pages; + @Expose + protected String baseUrl; + @Expose + protected String anchor; + @Expose + protected String transformerKey; + @Expose + protected String attachmentsPrefix; + @Expose + protected ReportParametersList parameters; + + private ExecutionRequest(String reportUnitUri) { + this.reportUnitUri = reportUnitUri; + } + + public static ExecutionRequest newRequest(String uri) { + return new ExecutionRequest(uri); + } + + public ExecutionRequest withAsync(Boolean async) { + this.async = async; + return this; + } + + public ExecutionRequest withAttachmentsPrefix(String attachmentsPrefix) { + this.attachmentsPrefix = attachmentsPrefix; + return this; + } + + public ExecutionRequest withFreshData(Boolean freshData) { + this.freshData = freshData; + return this; + } + + public ExecutionRequest withIgnorePagination(Boolean ignorePagination) { + this.ignorePagination = ignorePagination; + return this; + } + + public ExecutionRequest withInteractive(Boolean interactive) { + this.interactive = interactive; + return this; + } + + public ExecutionRequest withOutputFormat(String outputFormat) { + this.outputFormat = outputFormat; + return this; + } + + public ExecutionRequest withPages(String pages) { + this.pages = pages; + return this; + } + + public ExecutionRequest withParameters(List parameters) { + this.parameters = ReportParametersList.wrap(parameters); + return this; + } + + public ExecutionRequest withSaveDataSnapshot(Boolean saveDataSnapshot) { + this.saveDataSnapshot = saveDataSnapshot; + return this; + } + + public ExecutionRequest withTransformerKey(String transformerKey) { + this.transformerKey = transformerKey; + return this; + } + + public ExecutionRequest withAnchor(String anchor) { + this.anchor = anchor; + return this; + } + + public ExecutionRequest withBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public ExecutionRequest withAllowInlineScripts(Boolean allowInlineScripts) { + this.allowInlineScripts = allowInlineScripts; + return this; + } + + public Boolean getAsync() { + return async; + } + + public String getAttachmentsPrefix() { + return attachmentsPrefix; + } + + public Boolean getFreshData() { + return freshData; + } + + public Boolean getIgnorePagination() { + return ignorePagination; + } + + public Boolean getInteractive() { + return interactive; + } + + public String getOutputFormat() { + return outputFormat; + } + + public String getPages() { + return pages; + } + + public List getParameters() { + return parameters.getReportParameters(); + } + + public String getReportUnitUri() { + return reportUnitUri; + } + + public Boolean getSaveDataSnapshot() { + return saveDataSnapshot; + } + + public Boolean getAllowInlineScripts() { + return allowInlineScripts; + } + + public String getAnchor() { + return anchor; + } + + public String getBaseUrl() { + return baseUrl; + } + + public String getTransformerKey() { + return transformerKey; + } + + @Override + public String toString() { + return "ExecutionRequest{" + + "async=" + async + + ", reportUnitUri='" + reportUnitUri + '\'' + + ", freshData=" + freshData + + ", saveDataSnapshot=" + saveDataSnapshot + + ", outputFormat='" + outputFormat + '\'' + + ", interactive=" + interactive + + ", ignorePagination=" + ignorePagination + + ", pages='" + pages + '\'' + + ", attachmentsPrefix='" + attachmentsPrefix + '\'' + + ", parameters=" + parameters + + '}'; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java new file mode 100644 index 00000000..cad76bc9 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java @@ -0,0 +1,105 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExportExecution { + @Expose + private String id; + @Expose + private String status; + @Expose + private ReportOutputResource outputResource; + @Expose + private Set attachments = Collections.emptySet(); + @Expose + private ErrorDescriptor errorDescriptor; + + public Set getAttachments() { + return attachments; + } + + public ErrorDescriptor getErrorDescriptor() { + return errorDescriptor; + } + + public String getId() { + return id; + } + + public ReportOutputResource getOutputResource() { + return outputResource; + } + + public String getStatus() { + return status; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ExportExecution that = (ExportExecution) o; + + if (id != null ? !id.equals(that.id) : that.id != null) return false; + if (status != null ? !status.equals(that.status) : that.status != null) return false; + if (outputResource != null ? !outputResource.equals(that.outputResource) : that.outputResource != null) + return false; + if (attachments != null ? !attachments.equals(that.attachments) : that.attachments != null) + return false; + return !(errorDescriptor != null ? !errorDescriptor.equals(that.errorDescriptor) : that.errorDescriptor != null); + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (status != null ? status.hashCode() : 0); + result = 31 * result + (outputResource != null ? outputResource.hashCode() : 0); + result = 31 * result + (attachments != null ? attachments.hashCode() : 0); + result = 31 * result + (errorDescriptor != null ? errorDescriptor.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "ExportExecution{" + + "attachments=" + Arrays.toString(attachments.toArray()) + + ", id='" + id + '\'' + + ", status='" + status + '\'' + + ", outputResource=" + outputResource + + ", errorDescriptor=" + errorDescriptor + + '}'; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java new file mode 100644 index 00000000..c3b68071 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java @@ -0,0 +1,93 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExecutionResponse { + @Expose + private String requestId; + @Expose + private String reportURI; + @Expose + private String status; + @Expose + private int currentPage; + @Expose + private int totalPages; + @Expose + private Set exports = Collections.emptySet(); + @Expose + private ErrorDescriptor errorDescriptor; + + public int getCurrentPage() { + return currentPage; + } + + public ErrorDescriptor getErrorDescriptor() { + return errorDescriptor; + } + + public Set getExports() { + return exports; + } + + public String getReportURI() { + return reportURI; + } + + public String getRequestId() { + return requestId; + } + + public String getStatus() { + return status; + } + + public int getTotalPages() { + return totalPages; + } + + @Override + public String toString() { + return "ReportExecutionResponse{" + + "currentPage=" + currentPage + + ", requestId='" + requestId + '\'' + + ", reportURI='" + reportURI + '\'' + + ", status='" + status + '\'' + + ", exports=" + Arrays.toString(exports.toArray()) + + ", totalPages=" + totalPages + + ", errorDescriptor=" + errorDescriptor + + '}'; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResource.java new file mode 100644 index 00000000..49266fe8 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResource.java @@ -0,0 +1,74 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportOutputResource { + @Expose + private String contentType; + @Expose + private String fileName; + + public String getContentType() { + return contentType; + } + + public String getFileName() { + return fileName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ReportOutputResource that = (ReportOutputResource) o; + + if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) + return false; + return !(fileName != null ? !fileName.equals(that.fileName) : that.fileName != null); + + } + + @Override + public int hashCode() { + int result = contentType != null ? contentType.hashCode() : 0; + result = 31 * result + (fileName != null ? fileName.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "ReportOutputResource{" + + "contentType='" + contentType + '\'' + + ", fileName='" + fileName + '\'' + + '}'; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java new file mode 100644 index 00000000..01aa348e --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java @@ -0,0 +1,65 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.Arrays; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportParameter { + @Expose + private final String name; + + @Expose + @SerializedName("value") + private final Set values; + + public ReportParameter(String name, Set values) { + this.name = name; + this.values = values; + } + + public String getName() { + return name; + } + + public Set getValues() { + return values; + } + + @Override + public String toString() { + return "ReportParameter{" + + "name='" + name + '\'' + + ", values=" + Arrays.toString(values.toArray()) + + '}'; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java new file mode 100644 index 00000000..5149feec --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java @@ -0,0 +1,58 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.Arrays; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportParametersList { + @Expose + @SerializedName("reportParameter") + private final List reportParameters; + + private ReportParametersList(List reportParameters) { + this.reportParameters = reportParameters; + } + + public List getReportParameters() { + return reportParameters; + } + + public static ReportParametersList wrap(List params) { + return new ReportParametersList(params); + } + + @Override + public String toString() { + return Arrays.toString(reportParameters.toArray()); + } +} diff --git a/client-network/src/test/resources/json/report_execution_request.json b/client-network/src/test/resources/json/report_execution_request.json new file mode 100644 index 00000000..f0c9716a --- /dev/null +++ b/client-network/src/test/resources/json/report_execution_request.json @@ -0,0 +1,29 @@ +{ + "reportUnitUri":"/reports/samples/AllAccounts", + "async":"true", + "outputFormat":"html", + "interactive":"true", + "freshData":"false", + "saveDataSnapshot":"false", + "ignorePagination":"false", + "allowInlineScripts": "true", + "transformerKey":null, + "pages":"1-5", + "anchor": "someAnchor", + "attachmentsPrefix":"{contextPath}/rest_v2/reportExecutions/{reportExecutionId}/exports/{exportExecutionId}/attachments/", + "baseUrl":"http://localhost:8080/jasperserver-pro", + "parameters": + { + "reportParameter": + [ + { + "name":"someParameterName", + "value":["value 1", "value 2"] + }, + { + "name":"someAnotherParameterName", + "value":["another value"] + } + ] + } +} \ No newline at end of file diff --git a/client-network/src/test/resources/json/report_execution_response.json b/client-network/src/test/resources/json/report_execution_response.json new file mode 100644 index 00000000..7bc5d3e6 --- /dev/null +++ b/client-network/src/test/resources/json/report_execution_response.json @@ -0,0 +1,17 @@ +{ + "status": "queued", + "requestId": "f3a9805a-4089-4b53-b9e9-b54752f91586", + "reportURI": "/reports/samples/AllAccounts", + "exports": [ + { + "id": "4bac4889-0e63-4f09-bbe8-9593674f0700", + "options": { + "outputFormat": "html", + "attachmentsPrefix": "{contextPath}/rest_v2/reportExecutions/{reportExecutionId}/exports/{exportExecutionId}/attachments/", + "baseUrl": "http://localhost:8080/jasperserver-pro", + "allowInlineScripts": true + }, + "status": "queued" + } + ] +} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java index c0bd5fbf..ab7301a6 100644 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java @@ -17,30 +17,30 @@ */ public class ExecutionRequest { public static final String DEFAULT_ATTACHMENT_PREFIX = "/reportExecutions/{reportExecutionId}/exports/{exportExecutionId}/attachments/"; - public static final String MARKUP_TYPE_EMBEDDABLE = "embeddable"; - public static final String MARKUP_TYPE_FULL = "full"; + public static final String MARKUP_TYPE_EMBEDDABLE = "embeddable"; + public static final String MARKUP_TYPE_FULL = "full"; @Expose - @Element(required=false) + @Element(required = false) protected String reportUnitUri; @Expose - @Element(required=false) + @Element(required = false) protected String markupType; - @Element(required=false) + @Element(required = false) protected String baseUrl; @Expose - @Element(required=false) + @Element(required = false) protected Boolean async; @Expose - @Element(required=false) + @Element(required = false) protected Boolean freshData; @Expose - @Element(required=false) + @Element(required = false) protected Boolean saveDataSnapshot; @Expose @@ -48,26 +48,26 @@ public class ExecutionRequest { protected String outputFormat; @Expose - @Element(required=false) + @Element(required = false) protected Boolean interactive; @Expose - @Element(required=false) + @Element(required = false) protected Boolean ignorePagination; @Expose - @Element(required=false) + @Element(required = false) protected Boolean allowInlineScripts; @Expose - @Element(required=false) + @Element(required = false) protected String pages; @Expose - @Element(required=false) + @Element(required = false) protected String attachmentsPrefix; - @ElementList(required=false) + @ElementList(required = false) protected List parameters = new ArrayList(); @Expose @@ -83,8 +83,6 @@ public void setEscapedAttachmentsPrefix(String attachmentsPrefix) { this.attachmentsPrefix = URLEncoder.encode(attachmentsPrefix, "UTF-8"); } catch (UnsupportedEncodingException exception) { this.attachmentsPrefix = attachmentsPrefix; - } catch (NullPointerException exception) { - this.attachmentsPrefix = attachmentsPrefix; } } From 1176f2ec007837583f91e8818b5648895347b976 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 13:56:52 +0300 Subject: [PATCH 040/457] Add tests for 'execution request data' object --- client-network/build.gradle | 4 + .../v2/entity/execution/ExecutionRequest.java | 69 ++++++--- .../execution/ReportParametersList.java | 4 + .../execution/ExecutionRequestTest.java | 138 ++++++++++++++++++ .../execution/ReportParametersListTest.java | 43 ++++++ 5 files changed, 237 insertions(+), 21 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersListTest.java diff --git a/client-network/build.gradle b/client-network/build.gradle index 4b93a1cf..1596c987 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -38,6 +38,10 @@ dependencies { compile 'com.squareup.retrofit:retrofit:1.9.0' + testCompile('pl.pragmatists:JUnitParams:1.0.4') { + exclude group: 'org.hamcrest' + } + testCompile 'org.hamcrest:hamcrest-integration:1.3' testCompile("org.mockito:mockito-core:1.10.19") { exclude group: 'org.hamcrest' diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java index e86a6e07..0c0635b9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java @@ -26,6 +26,8 @@ import com.google.gson.annotations.Expose; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.List; /** @@ -34,8 +36,6 @@ */ public final class ExecutionRequest { - @Expose - protected final String reportUnitUri; @Expose protected Boolean async; @Expose @@ -43,14 +43,16 @@ public final class ExecutionRequest { @Expose protected Boolean saveDataSnapshot; @Expose - protected String outputFormat; - @Expose protected Boolean interactive; @Expose protected Boolean ignorePagination; @Expose protected Boolean allowInlineScripts; @Expose + protected final String reportUnitUri; + @Expose + protected String outputFormat; + @Expose protected String pages; @Expose protected String baseUrl; @@ -68,65 +70,90 @@ private ExecutionRequest(String reportUnitUri) { } public static ExecutionRequest newRequest(String uri) { + if (uri == null || uri.length() == 0) { + throw new IllegalArgumentException("Uri should not be null"); + } return new ExecutionRequest(uri); } - public ExecutionRequest withAsync(Boolean async) { + public ExecutionRequest withAsync(boolean async) { this.async = async; return this; } - public ExecutionRequest withAttachmentsPrefix(String attachmentsPrefix) { - this.attachmentsPrefix = attachmentsPrefix; - return this; - } - - public ExecutionRequest withFreshData(Boolean freshData) { + public ExecutionRequest withFreshData(boolean freshData) { this.freshData = freshData; return this; } - public ExecutionRequest withIgnorePagination(Boolean ignorePagination) { + public ExecutionRequest withIgnorePagination(boolean ignorePagination) { this.ignorePagination = ignorePagination; return this; } - public ExecutionRequest withInteractive(Boolean interactive) { + public ExecutionRequest withInteractive(boolean interactive) { this.interactive = interactive; return this; } - public ExecutionRequest withOutputFormat(String outputFormat) { - this.outputFormat = outputFormat; + public ExecutionRequest withSaveDataSnapshot(boolean saveDataSnapshot) { + this.saveDataSnapshot = saveDataSnapshot; return this; } - public ExecutionRequest withPages(String pages) { - this.pages = pages; + public ExecutionRequest withParameters(List parameters) { + this.parameters = ReportParametersList.wrap(parameters); return this; } - public ExecutionRequest withParameters(List parameters) { - this.parameters = ReportParametersList.wrap(parameters); + public ExecutionRequest withAttachmentsPrefix(String attachmentsPrefix) { + if (attachmentsPrefix == null || attachmentsPrefix.length() == 0) { + throw new IllegalArgumentException("Attachment prefix should not be null or empty"); + } + try { + this.attachmentsPrefix = URLEncoder.encode(attachmentsPrefix, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException("This should not be possible", e); + } return this; } - public ExecutionRequest withSaveDataSnapshot(Boolean saveDataSnapshot) { - this.saveDataSnapshot = saveDataSnapshot; + public ExecutionRequest withOutputFormat(String outputFormat) { + if (outputFormat == null || outputFormat.length() == 0) { + throw new IllegalArgumentException("Output format should not be null or empty"); + } + this.outputFormat = outputFormat; + return this; + } + + public ExecutionRequest withPages(String pages) { + if (pages == null || pages.length() == 0) { + throw new IllegalArgumentException("Pages should not be null or empty"); + } + this.pages = pages; return this; } public ExecutionRequest withTransformerKey(String transformerKey) { + if (transformerKey == null || transformerKey.length() == 0) { + throw new IllegalArgumentException("Transform key should not be null or empty"); + } this.transformerKey = transformerKey; return this; } public ExecutionRequest withAnchor(String anchor) { + if (anchor == null || anchor.length() == 0) { + throw new IllegalArgumentException("Anchor should not be null or empty"); + } this.anchor = anchor; return this; } public ExecutionRequest withBaseUrl(String baseUrl) { + if (baseUrl == null || baseUrl.length() == 0) { + throw new IllegalArgumentException("Base url should not be null or empty"); + } this.baseUrl = baseUrl; return this; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java index 5149feec..97bb1cef 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java @@ -28,6 +28,7 @@ import com.google.gson.annotations.SerializedName; import java.util.Arrays; +import java.util.Collections; import java.util.List; /** @@ -48,6 +49,9 @@ public List getReportParameters() { } public static ReportParametersList wrap(List params) { + if (params == null) { + params = Collections.emptyList(); + } return new ReportParametersList(params); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java new file mode 100644 index 00000000..5e10691b --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java @@ -0,0 +1,138 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; + +import java.lang.reflect.Method; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ExecutionRequestTest { + + private ExecutionRequest requestUnderTest; + + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + private Gson mGson; + + @Before + public void setup() { + requestUnderTest = ExecutionRequest.newRequest("/some/uri"); + mGson = GsonFactory.create(); + } + + @Test + @Parameters({ + "withOutputFormat", + "withPages", + "withTransformerKey", + "withAnchor", + "withBaseUrl", + }) + public void shouldNotAcceptNullForBuilderMethods(String methodName) throws Exception { + mExpectedException.expect(IllegalArgumentException.class); + Method method = requestUnderTest.getClass().getMethod(methodName, String.class); + method.invoke(new Object[]{null}); + } + + @Test + @Parameters({ + "withOutputFormat", + "withPages", + "withTransformerKey", + "withAnchor", + "withBaseUrl", + }) + public void shouldNotAcceptEmptyForBuilderMethods(String methodName) throws Exception { + mExpectedException.expect(IllegalArgumentException.class); + Method method = requestUnderTest.getClass().getMethod(methodName, String.class); + method.invoke(""); + } + + @Test + public void shouldWithAttachmentsPrefixShouldEncodePrefix() { + String prefix = requestUnderTest.withAttachmentsPrefix("./").getAttachmentsPrefix(); + assertThat(prefix, is(".%2F")); + } + + @Test + public void factoryMethodShouldNotAllowNull() { + mExpectedException.expect(IllegalArgumentException.class); + ExecutionRequest.newRequest(null); + } + + @Test + public void factoryMethodShouldNotAllowEmptyString() { + mExpectedException.expect(IllegalArgumentException.class); + ExecutionRequest.newRequest(""); + } + + @Test + @Parameters({ + "withOutputFormat, outputFormat", + "withPages, pages", + "withTransformerKey, transformerKey", + "withAnchor, anchor", + "withBaseUrl, baseUrl", + }) + public void shouldSerializeStringField(String methodName, String key) throws Exception { + Method method = requestUnderTest.getClass().getMethod(methodName, String.class); + method.invoke(requestUnderTest, "some value"); + String json = mGson.toJson(requestUnderTest); + assertThat(json, is("{\"reportUnitUri\":\"/some/uri\",\"" + key + "\":\"some value\"}")); + } + + @Test + @Parameters({ + "withAsync, async", + "withFreshData, freshData", + "withIgnorePagination, ignorePagination", + "withInteractive, interactive", + "withSaveDataSnapshot, saveDataSnapshot", + }) + public void shouldSerializeBooleanField(String methodName, String key) throws Exception { + Method method = requestUnderTest.getClass().getMethod(methodName, boolean.class); + method.invoke(requestUnderTest, true); + String json = mGson.toJson(requestUnderTest); + assertThat(json, is("{\"" + key + "\":true,\"reportUnitUri\":\"/some/uri\"}")); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersListTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersListTest.java new file mode 100644 index 00000000..a09be786 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersListTest.java @@ -0,0 +1,43 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import org.junit.Test; + +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportParametersListTest { + @Test + public void factoryMethodAcceptsNull() { + ReportParametersList reportParametersList = ReportParametersList.wrap(null); + assertThat(reportParametersList.getReportParameters(), is(empty())); + } +} From 4d3d5428d295b94b3f7a37560673d70049a37f57 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 14:10:03 +0300 Subject: [PATCH 041/457] Implementing 'ReportParameterTest' --- .../v2/entity/execution/ReportParameter.java | 18 ++- .../entity/execution/ReportParameterTest.java | 103 ++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java index 01aa348e..d9b12b4d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java @@ -28,6 +28,7 @@ import com.google.gson.annotations.SerializedName; import java.util.Arrays; +import java.util.Collections; import java.util.Set; /** @@ -42,11 +43,26 @@ public final class ReportParameter { @SerializedName("value") private final Set values; - public ReportParameter(String name, Set values) { + private ReportParameter(String name, Set values) { this.name = name; this.values = values; } + @SuppressWarnings("unchecked") + public static ReportParameter createWithEmptyValue(String name) { + return create(name, Collections.EMPTY_SET); + } + + public static ReportParameter create(String name, Set values) { + if (name == null || name.length() == 0) { + throw new IllegalArgumentException("Name should not be null"); + } + if (values == null) { + throw new IllegalArgumentException("Values should not be null. Otherwise use ReportParameter.createWithEmptyValue()"); + } + return new ReportParameter(name, values); + } + public String getName() { return name; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java new file mode 100644 index 00000000..775dc697 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java @@ -0,0 +1,103 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Collections; +import java.util.HashSet; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.collection.IsEmptyCollection.empty; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@SuppressWarnings("unchecked") +public class ReportParameterTest { + + @Rule + public ExpectedException mExpectedException = ExpectedException.none(); + private Gson mGson; + + @Before + public void setup() { + mGson = GsonFactory.create(); + } + + @Test + public void factoryMethodShouldNotAllowEmptyName() { + mExpectedException.expect(IllegalArgumentException.class); + ReportParameter.create(null, Collections.EMPTY_SET); + } + + @Test + public void factoryMethodShouldNotAllowNullName() { + mExpectedException.expect(IllegalArgumentException.class); + ReportParameter.create("", Collections.EMPTY_SET); + } + + @Test + public void factoryMethodShouldNotAllowNullValueSet() { + mExpectedException.expect(IllegalArgumentException.class); + mExpectedException.expectMessage("Values should not be null. Otherwise use ReportParameter.createWithEmptyValue()"); + ReportParameter.create("key", null); + } + + @Test + public void factoryMethodCanCreateParameterWithEmptyValueSet() { + ReportParameter reportParameter = ReportParameter.createWithEmptyValue("key"); + assertThat(reportParameter.getValues(), is(empty())); + } + + @Test + public void factoryMethod1ShouldAssignName() { + ReportParameter reportParameter = ReportParameter.createWithEmptyValue("key"); + assertThat(reportParameter.getName(), is("key")); + } + + @Test + public void factoryMethod2ShouldAssignName() { + ReportParameter reportParameter = ReportParameter.create("key", Collections.EMPTY_SET); + assertThat(reportParameter.getName(), is("key")); + } + + @Test + public void shouldBeSerializableToJson() { + ReportParameter reportParameter = ReportParameter.create("key", new HashSet(){{ + add("value"); + }}); + String json = mGson.toJson(reportParameter); + assertThat(json, is("{\"name\":\"key\",\"value\":[\"value\"]}")); + } +} From 5d3c7570c6a0aed557d06967ffff9f30002b7443 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 14:15:25 +0300 Subject: [PATCH 042/457] Assert serialization of 'report parameters' --- .../v2/entity/execution/ExecutionRequest.java | 10 +++++----- ...ParametersList.java => ReportParameters.java} | 16 ++++++++-------- .../entity/execution/ExecutionRequestTest.java | 12 ++++++++++++ ...rsListTest.java => ReportParametersTest.java} | 6 +++--- 4 files changed, 28 insertions(+), 16 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ReportParametersList.java => ReportParameters.java} (79%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ReportParametersListTest.java => ReportParametersTest.java} (87%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java index 0c0635b9..794fdea1 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java @@ -28,7 +28,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.List; +import java.util.Set; /** * @author Tom Koptel @@ -63,7 +63,7 @@ public final class ExecutionRequest { @Expose protected String attachmentsPrefix; @Expose - protected ReportParametersList parameters; + protected ReportParameters parameters; private ExecutionRequest(String reportUnitUri) { this.reportUnitUri = reportUnitUri; @@ -101,8 +101,8 @@ public ExecutionRequest withSaveDataSnapshot(boolean saveDataSnapshot) { return this; } - public ExecutionRequest withParameters(List parameters) { - this.parameters = ReportParametersList.wrap(parameters); + public ExecutionRequest withParameters(Set parameters) { + this.parameters = ReportParameters.wrap(parameters); return this; } @@ -191,7 +191,7 @@ public String getPages() { return pages; } - public List getParameters() { + public Set getParameters() { return parameters.getReportParameters(); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java similarity index 79% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java index 97bb1cef..d6ffa9d5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersList.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java @@ -29,30 +29,30 @@ import java.util.Arrays; import java.util.Collections; -import java.util.List; +import java.util.Set; /** * @author Tom Koptel * @since 2.0 */ -final class ReportParametersList { +final class ReportParameters { @Expose @SerializedName("reportParameter") - private final List reportParameters; + private final Set reportParameters; - private ReportParametersList(List reportParameters) { + private ReportParameters(Set reportParameters) { this.reportParameters = reportParameters; } - public List getReportParameters() { + public Set getReportParameters() { return reportParameters; } - public static ReportParametersList wrap(List params) { + public static ReportParameters wrap(Set params) { if (params == null) { - params = Collections.emptyList(); + params = Collections.emptySet(); } - return new ReportParametersList(params); + return new ReportParameters(params); } @Override diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java index 5e10691b..99a87df0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java @@ -34,6 +34,8 @@ import org.junit.runner.RunWith; import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; import junitparams.JUnitParamsRunner; import junitparams.Parameters; @@ -135,4 +137,14 @@ public void shouldSerializeBooleanField(String methodName, String key) throws Ex String json = mGson.toJson(requestUnderTest); assertThat(json, is("{\"" + key + "\":true,\"reportUnitUri\":\"/some/uri\"}")); } + + @Test + public void shouldSerializeParametersList() { + ReportParameter reportParameter = ReportParameter.createWithEmptyValue("some_param"); + Set parameters = new HashSet<>(); + parameters.add(reportParameter); + requestUnderTest.withParameters(parameters); + String json = mGson.toJson(requestUnderTest); + assertThat(json, is("{\"reportUnitUri\":\"/some/uri\",\"parameters\":{\"reportParameter\":[{\"name\":\"some_param\",\"value\":[]}]}}")); + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersListTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java similarity index 87% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersListTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java index a09be786..2adbfeec 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersListTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java @@ -34,10 +34,10 @@ * @author Tom Koptel * @since 2.0 */ -public class ReportParametersListTest { +public class ReportParametersTest { @Test public void factoryMethodAcceptsNull() { - ReportParametersList reportParametersList = ReportParametersList.wrap(null); - assertThat(reportParametersList.getReportParameters(), is(empty())); + ReportParameters reportParameters = ReportParameters.wrap(null); + assertThat(reportParameters.getReportParameters(), is(empty())); } } From 182e8a8ca9b53a57574b51a600aa8b78511747a6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 14:16:13 +0300 Subject: [PATCH 043/457] Refactor 'ExecutionRequest' to 'ExecutionRequestData' --- .../rest/v2/api/ReportExecutionRestApi.java | 4 +-- ...Request.java => ExecutionRequestData.java} | 34 +++++++++---------- ...est.java => ExecutionRequestDataTest.java} | 10 +++--- 3 files changed, 24 insertions(+), 24 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ExecutionRequest.java => ExecutionRequestData.java} (83%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ExecutionRequestTest.java => ExecutionRequestDataTest.java} (95%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 7452805a..652dc8cd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequest; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; import retrofit.http.Headers; @@ -41,6 +41,6 @@ public interface ReportExecutionRestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions") - ReportExecutionResponse runReportExecution(@NonNull ExecutionRequest reportExecutionRequest); + ReportExecutionResponse runReportExecution(@NonNull ExecutionRequestData reportExecutionRequestData); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestData.java similarity index 83% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestData.java index 794fdea1..7be4902b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequest.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestData.java @@ -34,7 +34,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExecutionRequest { +public final class ExecutionRequestData { @Expose protected Boolean async; @@ -65,48 +65,48 @@ public final class ExecutionRequest { @Expose protected ReportParameters parameters; - private ExecutionRequest(String reportUnitUri) { + private ExecutionRequestData(String reportUnitUri) { this.reportUnitUri = reportUnitUri; } - public static ExecutionRequest newRequest(String uri) { + public static ExecutionRequestData newRequest(String uri) { if (uri == null || uri.length() == 0) { throw new IllegalArgumentException("Uri should not be null"); } - return new ExecutionRequest(uri); + return new ExecutionRequestData(uri); } - public ExecutionRequest withAsync(boolean async) { + public ExecutionRequestData withAsync(boolean async) { this.async = async; return this; } - public ExecutionRequest withFreshData(boolean freshData) { + public ExecutionRequestData withFreshData(boolean freshData) { this.freshData = freshData; return this; } - public ExecutionRequest withIgnorePagination(boolean ignorePagination) { + public ExecutionRequestData withIgnorePagination(boolean ignorePagination) { this.ignorePagination = ignorePagination; return this; } - public ExecutionRequest withInteractive(boolean interactive) { + public ExecutionRequestData withInteractive(boolean interactive) { this.interactive = interactive; return this; } - public ExecutionRequest withSaveDataSnapshot(boolean saveDataSnapshot) { + public ExecutionRequestData withSaveDataSnapshot(boolean saveDataSnapshot) { this.saveDataSnapshot = saveDataSnapshot; return this; } - public ExecutionRequest withParameters(Set parameters) { + public ExecutionRequestData withParameters(Set parameters) { this.parameters = ReportParameters.wrap(parameters); return this; } - public ExecutionRequest withAttachmentsPrefix(String attachmentsPrefix) { + public ExecutionRequestData withAttachmentsPrefix(String attachmentsPrefix) { if (attachmentsPrefix == null || attachmentsPrefix.length() == 0) { throw new IllegalArgumentException("Attachment prefix should not be null or empty"); } @@ -118,7 +118,7 @@ public ExecutionRequest withAttachmentsPrefix(String attachmentsPrefix) { return this; } - public ExecutionRequest withOutputFormat(String outputFormat) { + public ExecutionRequestData withOutputFormat(String outputFormat) { if (outputFormat == null || outputFormat.length() == 0) { throw new IllegalArgumentException("Output format should not be null or empty"); } @@ -126,7 +126,7 @@ public ExecutionRequest withOutputFormat(String outputFormat) { return this; } - public ExecutionRequest withPages(String pages) { + public ExecutionRequestData withPages(String pages) { if (pages == null || pages.length() == 0) { throw new IllegalArgumentException("Pages should not be null or empty"); } @@ -134,7 +134,7 @@ public ExecutionRequest withPages(String pages) { return this; } - public ExecutionRequest withTransformerKey(String transformerKey) { + public ExecutionRequestData withTransformerKey(String transformerKey) { if (transformerKey == null || transformerKey.length() == 0) { throw new IllegalArgumentException("Transform key should not be null or empty"); } @@ -142,7 +142,7 @@ public ExecutionRequest withTransformerKey(String transformerKey) { return this; } - public ExecutionRequest withAnchor(String anchor) { + public ExecutionRequestData withAnchor(String anchor) { if (anchor == null || anchor.length() == 0) { throw new IllegalArgumentException("Anchor should not be null or empty"); } @@ -150,7 +150,7 @@ public ExecutionRequest withAnchor(String anchor) { return this; } - public ExecutionRequest withBaseUrl(String baseUrl) { + public ExecutionRequestData withBaseUrl(String baseUrl) { if (baseUrl == null || baseUrl.length() == 0) { throw new IllegalArgumentException("Base url should not be null or empty"); } @@ -158,7 +158,7 @@ public ExecutionRequest withBaseUrl(String baseUrl) { return this; } - public ExecutionRequest withAllowInlineScripts(Boolean allowInlineScripts) { + public ExecutionRequestData withAllowInlineScripts(Boolean allowInlineScripts) { this.allowInlineScripts = allowInlineScripts; return this; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestDataTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestDataTest.java index 99a87df0..e4068908 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestDataTest.java @@ -48,9 +48,9 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ExecutionRequestTest { +public class ExecutionRequestDataTest { - private ExecutionRequest requestUnderTest; + private ExecutionRequestData requestUnderTest; @Rule public final ExpectedException mExpectedException = ExpectedException.none(); @@ -58,7 +58,7 @@ public class ExecutionRequestTest { @Before public void setup() { - requestUnderTest = ExecutionRequest.newRequest("/some/uri"); + requestUnderTest = ExecutionRequestData.newRequest("/some/uri"); mGson = GsonFactory.create(); } @@ -99,13 +99,13 @@ public void shouldWithAttachmentsPrefixShouldEncodePrefix() { @Test public void factoryMethodShouldNotAllowNull() { mExpectedException.expect(IllegalArgumentException.class); - ExecutionRequest.newRequest(null); + ExecutionRequestData.newRequest(null); } @Test public void factoryMethodShouldNotAllowEmptyString() { mExpectedException.expect(IllegalArgumentException.class); - ExecutionRequest.newRequest(""); + ExecutionRequestData.newRequest(""); } @Test From 7beb3e45cecb20b170d069feca417b06eae58b7d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 14:31:26 +0300 Subject: [PATCH 044/457] Implementing 'ReportExecutionResponseTest' --- .../execution/ReportExecutionResponse.java | 24 ++--- .../ReportExecutionResponseTest.java | 93 +++++++++++++++++++ 2 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java index c3b68071..a4860992 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java @@ -50,18 +50,6 @@ public final class ReportExecutionResponse { @Expose private ErrorDescriptor errorDescriptor; - public int getCurrentPage() { - return currentPage; - } - - public ErrorDescriptor getErrorDescriptor() { - return errorDescriptor; - } - - public Set getExports() { - return exports; - } - public String getReportURI() { return reportURI; } @@ -74,10 +62,22 @@ public String getStatus() { return status; } + public int getCurrentPage() { + return currentPage; + } + public int getTotalPages() { return totalPages; } + public ErrorDescriptor getErrorDescriptor() { + return errorDescriptor; + } + + public Set getExports() { + return exports; + } + @Override public String toString() { return "ReportExecutionResponse{" + diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java new file mode 100644 index 00000000..bf4d7d15 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java @@ -0,0 +1,93 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Method; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ReportExecutionResponseTest { + + private final Gson mGson = GsonFactory.create(); + + @Test + @Parameters({ + "getReportURI, reportURI, /some/uri", + "getRequestId, requestId, 1234-5678-9101", + "getStatus, status, execute", + }) + public void shouldDeserializeStringField(String methodName, String key, String value) throws Exception { + ReportExecutionResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); + Method method = response.getClass().getMethod(methodName); + String result = (String) method.invoke(response); + assertThat(result, is(value)); + } + + @Test + @Parameters({ + "getCurrentPage, currentPage, 1", + "getTotalPages, totalPages, 100", + }) + public void shouldDeserializeIntField(String methodName, String key, String value) throws Exception { + ReportExecutionResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); + Method method = response.getClass().getMethod(methodName); + Integer result = (Integer) method.invoke(response); + assertThat(result, is(Integer.parseInt(value))); + } + + @Test + public void shouldDeserializeExports() { + ReportExecutionResponse response = deserialize("{\"exports\": []}"); + assertThat(response.getExports(), is(notNullValue())); + assertThat(response.getExports(), is(empty())); + } + + @Test + public void shouldDeserializeErrorDescriptor() { + ReportExecutionResponse response = deserialize("{\"errorDescriptor\": {}}"); + assertThat(response.getErrorDescriptor(), is(notNullValue())); + } + + private ReportExecutionResponse deserialize(String json) { + return mGson.fromJson(json, ReportExecutionResponse.class); + } +} From d837b711b64e643509e62652244d70a195ededbf Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 14:40:54 +0300 Subject: [PATCH 045/457] Implementing 'ExportExecutionTest' --- .../entity/execution/ExportExecutionTest.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java new file mode 100644 index 00000000..4dd8b18d --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java @@ -0,0 +1,83 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Test; + +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ExportExecutionTest { + + @Test + public void shouldDeserializeId() { + ExportExecution exportExecution = deserialize("{\"id\": \"1234-1234\"}"); + String result = exportExecution.getId(); + assertThat(result, is("1234-1234")); + } + + @Test + public void shouldDeserializeStatus() { + ExportExecution exportExecution = deserialize("{\"status\": \"executed\"}"); + String result = exportExecution.getStatus(); + assertThat(result, is("executed")); + } + + @Test + public void shouldDeserializeOutputResource() { + ExportExecution exportExecution = deserialize("{\"outputResource\": {}}"); + ReportOutputResource result = exportExecution.getOutputResource(); + assertThat(result, is(notNullValue())); + } + + @Test + public void shouldDeserializeAttachments() { + ExportExecution exportExecution = deserialize("{\"attachments\": []}"); + Set result = exportExecution.getAttachments(); + assertThat(result, is(notNullValue())); + assertThat(result, is(empty())); + } + + @Test + public void shouldDeserializeErrorDescriptor() { + ExportExecution exportExecution = deserialize("{\"errorDescriptor\": {}}"); + ErrorDescriptor result = exportExecution.getErrorDescriptor(); + assertThat(result, is(notNullValue())); + } + + private ExportExecution deserialize(String json) { + return GsonFactory.create().fromJson(json, ExportExecution.class); + } +} From 8313f0cdcb5de37332a1193446419b558e546e77 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 14:43:34 +0300 Subject: [PATCH 046/457] Implementing 'ReportOutputResourceTest' --- .../execution/ReportOutputResourceTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java new file mode 100644 index 00000000..c4a4d3b6 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportOutputResourceTest { + + @Test + public void shouldDeserializeContentType() { + ReportOutputResource reportOutputResource = deserialize("{\"contentType\": \"text/html\"}"); + String result = reportOutputResource.getContentType(); + assertThat(result, is("text/html")); + } + + @Test + public void shouldDeserializeFileName() { + ReportOutputResource reportOutputResource = deserialize("{\"fileName\": \"img_0_46_0\"}"); + String result = reportOutputResource.getFileName(); + assertThat(result, is("img_0_46_0")); + } + + private ReportOutputResource deserialize(String json) { + return GsonFactory.create().fromJson(json, ReportOutputResource.class); + } +} From 7dd21c5f1b8028f03e3e066c4d513afc9890c247 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 14:48:26 +0300 Subject: [PATCH 047/457] Implementing 'ErrorDescriptorTest' --- .../entity/execution/ErrorDescriptorTest.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java new file mode 100644 index 00000000..7ca36e70 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ErrorDescriptorTest { + + @Test + public void shouldDeserializeErrorCode() { + ErrorDescriptor errorDescriptor = deserialize("{\"errorCode\": \"Input controls validation failure\"}"); + String result = errorDescriptor.getErrorCode(); + assertThat(result, is("Input controls validation failure")); + } + + @Test + public void shouldDeserializeMessage() { + ErrorDescriptor errorDescriptor = deserialize("{\"message\": \"input.controls.validation.error\"}"); + String result = errorDescriptor.getMessage(); + assertThat(result, is("input.controls.validation.error")); + } + + @Test + public void shouldDeserializeParameters() { + ErrorDescriptor errorDescriptor = deserialize("{\"parameters\": [\"Specify a valid value for type Integer.\"]}"); + Set result = errorDescriptor.getParameters(); + assertThat(result, is(notNullValue())); + assertThat(new ArrayList(result).get(0), is("Specify a valid value for type Integer.")); + } + + private ErrorDescriptor deserialize(String json) { + return GsonFactory.create().fromJson(json, ErrorDescriptor.class); + } +} From ee55e5e5d5291e950aaaedf203f0f5873cfb59c6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 15:03:00 +0300 Subject: [PATCH 048/457] Add unit/integration tests for 'startReportExuction' api --- .../network/rest/v2/api/AuthBaseBuilder.java | 66 +++++++++++++ .../sdk/network/rest/v2/api/BaseBuilder.java | 2 +- .../rest/v2/api/ReportExecutionRestApi.java | 13 ++- .../rest/v2/api/RepositoryRestApi.java | 21 +--- .../v2/api/ReportExecutionRestApiTest.java | 98 +++++++++++++++++++ .../api/ReportExecutionRestApiTest.java | 82 ++++++++++++++++ 6 files changed, 262 insertions(+), 20 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java new file mode 100644 index 00000000..8590d149 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import retrofit.RequestInterceptor; +import retrofit.RestAdapter; +import retrofit.converter.GsonConverter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class AuthBaseBuilder extends BaseBuilder { + private final String mCookie; + + public AuthBaseBuilder(String baseUrl, String cookie) { + super(baseUrl); + if (cookie == null || cookie.length() == 0) { + throw new IllegalArgumentException("Cookie should not be null or empty"); + } + mCookie = cookie; + } + + @Override + public RestAdapter.Builder getDefaultBuilder() { + RestAdapter.Builder builder = super.getDefaultBuilder(); + + builder.setConverter(new GsonConverter(GsonFactory.create())); + builder.setRequestInterceptor(new RequestInterceptor() { + @Override + public void intercept(RequestFacade request) { + request.addHeader("Cookie", getCookie()); + } + }); + + return builder; + } + + public String getCookie() { + return mCookie; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java index e5de6b41..ec74ab74 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java @@ -53,7 +53,7 @@ public Throwable handleError(RetrofitError cause) { }); } - protected RestAdapter.Builder getDefaultBuilder() { + public RestAdapter.Builder getDefaultBuilder() { return mRestAdapterBuilder; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 652dc8cd..704dd8fd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; +import retrofit.http.Body; import retrofit.http.Headers; import retrofit.http.POST; @@ -41,6 +42,16 @@ public interface ReportExecutionRestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions") - ReportExecutionResponse runReportExecution(@NonNull ExecutionRequestData reportExecutionRequestData); + ReportExecutionResponse runReportExecution(@NonNull @Body ExecutionRequestData reportExecutionRequestData); + class Builder extends AuthBaseBuilder { + public Builder(String baseUrl, String cookie) { + super(baseUrl, cookie); + } + + @Override + public ReportExecutionRestApi build() { + return getDefaultBuilder().build().create(ReportExecutionRestApi.class); + } + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index dea89a78..1b08be19 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -60,28 +60,13 @@ public interface RepositoryRestApi { @NonNull FolderLookupResponse requestFolderResource(@NonNull String resourceUri); - class Builder extends BaseBuilder { - private final String mCookie; - + class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { - super(baseUrl); - if (cookie == null || cookie.length() == 0) { - throw new IllegalArgumentException("Cookie should not be null or empty"); - } - mCookie = cookie; + super(baseUrl, cookie); } public RepositoryRestApi build() { - RestAdapter.Builder builder = getDefaultBuilder(); - builder.setConverter(new GsonConverter(GsonFactory.create())); - builder.setRequestInterceptor(new RequestInterceptor() { - @Override - public void intercept(RequestFacade request) { - request.addHeader("Cookie", mCookie); - } - }); - RestAdapter restAdapter = builder.build(); - + RestAdapter restAdapter = getDefaultBuilder().build(); return new RepositoryRestApiImpl(restAdapter); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java new file mode 100644 index 00000000..f88242b1 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -0,0 +1,98 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; +import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.test.WebMockRule; +import com.squareup.okhttp.mockwebserver.MockResponse; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ExecutionRequestData.class}) +public class ReportExecutionRestApiTest { + + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + private ReportExecutionRestApi restApiUnderTest; + + @Mock + ExecutionRequestData mExecutionRequestData; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + restApiUnderTest = new ReportExecutionRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { + mExpectedException.expect(IllegalArgumentException.class); + new RepositoryRestApi.Builder(null, "cookie").build(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullCookie() { + mExpectedException.expect(IllegalArgumentException.class); + RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); + } + + @Test + public void shouldThroughRestErrorOnSearchRequestIfHttpError() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(create500Response()); + + restApiUnderTest.runReportExecution(mExecutionRequestData); + } + + @Test + public void bodyParameterShouldNotBeNull() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Body parameter value must not be null."); + + restApiUnderTest.runReportExecution(null); + } + + private MockResponse create500Response() { + return new MockResponse() + .setStatus("HTTP/1.1 500 Internal Server Error"); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java new file mode 100644 index 00000000..0ca1aedd --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -0,0 +1,82 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api; + +import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; +import org.robolectric.shadows.httpclient.FakeHttp; + +import java.io.IOException; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(RobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class ReportExecutionRestApiTest { + + String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + AuthResponse mAuthResponse; + + @Before + public void setup() { + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + } + + @Test + public void shouldStartReportExecution() throws IOException { + ReportExecutionRestApi api = createApi(); + ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); + ReportExecutionResponse response = api.runReportExecution(executionRequestData); + assertThat(response, is(notNullValue())); + assertThat(response.getStatus(), is(notNullValue())); + } + + private ReportExecutionRestApi createApi() { + return new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); + } + + private AuthResponse getAuthResponse() { + if (mAuthResponse == null) { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", null, null); + } + return mAuthResponse; + } +} From 021b041e0d6390842b3bebc1c143bc542f923e1b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 15:49:34 +0300 Subject: [PATCH 049/457] Add api 'requestReportExecutionStatus' for ReportExecutionRestApi --- .../rest/v2/api/ReportExecutionRestApi.java | 8 +++ .../execution/ReportExecutionResponse.java | 10 ++-- .../ReportExecutionStatusResponse.java | 48 +++++++++++++++++ .../v2/api/ReportExecutionRestApiTest.java | 10 +++- .../ReportExecutionStatusResponseTest.java | 46 ++++++++++++++++ .../api/ReportExecutionRestApiTest.java | 11 ++++ .../json/report_execution_details.json | 53 +++++++++++++++++++ 7 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java create mode 100644 client-network/src/test/resources/json/report_execution_details.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 704dd8fd..5811f42d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -28,10 +28,13 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import retrofit.http.Body; +import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.POST; +import retrofit.http.Path; /** * @author Tom Koptel @@ -44,6 +47,11 @@ public interface ReportExecutionRestApi { @POST("/rest_v2/reportExecutions") ReportExecutionResponse runReportExecution(@NonNull @Body ExecutionRequestData reportExecutionRequestData); + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reportExecutions/{executionId}/status") + ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull @Path(value = "executionId", encode = false) String executionId); + class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java index a4860992..aac23b19 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; import java.util.Arrays; import java.util.Collections; @@ -36,7 +37,8 @@ */ public final class ReportExecutionResponse { @Expose - private String requestId; + @SerializedName("requestId") + private String executionId; @Expose private String reportURI; @Expose @@ -54,8 +56,8 @@ public String getReportURI() { return reportURI; } - public String getRequestId() { - return requestId; + public String getExecutionId() { + return executionId; } public String getStatus() { @@ -82,7 +84,7 @@ public Set getExports() { public String toString() { return "ReportExecutionResponse{" + "currentPage=" + currentPage + - ", requestId='" + requestId + '\'' + + ", executionId='" + executionId + '\'' + ", reportURI='" + reportURI + '\'' + ", status='" + status + '\'' + ", exports=" + Arrays.toString(exports.toArray()) + diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java new file mode 100644 index 00000000..41c59510 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportExecutionStatusResponse { + + @Expose + private String value; + + public String getValue() { + return value; + } + + @Override + public String toString() { + return "ReportExecutionStatusResponse{" + + "value='" + value + '\'' + + '}'; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java index f88242b1..031c06e0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -84,13 +84,21 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { } @Test - public void bodyParameterShouldNotBeNull() { + public void bodyParameterShouldNotBeNullForRunReportExecution() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Body parameter value must not be null."); restApiUnderTest.runReportExecution(null); } + @Test + public void pathParameterShouldNotBeNullForRequestExecutionStatus() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + + restApiUnderTest.requestReportExecutionStatus(null); + } + private MockResponse create500Response() { return new MockResponse() .setStatus("HTTP/1.1 500 Internal Server Error"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java new file mode 100644 index 00000000..07923bb4 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java @@ -0,0 +1,46 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; + +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportExecutionStatusResponseTest { + @Test + public void shouldDeserializeValue() { + Gson gson = GsonFactory.create(); + ReportExecutionStatusResponse response = gson.fromJson("{\"status\": \"ready\"}", ReportExecutionStatusResponse.class); + assertThat(response.getValue(), is("ready")); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 0ca1aedd..9d81ac1f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import org.junit.Before; @@ -68,6 +69,16 @@ public void shouldStartReportExecution() throws IOException { assertThat(response.getStatus(), is(notNullValue())); } + @Test + public void shouldCheckReportExecution() throws IOException { + ReportExecutionRestApi api = createApi(); + ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); + ReportExecutionResponse executionResponse = api.runReportExecution(executionRequestData); + + ReportExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); + assertThat(response.getValue(), is(notNullValue())); + } + private ReportExecutionRestApi createApi() { return new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); } diff --git a/client-network/src/test/resources/json/report_execution_details.json b/client-network/src/test/resources/json/report_execution_details.json new file mode 100644 index 00000000..83536ecd --- /dev/null +++ b/client-network/src/test/resources/json/report_execution_details.json @@ -0,0 +1,53 @@ +{ + "status": "ready", + "totalPages": 47, + "requestId": "f3a9805a-4089-4b53-b9e9-b54752f91586", + "reportURI": "/reports/samples/AllAccounts", + "exports": [ + { + "id": "195a65cb-1762-450a-be2b-1196a02bb625", + "options": { + "outputFormat": "html", + "attachmentsPrefix": "./images/", + "allowInlineScripts": false + }, + "status": "ready", + "outputResource": { + "contentType": "text/html" + }, + "attachments": [ + { + "contentType": "image/png", + "fileName": "img_0_46_0" + }, + { + "contentType": "image/png", + "fileName": "img_0_0_0" + }, + { + "contentType": "image/jpeg", + "fileName": "img_0_46_1" + } + ] + }, + { + "id": "4bac4889-0e63-4f09-bbe8-9593674f0700", + "options": { + "outputFormat": "html", + "attachmentsPrefix": "{contextPath}/rest_v2/reportExecutions/{reportExecutionId}/exports/{exportExecutionId}/attachments/", + "baseUrl": "http://localhost:8080/jasperserver-pro", + "allowInlineScripts": true + }, + "status": "ready", + "outputResource": { + "contentType": "text/html" + }, + "attachments": [ + { + "contentType": "image/png", + "fileName": "img_0_0_0" + } + ] + } + ] +} \ No newline at end of file From 3cafe4e454d312e8ccd3295d301eb9535badcca3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 16:02:19 +0300 Subject: [PATCH 050/457] Add api 'requestReportExecutionDetails' for ReportExecutionRestApi --- .../rest/v2/api/ReportExecutionRestApi.java | 5 +++++ .../v2/entity/execution/ExportExecution.java | 17 ++++++++++++---- .../v2/api/ReportExecutionRestApiTest.java | 8 ++++++++ .../ReportExecutionResponseTest.java | 20 ++++++++++++++++++- .../api/ReportExecutionRestApiTest.java | 13 +++++++++++- 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 5811f42d..c5ed9392 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -47,6 +47,11 @@ public interface ReportExecutionRestApi { @POST("/rest_v2/reportExecutions") ReportExecutionResponse runReportExecution(@NonNull @Body ExecutionRequestData reportExecutionRequestData); + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reportExecutions/{executionId}") + ReportExecutionResponse requestReportExecutionDetails(@NonNull @Path(value = "executionId", encode = false) String executionId); + @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions/{executionId}/status") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java index cad76bc9..8ad4ea44 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java @@ -40,6 +40,8 @@ public final class ExportExecution { @Expose private String status; @Expose + private ExecutionRequestData options; + @Expose private ReportOutputResource outputResource; @Expose private Set attachments = Collections.emptySet(); @@ -58,6 +60,10 @@ public String getId() { return id; } + public ExecutionRequestData getOptions() { + return options; + } + public ReportOutputResource getOutputResource() { return outputResource; } @@ -73,8 +79,9 @@ public boolean equals(Object o) { ExportExecution that = (ExportExecution) o; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (status != null ? !status.equals(that.status) : that.status != null) return false; + if (!id.equals(that.id)) return false; + if (!status.equals(that.status)) return false; + if (options != null ? !options.equals(that.options) : that.options != null) return false; if (outputResource != null ? !outputResource.equals(that.outputResource) : that.outputResource != null) return false; if (attachments != null ? !attachments.equals(that.attachments) : that.attachments != null) @@ -84,8 +91,9 @@ public boolean equals(Object o) { @Override public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (status != null ? status.hashCode() : 0); + int result = id.hashCode(); + result = 31 * result + status.hashCode(); + result = 31 * result + (options != null ? options.hashCode() : 0); result = 31 * result + (outputResource != null ? outputResource.hashCode() : 0); result = 31 * result + (attachments != null ? attachments.hashCode() : 0); result = 31 * result + (errorDescriptor != null ? errorDescriptor.hashCode() : 0); @@ -98,6 +106,7 @@ public String toString() { "attachments=" + Arrays.toString(attachments.toArray()) + ", id='" + id + '\'' + ", status='" + status + '\'' + + ", options=" + options + ", outputResource=" + outputResource + ", errorDescriptor=" + errorDescriptor + '}'; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java index 031c06e0..76610f5c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -91,6 +91,14 @@ public void bodyParameterShouldNotBeNullForRunReportExecution() { restApiUnderTest.runReportExecution(null); } + @Test + public void pathParameterShouldNotBeNullForRequestExecutionDetails() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + + restApiUnderTest.requestReportExecutionDetails(null); + } + @Test public void pathParameterShouldNotBeNullForRequestExecutionStatus() { mExpectedException.expect(RestError.class); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java index bf4d7d15..336b4df5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java @@ -26,7 +26,11 @@ import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -49,10 +53,24 @@ public class ReportExecutionResponseTest { private final Gson mGson = GsonFactory.create(); + @ResourceFile("json/report_execution_details.json") + TestResource compoundDetailsResponse; + + @Before + public void setup() { + TestResourceInjector.inject(this); + } + + @Test + public void shouldDeserializeCompoundJsonResponse() { + ReportExecutionResponse response = deserialize(compoundDetailsResponse.asString()); + assertThat(response, is(notNullValue())); + } + @Test @Parameters({ "getReportURI, reportURI, /some/uri", - "getRequestId, requestId, 1234-5678-9101", + "getExecutionId, requestId, 1234-5678-9101", "getStatus, status, execute", }) public void shouldDeserializeStringField(String methodName, String key, String value) throws Exception { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 9d81ac1f..f6e5d4f1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -70,7 +70,18 @@ public void shouldStartReportExecution() throws IOException { } @Test - public void shouldCheckReportExecution() throws IOException { + public void shouldReturnReportExecutionDetails() throws IOException { + ReportExecutionRestApi api = createApi(); + ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); + ReportExecutionResponse executionResponse = api.runReportExecution(executionRequestData); + + String executionId = executionResponse.getExecutionId(); + ReportExecutionResponse response = api.requestReportExecutionDetails(executionResponse.getExecutionId()); + assertThat(response.getExecutionId(), is(executionId)); + } + + @Test + public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionRestApi api = createApi(); ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); ReportExecutionResponse executionResponse = api.runReportExecution(executionRequestData); From 8e092190fe342413f95f2ae5681cdebbe8c0d4b6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 16:03:46 +0300 Subject: [PATCH 051/457] Refactoring 'ReportExecutionResponse' to 'ReportExecutionDetailsResponse' --- .../rest/v2/api/ReportExecutionRestApi.java | 6 +++--- ....java => ReportExecutionDetailsResponse.java} | 2 +- .../execution/ReportExecutionStatusResponse.java | 4 ++-- ...a => ReportExecutionDetailsResponseTest.java} | 16 ++++++++-------- .../ReportExecutionStatusResponseTest.java | 4 ++-- .../api/ReportExecutionRestApiTest.java | 12 ++++++------ 6 files changed, 22 insertions(+), 22 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ReportExecutionResponse.java => ReportExecutionDetailsResponse.java} (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ReportExecutionResponseTest.java => ReportExecutionDetailsResponseTest.java} (83%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index c5ed9392..aca88950 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -27,7 +27,7 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import retrofit.http.Body; @@ -45,12 +45,12 @@ public interface ReportExecutionRestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions") - ReportExecutionResponse runReportExecution(@NonNull @Body ExecutionRequestData reportExecutionRequestData); + ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ExecutionRequestData reportExecutionRequestData); @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions/{executionId}") - ReportExecutionResponse requestReportExecutionDetails(@NonNull @Path(value = "executionId", encode = false) String executionId); + ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull @Path(value = "executionId", encode = false) String executionId); @NonNull @Headers("Accept: application/json") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponse.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponse.java index aac23b19..8da24a7f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponse.java @@ -35,7 +35,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportExecutionResponse { +public final class ReportExecutionDetailsResponse { @Expose @SerializedName("requestId") private String executionId; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java index 41c59510..a25036ec 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java @@ -30,12 +30,12 @@ * @author Tom Koptel * @since 2.0 */ -public class ReportExecutionStatusResponse { +public final class ReportExecutionStatusResponse { @Expose private String value; - public String getValue() { + public String getStatus() { return value; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java similarity index 83% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java index 336b4df5..bb80f77a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java @@ -49,7 +49,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ReportExecutionResponseTest { +public class ReportExecutionDetailsResponseTest { private final Gson mGson = GsonFactory.create(); @@ -63,7 +63,7 @@ public void setup() { @Test public void shouldDeserializeCompoundJsonResponse() { - ReportExecutionResponse response = deserialize(compoundDetailsResponse.asString()); + ReportExecutionDetailsResponse response = deserialize(compoundDetailsResponse.asString()); assertThat(response, is(notNullValue())); } @@ -74,7 +74,7 @@ public void shouldDeserializeCompoundJsonResponse() { "getStatus, status, execute", }) public void shouldDeserializeStringField(String methodName, String key, String value) throws Exception { - ReportExecutionResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); + ReportExecutionDetailsResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); Method method = response.getClass().getMethod(methodName); String result = (String) method.invoke(response); assertThat(result, is(value)); @@ -86,7 +86,7 @@ public void shouldDeserializeStringField(String methodName, String key, String v "getTotalPages, totalPages, 100", }) public void shouldDeserializeIntField(String methodName, String key, String value) throws Exception { - ReportExecutionResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); + ReportExecutionDetailsResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); Method method = response.getClass().getMethod(methodName); Integer result = (Integer) method.invoke(response); assertThat(result, is(Integer.parseInt(value))); @@ -94,18 +94,18 @@ public void shouldDeserializeIntField(String methodName, String key, String valu @Test public void shouldDeserializeExports() { - ReportExecutionResponse response = deserialize("{\"exports\": []}"); + ReportExecutionDetailsResponse response = deserialize("{\"exports\": []}"); assertThat(response.getExports(), is(notNullValue())); assertThat(response.getExports(), is(empty())); } @Test public void shouldDeserializeErrorDescriptor() { - ReportExecutionResponse response = deserialize("{\"errorDescriptor\": {}}"); + ReportExecutionDetailsResponse response = deserialize("{\"errorDescriptor\": {}}"); assertThat(response.getErrorDescriptor(), is(notNullValue())); } - private ReportExecutionResponse deserialize(String json) { - return mGson.fromJson(json, ReportExecutionResponse.class); + private ReportExecutionDetailsResponse deserialize(String json) { + return mGson.fromJson(json, ReportExecutionDetailsResponse.class); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java index 07923bb4..9edb313c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java @@ -40,7 +40,7 @@ public class ReportExecutionStatusResponseTest { @Test public void shouldDeserializeValue() { Gson gson = GsonFactory.create(); - ReportExecutionStatusResponse response = gson.fromJson("{\"status\": \"ready\"}", ReportExecutionStatusResponse.class); - assertThat(response.getValue(), is("ready")); + ReportExecutionStatusResponse response = gson.fromJson("{\"value\": \"ready\"}", ReportExecutionStatusResponse.class); + assertThat(response.getStatus(), is("ready")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index f6e5d4f1..02602155 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; @@ -64,7 +64,7 @@ public void setup() { public void shouldStartReportExecution() throws IOException { ReportExecutionRestApi api = createApi(); ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); - ReportExecutionResponse response = api.runReportExecution(executionRequestData); + ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestData); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(notNullValue())); } @@ -73,10 +73,10 @@ public void shouldStartReportExecution() throws IOException { public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionRestApi api = createApi(); ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); - ReportExecutionResponse executionResponse = api.runReportExecution(executionRequestData); + ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestData); String executionId = executionResponse.getExecutionId(); - ReportExecutionResponse response = api.requestReportExecutionDetails(executionResponse.getExecutionId()); + ReportExecutionDetailsResponse response = api.requestReportExecutionDetails(executionResponse.getExecutionId()); assertThat(response.getExecutionId(), is(executionId)); } @@ -84,10 +84,10 @@ public void shouldReturnReportExecutionDetails() throws IOException { public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionRestApi api = createApi(); ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); - ReportExecutionResponse executionResponse = api.runReportExecution(executionRequestData); + ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestData); ReportExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); - assertThat(response.getValue(), is(notNullValue())); + assertThat(response.getStatus(), is(notNullValue())); } private ReportExecutionRestApi createApi() { From fdf5d7f488029d626feec72ef62264ad03509aa1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 16:07:32 +0300 Subject: [PATCH 052/457] Refactoring 'ExecutionRequestData' to 'ExecutionRequestOptions' --- .../rest/v2/api/ReportExecutionRestApi.java | 4 +- ...Data.java => ExecutionRequestOptions.java} | 51 ++++++++++--------- .../v2/entity/execution/ExportExecution.java | 4 +- .../v2/entity/execution/ReportParameters.java | 4 ++ .../v2/api/ReportExecutionRestApiTest.java | 8 +-- ....java => ExecutionRequestOptionsTest.java} | 10 ++-- .../api/ReportExecutionRestApiTest.java | 14 ++--- 7 files changed, 52 insertions(+), 43 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ExecutionRequestData.java => ExecutionRequestOptions.java} (77%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ExecutionRequestDataTest.java => ExecutionRequestOptionsTest.java} (94%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index aca88950..9ae968ff 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; @@ -45,7 +45,7 @@ public interface ReportExecutionRestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions") - ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ExecutionRequestData reportExecutionRequestData); + ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestData.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java similarity index 77% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestData.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java index 7be4902b..375f71c6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestData.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java @@ -28,13 +28,14 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import java.util.Arrays; import java.util.Set; /** * @author Tom Koptel * @since 2.0 */ -public final class ExecutionRequestData { +public final class ExecutionRequestOptions { @Expose protected Boolean async; @@ -63,50 +64,50 @@ public final class ExecutionRequestData { @Expose protected String attachmentsPrefix; @Expose - protected ReportParameters parameters; + protected ReportParameters parameters = ReportParameters.empty(); - private ExecutionRequestData(String reportUnitUri) { + private ExecutionRequestOptions(String reportUnitUri) { this.reportUnitUri = reportUnitUri; } - public static ExecutionRequestData newRequest(String uri) { + public static ExecutionRequestOptions newRequest(String uri) { if (uri == null || uri.length() == 0) { throw new IllegalArgumentException("Uri should not be null"); } - return new ExecutionRequestData(uri); + return new ExecutionRequestOptions(uri); } - public ExecutionRequestData withAsync(boolean async) { + public ExecutionRequestOptions withAsync(boolean async) { this.async = async; return this; } - public ExecutionRequestData withFreshData(boolean freshData) { + public ExecutionRequestOptions withFreshData(boolean freshData) { this.freshData = freshData; return this; } - public ExecutionRequestData withIgnorePagination(boolean ignorePagination) { + public ExecutionRequestOptions withIgnorePagination(boolean ignorePagination) { this.ignorePagination = ignorePagination; return this; } - public ExecutionRequestData withInteractive(boolean interactive) { + public ExecutionRequestOptions withInteractive(boolean interactive) { this.interactive = interactive; return this; } - public ExecutionRequestData withSaveDataSnapshot(boolean saveDataSnapshot) { + public ExecutionRequestOptions withSaveDataSnapshot(boolean saveDataSnapshot) { this.saveDataSnapshot = saveDataSnapshot; return this; } - public ExecutionRequestData withParameters(Set parameters) { + public ExecutionRequestOptions withParameters(Set parameters) { this.parameters = ReportParameters.wrap(parameters); return this; } - public ExecutionRequestData withAttachmentsPrefix(String attachmentsPrefix) { + public ExecutionRequestOptions withAttachmentsPrefix(String attachmentsPrefix) { if (attachmentsPrefix == null || attachmentsPrefix.length() == 0) { throw new IllegalArgumentException("Attachment prefix should not be null or empty"); } @@ -118,7 +119,7 @@ public ExecutionRequestData withAttachmentsPrefix(String attachmentsPrefix) { return this; } - public ExecutionRequestData withOutputFormat(String outputFormat) { + public ExecutionRequestOptions withOutputFormat(String outputFormat) { if (outputFormat == null || outputFormat.length() == 0) { throw new IllegalArgumentException("Output format should not be null or empty"); } @@ -126,7 +127,7 @@ public ExecutionRequestData withOutputFormat(String outputFormat) { return this; } - public ExecutionRequestData withPages(String pages) { + public ExecutionRequestOptions withPages(String pages) { if (pages == null || pages.length() == 0) { throw new IllegalArgumentException("Pages should not be null or empty"); } @@ -134,7 +135,7 @@ public ExecutionRequestData withPages(String pages) { return this; } - public ExecutionRequestData withTransformerKey(String transformerKey) { + public ExecutionRequestOptions withTransformerKey(String transformerKey) { if (transformerKey == null || transformerKey.length() == 0) { throw new IllegalArgumentException("Transform key should not be null or empty"); } @@ -142,7 +143,7 @@ public ExecutionRequestData withTransformerKey(String transformerKey) { return this; } - public ExecutionRequestData withAnchor(String anchor) { + public ExecutionRequestOptions withAnchor(String anchor) { if (anchor == null || anchor.length() == 0) { throw new IllegalArgumentException("Anchor should not be null or empty"); } @@ -150,7 +151,7 @@ public ExecutionRequestData withAnchor(String anchor) { return this; } - public ExecutionRequestData withBaseUrl(String baseUrl) { + public ExecutionRequestOptions withBaseUrl(String baseUrl) { if (baseUrl == null || baseUrl.length() == 0) { throw new IllegalArgumentException("Base url should not be null or empty"); } @@ -158,7 +159,7 @@ public ExecutionRequestData withBaseUrl(String baseUrl) { return this; } - public ExecutionRequestData withAllowInlineScripts(Boolean allowInlineScripts) { + public ExecutionRequestOptions withAllowInlineScripts(Boolean allowInlineScripts) { this.allowInlineScripts = allowInlineScripts; return this; } @@ -221,17 +222,21 @@ public String getTransformerKey() { @Override public String toString() { - return "ExecutionRequest{" + - "async=" + async + - ", reportUnitUri='" + reportUnitUri + '\'' + + return "ExecutionRequestOptions{" + + "allowInlineScripts=" + allowInlineScripts + + ", async=" + async + ", freshData=" + freshData + ", saveDataSnapshot=" + saveDataSnapshot + - ", outputFormat='" + outputFormat + '\'' + ", interactive=" + interactive + ", ignorePagination=" + ignorePagination + + ", reportUnitUri='" + reportUnitUri + '\'' + + ", outputFormat='" + outputFormat + '\'' + ", pages='" + pages + '\'' + + ", baseUrl='" + baseUrl + '\'' + + ", anchor='" + anchor + '\'' + + ", transformerKey='" + transformerKey + '\'' + ", attachmentsPrefix='" + attachmentsPrefix + '\'' + - ", parameters=" + parameters + + ", parameters=" + Arrays.toString(parameters.getReportParameters().toArray()) + '}'; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java index 8ad4ea44..615d8398 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java @@ -40,7 +40,7 @@ public final class ExportExecution { @Expose private String status; @Expose - private ExecutionRequestData options; + private ExecutionRequestOptions options; @Expose private ReportOutputResource outputResource; @Expose @@ -60,7 +60,7 @@ public String getId() { return id; } - public ExecutionRequestData getOptions() { + public ExecutionRequestOptions getOptions() { return options; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java index d6ffa9d5..53333e83 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java @@ -48,6 +48,10 @@ public Set getReportParameters() { return reportParameters; } + public static ReportParameters empty() { + return wrap(null); + } + public static ReportParameters wrap(Set params) { if (params == null) { params = Collections.emptySet(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java index 76610f5c..7542692a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network.rest.v2.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; @@ -44,7 +44,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionRequestData.class}) +@PrepareForTest({ExecutionRequestOptions.class}) public class ReportExecutionRestApiTest { @Rule @@ -54,7 +54,7 @@ public class ReportExecutionRestApiTest { private ReportExecutionRestApi restApiUnderTest; @Mock - ExecutionRequestData mExecutionRequestData; + ExecutionRequestOptions mExecutionRequestOptions; @Before public void setup() { @@ -80,7 +80,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runReportExecution(mExecutionRequestData); + restApiUnderTest.runReportExecution(mExecutionRequestOptions); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestDataTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestDataTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java index e4068908..5a716527 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestDataTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java @@ -48,9 +48,9 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ExecutionRequestDataTest { +public class ExecutionRequestOptionsTest { - private ExecutionRequestData requestUnderTest; + private ExecutionRequestOptions requestUnderTest; @Rule public final ExpectedException mExpectedException = ExpectedException.none(); @@ -58,7 +58,7 @@ public class ExecutionRequestDataTest { @Before public void setup() { - requestUnderTest = ExecutionRequestData.newRequest("/some/uri"); + requestUnderTest = ExecutionRequestOptions.newRequest("/some/uri"); mGson = GsonFactory.create(); } @@ -99,13 +99,13 @@ public void shouldWithAttachmentsPrefixShouldEncodePrefix() { @Test public void factoryMethodShouldNotAllowNull() { mExpectedException.expect(IllegalArgumentException.class); - ExecutionRequestData.newRequest(null); + ExecutionRequestOptions.newRequest(null); } @Test public void factoryMethodShouldNotAllowEmptyString() { mExpectedException.expect(IllegalArgumentException.class); - ExecutionRequestData.newRequest(""); + ExecutionRequestOptions.newRequest(""); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 02602155..d9445233 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestData; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; @@ -63,8 +63,8 @@ public void setup() { @Test public void shouldStartReportExecution() throws IOException { ReportExecutionRestApi api = createApi(); - ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); - ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestData); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest("/public/Samples/Reports/AllAccounts"); + ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestOptions); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(notNullValue())); } @@ -72,8 +72,8 @@ public void shouldStartReportExecution() throws IOException { @Test public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionRestApi api = createApi(); - ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); - ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestData); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest("/public/Samples/Reports/AllAccounts"); + ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); String executionId = executionResponse.getExecutionId(); ReportExecutionDetailsResponse response = api.requestReportExecutionDetails(executionResponse.getExecutionId()); @@ -83,8 +83,8 @@ public void shouldReturnReportExecutionDetails() throws IOException { @Test public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionRestApi api = createApi(); - ExecutionRequestData executionRequestData = ExecutionRequestData.newRequest("/public/Samples/Reports/AllAccounts"); - ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestData); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest("/public/Samples/Reports/AllAccounts"); + ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); ReportExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); assertThat(response.getStatus(), is(notNullValue())); From 648b63efc28039e2ed4466f49f02514075cb3c7a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 16:15:02 +0300 Subject: [PATCH 053/457] Add 'errorDescriptor' property for 'ReportExecutionStatusResponse' --- .../execution/ReportExecutionStatusResponse.java | 6 ++++++ .../ReportExecutionStatusResponseTest.java | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java index a25036ec..31a307e1 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java @@ -34,11 +34,17 @@ public final class ReportExecutionStatusResponse { @Expose private String value; + @Expose + private ErrorDescriptor errorDescriptor; public String getStatus() { return value; } + public ErrorDescriptor getErrorDescriptor() { + return errorDescriptor; + } + @Override public String toString() { return "ReportExecutionStatusResponse{" + diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java index 9edb313c..36a08839 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java @@ -24,12 +24,12 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import org.junit.Test; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; /** @@ -39,8 +39,17 @@ public class ReportExecutionStatusResponseTest { @Test public void shouldDeserializeValue() { - Gson gson = GsonFactory.create(); - ReportExecutionStatusResponse response = gson.fromJson("{\"value\": \"ready\"}", ReportExecutionStatusResponse.class); + ReportExecutionStatusResponse response = deserialize("{\"value\": \"ready\"}"); assertThat(response.getStatus(), is("ready")); } + + @Test + public void shouldDeserializeErrorDescriptor() { + ReportExecutionStatusResponse response = deserialize("{\"errorDescriptor\": {}}"); + assertThat(response.getErrorDescriptor(), is(notNullValue())); + } + + private ReportExecutionStatusResponse deserialize(String json) { + return GsonFactory.create().fromJson(json, ReportExecutionStatusResponse.class); + } } From e4dccd7cd25e060b65ee7cc38daa0da46db5cd56 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 17:01:58 +0300 Subject: [PATCH 054/457] Implementing 'cancelReportExecution' api --- .../rest/v2/api/ReportExecutionRestApi.java | 22 ++-- .../v2/api/ReportExecutionRestApiImpl.java | 101 ++++++++++++++++++ .../execution/ExecutionRequestOptions.java | 2 +- .../ReportExecutionStatusResponse.java | 10 ++ .../v2/api/ReportExecutionRestApiTest.java | 60 +++++++++-- .../api/ReportExecutionRestApiTest.java | 16 ++- .../json/cancelled_report_response.json | 3 + 7 files changed, 183 insertions(+), 31 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java create mode 100644 client-network/src/test/resources/json/cancelled_report_response.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 9ae968ff..67c02729 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -30,12 +30,6 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; -import retrofit.http.Body; -import retrofit.http.GET; -import retrofit.http.Headers; -import retrofit.http.POST; -import retrofit.http.Path; - /** * @author Tom Koptel * @since 2.0 @@ -43,19 +37,15 @@ public interface ReportExecutionRestApi { @NonNull - @Headers("Accept: application/json") - @POST("/rest_v2/reportExecutions") - ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ExecutionRequestOptions executionOptions); + ReportExecutionDetailsResponse runReportExecution(@NonNull ExecutionRequestOptions executionOptions); @NonNull - @Headers("Accept: application/json") - @GET("/rest_v2/reportExecutions/{executionId}") - ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull @Path(value = "executionId", encode = false) String executionId); + ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId); @NonNull - @Headers("Accept: application/json") - @GET("/rest_v2/reportExecutions/{executionId}/status") - ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull @Path(value = "executionId", encode = false) String executionId); + ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId); + + boolean cancelReportExecution(@NonNull String executionId); class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { @@ -64,7 +54,7 @@ public Builder(String baseUrl, String cookie) { @Override public ReportExecutionRestApi build() { - return getDefaultBuilder().build().create(ReportExecutionRestApi.class); + return new ReportExecutionRestApiImpl(getDefaultBuilder().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java new file mode 100644 index 00000000..2f38d616 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java @@ -0,0 +1,101 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; + +import retrofit.RestAdapter; +import retrofit.client.Response; +import retrofit.http.Body; +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.POST; +import retrofit.http.PUT; +import retrofit.http.Path; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { + + private final RestApi mRestApi; + + ReportExecutionRestApiImpl(RestAdapter restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } + + @NonNull + @Override + public ReportExecutionDetailsResponse runReportExecution(@NonNull ExecutionRequestOptions executionOptions) { + return mRestApi.runReportExecution(executionOptions); + } + + @NonNull + @Override + public ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId) { + return mRestApi.requestReportExecutionDetails(executionId); + } + + @NonNull + @Override + public ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId) { + return mRestApi.requestReportExecutionStatus(executionId); + } + + @Override + public boolean cancelReportExecution(@NonNull String executionId) { + Response response = mRestApi.cancelReportExecution(executionId, ReportExecutionStatusResponse.cancelledStatus()); + int status = response.getStatus(); + return status != 204; + } + + private interface RestApi { + @NonNull + @Headers("Accept: application/json") + @POST("/rest_v2/reportExecutions") + ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ExecutionRequestOptions executionOptions); + + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reportExecutions/{executionId}") + ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull @Path(value = "executionId", encode = false) String executionId); + + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reportExecutions/{executionId}/status") + ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull @Path(value = "executionId", encode = false) String executionId); + + @NonNull + @Headers("Accept: application/json") + @PUT("/rest_v2/reportExecutions/{executionId}/status") + Response cancelReportExecution(@NonNull @Path(value = "executionId", encode = false) String executionId, + @NonNull @Body ReportExecutionStatusResponse statusResponse); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java index 375f71c6..82e9fe1b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java @@ -64,7 +64,7 @@ public final class ExecutionRequestOptions { @Expose protected String attachmentsPrefix; @Expose - protected ReportParameters parameters = ReportParameters.empty(); + protected ReportParameters parameters; private ExecutionRequestOptions(String reportUnitUri) { this.reportUnitUri = reportUnitUri; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java index 31a307e1..bfaae004 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java @@ -37,6 +37,16 @@ public final class ReportExecutionStatusResponse { @Expose private ErrorDescriptor errorDescriptor; + public ReportExecutionStatusResponse() {} + + private ReportExecutionStatusResponse(String value) { + this.value = value; + } + + public static ReportExecutionStatusResponse cancelledStatus() { + return new ReportExecutionStatusResponse("cancelled"); + } + public String getStatus() { return value; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java index 7542692a..1a2af924 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -27,38 +27,38 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; /** * @author Tom Koptel * @since 2.0 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionRequestOptions.class}) public class ReportExecutionRestApiTest { + @ResourceFile("json/cancelled_report_response.json") + TestResource cancelledResponse; + @Rule public final WebMockRule mWebMockRule = new WebMockRule(); @Rule public final ExpectedException mExpectedException = ExpectedException.none(); private ReportExecutionRestApi restApiUnderTest; - @Mock - ExecutionRequestOptions mExecutionRequestOptions; - @Before public void setup() { - MockitoAnnotations.initMocks(this); + TestResourceInjector.inject(this); restApiUnderTest = new ReportExecutionRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); } @@ -80,7 +80,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runReportExecution(mExecutionRequestOptions); + restApiUnderTest.runReportExecution(ExecutionRequestOptions.newRequest("/any/uri")); } @Test @@ -107,6 +107,44 @@ public void pathParameterShouldNotBeNullForRequestExecutionStatus() { restApiUnderTest.requestReportExecutionStatus(null); } + @Test + public void pathParameterShouldNotBeNullForCancelRequestExecution() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + + restApiUnderTest.cancelReportExecution(null); + } + + @Test + public void responseShouldNotBeCancelledIfResponseIs204() { + mWebMockRule.enqueue(create204Response()); + + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); + + assertThat(cancelled, is(false)); + } + + @Test + public void responseShouldBeCancelledIfResponseIs200() { + MockResponse response = create200Response(); + response.setBody(cancelledResponse.asString()); + mWebMockRule.enqueue(response); + + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); + + assertThat(cancelled, is(true)); + } + + private MockResponse create200Response() { + return new MockResponse() + .setStatus("HTTP/1.1 200 Ok"); + } + + private MockResponse create204Response() { + return new MockResponse() + .setStatus("HTTP/1.1 204 No Content"); + } + private MockResponse create500Response() { return new MockResponse() .setStatus("HTTP/1.1 500 Internal Server Error"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index d9445233..cfeae5f1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -53,6 +53,7 @@ public class ReportExecutionRestApiTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + String reportUri = "/public/Samples/Reports/AllAccounts"; AuthResponse mAuthResponse; @Before @@ -63,16 +64,25 @@ public void setup() { @Test public void shouldStartReportExecution() throws IOException { ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest("/public/Samples/Reports/AllAccounts"); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestOptions); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(notNullValue())); } + @Test + public void shouldCancelReportExecution() throws IOException { + ReportExecutionRestApi api = createApi(); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); + ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestOptions); + boolean cancelled = api.cancelReportExecution(response.getExecutionId()); + assertThat(cancelled, is(true)); + } + @Test public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest("/public/Samples/Reports/AllAccounts"); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); String executionId = executionResponse.getExecutionId(); @@ -83,7 +93,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { @Test public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest("/public/Samples/Reports/AllAccounts"); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); ReportExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); diff --git a/client-network/src/test/resources/json/cancelled_report_response.json b/client-network/src/test/resources/json/cancelled_report_response.json new file mode 100644 index 00000000..129de1dd --- /dev/null +++ b/client-network/src/test/resources/json/cancelled_report_response.json @@ -0,0 +1,3 @@ +{ + "value": "cancelled" +} \ No newline at end of file From cb9f5683b27bc952646820b912ad72e716a468aa Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 17:11:45 +0300 Subject: [PATCH 055/457] Refactor 'ReportParameter' 'empty' factory method --- .../network/rest/v2/entity/execution/ReportParameter.java | 4 ++-- .../v2/entity/execution/ExecutionRequestOptionsTest.java | 2 +- .../rest/v2/entity/execution/ReportParameterTest.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java index d9b12b4d..920edcaa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java @@ -49,7 +49,7 @@ private ReportParameter(String name, Set values) { } @SuppressWarnings("unchecked") - public static ReportParameter createWithEmptyValue(String name) { + public static ReportParameter emptyParameter(String name) { return create(name, Collections.EMPTY_SET); } @@ -58,7 +58,7 @@ public static ReportParameter create(String name, Set values) { throw new IllegalArgumentException("Name should not be null"); } if (values == null) { - throw new IllegalArgumentException("Values should not be null. Otherwise use ReportParameter.createWithEmptyValue()"); + throw new IllegalArgumentException("Values should not be null. Otherwise use ReportParameter.emptyParameter()"); } return new ReportParameter(name, values); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java index 5a716527..69a06dd6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java @@ -140,7 +140,7 @@ public void shouldSerializeBooleanField(String methodName, String key) throws Ex @Test public void shouldSerializeParametersList() { - ReportParameter reportParameter = ReportParameter.createWithEmptyValue("some_param"); + ReportParameter reportParameter = ReportParameter.emptyParameter("some_param"); Set parameters = new HashSet<>(); parameters.add(reportParameter); requestUnderTest.withParameters(parameters); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java index 775dc697..8a67d864 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java @@ -70,19 +70,19 @@ public void factoryMethodShouldNotAllowNullName() { @Test public void factoryMethodShouldNotAllowNullValueSet() { mExpectedException.expect(IllegalArgumentException.class); - mExpectedException.expectMessage("Values should not be null. Otherwise use ReportParameter.createWithEmptyValue()"); + mExpectedException.expectMessage("Values should not be null. Otherwise use ReportParameter.emptyParameter()"); ReportParameter.create("key", null); } @Test public void factoryMethodCanCreateParameterWithEmptyValueSet() { - ReportParameter reportParameter = ReportParameter.createWithEmptyValue("key"); + ReportParameter reportParameter = ReportParameter.emptyParameter("key"); assertThat(reportParameter.getValues(), is(empty())); } @Test public void factoryMethod1ShouldAssignName() { - ReportParameter reportParameter = ReportParameter.createWithEmptyValue("key"); + ReportParameter reportParameter = ReportParameter.emptyParameter("key"); assertThat(reportParameter.getName(), is("key")); } From d8dc3a6828b028b6794e9652109df96e1c8e4c68 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 11 Aug 2015 17:12:58 +0300 Subject: [PATCH 056/457] Reverse null accept behaviour for 'ReportParams' factory method --- .../rest/v2/entity/execution/ReportParameters.java | 7 +------ .../v2/entity/execution/ReportParametersTest.java | 11 +++-------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java index 53333e83..3bc0cd7b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java @@ -28,7 +28,6 @@ import com.google.gson.annotations.SerializedName; import java.util.Arrays; -import java.util.Collections; import java.util.Set; /** @@ -48,13 +47,9 @@ public Set getReportParameters() { return reportParameters; } - public static ReportParameters empty() { - return wrap(null); - } - public static ReportParameters wrap(Set params) { if (params == null) { - params = Collections.emptySet(); + throw new IllegalArgumentException("Parameters should not be null"); } return new ReportParameters(params); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java index 2adbfeec..e4b8a5e8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java @@ -26,18 +26,13 @@ import org.junit.Test; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - /** * @author Tom Koptel * @since 2.0 */ public class ReportParametersTest { - @Test - public void factoryMethodAcceptsNull() { - ReportParameters reportParameters = ReportParameters.wrap(null); - assertThat(reportParameters.getReportParameters(), is(empty())); + @Test(expected = IllegalArgumentException.class) + public void factoryMethodShouldNotAcceptNull() { + ReportParameters.wrap(null); } } From 56e943cd822798a9ddf80eec100d227853ce2172 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 12:06:28 +0300 Subject: [PATCH 057/457] Change serialization strategy to reflection field check --- .../entity/execution/ErrorDescriptorTest.java | 45 ++---- .../ExecutionRequestOptionsTest.java | 52 +++---- .../entity/execution/ExportExecutionTest.java | 61 +++----- .../ReportExecutionDetailsResponseTest.java | 77 ++-------- .../ReportExecutionStatusResponseTest.java | 34 ++--- .../execution/ReportOutputResourceTest.java | 36 +++-- .../entity/execution/ReportParameterTest.java | 32 ++-- .../resource/DashboardLookupResponseTest.java | 109 +++----------- .../resource/FolderLookupResponseTest.java | 73 +-------- .../LegacyDashboardLookupResponseTest.java | 9 +- .../resource/ReportLookupResponseTest.java | 139 +++--------------- ...ResourceLookupResponseJsonConvertTest.java | 97 +++--------- .../ServerInfoResponseJsonConvertTest.java | 111 -------------- .../entity/server/ServerInfoResponseTest.java | 60 ++++++++ .../sdk/test/matcher/HasAnnotation.java | 61 ++++++++ 15 files changed, 304 insertions(+), 692 deletions(-) delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java index 7ca36e70..32e4cfd1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java @@ -24,46 +24,33 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.google.gson.annotations.Expose; import org.junit.Test; +import org.junit.runner.RunWith; -import java.util.ArrayList; -import java.util.Set; +import java.lang.reflect.Field; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class ErrorDescriptorTest { - - @Test - public void shouldDeserializeErrorCode() { - ErrorDescriptor errorDescriptor = deserialize("{\"errorCode\": \"Input controls validation failure\"}"); - String result = errorDescriptor.getErrorCode(); - assertThat(result, is("Input controls validation failure")); - } - @Test - public void shouldDeserializeMessage() { - ErrorDescriptor errorDescriptor = deserialize("{\"message\": \"input.controls.validation.error\"}"); - String result = errorDescriptor.getMessage(); - assertThat(result, is("input.controls.validation.error")); - } - - @Test - public void shouldDeserializeParameters() { - ErrorDescriptor errorDescriptor = deserialize("{\"parameters\": [\"Specify a valid value for type Integer.\"]}"); - Set result = errorDescriptor.getParameters(); - assertThat(result, is(notNullValue())); - assertThat(new ArrayList(result).get(0), is("Specify a valid value for type Integer.")); - } - - private ErrorDescriptor deserialize(String json) { - return GsonFactory.create().fromJson(json, ErrorDescriptor.class); + @Parameters({ + "errorCode", + "message", + "parameters", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ErrorDescriptor.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java index 69a06dd6..d4a25c99 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; import com.google.gson.Gson; +import com.google.gson.annotations.Expose; import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import org.junit.Before; @@ -33,6 +34,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashSet; import java.util.Set; @@ -40,6 +42,7 @@ import junitparams.JUnitParamsRunner; import junitparams.Parameters; +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -62,6 +65,24 @@ public void setup() { mGson = GsonFactory.create(); } + @Test + @Parameters({ + "async", + "freshData", + "ignorePagination", + "interactive", + "saveDataSnapshot", + "outputFormat", + "pages", + "transformerKey", + "anchor", + "baseUrl", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ExecutionRequestOptions.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + @Test @Parameters({ "withOutputFormat", @@ -107,37 +128,6 @@ public void factoryMethodShouldNotAllowEmptyString() { mExpectedException.expect(IllegalArgumentException.class); ExecutionRequestOptions.newRequest(""); } - - @Test - @Parameters({ - "withOutputFormat, outputFormat", - "withPages, pages", - "withTransformerKey, transformerKey", - "withAnchor, anchor", - "withBaseUrl, baseUrl", - }) - public void shouldSerializeStringField(String methodName, String key) throws Exception { - Method method = requestUnderTest.getClass().getMethod(methodName, String.class); - method.invoke(requestUnderTest, "some value"); - String json = mGson.toJson(requestUnderTest); - assertThat(json, is("{\"reportUnitUri\":\"/some/uri\",\"" + key + "\":\"some value\"}")); - } - - @Test - @Parameters({ - "withAsync, async", - "withFreshData, freshData", - "withIgnorePagination, ignorePagination", - "withInteractive, interactive", - "withSaveDataSnapshot, saveDataSnapshot", - }) - public void shouldSerializeBooleanField(String methodName, String key) throws Exception { - Method method = requestUnderTest.getClass().getMethod(methodName, boolean.class); - method.invoke(requestUnderTest, true); - String json = mGson.toJson(requestUnderTest); - assertThat(json, is("{\"" + key + "\":true,\"reportUnitUri\":\"/some/uri\"}")); - } - @Test public void shouldSerializeParametersList() { ReportParameter reportParameter = ReportParameter.emptyParameter("some_param"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java index 4dd8b18d..4654b6de 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java @@ -24,60 +24,35 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.google.gson.annotations.Expose; import org.junit.Test; +import org.junit.runner.RunWith; -import java.util.Set; +import java.lang.reflect.Field; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class ExportExecutionTest { - - @Test - public void shouldDeserializeId() { - ExportExecution exportExecution = deserialize("{\"id\": \"1234-1234\"}"); - String result = exportExecution.getId(); - assertThat(result, is("1234-1234")); - } - - @Test - public void shouldDeserializeStatus() { - ExportExecution exportExecution = deserialize("{\"status\": \"executed\"}"); - String result = exportExecution.getStatus(); - assertThat(result, is("executed")); - } - @Test - public void shouldDeserializeOutputResource() { - ExportExecution exportExecution = deserialize("{\"outputResource\": {}}"); - ReportOutputResource result = exportExecution.getOutputResource(); - assertThat(result, is(notNullValue())); - } - - @Test - public void shouldDeserializeAttachments() { - ExportExecution exportExecution = deserialize("{\"attachments\": []}"); - Set result = exportExecution.getAttachments(); - assertThat(result, is(notNullValue())); - assertThat(result, is(empty())); - } - - @Test - public void shouldDeserializeErrorDescriptor() { - ExportExecution exportExecution = deserialize("{\"errorDescriptor\": {}}"); - ErrorDescriptor result = exportExecution.getErrorDescriptor(); - assertThat(result, is(notNullValue())); - } - - private ExportExecution deserialize(String json) { - return GsonFactory.create().fromJson(json, ExportExecution.class); + @Parameters({ + "id", + "status", + "outputResource", + "attachments", + "errorDescriptor", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ExportExecution.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java index bb80f77a..fbc9c76a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java @@ -24,25 +24,18 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; +import com.google.gson.annotations.Expose; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import java.lang.reflect.Method; +import java.lang.reflect.Field; import junitparams.JUnitParamsRunner; import junitparams.Parameters; -import static org.hamcrest.CoreMatchers.notNullValue; +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.Is.is; /** * @author Tom Koptel @@ -50,62 +43,18 @@ */ @RunWith(JUnitParamsRunner.class) public class ReportExecutionDetailsResponseTest { - - private final Gson mGson = GsonFactory.create(); - - @ResourceFile("json/report_execution_details.json") - TestResource compoundDetailsResponse; - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - - @Test - public void shouldDeserializeCompoundJsonResponse() { - ReportExecutionDetailsResponse response = deserialize(compoundDetailsResponse.asString()); - assertThat(response, is(notNullValue())); - } - @Test @Parameters({ - "getReportURI, reportURI, /some/uri", - "getExecutionId, requestId, 1234-5678-9101", - "getStatus, status, execute", + "reportURI", + "executionId", + "status", + "currentPage", + "totalPages", + "exports", + "errorDescriptor", }) - public void shouldDeserializeStringField(String methodName, String key, String value) throws Exception { - ReportExecutionDetailsResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); - Method method = response.getClass().getMethod(methodName); - String result = (String) method.invoke(response); - assertThat(result, is(value)); - } - - @Test - @Parameters({ - "getCurrentPage, currentPage, 1", - "getTotalPages, totalPages, 100", - }) - public void shouldDeserializeIntField(String methodName, String key, String value) throws Exception { - ReportExecutionDetailsResponse response = deserialize("{\"" + key + "\": \"" + value + "\"}"); - Method method = response.getClass().getMethod(methodName); - Integer result = (Integer) method.invoke(response); - assertThat(result, is(Integer.parseInt(value))); - } - - @Test - public void shouldDeserializeExports() { - ReportExecutionDetailsResponse response = deserialize("{\"exports\": []}"); - assertThat(response.getExports(), is(notNullValue())); - assertThat(response.getExports(), is(empty())); - } - - @Test - public void shouldDeserializeErrorDescriptor() { - ReportExecutionDetailsResponse response = deserialize("{\"errorDescriptor\": {}}"); - assertThat(response.getErrorDescriptor(), is(notNullValue())); - } - - private ReportExecutionDetailsResponse deserialize(String json) { - return mGson.fromJson(json, ReportExecutionDetailsResponse.class); + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportExecutionDetailsResponse.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java index 36a08839..14cc511a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java @@ -24,32 +24,32 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.google.gson.annotations.Expose; +import org.hamcrest.MatcherAssert; import org.junit.Test; +import org.junit.runner.RunWith; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class ReportExecutionStatusResponseTest { @Test - public void shouldDeserializeValue() { - ReportExecutionStatusResponse response = deserialize("{\"value\": \"ready\"}"); - assertThat(response.getStatus(), is("ready")); - } - - @Test - public void shouldDeserializeErrorDescriptor() { - ReportExecutionStatusResponse response = deserialize("{\"errorDescriptor\": {}}"); - assertThat(response.getErrorDescriptor(), is(notNullValue())); - } - - private ReportExecutionStatusResponse deserialize(String json) { - return GsonFactory.create().fromJson(json, ReportExecutionStatusResponse.class); + @Parameters({ + "value", + "errorDescriptor", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportExecutionStatusResponse.class.getDeclaredField(fieldName); + MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java index c4a4d3b6..27353039 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java @@ -24,34 +24,32 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.google.gson.annotations.Expose; +import org.hamcrest.MatcherAssert; import org.junit.Test; +import org.junit.runner.RunWith; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class ReportOutputResourceTest { - - @Test - public void shouldDeserializeContentType() { - ReportOutputResource reportOutputResource = deserialize("{\"contentType\": \"text/html\"}"); - String result = reportOutputResource.getContentType(); - assertThat(result, is("text/html")); - } - @Test - public void shouldDeserializeFileName() { - ReportOutputResource reportOutputResource = deserialize("{\"fileName\": \"img_0_46_0\"}"); - String result = reportOutputResource.getFileName(); - assertThat(result, is("img_0_46_0")); - } - - private ReportOutputResource deserialize(String json) { - return GsonFactory.create().fromJson(json, ReportOutputResource.class); + @Parameters({ + "contentType", + "fileName", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportOutputResource.class.getDeclaredField(fieldName); + MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java index 8a67d864..1629eaef 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java @@ -24,17 +24,21 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.google.gson.annotations.Expose; -import org.junit.Before; +import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import java.lang.reflect.Field; import java.util.Collections; -import java.util.HashSet; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.collection.IsEmptyCollection.empty; @@ -44,16 +48,11 @@ * @since 2.0 */ @SuppressWarnings("unchecked") +@RunWith(JUnitParamsRunner.class) public class ReportParameterTest { @Rule public ExpectedException mExpectedException = ExpectedException.none(); - private Gson mGson; - - @Before - public void setup() { - mGson = GsonFactory.create(); - } @Test public void factoryMethodShouldNotAllowEmptyName() { @@ -93,11 +92,12 @@ public void factoryMethod2ShouldAssignName() { } @Test - public void shouldBeSerializableToJson() { - ReportParameter reportParameter = ReportParameter.create("key", new HashSet(){{ - add("value"); - }}); - String json = mGson.toJson(reportParameter); - assertThat(json, is("{\"name\":\"key\",\"value\":[\"value\"]}")); + @Parameters({ + "name", + "values", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportParameter.class.getDeclaredField(fieldName); + MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java index 81256010..68bddbaa 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java @@ -24,111 +24,40 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; +import com.google.gson.annotations.Expose; -import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; +import static org.hamcrest.Matchers.is; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class DashboardLookupResponseTest { - @com.jaspersoft.android.sdk.test.resource.ResourceFile("json/dashboard_unit_resource.json") - TestResource dashboardResponse1; - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - @Test - public void shouldDeserializeResponse1FromWholeJson() { - DashboardLookupResponse response1 = deserialize(dashboardResponse1.asString()); - assertThat(response1, is(notNullValue())); + @Parameters({ + "foundations", + "resources", + "defaultFoundation", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = DashboardLookupResponse.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); } @Test public void shouldAlwaysReturnReportUnitUriAsType() { - DashboardLookupResponse response = deserialize("{}"); + DashboardLookupResponse response = new DashboardLookupResponse(); assertThat(response.getResourceType(), is("dashboard")); } - - @Test - public void shouldDeserializeVersion() { - DashboardLookupResponse response = deserialize("{\"version\": 2}"); - assertThat(response.getVersion(), is(2)); - } - - @Test - public void shouldDeserializePermissionMask() { - DashboardLookupResponse response = deserialize("{\"permissionMask\": 1}"); - assertThat(response.getPermissionMask(), is(1)); - } - - @Test - public void shouldDeserializeCreationDate() { - DashboardLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); - assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); - } - - @Test - public void shouldDeserializeUpdateDate() { - DashboardLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); - assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); - } - - @Test - public void shouldDeserializeLabel() { - DashboardLookupResponse response = deserialize("{\"label\": \"1. Supermart Dashboard\"}"); - assertThat(response.getLabel(), is("1. Supermart Dashboard")); - } - - @Test - public void shouldDeserializeDescription() { - DashboardLookupResponse response = deserialize("{\"description\": \"Sample containing 5 Dashlets\"}"); - assertThat(response.getDescription(), is("Sample containing 5 Dashlets")); - } - - @Test - public void shouldDeserializeUri() { - DashboardLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Dashboards/1._Supermart_Dashboard\"}"); - assertThat(response.getUri(), is("/public/Samples/Dashboards/1._Supermart_Dashboard")); - } - - @Test - public void shouldDeserializeFoundations() { - DashboardLookupResponse response = deserialize("{\"foundations\": [{\"id\": \"default\",\"layout\": \"layout\",\"wiring\": \"wiring\",\"components\": \"components\"}]}"); - DashboardFoundation foundation = response.getFoundations().get(0); - assertThat(foundation.getId(), is("default")); - assertThat(foundation.getLayout(), is("layout")); - assertThat(foundation.getWiring(), is("wiring")); - assertThat(foundation.getComponents(), is("components")); - } - - @Test - public void shouldDeserializeDefaultFoundation() { - DashboardLookupResponse response = deserialize("{\"defaultFoundation\": \"default\"}"); - assertThat(response.getDefaultFoundation(), is("default")); - } - - @Test - public void shouldDeserializeResources() { - DashboardLookupResponse response = deserialize("{\"resources\": [{\"name\": \"wiring\",\"type\": \"wiring\",\"resource\": {\"resourceReference\": {\"uri\": \"/public/Samples/Dashboards/1._Supermart_Dashboard_files/wiring\"}}}]}"); - DashboardResource resource = response.getResources().get(0); - DashboardResourceInfo info = resource.getResource(); - assertThat(resource.getName(), is("wiring")); - assertThat(resource.getType(), is("wiring")); - assertThat(info.getResourceReference().getUri(), is("/public/Samples/Dashboards/1._Supermart_Dashboard_files/wiring")); - } - - private DashboardLookupResponse deserialize(String json) { - return GsonFactory.create().fromJson(json, DashboardLookupResponse.class); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java index 58e915a1..15cb4ebc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,17 +24,10 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; - -import org.junit.Before; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; /** * @@ -42,71 +35,9 @@ * @since 2.0 */ public class FolderLookupResponseTest { - - @ResourceFile("json/root_folder.json") - TestResource rootFolderResponse; - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - - @Test - public void shouldDeserializeResponse1FromWholeJson() { - FolderLookupResponse response1 = deserialize(rootFolderResponse.asString()); - assertThat(response1, is(notNullValue())); - } - @Test public void shouldAlwaysReturnReportUnitUriAsType() { - FolderLookupResponse response = deserialize("{}"); + FolderLookupResponse response = new FolderLookupResponse(); assertThat(response.getResourceType(), is("folder")); } - - @Test - public void shouldDeserializeVersion() { - FolderLookupResponse response = deserialize("{\"version\": 0}"); - assertThat(response.getVersion(), is(0)); - } - - @Test - public void shouldDeserializePermissionMask() { - FolderLookupResponse response = deserialize("{\"permissionMask\": 2}"); - assertThat(response.getPermissionMask(), is(2)); - } - - @Test - public void shouldDeserializeCreationDate() { - FolderLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); - assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); - } - - @Test - public void shouldDeserializeUpdateDate() { - FolderLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); - assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); - } - - @Test - public void shouldDeserializeLabel() { - FolderLookupResponse response = deserialize("{\"label\": \"Organization\"}"); - assertThat(response.getLabel(), is("Organization")); - } - - @Test - public void shouldDeserializeDescription() { - FolderLookupResponse response = deserialize("{\"description\": \"Organization\"}"); - assertThat(response.getDescription(), is("Organization")); - } - - @Test - public void shouldDeserializeUri() { - FolderLookupResponse response = deserialize("{\"uri\": \"/\"}"); - assertThat(response.getUri(), is("/")); - } - - private FolderLookupResponse deserialize(String json) { - return GsonFactory.create().fromJson(json, FolderLookupResponse.class); - } - } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java index 7d79fd13..98d81674 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; - import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -36,14 +34,9 @@ * @since 2.0 */ public class LegacyDashboardLookupResponseTest { - @Test public void shouldAlwaysReturnReportUnitUriAsType() { - LegacyDashboardLookupResponse response = deserialize("{}"); + LegacyDashboardLookupResponse response = new LegacyDashboardLookupResponse(); assertThat(response.getResourceType(), is("legacyDashboard")); } - - private LegacyDashboardLookupResponse deserialize(String json) { - return GsonFactory.create().fromJson(json, LegacyDashboardLookupResponse.class); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java index 9e7cf906..9335af66 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java @@ -24,139 +24,44 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; +import com.google.gson.annotations.Expose; -import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class ReportLookupResponseTest { - @com.jaspersoft.android.sdk.test.resource.ResourceFile("json/report_unit_resource1.json") - TestResource reportResponse1; - @com.jaspersoft.android.sdk.test.resource.ResourceFile("json/report_unit_resource2.json") - TestResource reportResponse2; - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - - @Test - public void shouldDeserializeResponse1FromWholeJson() { - ReportLookupResponse response1 = deserialize(reportResponse1.asString()); - assertThat(response1, is(notNullValue())); - } - @Test - public void shouldDeserializeResponse2FromWholeJson() { - ReportLookupResponse response2 = deserialize(reportResponse2.asString()); - assertThat(response2, is(notNullValue())); + @Parameters({ + "dataSource", + "jrxml", + "inputControlRenderingView", + "reportRenderingView", + "alwaysPromptControls", + "controlsLayout", + "resources", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportLookupResponse.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); } @Test public void shouldAlwaysReturnReportUnitUriAsType() { - ReportLookupResponse response = deserialize("{}"); + ReportLookupResponse response = new ReportLookupResponse(); assertThat(response.getResourceType(), is("reportUnit")); } - - @Test - public void shouldDeserializeVersion() { - ReportLookupResponse response = deserialize("{\"version\": 2}"); - assertThat(response.getVersion(), is(2)); - } - - @Test - public void shouldDeserializePermissionMask() { - ReportLookupResponse response = deserialize("{\"permissionMask\": 1}"); - assertThat(response.getPermissionMask(), is(1)); - } - - @Test - public void shouldDeserializeCreationDate() { - ReportLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); - assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); - } - - @Test - public void shouldDeserializeUpdateDate() { - ReportLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); - assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); - } - - @Test - public void shouldDeserializeLabel() { - ReportLookupResponse response = deserialize("{\"label\": \"01. Geographic Results by Segment\"}"); - assertThat(response.getLabel(), is("01. Geographic Results by Segment")); - } - - @Test - public void shouldDeserializeDescription() { - ReportLookupResponse response = deserialize("{\"description\": \"Sample HTML5 multi-axis column chart\"}"); - assertThat(response.getDescription(), is("Sample HTML5 multi-axis column chart")); - } - - @Test - public void shouldDeserializeUri() { - ReportLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment\"}"); - assertThat(response.getUri(), is("/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment")); - } - - @Test - public void shouldDeserializeDataSource() { - ReportLookupResponse response = deserialize("{\"dataSource\": {\"dataSourceReference\": {\"uri\": \"/public/Samples/Data_Sources/JServerJNDIDS\"}}}"); - assertThat(response.getDataSource().getDataSourceReference().getUri(), is("/public/Samples/Data_Sources/JServerJNDIDS")); - } - - @Test - public void shouldDeserializeJrxml() { - ReportLookupResponse response = deserialize("{\"jrxml\": {\"jrxmlFileReference\": {\"uri\": \"/public/Samples/Reports/AllAccounts_files/main_jrxml\"}}}"); - assertThat(response.getJrxml().getJrxmlFileReference().getUri(), is("/public/Samples/Reports/AllAccounts_files/main_jrxml")); - } - - @Test - public void shouldDeserializeInputControlRenderingView() { - ReportLookupResponse response = deserialize("{\"inputControlRenderingView\": \"any view\"}"); - assertThat(response.getInputControlRenderingView(), is("any view")); - } - - @Test - public void shouldDeserializeReportRenderingView() { - ReportLookupResponse response = deserialize("{\"reportRenderingView\": \"any view\"}"); - assertThat(response.getReportRenderingView(), is("any view")); - } - - @Test - public void shouldDeserializeAlwaysPrompt() { - ReportLookupResponse response = deserialize("{\"alwaysPromptControls\": \"true\"}"); - assertThat(response.isAlwaysPromptControls(), is(true)); - } - - @Test - public void shouldDeserializeControlsLayout() { - ReportLookupResponse response = deserialize("{\"controlsLayout\": \"any layout\"}"); - assertThat(response.getControlsLayout(), is("any layout")); - } - - @Test - public void shouldDeserializeResources() { - ReportLookupResponse response = deserialize("{\"resources\": {\"resource\": [{\"name\": \"SampleReportsStyles.jrtx\",\"file\": {\"fileReference\": {\"uri\": \"/public/Samples/Resources/Extras/SampleReportStyles.jrtx\"}}}]}}"); - - ReportResource reportResource = response.getResources().get(0); - ResourceFile file = reportResource.getFile(); - assertThat(file.getFileReference().getUri(), is("/public/Samples/Resources/Extras/SampleReportStyles.jrtx")); - assertThat(reportResource.getName(), is("SampleReportsStyles.jrtx")); - } - - private ReportLookupResponse deserialize(String json) { - return GsonFactory.create().fromJson(json, ReportLookupResponse.class); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java index c36585f8..ba019215 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java @@ -24,92 +24,37 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; +import com.google.gson.annotations.Expose; -import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class ResourceLookupResponseJsonConvertTest { - @ResourceFile("json/all_resources.json") - TestResource mJsonResources; - @ResourceFile("json/resource_lookup_item.json") - TestResource mJsonResource; - - Gson mGson = GsonFactory.create(); - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - - @Test - public void shouldDeserializeCollectionFromJson() { - ResourceSearchResponse resourceSearchResponse = mGson.fromJson(mJsonResources.asString(), ResourceSearchResponse.class); - assertThat(resourceSearchResponse.getResources(), is(not(empty()))); - } - - @Test - public void shouldDeserializeVersion() { - ResourceLookupResponse response = deserialize("{\"version\": 2}"); - assertThat(response.getVersion(), is(2)); - } - - @Test - public void shouldDeserializePermissionMask() { - ResourceLookupResponse response = deserialize("{\"permissionMask\": 1}"); - assertThat(response.getPermissionMask(), is(1)); - } - - @Test - public void shouldDeserializeCreationDate() { - ResourceLookupResponse response = deserialize("{\"creationDate\": \"2015-06-05T07:21:11\"}"); - assertThat(response.getCreationDate(), is("2015-06-05T07:21:11")); - } - - @Test - public void shouldDeserializeUpdateDate() { - ResourceLookupResponse response = deserialize("{\"updateDate\": \"2014-05-14T17:38:49\"}"); - assertThat(response.getUpdateDate(), is("2014-05-14T17:38:49")); - } - - @Test - public void shouldDeserializeLabel() { - ResourceLookupResponse response = deserialize("{\"label\": \"01. Geographic Results by Segment\"}"); - assertThat(response.getLabel(), is("01. Geographic Results by Segment")); - } - @Test - public void shouldDeserializeDescription() { - ResourceLookupResponse response = deserialize("{\"description\": \"Sample HTML5 multi-axis column chart\"}"); - assertThat(response.getDescription(), is("Sample HTML5 multi-axis column chart")); - } - - @Test - public void shouldDeserializeUri() { - ResourceLookupResponse response = deserialize("{\"uri\": \"/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment\"}"); - assertThat(response.getUri(), is("/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment")); - } - - @Test - public void shouldDeserializeResourceType() { - ResourceLookupResponse response = deserialize("{\"resourceType\": \"adhocDataView\"}"); - assertThat(response.getResourceType(), is("adhocDataView")); - } - - private ResourceLookupResponse deserialize(String json) { - return mGson.fromJson(json, ResourceLookupResponse.class); + @Parameters({ + "label", + "description", + "uri", + "resourceType", + "version", + "creationDate", + "updateDate", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ResourceLookupResponse.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java deleted file mode 100644 index 57855635..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseJsonConvertTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.jaspersoft.android.sdk.network.rest.v2.entity.server; -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; - -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ServerInfoResponseJsonConvertTest { - @ResourceFile("json/default_server_info.json") - TestResource mJsonResource; - - Gson mGson = GsonFactory.create(); - - @Before - public void setup() { - TestResourceInjector.inject(this); - } - - @Test - public void shouldDeserializeDefaultJsonResponse() { - ServerInfoResponse response = deserialize(mJsonResource.asString()); - assertThat(response, is(notNullValue())); - } - - @Test - public void shouldDeserializeDateFormatPattern() { - ServerInfoResponse response = deserialize("{\"dateFormatPattern\": \"yyyy-MM-dd\"}"); - assertThat(response.getDateFormatPattern(), is("yyyy-MM-dd")); - } - - @Test - public void shouldDeserializeDateTimeFormatPattern() { - ServerInfoResponse response = deserialize("{\"datetimeFormatPattern\": \"yyyy-MM-dd'T'HH:mm:ss\"}"); - assertThat(response.getDatetimeFormatPattern(), is("yyyy-MM-dd'T'HH:mm:ss")); - } - - @Test - public void shouldDeserializeVersion() { - ServerInfoResponse response = deserialize("{\"version\": \"6.1\"}"); - assertThat(response.getVersion(), is("6.1")); - } - - @Test - public void shouldDeserializeEdition() { - ServerInfoResponse response = deserialize("{\"edition\": \"PRO\"}"); - assertThat(response.getEdition(), is("PRO")); - } - - @Test - public void shouldDeserializeEditionName() { - ServerInfoResponse response = deserialize("{\"editionName\": \"Enterprise for AWS\"}"); - assertThat(response.getEditionName(), is("Enterprise for AWS")); - } - - @Test - public void shouldDeserializeLicenseType() { - ServerInfoResponse response = deserialize("{\"licenseType\": \"Commercial\"}"); - assertThat(response.getLicenseType(), is("Commercial")); - } - - @Test - public void shouldDeserializeBuild() { - ServerInfoResponse response = deserialize("{\"build\": \"20150527_1447\"}"); - assertThat(response.getBuild(), is("20150527_1447")); - } - - @Test - public void shouldDeserializeFeatures() { - ServerInfoResponse response = deserialize("{\"features\": \"Fusion AHD EXP DB AUD ANA MT \"}"); - assertThat(response.getFeatures(), is("Fusion AHD EXP DB AUD ANA MT ")); - } - - private ServerInfoResponse deserialize(String json) { - return mGson.fromJson(json, ServerInfoResponse.class); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java new file mode 100644 index 00000000..4d2469e5 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java @@ -0,0 +1,60 @@ +package com.jaspersoft.android.sdk.network.rest.v2.entity.server; +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ServerInfoResponseTest { + @Test + @Parameters({ + "dateFormatPattern", + "datetimeFormatPattern", + "version", + "edition", + "licenseType", + "build", + "editionName", + "features", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ServerInfoResponse.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java new file mode 100644 index 00000000..281492c8 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.matcher; + +import org.hamcrest.Description; +import org.hamcrest.Factory; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class HasAnnotation extends TypeSafeMatcher { + private final Class mAnnotationClass; + + private HasAnnotation(Class annotationClass) { + mAnnotationClass = annotationClass; + } + + @Override + protected boolean matchesSafely(Field item) { + Annotation annotation = item.getAnnotation(mAnnotationClass); + return annotation != null; + } + + @Override + public void describeTo(Description description) { + description.appendText("is not annotated with " + mAnnotationClass); + } + + @Factory + public static Matcher hasAnnotation(Class annotationClass) { + return new HasAnnotation(annotationClass); + } +} \ No newline at end of file From b20876baa16c2e8df9e94bdc6b1e3982d8729f4a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 12:17:51 +0300 Subject: [PATCH 058/457] Add test cases for SerializedName fields --- ...=> ResourceSearchResponseAdapterTest.java} | 10 ++- .../ReportExecutionDetailsResponseTest.java | 7 +++ .../entity/execution/ReportParameterTest.java | 7 +++ .../execution/ReportParametersTest.java | 11 ++++ .../sdk/test/matcher/HasSerializedName.java | 62 +++++++++++++++++++ 5 files changed, 96 insertions(+), 1 deletion(-) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/{ResourceResourceSearchResponseAdapterTest.java => ResourceSearchResponseAdapterTest.java} (92%) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceResourceSearchResponseAdapterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapterTest.java similarity index 92% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceResourceSearchResponseAdapterTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapterTest.java index e3444c04..6313dec7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceResourceSearchResponseAdapterTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapterTest.java @@ -37,6 +37,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.lang.reflect.Field; import java.util.ArrayList; import retrofit.client.Header; @@ -44,6 +45,7 @@ import retrofit.mime.TypedInput; import retrofit.mime.TypedString; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; @@ -56,7 +58,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({Response.class}) -public class ResourceResourceSearchResponseAdapterTest { +public class ResourceSearchResponseAdapterTest { @ResourceFile("json/all_resources.json") TestResource searchResponse; @@ -140,4 +142,10 @@ public void shouldParseJsonResponseFromBody() { ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); assertThat(response.getResources(), is(not(empty()))); } + + @Test + public void mResourcesFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ResourceSearchResponse.class.getDeclaredField("mResources"); + assertThat(field, hasSerializedName("resourceLookup")); + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java index fbc9c76a..a267ccd6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java @@ -35,6 +35,7 @@ import junitparams.Parameters; import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; import static org.hamcrest.MatcherAssert.assertThat; /** @@ -57,4 +58,10 @@ public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFi Field field = ReportExecutionDetailsResponse.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } + + @Test + public void executionIdFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ReportExecutionDetailsResponse.class.getDeclaredField("executionId"); + assertThat(field, hasSerializedName("requestId")); + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java index 1629eaef..7643baa5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java @@ -39,6 +39,7 @@ import junitparams.Parameters; import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.collection.IsEmptyCollection.empty; @@ -100,4 +101,10 @@ public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFi Field field = ReportParameter.class.getDeclaredField(fieldName); MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); } + + @Test + public void valuesFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ReportParameter.class.getDeclaredField("values"); + assertThat(field, hasSerializedName("value")); + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java index e4b8a5e8..53d7c85a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java @@ -26,6 +26,11 @@ import org.junit.Test; +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; +import static org.hamcrest.MatcherAssert.assertThat; + /** * @author Tom Koptel * @since 2.0 @@ -35,4 +40,10 @@ public class ReportParametersTest { public void factoryMethodShouldNotAcceptNull() { ReportParameters.wrap(null); } + + @Test + public void reportParameterFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ReportParameters.class.getDeclaredField("reportParameters"); + assertThat(field, hasSerializedName("reportParameter")); + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java new file mode 100644 index 00000000..d6fcbb27 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.matcher; + +import com.google.gson.annotations.SerializedName; + +import org.hamcrest.Description; +import org.hamcrest.Factory; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +import java.lang.reflect.Field; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class HasSerializedName extends TypeSafeMatcher { + private final String mValue; + + private HasSerializedName(String value) { + mValue = value; + } + + @Override + protected boolean matchesSafely(Field item) { + SerializedName annotation = item.getAnnotation(SerializedName.class); + return annotation.value().equals(mValue); + } + + @Override + public void describeTo(Description description) { + description.appendText("annotation <" + SerializedName.class + "> has value: " + mValue); + } + + @Factory + public static Matcher hasSerializedName(String value) { + return new HasSerializedName(value); + } +} From c98863923e18f0101429445ea830fcb8f78d9497 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 13:58:04 +0300 Subject: [PATCH 059/457] Add experimental wrapper around restAdapter --- .../main/java/retrofit/ResponseEntity.java | 49 +++++++++ .../java/retrofit/RestAdapterWrapper.java | 104 ++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 client-network/src/main/java/retrofit/ResponseEntity.java create mode 100644 client-network/src/main/java/retrofit/RestAdapterWrapper.java diff --git a/client-network/src/main/java/retrofit/ResponseEntity.java b/client-network/src/main/java/retrofit/ResponseEntity.java new file mode 100644 index 00000000..9fd05b93 --- /dev/null +++ b/client-network/src/main/java/retrofit/ResponseEntity.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package retrofit; + +import retrofit.client.Response; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ResponseEntity { + private final Entity mEntity; + private final Response mResponse; + + public ResponseEntity(Entity entity, Response response) { + mEntity = entity; + mResponse = response; + } + + public Entity getEntity() { + return mEntity; + } + + public Response getResponse() { + return mResponse; + } +} diff --git a/client-network/src/main/java/retrofit/RestAdapterWrapper.java b/client-network/src/main/java/retrofit/RestAdapterWrapper.java new file mode 100644 index 00000000..0bef113b --- /dev/null +++ b/client-network/src/main/java/retrofit/RestAdapterWrapper.java @@ -0,0 +1,104 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package retrofit; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; + +import retrofit.client.Response; +import retrofit.converter.ConversionException; +import retrofit.converter.Converter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class RestAdapterWrapper { + private final Converter converter; + private final RestAdapter restAdapter; + volatile RestAdapter.LogLevel logLevel; + private final RestAdapter.Log log; + + private RestAdapterWrapper(RestAdapter restAdapter) { + this.restAdapter = restAdapter; + this.converter = restAdapter.converter; + this.log = restAdapter.log; + this.logLevel = restAdapter.logLevel; + } + + public static RestAdapterWrapper wrap(RestAdapter restAdapter) { + return new RestAdapterWrapper(restAdapter); + } + + public RestAdapter getRestAdapter() { + return restAdapter; + } + + @SuppressWarnings("unchecked") + public ResponseEntity produce(Response response, Class type) { + String url = response.getUrl(); + try { + ExceptionCatchingTypedInput wrapped = new ExceptionCatchingTypedInput(response.getBody()); + try { + Object convert = converter.fromBody(wrapped, type); + Entity enity = (Entity) convert; + return new ResponseEntity(enity, response); + } catch (ConversionException e) { + // If the underlying input stream threw an exception, propagate that rather than + // indicating that it was a conversion exception. + if (wrapped.threwException()) { + throw wrapped.getThrownException(); + } + + // The response body was partially read by the converter. Replace it with null. + response = Utils.replaceResponseBody(response, null); + + throw RetrofitError.conversionError(response.getUrl(), response, converter, type, e); + } + } catch (RetrofitError e) { + throw e; // Pass through our own errors. + } catch (IOException e) { + if (logLevel.log()) { + logException(e, url); + } + throw RetrofitError.networkError(url, e); + } catch (Throwable t) { + if (logLevel.log()) { + logException(t, url); + } + throw RetrofitError.unexpectedError(url, t); + } + } + + /** Log an exception that occurred during the processing of a request or response. */ + void logException(Throwable t, String url) { + log.log(String.format("---- ERROR %s", url != null ? url : "")); + StringWriter sw = new StringWriter(); + t.printStackTrace(new PrintWriter(sw)); + log.log(sw.toString()); + log.log("---- END ERROR"); + } +} From bf473ab2265958e4d103157f001cf0319421319f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 14:33:34 +0300 Subject: [PATCH 060/457] Add 'setLog' and 'setLogLevel' api --- .../network/rest/v2/api/AuthBaseBuilder.java | 2 +- .../rest/v2/api/AuthenticationRestApi.java | 5 +- .../sdk/network/rest/v2/api/BaseBuilder.java | 27 ++++++++-- .../rest/v2/api/ReportExecutionRestApi.java | 4 +- .../rest/v2/api/RepositoryRestApi.java | 8 ++- .../sdk/network/rest/v2/api/RestApiLog.java | 14 +++++ .../network/rest/v2/api/RestApiLogLevel.java | 52 +++++++++++++++++++ .../sdk/network/rest/v2/api/RetrofitLog.java | 44 ++++++++++++++++ .../network/rest/v2/api/ServerRestApi.java | 5 +- .../android/sdk/test/TestLogger.java | 52 +++++++++++++++++++ .../api/AuthenticationRestApiTest.java | 7 ++- .../api/ReportExecutionRestApiTest.java | 7 ++- .../api/RepositoryRestApiTest.java | 7 ++- .../test/integration/api/ServerRestTest.java | 7 ++- 14 files changed, 222 insertions(+), 19 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLog.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLogLevel.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitLog.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java index 8590d149..9b4250f6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java @@ -34,7 +34,7 @@ * @author Tom Koptel * @since 2.0 */ -abstract class AuthBaseBuilder extends BaseBuilder { +abstract class AuthBaseBuilder extends BaseBuilder { private final String mCookie; public AuthBaseBuilder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java index 6e87628c..61a97aa6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java @@ -46,12 +46,13 @@ AuthResponse authenticate(@NonNull String username, @Nullable String organization, @Nullable Map params); - class Builder extends BaseBuilder { + class Builder extends BaseBuilder { public Builder(String baseUrl) { super(baseUrl); } - public AuthenticationRestApi build() { + @Override + AuthenticationRestApi createApi() { RestAdapter.Builder builder = getDefaultBuilder(); OkHttpClient httpClient = new OkHttpClient(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java index ec74ab74..8d7d4b42 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java @@ -33,9 +33,11 @@ * @author Tom Koptel * @since 2.0 */ -abstract class BaseBuilder { +abstract class BaseBuilder { private final String mBaseUrl; private final RestAdapter.Builder mRestAdapterBuilder; + private RestApiLog mLog = RestApiLog.NONE; + private RestApiLogLevel mLogLevel = RestApiLogLevel.NONE; public BaseBuilder(String baseUrl){ if (baseUrl == null || baseUrl.length() == 0) { @@ -43,6 +45,7 @@ public BaseBuilder(String baseUrl){ } mBaseUrl = baseUrl; mRestAdapterBuilder = new RestAdapter.Builder(); + mRestAdapterBuilder.setEndpoint(mBaseUrl); mRestAdapterBuilder.setErrorHandler(new retrofit.ErrorHandler() { @Override @@ -53,9 +56,27 @@ public Throwable handleError(RetrofitError cause) { }); } - public RestAdapter.Builder getDefaultBuilder() { + @SuppressWarnings("unchecked") + public SubBuilder setLog(RestApiLog log) { + mLog = log; + return (SubBuilder) this; + } + + @SuppressWarnings("unchecked") + public SubBuilder setLogLevel(RestApiLogLevel logLevel) { + mLogLevel = logLevel; + return (SubBuilder) this; + } + + RestAdapter.Builder getDefaultBuilder() { return mRestAdapterBuilder; } - public abstract API build(); + abstract API createApi(); + + public API build() { + mRestAdapterBuilder.setLog(new RetrofitLog(mLog)); + mRestAdapterBuilder.setLogLevel(RestApiLogLevel.toRetrofitLog(mLogLevel)); + return createApi(); + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 67c02729..4948240e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -47,13 +47,13 @@ public interface ReportExecutionRestApi { boolean cancelReportExecution(@NonNull String executionId); - class Builder extends AuthBaseBuilder { + class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); } @Override - public ReportExecutionRestApi build() { + ReportExecutionRestApi createApi() { return new ReportExecutionRestApiImpl(getDefaultBuilder().build()); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index 1b08be19..9d7b118e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -32,13 +32,10 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import java.util.Map; -import retrofit.RequestInterceptor; import retrofit.RestAdapter; -import retrofit.converter.GsonConverter; /** * @author Tom Koptel @@ -60,12 +57,13 @@ public interface RepositoryRestApi { @NonNull FolderLookupResponse requestFolderResource(@NonNull String resourceUri); - class Builder extends AuthBaseBuilder { + class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); } - public RepositoryRestApi build() { + @Override + RepositoryRestApi createApi() { RestAdapter restAdapter = getDefaultBuilder().build(); return new RepositoryRestApiImpl(restAdapter); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLog.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLog.java new file mode 100644 index 00000000..95fcd4f1 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLog.java @@ -0,0 +1,14 @@ +package com.jaspersoft.android.sdk.network.rest.v2.api; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RestApiLog { + void log(String message); + + RestApiLog NONE = new RestApiLog() { + @Override public void log(String message) { + } + }; +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLogLevel.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLogLevel.java new file mode 100644 index 00000000..b441a3a9 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLogLevel.java @@ -0,0 +1,52 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import retrofit.RestAdapter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum RestApiLogLevel { + /** No logging. */ + NONE, + /** Log only the request method and URL and the response status code and execution time. */ + BASIC, + /** Log the basic information along with request and response headers. */ + HEADERS, + /** Log the basic information along with request and response objects via toString(). */ + HEADERS_AND_ARGS, + /** + * Log the headers, body, and metadata for both requests and responses. + *

+ * Note: This requires that the entire request and response body be buffered in memory! + */ + FULL; + + static RestAdapter.LogLevel toRetrofitLog(RestApiLogLevel logLevel) { + return RestAdapter.LogLevel.valueOf(logLevel.name()); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitLog.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitLog.java new file mode 100644 index 00000000..5d3cda62 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitLog.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import retrofit.RestAdapter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RetrofitLog implements RestAdapter.Log { + private final RestApiLog delegate; + + RetrofitLog(RestApiLog log) { + delegate = log; + } + + @Override + public void log(String message) { + delegate.log(message); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java index 633d285d..a61a0572 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java @@ -44,12 +44,13 @@ public interface ServerRestApi { @GET(value = "/rest_v2/serverInfo") ServerInfoResponse getServerInfo(); - class Builder extends BaseBuilder { + class Builder extends BaseBuilder { public Builder(String baseUrl) { super(baseUrl); } - public ServerRestApi build() { + @Override + ServerRestApi createApi() { RestAdapter.Builder builder = getDefaultBuilder(); builder.setConverter(new GsonConverter(GsonFactory.create())); RestAdapter restAdapter = builder.build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java new file mode 100644 index 00000000..50080fbe --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java @@ -0,0 +1,52 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test; + +import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLog; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class TestLogger implements RestApiLog { + + private final Logger logger; + + private TestLogger(String logTarget) { + logger = Logger.getLogger(logTarget); + } + + public static TestLogger get(Object target) { + return new TestLogger(target.getClass().getSimpleName()); + } + + @Override + public void log(String message) { + logger.log(Level.INFO, message); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index c3c1abff..315defa8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -24,8 +24,10 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; import org.junit.Test; @@ -51,7 +53,10 @@ public void setup() { @Test public void shouldReturnResponseForSpringRequest() throws IOException { - AuthenticationRestApi authApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + AuthenticationRestApi authApi = new AuthenticationRestApi.Builder(mobileDemo2) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); AuthResponse response = authApi.authenticate("joeuser", "joeuser", "null", null); assertThat(response.getToken(), is(notNullValue())); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index cfeae5f1..68c56244 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -26,10 +26,12 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; import org.junit.Test; @@ -101,7 +103,10 @@ public void shouldCheckReportExecutionStatus() throws IOException { } private ReportExecutionRestApi createApi() { - return new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); + return new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); } private AuthResponse getAuthResponse() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index aea337ef..1f6cd477 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -26,11 +26,13 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; import org.junit.Test; @@ -100,7 +102,10 @@ private RepositoryRestApi createApi() { private AuthResponse getAuthResponse() { if (mAuthResponse == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); mAuthResponse = restApi.authenticate("joeuser", "joeuser", null, null); } return mAuthResponse; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 624c0ddb..86d4e5f6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -25,8 +25,10 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.network.rest.v2.api.ServerRestApi; +import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; import org.junit.Test; @@ -58,7 +60,10 @@ public void setup() { @Test public void shouldRequestServerInfo() throws IOException { - ServerRestApi api = new ServerRestApi.Builder(mobileDemo2).build(); + ServerRestApi api = new ServerRestApi.Builder(mobileDemo2) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); ServerInfoResponse response = api.getServerInfo(); assertThat(response, is(notNullValue())); } From d02de72b7a5a640b1dff76a97c545092b04d936b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 14:55:31 +0300 Subject: [PATCH 061/457] Add search execution api --- .../rest/v2/api/ReportExecutionRestApi.java | 6 ++ .../v2/api/ReportExecutionRestApiImpl.java | 29 ++++++++- .../execution/ReportExecutionSearchItem.java | 46 ++++++++++++++ .../ReportExecutionSearchResponse.java | 54 ++++++++++++++++ .../v2/api/ReportExecutionRestApiTest.java | 26 +++++++- .../ReportExecutionSearchResponseTest.java | 61 +++++++++++++++++++ .../api/ReportExecutionRestApiTest.java | 18 ++++++ .../json/search_execution_response.json | 9 +++ 8 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchItem.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponse.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponseTest.java create mode 100644 client-network/src/test/resources/json/search_execution_response.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 4948240e..ca9743dd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -28,8 +28,11 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; +import java.util.Map; + /** * @author Tom Koptel * @since 2.0 @@ -47,6 +50,9 @@ public interface ReportExecutionRestApi { boolean cancelReportExecution(@NonNull String executionId); + @NonNull + ReportExecutionSearchResponse searchReportExecution(Map params); + class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java index 2f38d616..de4b2563 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java @@ -25,12 +25,18 @@ package com.jaspersoft.android.sdk.network.rest.v2.api; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; +import java.util.Map; + +import retrofit.ResponseEntity; import retrofit.RestAdapter; +import retrofit.RestAdapterWrapper; import retrofit.client.Response; import retrofit.http.Body; import retrofit.http.GET; @@ -38,6 +44,7 @@ import retrofit.http.POST; import retrofit.http.PUT; import retrofit.http.Path; +import retrofit.http.QueryMap; /** * @author Tom Koptel @@ -46,9 +53,11 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { private final RestApi mRestApi; + private final RestAdapterWrapper mRestAdapterWrapper; ReportExecutionRestApiImpl(RestAdapter restAdapter) { mRestApi = restAdapter.create(RestApi.class); + mRestAdapterWrapper = RestAdapterWrapper.wrap(restAdapter); } @NonNull @@ -76,7 +85,21 @@ public boolean cancelReportExecution(@NonNull String executionId) { return status != 204; } - private interface RestApi { + @NonNull + @Override + public ReportExecutionSearchResponse searchReportExecution(Map params) { + Response response = mRestApi.searchReportExecution(params); + int status = response.getStatus(); + if (status == 204) { + return ReportExecutionSearchResponse.empty(); + } else { + ResponseEntity responseEntity = + mRestAdapterWrapper.produce(response, ReportExecutionSearchResponse.class); + return responseEntity.getEntity(); + } + } + + interface RestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions") @@ -97,5 +120,9 @@ private interface RestApi { @PUT("/rest_v2/reportExecutions/{executionId}/status") Response cancelReportExecution(@NonNull @Path(value = "executionId", encode = false) String executionId, @NonNull @Body ReportExecutionStatusResponse statusResponse); + + @Headers("Accept: application/json") + @GET("/rest_v2/reportExecutions") + Response searchReportExecution(@Nullable @QueryMap(encodeValues = false) Map params); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchItem.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchItem.java new file mode 100644 index 00000000..47af7260 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchItem.java @@ -0,0 +1,46 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExecutionSearchItem { + @Expose + private String requestId; + @Expose + private String reportURI; + + public String getReportURI() { + return reportURI; + } + + public String getRequestId() { + return requestId; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponse.java new file mode 100644 index 00000000..a1fa9892 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExecutionSearchResponse { + @Expose + @SerializedName("reportExecution") + private Set items; + + private ReportExecutionSearchResponse(Set items) { + this.items = items; + } + + @SuppressWarnings("unchecked") + public static ReportExecutionSearchResponse empty() { + return new ReportExecutionSearchResponse(Collections.EMPTY_SET); + } + + public Set getItems() { + return items; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java index 1a2af924..2296ac4d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.rest.v2.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -36,9 +37,10 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; +import static org.hamcrest.Matchers.empty; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertThat; /** @@ -49,6 +51,8 @@ public class ReportExecutionRestApiTest { @ResourceFile("json/cancelled_report_response.json") TestResource cancelledResponse; + @ResourceFile("json/search_execution_response.json") + TestResource searchExecutionResponse; @Rule public final WebMockRule mWebMockRule = new WebMockRule(); @@ -135,6 +139,26 @@ public void responseShouldBeCancelledIfResponseIs200() { assertThat(cancelled, is(true)); } + @Test + public void executionSearchResponseShouldBeEmptyIfResponseIs204() { + mWebMockRule.enqueue(create204Response()); + + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(null); + + assertThat(response.getItems(), is(empty())); + } + + @Test + public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() { + MockResponse mockResponse = create200Response(); + mockResponse.setBody(searchExecutionResponse.asString()); + mWebMockRule.enqueue(mockResponse); + + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(null); + + assertThat(response.getItems(), is(not(empty()))); + } + private MockResponse create200Response() { return new MockResponse() .setStatus("HTTP/1.1 200 Ok"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponseTest.java new file mode 100644 index 00000000..a367d6ec --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponseTest.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ReportExecutionSearchResponseTest { + @Test + @Parameters({ + "items", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportExecutionSearchResponse.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void valuesFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ReportExecutionSearchResponse.class.getDeclaredField("items"); + assertThat(field, hasSerializedName("reportExecution")); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 68c56244..f557ec5e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; @@ -41,8 +42,12 @@ import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -102,6 +107,19 @@ public void shouldCheckReportExecutionStatus() throws IOException { assertThat(response.getStatus(), is(notNullValue())); } + @Test + public void searchForExecutionShouldReturnResult() throws IOException { + ReportExecutionRestApi api = createApi(); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); + ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); + + Map params = new HashMap<>(); + params.put("reportURI", executionResponse.getReportURI()); + + ReportExecutionSearchResponse searchResponse = api.searchReportExecution(params); + assertThat(searchResponse.getItems(), is(not(empty()))); + } + private ReportExecutionRestApi createApi() { return new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) .setLog(TestLogger.get(this)) diff --git a/client-network/src/test/resources/json/search_execution_response.json b/client-network/src/test/resources/json/search_execution_response.json new file mode 100644 index 00000000..f359e24b --- /dev/null +++ b/client-network/src/test/resources/json/search_execution_response.json @@ -0,0 +1,9 @@ +{ + "reportExecution": + [ + { + "requestId": "1775670827_1355224685209_6", + "reportURI": "repo:/supermart/details/CustomerDetailReport" + } + ] +} \ No newline at end of file From 4eb6b0cdf92a6f70601887b2d3723924228f8c05 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 15:17:27 +0300 Subject: [PATCH 062/457] Add search execution api --- .../rest/v2/api/ReportExecutionRestApi.java | 5 +++++ .../v2/api/ReportExecutionRestApiImpl.java | 15 +++++++++++++ .../v2/api/ReportExecutionRestApiTest.java | 20 +++++++++++++++++ .../api/ReportExecutionRestApiTest.java | 22 ++++++++++++++----- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index ca9743dd..655377d5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -30,7 +30,9 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; +import java.util.Collection; import java.util.Map; /** @@ -50,9 +52,12 @@ public interface ReportExecutionRestApi { boolean cancelReportExecution(@NonNull String executionId); + boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params); + @NonNull ReportExecutionSearchResponse searchReportExecution(Map params); + class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java index de4b2563..9ca92028 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java @@ -31,7 +31,9 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; +import java.util.Collection; import java.util.Map; import retrofit.ResponseEntity; @@ -85,6 +87,13 @@ public boolean cancelReportExecution(@NonNull String executionId) { return status != 204; } + @Override + public boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params) { + Response response = mRestApi.updateReportExecution(executionId, params); + int status = response.getStatus(); + return status == 204; + } + @NonNull @Override public ReportExecutionSearchResponse searchReportExecution(Map params) { @@ -115,6 +124,12 @@ interface RestApi { @GET("/rest_v2/reportExecutions/{executionId}/status") ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull @Path(value = "executionId", encode = false) String executionId); + @NonNull + @Headers("Accept: application/json") + @POST("/rest_v2/reportExecutions/{executionId}/parameters") + Response updateReportExecution(@NonNull @Path(value = "executionId", encode = false) String executionId, + @NonNull @Body Collection params); + @NonNull @Headers("Accept: application/json") @PUT("/rest_v2/reportExecutions/{executionId}/status") diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java index 2296ac4d..e0ac1a9a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -38,6 +38,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import java.util.Collections; + import static org.hamcrest.Matchers.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -159,6 +161,24 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() { assertThat(response.getItems(), is(not(empty()))); } + @Test + @SuppressWarnings("unchecked") + public void executionUpdateRequestShouldBeSuccessIfResponseIs204() { + mWebMockRule.enqueue(create204Response()); + + boolean response = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_LIST); + + assertThat(response, is(true)); + } + + @Test + public void bodyParameterShouldNotBeNullForExecutionUpdate() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Body parameter value must not be null."); + + restApiUnderTest.updateReportExecution("any_id", null); + } + private MockResponse create200Response() { return new MockResponse() .setStatus("HTTP/1.1 200 Ok"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index f557ec5e..2b5c4919 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -41,7 +41,7 @@ import org.robolectric.annotation.Config; import org.robolectric.shadows.httpclient.FakeHttp; -import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -69,7 +69,7 @@ public void setup() { } @Test - public void shouldStartReportExecution() throws IOException { + public void shouldStartReportExecution() { ReportExecutionRestApi api = createApi(); ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestOptions); @@ -78,7 +78,7 @@ public void shouldStartReportExecution() throws IOException { } @Test - public void shouldCancelReportExecution() throws IOException { + public void shouldCancelReportExecution() { ReportExecutionRestApi api = createApi(); ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestOptions); @@ -87,7 +87,7 @@ public void shouldCancelReportExecution() throws IOException { } @Test - public void shouldReturnReportExecutionDetails() throws IOException { + public void shouldReturnReportExecutionDetails() { ReportExecutionRestApi api = createApi(); ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); @@ -98,7 +98,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { } @Test - public void shouldCheckReportExecutionStatus() throws IOException { + public void shouldCheckReportExecutionStatus() { ReportExecutionRestApi api = createApi(); ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); @@ -108,7 +108,7 @@ public void shouldCheckReportExecutionStatus() throws IOException { } @Test - public void searchForExecutionShouldReturnResult() throws IOException { + public void searchForExecutionShouldReturnResult() { ReportExecutionRestApi api = createApi(); ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); @@ -120,6 +120,16 @@ public void searchForExecutionShouldReturnResult() throws IOException { assertThat(searchResponse.getItems(), is(not(empty()))); } + @Test + public void updateOfParametersForExecutionShouldReturnResult() { + ReportExecutionRestApi api = createApi(); + ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); + ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); + + boolean success = api.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); + assertThat(success, is(true)); + } + private ReportExecutionRestApi createApi() { return new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) .setLog(TestLogger.get(this)) From 391e436d16edcf327b0cd8776b91dee257ddf684 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 16:03:38 +0300 Subject: [PATCH 063/457] Add 'runReportExportExecution' api --- .../rest/v2/api/ReportExecutionRestApi.java | 4 +- .../v2/api/ReportExecutionRestApiImpl.java | 6 +- .../rest/v2/api/ReportExportRestApi.java | 51 ++++++++ .../rest/v2/api/ReportExportRestApiImpl.java | 63 ++++++++++ .../execution/ExecutionRequestOptions.java | 20 +--- .../ReportExecutionRequestOptions.java | 47 ++++++++ .../export/ReportExportExecutionResponse.java | 49 ++++++++ .../v2/api/ReportExecutionRestApiTest.java | 4 +- .../rest/v2/api/ReportExportRestApiTest.java | 80 +++++++++++++ .../ExecutionRequestOptionsTest.java | 32 +---- .../ReportExecutionRequestOptionsTest.java | 50 ++++++++ .../ReportExportExecutionResponseTest.java | 62 ++++++++++ .../api/ReportExecutionRestApiTest.java | 53 +++++---- .../api/ReportExportRestApiTest.java | 112 ++++++++++++++++++ 14 files changed, 556 insertions(+), 77 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptions.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponse.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptionsTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponseTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index 655377d5..c3ea24f9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -26,8 +26,8 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; @@ -42,7 +42,7 @@ public interface ReportExecutionRestApi { @NonNull - ReportExecutionDetailsResponse runReportExecution(@NonNull ExecutionRequestOptions executionOptions); + ReportExecutionDetailsResponse runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); @NonNull ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java index 9ca92028..79e6a125 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java @@ -27,8 +27,8 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; @@ -64,7 +64,7 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NonNull @Override - public ReportExecutionDetailsResponse runReportExecution(@NonNull ExecutionRequestOptions executionOptions) { + public ReportExecutionDetailsResponse runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions) { return mRestApi.runReportExecution(executionOptions); } @@ -112,7 +112,7 @@ interface RestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions") - ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ExecutionRequestOptions executionOptions); + ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java new file mode 100644 index 00000000..8139726b --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ReportExportRestApi { + + @NonNull + ReportExportExecutionResponse runReportExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + + final class Builder extends AuthBaseBuilder { + public Builder(String baseUrl, String cookie) { + super(baseUrl, cookie); + } + + @Override + ReportExportRestApi createApi() { + return new ReportExportRestApiImpl(getDefaultBuilder().build()); + } + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java new file mode 100644 index 00000000..e205ec2b --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java @@ -0,0 +1,63 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; + +import retrofit.RestAdapter; +import retrofit.http.Body; +import retrofit.http.Headers; +import retrofit.http.POST; +import retrofit.http.Path; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExportRestApiImpl implements ReportExportRestApi { + private final RestApi mRestApi; + + public ReportExportRestApiImpl(RestAdapter restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } + + @NonNull + @Override + public ReportExportExecutionResponse runReportExportExecution(@NonNull String executionId, + @NonNull ExecutionRequestOptions executionOptions) { + return mRestApi.runReportExportExecution(executionId, executionOptions); + } + + private interface RestApi { + @NonNull + @Headers("Accept: application/json") + @POST("/rest_v2/reportExecutions/{executionId}/exports") + ReportExportExecutionResponse runReportExportExecution(@NonNull @Path("executionId") String executionId, + @NonNull @Body ExecutionRequestOptions executionOptions); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java index 82e9fe1b..5a19dd9c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java @@ -35,7 +35,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExecutionRequestOptions { +public class ExecutionRequestOptions { @Expose protected Boolean async; @@ -50,8 +50,6 @@ public final class ExecutionRequestOptions { @Expose protected Boolean allowInlineScripts; @Expose - protected final String reportUnitUri; - @Expose protected String outputFormat; @Expose protected String pages; @@ -66,15 +64,10 @@ public final class ExecutionRequestOptions { @Expose protected ReportParameters parameters; - private ExecutionRequestOptions(String reportUnitUri) { - this.reportUnitUri = reportUnitUri; - } + protected ExecutionRequestOptions() {} - public static ExecutionRequestOptions newRequest(String uri) { - if (uri == null || uri.length() == 0) { - throw new IllegalArgumentException("Uri should not be null"); - } - return new ExecutionRequestOptions(uri); + public static ExecutionRequestOptions newInstance() { + return new ExecutionRequestOptions(); } public ExecutionRequestOptions withAsync(boolean async) { @@ -196,10 +189,6 @@ public Set getParameters() { return parameters.getReportParameters(); } - public String getReportUnitUri() { - return reportUnitUri; - } - public Boolean getSaveDataSnapshot() { return saveDataSnapshot; } @@ -229,7 +218,6 @@ public String toString() { ", saveDataSnapshot=" + saveDataSnapshot + ", interactive=" + interactive + ", ignorePagination=" + ignorePagination + - ", reportUnitUri='" + reportUnitUri + '\'' + ", outputFormat='" + outputFormat + '\'' + ", pages='" + pages + '\'' + ", baseUrl='" + baseUrl + '\'' + diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptions.java new file mode 100644 index 00000000..b8ca483c --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptions.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExecutionRequestOptions extends ExecutionRequestOptions { + @Expose + private final String reportUnitUri; + + private ReportExecutionRequestOptions(String reportUnitUri) { + this.reportUnitUri = reportUnitUri; + } + + public static ReportExecutionRequestOptions newRequest(String uri) { + if (uri == null || uri.length() == 0) { + throw new IllegalArgumentException("Uri should not be null"); + } + return new ReportExecutionRequestOptions(uri); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponse.java new file mode 100644 index 00000000..259711c0 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.export; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExportExecutionResponse { + @Expose + @SerializedName("id") + private String exportId; + @Expose + private ExecutionRequestOptions options; + + public String getExportId() { + return exportId; + } + + public ExecutionRequestOptions getOptions() { + return options; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java index e0ac1a9a..cbddbdcf 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network.rest.v2.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -86,7 +86,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runReportExecution(ExecutionRequestOptions.newRequest("/any/uri")); + restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri")); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java new file mode 100644 index 00000000..70dbfd69 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.test.WebMockRule; +import com.squareup.okhttp.mockwebserver.MockResponse; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportExportRestApiTest { + + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + + private ReportExportRestApi restApiUnderTest; + + @Before + public void setup() { + restApiUnderTest = new ReportExportRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { + mExpectedException.expect(IllegalArgumentException.class); + new ReportExportRestApi.Builder(null, "cookie").build(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullCookie() { + mExpectedException.expect(IllegalArgumentException.class); + new ReportExportRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); + } + + @Test + public void shouldThroughRestErrorOnSearchRequestIfHttpError() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(create500Response()); + + restApiUnderTest.runReportExportExecution("any_id", ExecutionRequestOptions.newInstance()); + } + + private MockResponse create500Response() { + return new MockResponse() + .setStatus("HTTP/1.1 500 Internal Server Error"); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java index d4a25c99..465c97d3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java @@ -24,9 +24,7 @@ package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; -import com.google.gson.Gson; import com.google.gson.annotations.Expose; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; import org.junit.Before; import org.junit.Rule; @@ -36,8 +34,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; import junitparams.JUnitParamsRunner; import junitparams.Parameters; @@ -53,16 +49,13 @@ @RunWith(JUnitParamsRunner.class) public class ExecutionRequestOptionsTest { - private ExecutionRequestOptions requestUnderTest; - @Rule public final ExpectedException mExpectedException = ExpectedException.none(); - private Gson mGson; + ExecutionRequestOptions requestUnderTest; @Before public void setup() { - requestUnderTest = ExecutionRequestOptions.newRequest("/some/uri"); - mGson = GsonFactory.create(); + requestUnderTest = ExecutionRequestOptions.newInstance(); } @Test @@ -116,25 +109,4 @@ public void shouldWithAttachmentsPrefixShouldEncodePrefix() { String prefix = requestUnderTest.withAttachmentsPrefix("./").getAttachmentsPrefix(); assertThat(prefix, is(".%2F")); } - - @Test - public void factoryMethodShouldNotAllowNull() { - mExpectedException.expect(IllegalArgumentException.class); - ExecutionRequestOptions.newRequest(null); - } - - @Test - public void factoryMethodShouldNotAllowEmptyString() { - mExpectedException.expect(IllegalArgumentException.class); - ExecutionRequestOptions.newRequest(""); - } - @Test - public void shouldSerializeParametersList() { - ReportParameter reportParameter = ReportParameter.emptyParameter("some_param"); - Set parameters = new HashSet<>(); - parameters.add(reportParameter); - requestUnderTest.withParameters(parameters); - String json = mGson.toJson(requestUnderTest); - assertThat(json, is("{\"reportUnitUri\":\"/some/uri\",\"parameters\":{\"reportParameter\":[{\"name\":\"some_param\",\"value\":[]}]}}")); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptionsTest.java new file mode 100644 index 00000000..737ecef3 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptionsTest.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportExecutionRequestOptionsTest { + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + + @Test + public void factoryMethodShouldNotAllowNull() { + mExpectedException.expect(IllegalArgumentException.class); + ReportExecutionRequestOptions.newRequest(null); + } + + @Test + public void factoryMethodShouldNotAllowEmptyString() { + mExpectedException.expect(IllegalArgumentException.class); + ReportExecutionRequestOptions.newRequest(""); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponseTest.java new file mode 100644 index 00000000..fff34369 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponseTest.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.export; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ReportExportExecutionResponseTest { + @Test + @Parameters({ + "exportId", + "options", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportExportExecutionResponse.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void exportIdFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ReportExportExecutionResponse.class.getDeclaredField("exportId"); + assertThat(field, hasSerializedName("id")); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 2b5c4919..a468ea36 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -24,11 +24,13 @@ package com.jaspersoft.android.sdk.test.integration.api; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; @@ -62,6 +64,7 @@ public class ReportExecutionRestApiTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; String reportUri = "/public/Samples/Reports/AllAccounts"; AuthResponse mAuthResponse; + ReportExecutionRestApi mApi; @Before public void setup() { @@ -70,27 +73,23 @@ public void setup() { @Test public void shouldStartReportExecution() { - ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); - ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestOptions); + ReportExecutionDetailsResponse response = startExecution(); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(notNullValue())); } @Test public void shouldCancelReportExecution() { - ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); - ReportExecutionDetailsResponse response = api.runReportExecution(executionRequestOptions); + ReportExecutionRestApi api = getApi(); + ReportExecutionDetailsResponse response = startExecution(); boolean cancelled = api.cancelReportExecution(response.getExecutionId()); assertThat(cancelled, is(true)); } @Test public void shouldReturnReportExecutionDetails() { - ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); - ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); + ReportExecutionRestApi api = getApi(); + ReportExecutionDetailsResponse executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); ReportExecutionDetailsResponse response = api.requestReportExecutionDetails(executionResponse.getExecutionId()); @@ -99,9 +98,8 @@ public void shouldReturnReportExecutionDetails() { @Test public void shouldCheckReportExecutionStatus() { - ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); - ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); + ReportExecutionRestApi api = getApi(); + ReportExecutionDetailsResponse executionResponse = startExecution(); ReportExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); assertThat(response.getStatus(), is(notNullValue())); @@ -109,9 +107,8 @@ public void shouldCheckReportExecutionStatus() { @Test public void searchForExecutionShouldReturnResult() { - ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); - ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); + ReportExecutionRestApi api = getApi(); + ReportExecutionDetailsResponse executionResponse = startExecution(); Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); @@ -122,19 +119,27 @@ public void searchForExecutionShouldReturnResult() { @Test public void updateOfParametersForExecutionShouldReturnResult() { - ReportExecutionRestApi api = createApi(); - ExecutionRequestOptions executionRequestOptions = ExecutionRequestOptions.newRequest(reportUri); - ReportExecutionDetailsResponse executionResponse = api.runReportExecution(executionRequestOptions); + ReportExecutionRestApi api = getApi(); + ReportExecutionDetailsResponse executionResponse = startExecution(); boolean success = api.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); assertThat(success, is(true)); } - private ReportExecutionRestApi createApi() { - return new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) - .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) - .build(); + @NonNull + private ReportExecutionDetailsResponse startExecution() { + ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(reportUri); + return getApi().runReportExecution(executionRequestOptions); + } + + private ReportExecutionRestApi getApi() { + if (mApi == null) { + mApi = new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); + } + return mApi; } private AuthResponse getAuthResponse() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java new file mode 100644 index 00000000..ca8e936f --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -0,0 +1,112 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.test.TestLogger; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; +import org.robolectric.shadows.httpclient.FakeHttp; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(RobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class ReportExportRestApiTest { + String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + String reportUri = "/public/Samples/Reports/AllAccounts"; + AuthResponse mAuthResponse; + ReportExecutionRestApi mExecApi; + ReportExportRestApi mExportApi; + + @Before + public void setup() { + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + } + + @Test + public void runExportRequestShouldReturnResult() { + ReportExecutionDetailsResponse exec = startExecution(); + ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() + .withPages("1-10") + .withOutputFormat("PDF"); + ReportExportExecutionResponse execDetails = getApi().runReportExportExecution(exec.getExecutionId(), options); + assertThat(execDetails.getExportId(), is(notNullValue())); + } + + @NonNull + private ReportExecutionDetailsResponse startExecution() { + ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(reportUri); + return getReportExecApi().runReportExecution(executionRequestOptions); + } + + private ReportExportRestApi getApi() { + if (mExportApi == null) { + mExportApi = new ReportExportRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); + } + return mExportApi; + } + + private ReportExecutionRestApi getReportExecApi() { + if (mExecApi == null) { + mExecApi = new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); + } + return mExecApi; + } + + private AuthResponse getAuthResponse() { + if (mAuthResponse == null) { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", null, null); + } + return mAuthResponse; + } +} From 637b00bba69b43292491d50bfbf1a4c86064df8f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 16:04:26 +0300 Subject: [PATCH 064/457] Finalizing builders --- .../android/sdk/network/rest/v2/api/AuthenticationRestApi.java | 2 +- .../sdk/network/rest/v2/api/ReportExecutionRestApi.java | 3 +-- .../android/sdk/network/rest/v2/api/RepositoryRestApi.java | 2 +- .../android/sdk/network/rest/v2/api/ServerRestApi.java | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java index 61a97aa6..32ad9560 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java @@ -46,7 +46,7 @@ AuthResponse authenticate(@NonNull String username, @Nullable String organization, @Nullable Map params); - class Builder extends BaseBuilder { + final class Builder extends BaseBuilder { public Builder(String baseUrl) { super(baseUrl); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index c3ea24f9..c427e3dc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -57,8 +57,7 @@ public interface ReportExecutionRestApi { @NonNull ReportExecutionSearchResponse searchReportExecution(Map params); - - class Builder extends AuthBaseBuilder { + final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java index 9d7b118e..bdbb6440 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java @@ -57,7 +57,7 @@ public interface RepositoryRestApi { @NonNull FolderLookupResponse requestFolderResource(@NonNull String resourceUri); - class Builder extends AuthBaseBuilder { + final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java index a61a0572..dab9c9c5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java @@ -44,7 +44,7 @@ public interface ServerRestApi { @GET(value = "/rest_v2/serverInfo") ServerInfoResponse getServerInfo(); - class Builder extends BaseBuilder { + final class Builder extends BaseBuilder { public Builder(String baseUrl) { super(baseUrl); } From c2b9ae0eed33ee1df4234d6770394ef6282182de Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 16:07:23 +0300 Subject: [PATCH 065/457] Refactoring 'ReportExecutionStatusResponse' to 'ExecutionStatusResponse' --- .../network/rest/v2/api/ReportExecutionRestApi.java | 4 ++-- .../rest/v2/api/ReportExecutionRestApiImpl.java | 10 +++++----- ...tatusResponse.java => ExecutionStatusResponse.java} | 10 +++++----- ...ponseTest.java => ExecutionStatusResponseTest.java} | 4 ++-- .../integration/api/ReportExecutionRestApiTest.java | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ReportExecutionStatusResponse.java => ExecutionStatusResponse.java} (85%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/{ReportExecutionStatusResponseTest.java => ExecutionStatusResponseTest.java} (92%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java index c427e3dc..c0ee7615 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java @@ -29,7 +29,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; import java.util.Collection; @@ -48,7 +48,7 @@ public interface ReportExecutionRestApi { ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId); @NonNull - ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId); + ExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId); boolean cancelReportExecution(@NonNull String executionId); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java index 79e6a125..3a779d75 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java @@ -30,7 +30,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; import java.util.Collection; @@ -76,13 +76,13 @@ public ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull Str @NonNull @Override - public ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId) { + public ExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId) { return mRestApi.requestReportExecutionStatus(executionId); } @Override public boolean cancelReportExecution(@NonNull String executionId) { - Response response = mRestApi.cancelReportExecution(executionId, ReportExecutionStatusResponse.cancelledStatus()); + Response response = mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()); int status = response.getStatus(); return status != 204; } @@ -122,7 +122,7 @@ interface RestApi { @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions/{executionId}/status") - ReportExecutionStatusResponse requestReportExecutionStatus(@NonNull @Path(value = "executionId", encode = false) String executionId); + ExecutionStatusResponse requestReportExecutionStatus(@NonNull @Path(value = "executionId", encode = false) String executionId); @NonNull @Headers("Accept: application/json") @@ -134,7 +134,7 @@ Response updateReportExecution(@NonNull @Path(value = "executionId", encode = fa @Headers("Accept: application/json") @PUT("/rest_v2/reportExecutions/{executionId}/status") Response cancelReportExecution(@NonNull @Path(value = "executionId", encode = false) String executionId, - @NonNull @Body ReportExecutionStatusResponse statusResponse); + @NonNull @Body ExecutionStatusResponse statusResponse); @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponse.java similarity index 85% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponse.java index bfaae004..833209a9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponse.java @@ -30,21 +30,21 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportExecutionStatusResponse { +public final class ExecutionStatusResponse { @Expose private String value; @Expose private ErrorDescriptor errorDescriptor; - public ReportExecutionStatusResponse() {} + public ExecutionStatusResponse() {} - private ReportExecutionStatusResponse(String value) { + private ExecutionStatusResponse(String value) { this.value = value; } - public static ReportExecutionStatusResponse cancelledStatus() { - return new ReportExecutionStatusResponse("cancelled"); + public static ExecutionStatusResponse cancelledStatus() { + return new ExecutionStatusResponse("cancelled"); } public String getStatus() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponseTest.java similarity index 92% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponseTest.java index 14cc511a..391bca40 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionStatusResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponseTest.java @@ -42,14 +42,14 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ReportExecutionStatusResponseTest { +public class ExecutionStatusResponseTest { @Test @Parameters({ "value", "errorDescriptor", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ReportExecutionStatusResponse.class.getDeclaredField(fieldName); + Field field = ExecutionStatusResponse.class.getDeclaredField(fieldName); MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index a468ea36..9479ca53 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -32,7 +32,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; @@ -101,7 +101,7 @@ public void shouldCheckReportExecutionStatus() { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); - ReportExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); + ExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); assertThat(response.getStatus(), is(notNullValue())); } From 516aa028d64fa07756085948b7df41b7a804b7c6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 12 Aug 2015 16:28:06 +0300 Subject: [PATCH 066/457] Add 'checkExecutionStatus' api --- .../rest/v2/api/ReportExportRestApi.java | 5 ++- .../rest/v2/api/ReportExportRestApiImpl.java | 17 ++++++++-- .../rest/v2/api/ReportExportRestApiTest.java | 34 ++++++++++++++++++- .../api/ReportExportRestApiTest.java | 17 ++++++++-- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java index 8139726b..284756fa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; /** @@ -36,7 +37,9 @@ public interface ReportExportRestApi { @NonNull - ReportExportExecutionResponse runReportExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + ReportExportExecutionResponse runExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + @NonNull + ExecutionStatusResponse checkExecutionStatus(@NonNull String executionId, @NonNull String exportId); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java index e205ec2b..c01084cc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java @@ -27,10 +27,12 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; import retrofit.RestAdapter; import retrofit.http.Body; +import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.POST; import retrofit.http.Path; @@ -48,16 +50,27 @@ public ReportExportRestApiImpl(RestAdapter restAdapter) { @NonNull @Override - public ReportExportExecutionResponse runReportExportExecution(@NonNull String executionId, - @NonNull ExecutionRequestOptions executionOptions) { + public ReportExportExecutionResponse runExecution(@NonNull String executionId, + @NonNull ExecutionRequestOptions executionOptions) { return mRestApi.runReportExportExecution(executionId, executionOptions); } + @NonNull + @Override + public ExecutionStatusResponse checkExecutionStatus(@NonNull String executionId, @NonNull String exportId) { + return mRestApi.checkReportExportStatus(executionId, exportId); + } + private interface RestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions/{executionId}/exports") ReportExportExecutionResponse runReportExportExecution(@NonNull @Path("executionId") String executionId, @NonNull @Body ExecutionRequestOptions executionOptions); + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") + ExecutionStatusResponse checkReportExportStatus(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java index 70dbfd69..89d43976 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java @@ -70,7 +70,39 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runReportExportExecution("any_id", ExecutionRequestOptions.newInstance()); + restApiUnderTest.runExecution("any_id", ExecutionRequestOptions.newInstance()); + } + + @Test + public void pathParameterShouldNotBeNullForRunRequestExecution() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + + restApiUnderTest.runExecution(null, ExecutionRequestOptions.newInstance()); + } + + @Test + public void bodyShouldNotBeNullForRunRequestExecution() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Body parameter value must not be null."); + + restApiUnderTest.runExecution("any_id", null); + } + + @Test + public void pathParameter1ShouldNotBeNullForCheckRequestExecutionStatus() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + + restApiUnderTest.checkExecutionStatus(null, "any_id"); + } + + @Test + public void pathParameter2ShouldNotBeNullForCheckRequestExecutionStatus() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"exportId\" value must not be null."); + + restApiUnderTest.checkExecutionStatus("any_id", null); } private MockResponse create500Response() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index ca8e936f..f474fcae 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -31,6 +31,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; @@ -69,11 +70,23 @@ public void setup() { @Test public void runExportRequestShouldReturnResult() { ReportExecutionDetailsResponse exec = startExecution(); + ReportExportExecutionResponse execDetails = startExportExecution(exec); + assertThat(execDetails.getExportId(), is(notNullValue())); + } + @Test + public void checkExportRequestStatusShouldReturnResult() { + ReportExecutionDetailsResponse exec = startExecution(); + ReportExportExecutionResponse execDetails = startExportExecution(exec); + ExecutionStatusResponse response = getApi().checkExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); + assertThat(response, is(notNullValue())); + } + + @NonNull + private ReportExportExecutionResponse startExportExecution(ReportExecutionDetailsResponse exec) { ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() .withPages("1-10") .withOutputFormat("PDF"); - ReportExportExecutionResponse execDetails = getApi().runReportExportExecution(exec.getExecutionId(), options); - assertThat(execDetails.getExportId(), is(notNullValue())); + return getApi().runExecution(exec.getExecutionId(), options); } @NonNull From c138db03212a1b5cd1ddf78b53c7ce50e8b38398 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 13 Aug 2015 10:34:37 +0300 Subject: [PATCH 067/457] Add api for outputing report export --- .../sdk/network/rest/v2/api/HeaderUtil.java | 69 +++++++++++ .../rest/v2/api/ReportExportRestApi.java | 5 + .../rest/v2/api/ReportExportRestApiImpl.java | 26 ++++- .../rest/v2/api/RetrofitExportInput.java | 59 ++++++++++ .../sdk/network/rest/v2/api/SafeHeader.java | 69 +++++++++++ .../rest/v2/entity/export/ExportInput.java | 38 +++++++ .../entity/export/ExportResourceResponse.java | 65 +++++++++++ .../network/rest/v2/api/HeaderUtilTest.java | 79 +++++++++++++ .../rest/v2/api/ReportExportRestApiTest.java | 31 +++++ .../rest/v2/api/RetrofitExportInputTest.java | 72 ++++++++++++ .../network/rest/v2/api/SafeHeaderTEst.java | 107 ++++++++++++++++++ .../api/ReportExportRestApiTest.java | 14 ++- 12 files changed, 631 insertions(+), 3 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtil.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInput.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeader.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportInput.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportResourceResponse.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtilTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInputTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeaderTEst.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtil.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtil.java new file mode 100644 index 00000000..df2b3f0b --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtil.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; + +import java.util.ArrayList; +import java.util.List; + +import retrofit.client.Header; +import retrofit.client.Response; + +/** + * @author Tom Koptel + * @since 2.2 + */ +final class HeaderUtil { + private final List

mHeaders; + + HeaderUtil(@NonNull List
headers) { + mHeaders = headers; + } + + public static HeaderUtil wrap(@NonNull Response response) { + return new HeaderUtil(response.getHeaders()); + } + + @NonNull + public SafeHeader getFirstHeader(String name) { + List
headers = findHeaders(name); + if (headers.isEmpty()) { + return new SafeHeader(null); + } else { + return new SafeHeader(headers.get(0)); + } + } + + private List
findHeaders(String name) { + List
result = new ArrayList<>(); + for (Header header : mHeaders) { + if (header.getName().equals(name)) { + result.add(header); + } + } + return result; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java index 284756fa..1770812e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; /** @@ -38,9 +39,13 @@ public interface ReportExportRestApi { @NonNull ReportExportExecutionResponse runExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + @NonNull ExecutionStatusResponse checkExecutionStatus(@NonNull String executionId, @NonNull String exportId); + @NonNull + ExportResourceResponse requestOutput(@NonNull String executionId, @NonNull String exportId); + final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java index c01084cc..bfc5e701 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java @@ -28,9 +28,11 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; import retrofit.RestAdapter; +import retrofit.client.Response; import retrofit.http.Body; import retrofit.http.GET; import retrofit.http.Headers; @@ -61,16 +63,36 @@ public ExecutionStatusResponse checkExecutionStatus(@NonNull String executionId, return mRestApi.checkReportExportStatus(executionId, exportId); } + @NonNull + @Override + public ExportResourceResponse requestOutput(@NonNull String executionId, @NonNull String exportId) { + Response response = mRestApi.requestReportExportOutput(executionId, exportId); + RetrofitExportInput exportInput = new RetrofitExportInput(response.getBody()); + HeaderUtil headerUtil = HeaderUtil.wrap(response); + String pages = headerUtil.getFirstHeader("report-pages").asString(); + boolean isFinal = headerUtil.getFirstHeader("output-final").asBoolean(); + return ExportResourceResponse.create(exportInput, pages, isFinal); + } + private interface RestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions/{executionId}/exports") ReportExportExecutionResponse runReportExportExecution(@NonNull @Path("executionId") String executionId, - @NonNull @Body ExecutionRequestOptions executionOptions); + @NonNull @Body ExecutionRequestOptions executionOptions); + @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") ExecutionStatusResponse checkReportExportStatus(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId); + @NonNull @Path("exportId") String exportId); + + /** + * 'suppressContentDisposition' used due to security implications this header has + */ + @NonNull + @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") + Response requestReportExportOutput(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInput.java new file mode 100644 index 00000000..e428daef --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInput.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; + +import java.io.IOException; +import java.io.InputStream; + +import retrofit.mime.TypedInput; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RetrofitExportInput implements ExportInput { + private final TypedInput mDelegate; + + public RetrofitExportInput(TypedInput input) { + mDelegate = input; + } + + @Override + public String getMimeType() { + return mDelegate.mimeType(); + } + + @Override + public long getLength() { + return mDelegate.length(); + } + + @Override + public InputStream getStream() throws IOException { + return mDelegate.in(); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeader.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeader.java new file mode 100644 index 00000000..aa404690 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeader.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import retrofit.client.Header; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class SafeHeader { + private final Header mHeader; + + SafeHeader(@Nullable Header header) { + mHeader = header; + } + + public int asInt() { + if (mHeader == null) { + return 0; + } + try { + return Integer.parseInt(mHeader.getValue()); + } catch (NumberFormatException ex) { + return 0; + } + } + + public boolean asBoolean() { + return mHeader != null && Boolean.parseBoolean(mHeader.getValue()); + } + + @NonNull + public String asString() { + if (mHeader == null) { + return ""; + } + String value = mHeader.getValue(); + if (value == null) { + return ""; + } + return value; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportInput.java new file mode 100644 index 00000000..11a86c67 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportInput.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.export; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ExportInput { + String getMimeType(); + long getLength(); + InputStream getStream() throws IOException; +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportResourceResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportResourceResponse.java new file mode 100644 index 00000000..1113ecfe --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportResourceResponse.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.entity.export; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public final class ExportResourceResponse { + private final ExportInput mExportInput; + private final boolean mFinal; + private final String mPages; + + private ExportResourceResponse(ExportInput exportInput, String pages, boolean finalOutput) { + mExportInput = exportInput; + mFinal = finalOutput; + mPages = pages; + } + + public static ExportResourceResponse create(ExportInput exportInput, String pages, boolean finalOutput) { + return new ExportResourceResponse(exportInput, pages, finalOutput); + } + + public ExportInput getExportInput() { + return mExportInput; + } + + public boolean isFinal() { + return mFinal; + } + + public String getPages() { + return mPages; + } + + @Override + public String toString() { + return "ExportOutputResourceResponse{" + + ", mFinal=" + mFinal + + ", mPages='" + mPages + '\'' + + '}'; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtilTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtilTest.java new file mode 100644 index 00000000..dca8f667 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtilTest.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; +import java.util.Collections; + +import retrofit.client.Header; +import retrofit.client.Response; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(Response.class) +public class HeaderUtilTest { + @Mock + Response mResponse; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + @SuppressWarnings("unchecked") + public void shouldReturnSafeHeaderIfSearchResultWasEmpty() { + when(mResponse.getHeaders()).thenReturn(Collections.EMPTY_LIST); + HeaderUtil util = HeaderUtil.wrap(mResponse); + SafeHeader safeHeader = util.getFirstHeader("name"); + assertThat(safeHeader, is(notNullValue())); + } + + @Test + public void shouldReturnSafeHeaderForSuccessfulSearch() { + when(mResponse.getHeaders()).thenReturn(new ArrayList
(){{ + add(new Header("name", "value")); + }}); + HeaderUtil util = HeaderUtil.wrap(mResponse); + SafeHeader safeHeader = util.getFirstHeader("name"); + assertThat(safeHeader, is(notNullValue())); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java index 89d43976..d2979d3e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.rest.v2.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; @@ -34,6 +35,9 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + /** * @author Tom Koptel * @since 2.0 @@ -105,6 +109,33 @@ public void pathParameter2ShouldNotBeNullForCheckRequestExecutionStatus() { restApiUnderTest.checkExecutionStatus("any_id", null); } + @Test + public void requestForOutputShouldParsePagesFromHeader() { + MockResponse mockResponse = create200Response() + .setBody("") + .addHeader("report-pages", "1-10"); + mWebMockRule.enqueue(mockResponse); + + ExportResourceResponse resource = restApiUnderTest.requestOutput("any_id", "any_id"); + assertThat(resource.getPages(), is("1-10")); + } + + @Test + public void requestForOutputShouldParseIsFinalHeader() { + MockResponse mockResponse = create200Response() + .setBody("") + .addHeader("output-final", "true"); + mWebMockRule.enqueue(mockResponse); + + ExportResourceResponse resource = restApiUnderTest.requestOutput("any_id", "any_id"); + assertThat(resource.isFinal(), is(true)); + } + + private MockResponse create200Response() { + return new MockResponse() + .setStatus("HTTP/1.1 200 Ok"); + } + private MockResponse create500Response() { return new MockResponse() .setStatus("HTTP/1.1 500 Internal Server Error"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInputTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInputTest.java new file mode 100644 index 00000000..83196621 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInputTest.java @@ -0,0 +1,72 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.io.IOException; + +import retrofit.mime.TypedInput; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RetrofitExportInputTest { + @Mock + TypedInput mTypedInput; + + private RetrofitExportInput objectUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new RetrofitExportInput(mTypedInput); + } + + @Test + public void shouldDelegateMimeType() { + objectUnderTest.getMimeType(); + verify(mTypedInput, times(1)).mimeType(); + } + + @Test + public void shouldDelegateLengrh() { + objectUnderTest.getLength(); + verify(mTypedInput, times(1)).length(); + } + + @Test + public void shouldDelegateInputStream() throws IOException { + objectUnderTest.getStream(); + verify(mTypedInput, times(1)).in(); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeaderTEst.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeaderTEst.java new file mode 100644 index 00000000..6e354dc8 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeaderTEst.java @@ -0,0 +1,107 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.rest.v2.api; + +import org.junit.Test; + +import retrofit.client.Header; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class SafeHeaderTest { + + @Test + public void forNullHeaderShouldAlwaysReturnSafeValueIfStringRequested() { + SafeHeader safeHeader = new SafeHeader(null); + assertThat(safeHeader.asString(), is(notNullValue())); + assertThat(safeHeader.asString(), is("")); + } + + @Test + public void forNullHeaderShouldAlwaysReturnSafeHeaderIfIntRequested() { + SafeHeader safeHeader = new SafeHeader(null); + assertThat(safeHeader.asInt(), is(0)); + } + + @Test + public void forNullHeaderShouldAlwaysReturnSafeHeaderIfBooleanRequested() { + SafeHeader safeHeader = new SafeHeader(null); + assertThat(safeHeader.asBoolean(), is(false)); + } + + @Test + public void forNumberExceptionReturnsZero() { + SafeHeader safeHeader = new SafeHeader(new Header("any", "NUN")); + assertThat(safeHeader.asInt(), is(0)); + } + + @Test + public void forBooleanParseExceptionReturnsFalse() { + SafeHeader safeHeader = new SafeHeader(new Header("any", "NOT_A_BOOL")); + assertThat(safeHeader.asBoolean(), is(false)); + } + + @Test + public void forMissingValueInHeaderReturnsSafeObjectIfStringRequested() { + SafeHeader safeHeader = new SafeHeader(new Header("any", null)); + assertThat(safeHeader.asString(), is("")); + } + + @Test + public void forMissingValueInHeaderReturnsSafeObjectIfIntRequested() { + SafeHeader safeHeader = new SafeHeader(new Header("any", null)); + assertThat(safeHeader.asInt(), is(0)); + } + + @Test + public void forMissingValueInHeaderReturnsSafeObjectIfBooleanRequested() { + SafeHeader safeHeader = new SafeHeader(new Header("any", null)); + assertThat(safeHeader.asBoolean(), is(false)); + } + + @Test + public void shouldReturnParseIntFromValidHeader() { + SafeHeader safeHeader = new SafeHeader(new Header("any", "100")); + assertThat(safeHeader.asInt(), is(100)); + } + + @Test + public void shouldReturnParseStringFromValidHeader() { + SafeHeader safeHeader = new SafeHeader(new Header("any", "value")); + assertThat(safeHeader.asString(), is("value")); + } + + @Test + public void shouldReturnParseBooleanFromValidHeader() { + SafeHeader safeHeader = new SafeHeader(new Header("any", "true")); + assertThat(safeHeader.asBoolean(), is(true)); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index f474fcae..5f646503 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -34,6 +34,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; @@ -73,6 +74,7 @@ public void runExportRequestShouldReturnResult() { ReportExportExecutionResponse execDetails = startExportExecution(exec); assertThat(execDetails.getExportId(), is(notNullValue())); } + @Test public void checkExportRequestStatusShouldReturnResult() { ReportExecutionDetailsResponse exec = startExecution(); @@ -81,10 +83,20 @@ public void checkExportRequestStatusShouldReturnResult() { assertThat(response, is(notNullValue())); } + @Test + public void requestExportOutputShouldReturnResult() { + ReportExecutionDetailsResponse exec = startExecution(); + ReportExportExecutionResponse execDetails = startExportExecution(exec); + ExportResourceResponse output = getApi().requestOutput(exec.getExecutionId(), execDetails.getExportId()); + assertThat(output.getExportInput(), is(notNullValue())); + assertThat(output.getPages(), is("1-2")); + assertThat(output.isFinal(), is(false)); + } + @NonNull private ReportExportExecutionResponse startExportExecution(ReportExecutionDetailsResponse exec) { ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() - .withPages("1-10") + .withPages("1-2") .withOutputFormat("PDF"); return getApi().runExecution(exec.getExecutionId(), options); } From 1ecd0472dbfe1c38722ec3da22541279ebebd30c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 13 Aug 2015 11:03:57 +0300 Subject: [PATCH 068/457] Refactoring 'searchResources' api for repository --- .../rest/v2/api/RepositoryRestApiImpl.java | 23 ++- .../v2/api/ResourceSearchResponseAdapter.java | 76 --------- .../network/rest/v2/api/ResponseWrapper.java | 102 ------------ .../resource/ResourceSearchResponse.java | 10 +- .../rest/v2/api/RepositoryRestApiTest.java | 57 ++++++- .../ResourceSearchResponseAdapterTest.java | 151 ------------------ 6 files changed, 86 insertions(+), 333 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapterTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java index 961850a7..7d2ec76d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java @@ -35,7 +35,9 @@ import java.util.Map; +import retrofit.ResponseEntity; import retrofit.RestAdapter; +import retrofit.RestAdapterWrapper; import retrofit.client.Response; import retrofit.http.GET; import retrofit.http.Headers; @@ -48,9 +50,11 @@ */ final class RepositoryRestApiImpl implements RepositoryRestApi { private final RestApi mRestApi; + private final RestAdapterWrapper mRestAdapterWrapper; RepositoryRestApiImpl(RestAdapter restAdapter) { mRestApi = restAdapter.create(RestApi.class); + mRestAdapterWrapper = RestAdapterWrapper.wrap(restAdapter); } @NonNull @@ -59,9 +63,24 @@ public ResourceSearchResponse searchResources(@Nullable Map sear Response response = mRestApi.searchResources(searchParams); int status = response.getStatus(); if (status == 204) { - return ResourceSearchResponseAdapter.emptyResponse(); + return ResourceSearchResponse.empty(); } else { - return ResourceSearchResponseAdapter.adapt(response); + ResponseEntity responseEntity = + mRestAdapterWrapper.produce(response, ResourceSearchResponse.class); + ResourceSearchResponse entity = responseEntity.getEntity(); + + HeaderUtil headerUtil = HeaderUtil.wrap(response); + int resultCount = headerUtil.getFirstHeader("Result-Count").asInt(); + int totalCount = headerUtil.getFirstHeader("Total-Count").asInt(); + int startIndex = headerUtil.getFirstHeader("Start-Index").asInt(); + int nextOffset = headerUtil.getFirstHeader("Next-Offset").asInt(); + + entity.setResultCount(resultCount); + entity.setTotalCount(totalCount); + entity.setStartIndex(startIndex); + entity.setNextOffset(nextOffset); + + return entity; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java deleted file mode 100644 index 0ff86e00..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.rest.v2.api; - -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; - -import retrofit.client.Header; -import retrofit.client.Response; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ResourceSearchResponseAdapter { - - private ResourceSearchResponseAdapter() {} - - public static ResourceSearchResponse adapt(Response response) { - ResponseWrapper wrapper = ResponseWrapper.wrap(response, ResourceSearchResponse.class); - Header resultCountHeader = wrapper.getFirstHeader("Result-Count"); - Header totalCountHeader = wrapper.getFirstHeader("Total-Count"); - Header startIndexHeader = wrapper.getFirstHeader("Start-Index"); - Header nextOffsetHeader = wrapper.getFirstHeader("Next-Offset"); - - int resultCount = asInt(resultCountHeader); - int totalCount = asInt(totalCountHeader); - int startIndex = asInt(startIndexHeader); - int nextOffset = asInt(nextOffsetHeader); - - ResourceSearchResponse resourceSearchResponse = wrapper.parseResponse(); - resourceSearchResponse.setResultCount(resultCount); - resourceSearchResponse.setTotalCount(totalCount); - resourceSearchResponse.setStartIndex(startIndex); - resourceSearchResponse.setNextOffset(nextOffset); - return resourceSearchResponse; - } - - public static ResourceSearchResponse emptyResponse() { - return new ResourceSearchResponse(); - } - - static int asInt(Header header) { - if (header == null) { - return 0; - } - String value = header.getValue(); - try { - return Integer.parseInt(value); - } catch (NumberFormatException ex) { - return 0; - } - } - -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java deleted file mode 100644 index 39986441..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResponseWrapper.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.rest.v2.api; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -import retrofit.client.Header; -import retrofit.mime.TypedInput; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ResponseWrapper { - - private final retrofit.client.Response mResponse; - private final Type mType; - private final Gson mGson; - - private ResponseWrapper(retrofit.client.Response response, Type type) { - mResponse = response; - mType = type; - mGson = GsonFactory.create(); - } - - @SuppressWarnings("unchecked") - public static ResponseWrapper wrap(retrofit.client.Response response, Type type) { - return new ResponseWrapper(response, type); - } - - @NonNull - public Response parseResponse() { - TypedInput typedInput = mResponse.getBody(); - Reader reader = null; - try { - reader = new InputStreamReader(typedInput.in()); - } catch (IOException e) { - // TODO it is no good idea to rethrow it here. Better solution to wrap with RestError - throw new RuntimeException(e); - } - return mGson.fromJson(reader, mType); - } - - @Nullable - public Header getFirstHeader(String name) { - List
headers = findHeaders(name); - if (headers.isEmpty()) { - return null; - } else { - Header header = headers.get(0); - if (header == null) { - return null; - } - return header; - } - } - - private List
findHeaders(String name) { - List
result = new ArrayList<>(); - List
headers = mResponse.getHeaders(); - for (Header header : headers) { - if (header.getName().equals(name)) { - result.add(header); - } - } - return result; - } - -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java index 1d5a9988..b28def4c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java @@ -38,12 +38,20 @@ public final class ResourceSearchResponse { @Expose @SerializedName("resourceLookup") - private List mResources = Collections.emptyList(); + private List mResources; private int mResultCount; private int mTotalCount; private int mStartIndex; private int mNextOffset; + private ResourceSearchResponse(List resources) { + mResources = resources; + } + + public static ResourceSearchResponse empty() { + return new ResourceSearchResponse(Collections.emptyList()); + } + public int getNextOffset() { return mNextOffset; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java index acc6bd52..f487eec3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,6 +27,9 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; import org.junit.Before; @@ -44,6 +47,9 @@ */ public class RepositoryRestApiTest { + @ResourceFile("json/all_resources.json") + TestResource searchResponse; + @Rule public final WebMockRule mWebMockRule = new WebMockRule(); @Rule @@ -53,6 +59,7 @@ public class RepositoryRestApiTest { @Before public void setup() { + TestResourceInjector.inject(this); restApiUnderTest = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); } @@ -86,6 +93,54 @@ public void shouldThrowIllegalArgumentExceptionForNullCookie() { RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); } + @Test + public void requestForSearchShouldParseHeaderResultCount() { + MockResponse mockResponse = create200Response() + .setBody(searchResponse.asString()) + .addHeader("Result-Count", "100"); + mWebMockRule.enqueue(mockResponse); + + ResourceSearchResponse response = restApiUnderTest.searchResources(null); + assertThat(response.getResultCount(), is(100)); + } + + @Test + public void requestForSearchShouldParseHeaderTotalCount() { + MockResponse mockResponse = create200Response() + .setBody(searchResponse.asString()) + .addHeader("Total-Count", "1000"); + mWebMockRule.enqueue(mockResponse); + + ResourceSearchResponse response = restApiUnderTest.searchResources(null); + assertThat(response.getTotalCount(), is(1000)); + } + @Test + public void requestForSearchShouldParseHeaderStartIndex() { + MockResponse mockResponse = create200Response() + .setBody(searchResponse.asString()) + .addHeader("Start-Index", "5"); + mWebMockRule.enqueue(mockResponse); + + ResourceSearchResponse response = restApiUnderTest.searchResources(null); + assertThat(response.getStartIndex(), is(5)); + } + + @Test + public void requestForSearchShouldParseHeaderNextOffset() { + MockResponse mockResponse = create200Response() + .setBody(searchResponse.asString()) + .addHeader("Next-Offset", "10"); + mWebMockRule.enqueue(mockResponse); + + ResourceSearchResponse response = restApiUnderTest.searchResources(null); + assertThat(response.getNextOffset(), is(10)); + } + + private MockResponse create200Response() { + return new MockResponse() + .setStatus("HTTP/1.1 200 Ok"); + } + private MockResponse create204Response() { return new MockResponse() .setStatus("HTTP/1.1 204 No Content"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapterTest.java deleted file mode 100644 index 6313dec7..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ResourceSearchResponseAdapterTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.rest.v2.api; - -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; -import com.jaspersoft.android.sdk.test.resource.ResourceFile; -import com.jaspersoft.android.sdk.test.resource.TestResource; -import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.lang.reflect.Field; -import java.util.ArrayList; - -import retrofit.client.Header; -import retrofit.client.Response; -import retrofit.mime.TypedInput; -import retrofit.mime.TypedString; - -import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; -import static org.mockito.Mockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({Response.class}) -public class ResourceSearchResponseAdapterTest { - - @ResourceFile("json/all_resources.json") - TestResource searchResponse; - @Mock - Response mockResponse; - - @Before - public void setup() { - TestResourceInjector.inject(this); - MockitoAnnotations.initMocks(this); - - TypedInput emptyJsonInput = new TypedString("{}"); - when(mockResponse.getBody()).thenReturn(emptyJsonInput); - } - - @Test - public void shouldAssignDefaultValueToResultCountIfHeaderMissing() { - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getResultCount(), is(0)); - } - - @Test - public void shouldAssignDefaultValueToTotalCountIfHeaderMissing() { - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getTotalCount(), is(0)); - } - - @Test - public void shouldAssignDefaultValueToValueStartIndexIfHeaderMissing() { - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getStartIndex(), is(0)); - } - - @Test - public void shouldAssignDefaultValueToValueNextOffsetIfHeaderMissing() { - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getNextOffset(), is(0)); - } - - @Test - public void shouldExtractResultCountFromHeaders() { - when(mockResponse.getHeaders()).thenReturn(new ArrayList
() {{ - add(new Header("Result-Count", String.valueOf(2))); - }}); - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getResultCount(), is(2)); - } - - @Test - public void shouldExtractTotalCountFromHeaders() { - when(mockResponse.getHeaders()).thenReturn(new ArrayList
(){{ - add(new Header("Total-Count", String.valueOf(3))); - }}); - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getTotalCount(), is(3)); - } - - @Test - public void shouldExtractStartIndexFromHeaders() { - when(mockResponse.getHeaders()).thenReturn(new ArrayList
(){{ - add(new Header("Start-Index", String.valueOf(3))); - }}); - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getStartIndex(), is(3)); - } - - @Test - public void shouldExtractNextOffsetFromHeaders() { - when(mockResponse.getHeaders()).thenReturn(new ArrayList
(){{ - add(new Header("Next-Offset", String.valueOf(4))); - }}); - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getNextOffset(), is(4)); - } - - @Test - public void shouldParseJsonResponseFromBody() { - TypedInput typedInput = new TypedString(searchResponse.asString()); - when(mockResponse.getBody()).thenReturn(typedInput); - - ResourceSearchResponse response = ResourceSearchResponseAdapter.adapt(mockResponse); - assertThat(response.getResources(), is(not(empty()))); - } - - @Test - public void mResourcesFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { - Field field = ResourceSearchResponse.class.getDeclaredField("mResources"); - assertThat(field, hasSerializedName("resourceLookup")); - } -} From 3478b29e2d5edeb56ff4f823b5b1698baf38fab0 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 13 Aug 2015 11:44:28 +0300 Subject: [PATCH 069/457] Add api for 'downloanding attachment' --- .../rest/v2/api/ReportExportRestApi.java | 4 ++ .../rest/v2/api/ReportExportRestApiImpl.java | 15 ++++++ .../rest/v2/api/ReportExportRestApiTest.java | 52 ++++++++++++++++++- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java index 1770812e..bfd30b80 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; @@ -46,6 +47,9 @@ public interface ReportExportRestApi { @NonNull ExportResourceResponse requestOutput(@NonNull String executionId, @NonNull String exportId); + @NonNull + ExportInput requestAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); + final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java index bfc5e701..57a7da3c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; @@ -74,6 +75,14 @@ public ExportResourceResponse requestOutput(@NonNull String executionId, @NonNul return ExportResourceResponse.create(exportInput, pages, isFinal); } + @NonNull + @Override + public ExportInput requestAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId) { + Response response = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); + ExportInput input = new RetrofitExportInput(response.getBody()); + return input; + } + private interface RestApi { @NonNull @Headers("Accept: application/json") @@ -94,5 +103,11 @@ ExecutionStatusResponse checkReportExportStatus(@NonNull @Path("executionId") St @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") Response requestReportExportOutput(@NonNull @Path("executionId") String executionId, @NonNull @Path("exportId") String exportId); + + @NonNull + @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") + Response requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId, + @NonNull @Path("attachmentId") String attachmentId); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java index d2979d3e..5260d5fb 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java @@ -25,9 +25,13 @@ package com.jaspersoft.android.sdk.network.rest.v2.api; import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; import org.junit.Before; @@ -35,7 +39,11 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import java.io.IOException; +import java.io.InputStream; + import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; /** @@ -51,8 +59,12 @@ public class ReportExportRestApiTest { private ReportExportRestApi restApiUnderTest; + @ResourceFile("json/root_folder.json") + TestResource mResource; + @Before public void setup() { + TestResourceInjector.inject(this); restApiUnderTest = new ReportExportRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); } @@ -94,7 +106,7 @@ public void bodyShouldNotBeNullForRunRequestExecution() { } @Test - public void pathParameter1ShouldNotBeNullForCheckRequestExecutionStatus() { + public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); @@ -102,13 +114,37 @@ public void pathParameter1ShouldNotBeNullForCheckRequestExecutionStatus() { } @Test - public void pathParameter2ShouldNotBeNullForCheckRequestExecutionStatus() { + public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"exportId\" value must not be null."); restApiUnderTest.checkExecutionStatus("any_id", null); } + @Test + public void executionIdParameterShouldNotBeNullForAttachmentRequest() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + + restApiUnderTest.requestAttachment(null, "any_id", "any_id"); + } + + @Test + public void exportIdParameterShouldNotBeNullForAttachmentRequest() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"exportId\" value must not be null."); + + restApiUnderTest.requestAttachment("any_id", null, "any_id"); + } + + @Test + public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { + mExpectedException.expect(RestError.class); + mExpectedException.expectMessage("Path parameter \"attachmentId\" value must not be null."); + + restApiUnderTest.requestAttachment("any_id", "any_id", null); + } + @Test public void requestForOutputShouldParsePagesFromHeader() { MockResponse mockResponse = create200Response() @@ -131,6 +167,18 @@ public void requestForOutputShouldParseIsFinalHeader() { assertThat(resource.isFinal(), is(true)); } + @Test + public void requestForAttachmentShouldBeWrappedInsideInput() throws IOException { + MockResponse mockResponse = create200Response() + .setBody(mResource.asString()); + mWebMockRule.enqueue(mockResponse); + + ExportInput resource = restApiUnderTest.requestAttachment("any_id", "any_id", "any_id"); + InputStream stream = resource.getStream(); + assertThat(stream, is(notNullValue())); + stream.close(); + } + private MockResponse create200Response() { return new MockResponse() .setStatus("HTTP/1.1 200 Ok"); From 95194a2279ad52389a6d34d1f3221415eb593ea4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 11:05:09 +0300 Subject: [PATCH 070/457] Refactor package name --- .../{rest/v2 => }/api/AuthBaseBuilder.java | 4 ++-- .../v2 => }/api/AuthResponseFactory.java | 4 ++-- .../v2 => }/api/AuthenticationRestApi.java | 4 ++-- .../api/AuthenticationRestApiImpl.java | 11 +++------ .../{rest/v2 => }/api/BaseBuilder.java | 4 ++-- .../network/{rest/v2 => }/api/HeaderUtil.java | 2 +- .../v2 => }/api/ReportExecutionRestApi.java | 12 +++++----- .../api/ReportExecutionRestApiImpl.java | 12 +++++----- .../v2 => }/api/ReportExportRestApi.java | 12 +++++----- .../v2 => }/api/ReportExportRestApiImpl.java | 12 +++++----- .../{rest/v2 => }/api/RepositoryRestApi.java | 12 +++++----- .../v2 => }/api/RepositoryRestApiImpl.java | 12 +++++----- .../network/{rest/v2 => }/api/RestApiLog.java | 2 +- .../{rest/v2 => }/api/RestApiLogLevel.java | 2 +- .../v2 => }/api/RetrofitExportInput.java | 4 ++-- .../{rest/v2 => }/api/RetrofitLog.java | 2 +- .../network/{rest/v2 => }/api/SafeHeader.java | 2 +- .../{rest/v2 => }/api/ServerRestApi.java | 6 ++--- .../entity/execution/ErrorDescriptor.java | 2 +- .../execution/ExecutionRequestOptions.java | 2 +- .../execution/ExecutionStatusResponse.java | 2 +- .../entity/execution/ExportExecution.java | 2 +- .../ReportExecutionDetailsResponse.java | 2 +- .../ReportExecutionRequestOptions.java | 2 +- .../execution/ReportExecutionSearchItem.java | 2 +- .../ReportExecutionSearchResponse.java | 2 +- .../execution/ReportOutputResource.java | 2 +- .../entity/execution/ReportParameter.java | 2 +- .../entity/execution/ReportParameters.java | 2 +- .../v2 => }/entity/export/ExportInput.java | 2 +- .../entity/export/ExportResourceResponse.java | 2 +- .../export/ReportExportExecutionResponse.java | 4 ++-- .../entity/resource/DashboardFoundation.java | 2 +- .../resource/DashboardLookupResponse.java | 2 +- .../entity/resource/DashboardResource.java | 2 +- .../resource/DashboardResourceInfo.java | 2 +- .../v2 => }/entity/resource/DataSource.java | 2 +- .../entity/resource/DataSourceReference.java | 2 +- .../entity/resource/FolderLookupResponse.java | 2 +- .../{rest/v2 => }/entity/resource/JRXml.java | 2 +- .../entity/resource/JRXmlFileReference.java | 2 +- .../LegacyDashboardLookupResponse.java | 2 +- .../entity/resource/ReportLookupResponse.java | 2 +- .../entity/resource/ReportResource.java | 2 +- .../v2 => }/entity/resource/ResourceFile.java | 2 +- .../resource/ResourceLookupResponse.java | 2 +- .../entity/resource/ResourceReference.java | 2 +- .../resource/ResourceSearchResponse.java | 2 +- .../v2 => }/entity/server/AuthResponse.java | 2 +- .../entity/server/ServerInfoResponse.java | 2 +- .../type/CustomizedTypeAdapterFactory.java | 2 +- .../v2 => }/entity/type/GsonFactory.java | 2 +- ...eportLookupResponseTypeAdapterFactory.java | 4 ++-- .../{rest/v2 => }/exception/ErrorHandler.java | 2 +- .../{rest/v2 => }/exception/RestError.java | 2 +- .../exception/RetrofitErrorHandler.java | 2 +- .../v2 => }/api/AuthResponseFactoryTest.java | 5 ++-- .../api/AuthenticationRestApiTest.java | 6 ++--- .../{rest/v2 => }/api/HeaderUtilTest.java | 5 +++- .../api/ReportExecutionRestApiTest.java | 8 +++---- .../v2 => }/api/ReportExportRestApiTest.java | 10 ++++---- .../v2 => }/api/RepositoryRestApiTest.java | 6 ++--- .../v2 => }/api/RetrofitExportInputTest.java | 4 +++- .../SafeHeaderTest.java} | 2 +- .../{rest/v2 => }/api/ServerRestApiTest.java | 5 ++-- .../entity/execution/ErrorDescriptorTest.java | 2 +- .../ExecutionRequestOptionsTest.java | 2 +- .../ExecutionStatusResponseTest.java | 2 +- .../entity/execution/ExportExecutionTest.java | 2 +- .../ReportExecutionDetailsResponseTest.java | 2 +- .../ReportExecutionRequestOptionsTest.java | 2 +- .../ReportExecutionSearchResponseTest.java | 2 +- .../execution/ReportOutputResourceTest.java | 2 +- .../entity/execution/ReportParameterTest.java | 2 +- .../execution/ReportParametersTest.java | 2 +- .../ReportExportExecutionResponseTest.java | 2 +- .../resource/DashboardLookupResponseTest.java | 2 +- .../resource/FolderLookupResponseTest.java | 2 +- .../LegacyDashboardLookupResponseTest.java | 2 +- .../resource/ReportLookupResponseTest.java | 2 +- ...ResourceLookupResponseJsonConvertTest.java | 2 +- .../entity/server/ServerInfoResponseTest.java | 2 +- .../v2 => }/entity/type/GsonFactoryTest.java | 2 +- .../android/sdk/test/TestLogger.java | 2 +- .../api/AuthenticationRestApiTest.java | 8 +++---- .../api/ReportExecutionRestApiTest.java | 18 +++++++------- .../api/ReportExportRestApiTest.java | 24 +++++++++---------- .../api/RepositoryRestApiTest.java | 18 +++++++------- .../test/integration/api/ServerRestTest.java | 6 ++--- 89 files changed, 180 insertions(+), 182 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/AuthBaseBuilder.java (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/AuthResponseFactory.java (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/AuthenticationRestApi.java (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/AuthenticationRestApiImpl.java (91%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/BaseBuilder.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/HeaderUtil.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ReportExecutionRestApi.java (80%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ReportExecutionRestApiImpl.java (90%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ReportExportRestApi.java (79%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ReportExportRestApiImpl.java (90%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RepositoryRestApi.java (80%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RepositoryRestApiImpl.java (90%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RestApiLog.java (79%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RestApiLogLevel.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RetrofitExportInput.java (92%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RetrofitLog.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/SafeHeader.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ServerRestApi.java (89%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ErrorDescriptor.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ExecutionRequestOptions.java (99%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ExecutionStatusResponse.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ExportExecution.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportExecutionDetailsResponse.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportExecutionRequestOptions.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportExecutionSearchItem.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportExecutionSearchResponse.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportOutputResource.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportParameter.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportParameters.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/export/ExportInput.java (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/export/ExportResourceResponse.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/export/ReportExportExecutionResponse.java (90%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/DashboardFoundation.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/DashboardLookupResponse.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/DashboardResource.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/DashboardResourceInfo.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/DataSource.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/DataSourceReference.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/FolderLookupResponse.java (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/JRXml.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/JRXmlFileReference.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/LegacyDashboardLookupResponse.java (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ReportLookupResponse.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ReportResource.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ResourceFile.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ResourceLookupResponse.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ResourceReference.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ResourceSearchResponse.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/server/AuthResponse.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/server/ServerInfoResponse.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/type/CustomizedTypeAdapterFactory.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/type/GsonFactory.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/type/ReportLookupResponseTypeAdapterFactory.java (92%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/exception/ErrorHandler.java (74%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/exception/RestError.java (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/exception/RetrofitErrorHandler.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/AuthResponseFactoryTest.java (91%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/AuthenticationRestApiTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/HeaderUtilTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ReportExecutionRestApiTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ReportExportRestApiTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RepositoryRestApiTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/RetrofitExportInputTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2/api/SafeHeaderTEst.java => api/SafeHeaderTest.java} (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/api/ServerRestApiTest.java (91%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ErrorDescriptorTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ExecutionRequestOptionsTest.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ExecutionStatusResponseTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ExportExecutionTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportExecutionDetailsResponseTest.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportExecutionRequestOptionsTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportExecutionSearchResponseTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportOutputResourceTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportParameterTest.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/execution/ReportParametersTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/export/ReportExportExecutionResponseTest.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/DashboardLookupResponseTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/FolderLookupResponseTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/LegacyDashboardLookupResponseTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ReportLookupResponseTest.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/resource/ResourceLookupResponseJsonConvertTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/server/ServerInfoResponseTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{rest/v2 => }/entity/type/GsonFactoryTest.java (97%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java index 9b4250f6..5a8dbaa6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthBaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java @@ -22,9 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import retrofit.RequestInterceptor; import retrofit.RestAdapter; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java index 287bb3aa..533ec2dd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java @@ -22,9 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import java.util.ArrayList; import java.util.Iterator; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index 32ad9560..c4b5568c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.squareup.okhttp.OkHttpClient; import java.util.Map; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java similarity index 91% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index b167b868..865ff2d9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -22,25 +22,20 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; -import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.exception.RestError; import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.OkHttpClient; import java.util.List; import java.util.Map; -import retrofit.Endpoint; -import retrofit.Endpoints; import retrofit.RestAdapter; import retrofit.RetrofitError; import retrofit.client.Header; -import retrofit.client.OkClient; import retrofit.client.Response; import retrofit.http.Headers; import retrofit.http.Multipart; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index 8d7d4b42..98962f44 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -22,9 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.exception.ErrorHandler; +import com.jaspersoft.android.sdk.network.exception.ErrorHandler; import retrofit.RestAdapter; import retrofit.RetrofitError; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtil.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtil.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java index df2b3f0b..33f726a8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtil.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java similarity index 80% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index c0ee7615..6ddf007b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -22,15 +22,15 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; import java.util.Collection; import java.util.Map; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java similarity index 90% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 3a779d75..248b3209 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -22,16 +22,16 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; import java.util.Collection; import java.util.Map; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java similarity index 79% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index bfd30b80..f31f276c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -22,15 +22,15 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.export.ExportInput; +import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; +import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java similarity index 90% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index 57a7da3c..f7da90d6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -22,15 +22,15 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.export.ExportInput; +import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; +import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; import retrofit.RestAdapter; import retrofit.client.Response; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java similarity index 80% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index bdbb6440..c0112816 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -22,16 +22,16 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import java.util.Map; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java similarity index 90% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 7d2ec76d..c15d57ef 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -22,16 +22,16 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.LegacyDashboardLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import java.util.Map; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLog.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLog.java similarity index 79% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLog.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLog.java index 95fcd4f1..6a4460a0 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLog.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLog.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLogLevel.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLogLevel.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java index b441a3a9..24c22752 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RestApiLogLevel.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import retrofit.RestAdapter; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java similarity index 92% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInput.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java index e428daef..48b08b69 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInput.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java @@ -22,9 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; +import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import java.io.IOException; import java.io.InputStream; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitLog.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitLog.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitLog.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitLog.java index 5d3cda62..adb874ce 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitLog.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitLog.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import retrofit.RestAdapter; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeader.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/SafeHeader.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeader.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/SafeHeader.java index aa404690..404b121b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeader.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/SafeHeader.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; import android.support.annotation.Nullable; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java similarity index 89% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index dab9c9c5..4566334e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.type.GsonFactory; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import retrofit.RestAdapter; import retrofit.converter.GsonConverter; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptor.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java index 0a904f6e..4c7d2010 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java similarity index 99% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 5a19dd9c..0ac879f7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponse.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponse.java index 833209a9..89bcf09d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecution.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecution.java index 615d8398..086e96ef 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecution.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecution.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponse.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponse.java index 8da24a7f..26e72571 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptions.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java index b8ca483c..61f9fe6f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchItem.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchItem.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java index 47af7260..bf5515e9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchItem.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java index a1fa9892..de3ff8b4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResource.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java index 49266fe8..e913133f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameter.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameter.java index 920edcaa..9c8c731d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameter.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameter.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameters.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameters.java index 3bc0cd7b..5127e6c7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameters.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameters.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportInput.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java index 11a86c67..b7cc0019 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportInput.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.export; +package com.jaspersoft.android.sdk.network.entity.export; import java.io.IOException; import java.io.InputStream; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportResourceResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportResourceResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java index 1113ecfe..0e639913 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ExportResourceResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.export; +package com.jaspersoft.android.sdk.network.entity.export; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java similarity index 90% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java index 259711c0..465c4668 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java @@ -22,11 +22,11 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.export; +package com.jaspersoft.android.sdk.network.entity.export; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardFoundation.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardFoundation.java index 95028e59..c6d2974d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardFoundation.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardFoundation.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponse.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponse.java index 9048d950..d71f7ab8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResource.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResource.java index e1597854..eff4cbea 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResource.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResourceInfo.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResourceInfo.java index 714614ab..3a2f19aa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardResourceInfo.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResourceInfo.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSource.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSource.java index 7f63a5c4..87a63bb6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSource.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSourceReference.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSourceReference.java index cf1c3569..e8fdcd4e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DataSourceReference.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSourceReference.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java index 8b4fa17f..7ffcb5c9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXml.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXml.java index e06d6afb..f8844384 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXml.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXml.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXmlFileReference.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXmlFileReference.java index 27dc1348..b61bda31 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/JRXmlFileReference.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXmlFileReference.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponse.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponse.java index f9d553bf..7c6ec809 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java index d6317ebe..e94c194f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportResource.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportResource.java index ca817aea..c1f19ffe 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportResource.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceFile.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceFile.java index afe6d06a..07feb946 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceFile.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceFile.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponse.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponse.java index dcfe8177..898c95a7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceReference.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceReference.java index 065cc967..86ed1878 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceReference.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceReference.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResponse.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResponse.java index b28def4c..b2575981 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceSearchResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java index 65616a83..5fd338ba 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/AuthResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.server; +package com.jaspersoft.android.sdk.network.entity.server; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponse.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponse.java index 5cbade49..98f789a8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponse.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.server; +package com.jaspersoft.android.sdk.network.entity.server; import com.google.gson.annotations.Expose; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/CustomizedTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/CustomizedTypeAdapterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java index a70c7198..c262ee9e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/CustomizedTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.type; +package com.jaspersoft.android.sdk.network.entity.type; import com.google.gson.Gson; import com.google.gson.JsonElement; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java index e2bb09f8..246951ba 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.type; +package com.jaspersoft.android.sdk.network.entity.type; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportLookupResponseTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupResponseTypeAdapterFactory.java similarity index 92% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportLookupResponseTypeAdapterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupResponseTypeAdapterFactory.java index 5110f6d9..02ac682e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/ReportLookupResponseTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupResponseTypeAdapterFactory.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.type; +package com.jaspersoft.android.sdk.network.entity.type; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; /** diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/ErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java similarity index 74% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/ErrorHandler.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java index 852563cf..6dc857f5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/ErrorHandler.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.network.rest.v2.exception; +package com.jaspersoft.android.sdk.network.exception; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RestError.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java index 508925f2..61a78431 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.exception; +package com.jaspersoft.android.sdk.network.exception; import retrofit.RetrofitError; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RetrofitErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RetrofitErrorHandler.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java index 3489e950..8072d74d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/rest/v2/exception/RetrofitErrorHandler.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.exception; +package com.jaspersoft.android.sdk.network.exception; import retrofit.*; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java similarity index 91% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactoryTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java index cb581a55..9909e892 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthResponseFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java @@ -22,10 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.api.AuthResponseFactory; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import org.junit.Before; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index 2da32aa7..610c59f3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -22,10 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtilTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/HeaderUtilTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtilTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/HeaderUtilTest.java index dca8f667..4f7cc315 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/HeaderUtilTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/HeaderUtilTest.java @@ -22,7 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.HeaderUtil; +import com.jaspersoft.android.sdk.network.api.SafeHeader; import org.junit.Before; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index cbddbdcf..f7d54157 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -22,11 +22,11 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index 5260d5fb..be8bf3d5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportInput; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.export.ExportInput; +import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; +import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index f487eec3..0e4067fa 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -22,10 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInputTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInputTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java index 83196621..94054cff 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/RetrofitExportInputTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.RetrofitExportInput; import org.junit.Before; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeaderTEst.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/SafeHeaderTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeaderTEst.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/SafeHeaderTest.java index 6e354dc8..20f0bb57 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/SafeHeaderTEst.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/SafeHeaderTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java similarity index 91% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java index b87210fd..b2cb7c46 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java @@ -22,10 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.api; +package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.rest.v2.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.exception.RestError; +import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java index 32e4cfd1..0a99b72f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ErrorDescriptorTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java index 465c97d3..ed83f4ae 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionRequestOptionsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponseTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponseTest.java index 391bca40..29d5ddf4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExecutionStatusResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecutionTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecutionTest.java index 4654b6de..d9da9094 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ExportExecutionTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecutionTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponseTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponseTest.java index a267ccd6..0ef89d31 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionDetailsResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptionsTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java index 737ecef3..8049efc4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionRequestOptionsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import org.junit.Rule; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java index a367d6ec..c552e274 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportExecutionSearchResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResourceTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResourceTest.java index 27353039..8ef24a6f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportOutputResourceTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResourceTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameterTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameterTest.java index 7643baa5..d29e51be 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParameterTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameterTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParametersTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParametersTest.java index 53d7c85a..5c886aa3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/execution/ReportParametersTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParametersTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.execution; +package com.jaspersoft.android.sdk.network.entity.execution; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponseTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponseTest.java index fff34369..efb834c0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/export/ReportExportExecutionResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.export; +package com.jaspersoft.android.sdk.network.entity.export; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java index 68bddbaa..45e8238b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/DashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java index 15cb4ebc..b62cf2ef 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/FolderLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java index 98d81674..19bc463b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/LegacyDashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponseTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponseTest.java index 9335af66..05dc2b42 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ReportLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponseTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponseJsonConvertTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponseJsonConvertTest.java index ba019215..36fc95b4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/resource/ResourceLookupResponseJsonConvertTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponseJsonConvertTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.resource; +package com.jaspersoft.android.sdk.network.entity.resource; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponseTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponseTest.java index 4d2469e5..0c4418be 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/server/ServerInfoResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponseTest.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.network.rest.v2.entity.server; +package com.jaspersoft.android.sdk.network.entity.server; /* * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactoryTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java index ee7f6a51..8cd0757f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/rest/v2/entity/type/GsonFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.rest.v2.entity.type; +package com.jaspersoft.android.sdk.network.entity.type; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java index 50080fbe..760ccee6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test; -import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLog; +import com.jaspersoft.android.sdk.network.api.RestApiLog; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 315defa8..133998c1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -24,9 +24,9 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; @@ -57,7 +57,7 @@ public void shouldReturnResponseForSpringRequest() throws IOException { .setLog(TestLogger.get(this)) .setLogLevel(RestApiLogLevel.FULL) .build(); - AuthResponse response = authApi.authenticate("joeuser", "joeuser", "null", null); + AuthResponse response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); assertThat(response.getToken(), is(notNullValue())); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 9479ca53..7143dccf 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -26,14 +26,14 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; @@ -145,7 +145,7 @@ private ReportExecutionRestApi getApi() { private AuthResponse getAuthResponse() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", null, null); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null); } return mAuthResponse; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 5f646503..34370878 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -26,17 +26,17 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionDetailsResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; +import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; @@ -130,7 +130,7 @@ private ReportExecutionRestApi getReportExecApi() { private AuthResponse getAuthResponse() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", null, null); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null); } return mAuthResponse; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 1f6cd477..39cde67a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.rest.v2.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.DashboardLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.resource.ResourceSearchResponse; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; @@ -106,7 +106,7 @@ private AuthResponse getAuthResponse() { .setLog(TestLogger.get(this)) .setLogLevel(RestApiLogLevel.FULL) .build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", null, null); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null); } return mAuthResponse; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 86d4e5f6..1e619c42 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -25,9 +25,9 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.rest.v2.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.rest.v2.entity.server.ServerInfoResponse; -import com.jaspersoft.android.sdk.network.rest.v2.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; From 8855ae8cdb862df78ff1f635f8d73780f208cd15 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 12:45:15 +0300 Subject: [PATCH 071/457] Implementing entity objects for input controls requesting --- .../android/sdk/network/api/HeaderUtil.java | 2 +- .../network/entity/control/InputControl.java | 104 +++++++++++++++ .../entity/control/InputControlOption.java | 52 ++++++++ .../entity/control/InputControlResponse.java | 46 +++++++ .../entity/control/InputControlState.java | 68 ++++++++++ .../entity/control/ValidationRule.java | 82 ++++++++++++ .../entity/export/ExportResourceResponse.java | 2 +- .../sdk/network/entity/type/GsonFactory.java | 1 + ...nputControlResponseTypeAdapterFactory.java | 119 ++++++++++++++++++ .../control/InputControlOptionTest.java | 32 +++++ .../control/InputControlResponseTest.java | 83 ++++++++++++ .../entity/control/InputControlStateTest.java | 33 +++++ .../entity/control/InputControlTest.java | 40 ++++++ .../entity/control/ValidationRuleTest.java | 32 +++++ 14 files changed, 694 insertions(+), 2 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java index 33f726a8..9d7307a7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java @@ -34,7 +34,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ final class HeaderUtil { private final List
mHeaders; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java new file mode 100644 index 00000000..040e8cd4 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java @@ -0,0 +1,104 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class InputControl { + + @Expose + private String id; + @Expose + private String label; + @Expose + private boolean mandatory; + @Expose + private boolean readOnly; + @Expose + private String type; + @Expose + private String uri; + @Expose + private boolean visible; + @Expose + private Set masterDependencies = Collections.emptySet(); + @Expose + private Set slaveDependencies = Collections.emptySet(); + @Expose + private Set validationRules = Collections.emptySet(); + @Expose + private InputControlState state; + + public String getId() { + return id; + } + + public String getLabel() { + return label; + } + + public boolean isMandatory() { + return mandatory; + } + + public Set getMasterDependencies() { + return masterDependencies; + } + + public boolean isReadOnly() { + return readOnly; + } + + public Set getSlaveDependencies() { + return slaveDependencies; + } + + public String getType() { + return type; + } + + public String getUri() { + return uri; + } + + public Set getValidationRules() { + return Collections.unmodifiableSet(validationRules); + } + + public boolean isVisible() { + return visible; + } + + public InputControlState getState() { + return state; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java new file mode 100644 index 00000000..39829447 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java @@ -0,0 +1,52 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class InputControlOption { + @Expose + private String label; + @Expose + private String value; + @Expose + private boolean selected; + + public String getLabel() { + return label; + } + + public boolean isSelected() { + return selected; + } + + public String getValue() { + return value; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java new file mode 100644 index 00000000..36a21a34 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.Collections; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class InputControlResponse { + + @Expose + @SerializedName(value = "inputControl") + private List mControls = Collections.emptyList(); + + public List getControls() { + return mControls; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java new file mode 100644 index 00000000..4e2586fe --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java @@ -0,0 +1,68 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class InputControlState { + + @Expose + private String id; + @Expose + private String uri; + @Expose + private String value; + @Expose + private String error; + @Expose + private Set options = Collections.emptySet(); + + public String getError() { + return error; + } + + public String getId() { + return id; + } + + public Set getOptions() { + return options; + } + + public String getUri() { + return uri; + } + + public String getValue() { + return value; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java new file mode 100644 index 00000000..4e8a6688 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java @@ -0,0 +1,82 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ValidationRule { + @Expose + private String type; + @Expose + private String errorMessage; + @Expose + private String value; + + public String getErrorMessage() { + return errorMessage; + } + + public String getType() { + return type; + } + + public String getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ValidationRule that = (ValidationRule) o; + + if (type != null ? !type.equals(that.type) : that.type != null) return false; + if (errorMessage != null ? !errorMessage.equals(that.errorMessage) : that.errorMessage != null) + return false; + return !(value != null ? !value.equals(that.value) : that.value != null); + } + + @Override + public int hashCode() { + int result = type != null ? type.hashCode() : 0; + result = 31 * result + (errorMessage != null ? errorMessage.hashCode() : 0); + result = 31 * result + (value != null ? value.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "ValidationRule{" + + "errorMessage='" + errorMessage + '\'' + + ", type='" + type + '\'' + + ", value='" + value + '\'' + + '}'; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java index 0e639913..5f42226a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java @@ -26,7 +26,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ public final class ExportResourceResponse { private final ExportInput mExportInput; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java index 246951ba..50c313d3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java @@ -37,6 +37,7 @@ public static Gson create() { gsonBuilder.excludeFieldsWithoutExposeAnnotation(); gsonBuilder.disableHtmlEscaping(); gsonBuilder.registerTypeAdapterFactory(new ReportLookupResponseTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new InputControlResponseTypeAdapterFactory()); return gsonBuilder.create(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java new file mode 100644 index 00000000..810fccc0 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java @@ -0,0 +1,119 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.type; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class InputControlResponseTypeAdapterFactory extends CustomizedTypeAdapterFactory { + private static final String[] RULE_TYPES = {"dateTimeFormatValidationRule", "mandatoryValidationRule"}; + + public InputControlResponseTypeAdapterFactory() { + super(InputControlResponse.class); + } + + @Override + protected JsonElement afterRead(JsonElement deserialized) { + JsonObject jsonObject = deserialized.getAsJsonObject(); + JsonArray controls = jsonObject.getAsJsonArray("inputControl"); + if (controls != null) { + int count = controls.size(); + JsonObject jsonControl; + + for (int i = 0; i < count; i++) { + jsonControl = controls.get(i).getAsJsonObject(); + unwrapDependencies(jsonControl, "masterDependencies"); + unwrapDependencies(jsonControl, "slaveDependencies"); + unwrapValidationRule(jsonControl); + } + } + return jsonObject; + } + + private void unwrapValidationRule(JsonObject jsonControl) { + JsonArray rules = jsonControl.getAsJsonArray("validationRules"); + if (rules != null) { + int count = rules.size(); + + JsonObject rule, newRule; + JsonArray tmpArray = new JsonArray(); + for (int i = 0; i < count; i++) { + rule = rules.get(i).getAsJsonObject(); + newRule = unwrapRule(rule); + tmpArray.add(newRule); + } + jsonControl.remove("validationRules"); + jsonControl.add("validationRules", tmpArray); + } + } + + private JsonObject unwrapRule(JsonObject rule) { + return defineRuleType(rule); + } + + private JsonObject defineRuleType(JsonObject rule) { + JsonObject tmp = null; + for (String type : RULE_TYPES) { + tmp = rule.getAsJsonObject(type); + if (tmp != null) { + tmp.addProperty("type", type); + defineRuleValue(tmp); + break; + } + } + + if (tmp == null) { + throw new IllegalStateException("Failed to define type for validation rule: " + rule); + } + + return tmp; + } + + private void defineRuleValue(JsonObject tmp) { + String type = tmp.get("type").getAsString(); + if (type.equals("dateTimeFormatValidationRule")) { + String format = tmp.get("format").getAsString(); + tmp.remove("format"); + tmp.addProperty("value", format); + } + } + + private void unwrapDependencies(JsonObject jsonControl, String key) { + JsonObject jsonMasterDep; + JsonArray tempArray; + jsonMasterDep = jsonControl.getAsJsonObject(key); + if (jsonMasterDep != null) { + tempArray = jsonMasterDep.getAsJsonArray("controlId"); + jsonControl.remove(key); + jsonControl.add(key, tempArray); + } + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java new file mode 100644 index 00000000..2fc85a7b --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java @@ -0,0 +1,32 @@ +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class InputControlOptionTest { + @Test + @Parameters({ + "label", + "value", + "selected", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = InputControlOption.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java new file mode 100644 index 00000000..85bc3785 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java @@ -0,0 +1,83 @@ +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.Gson; +import com.google.gson.annotations.Expose; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; + +import org.junit.Test; + +import java.lang.reflect.Field; +import java.util.Set; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class InputControlResponseTest { + + Gson mGson = GsonFactory.create(); + + @Test + public void shouldHaveExposeAnnotationForFieldControls() throws NoSuchFieldException { + Field field = InputControlResponse.class.getDeclaredField("mControls"); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void valuesFieldShouldHaveSerializedNameAnnotationForFieldControls() throws NoSuchFieldException { + Field field = InputControlResponse.class.getDeclaredField("mControls"); + assertThat(field, hasSerializedName("inputControl")); + } + + @Test + public void shouldProperlyAdaptMasterDependencies() { + String json = "{\"inputControl\" : [ {\"masterDependencies\":{\"controlId\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}}]}"; + InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + + InputControl inputControl = response.getControls().get(0); + Set deps = inputControl.getMasterDependencies(); + + assertThat(deps, hasItem("Cascading_state_multi_select")); + } + + @Test + public void shouldProperlyAdaptSlaveDependencies() { + String json = "{\"inputControl\" : [ {\"slaveDependencies\":{\"controlId\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}}]}"; + InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + + InputControl inputControl = response.getControls().get(0); + Set deps = inputControl.getSlaveDependencies(); + + assertThat(deps, hasItem("Cascading_state_multi_select")); + } + + @Test + public void shouldProperlyAdaptDateTimeValidationRule() { + String json = "{\"inputControl\" : [ {\"validationRules\" : [ { \"dateTimeFormatValidationRule\" : { \"errorMessage\" : \"This field is mandatory so you must enter data.\", \"format\": \"YYYY-mm-dd\" } }]} ]}"; + InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + + InputControl inputControl = response.getControls().get(0); + ValidationRule rule = (ValidationRule) inputControl.getValidationRules().toArray()[0]; + + assertThat(rule.getErrorMessage(), is("This field is mandatory so you must enter data.")); + assertThat(rule.getType(), is("dateTimeFormatValidationRule")); + assertThat(rule.getValue(), is("YYYY-mm-dd")); + } + @Test + public void shouldProperlyAdaptMandatoryValidationRule() { + String json = "{\"inputControl\" : [ {\"validationRules\" : [ { \"mandatoryValidationRule\" : { \"errorMessage\" : \"This field is mandatory so you must enter data.\" } }]} ]}"; + InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + + InputControl inputControl = response.getControls().get(0); + ValidationRule rule = (ValidationRule) inputControl.getValidationRules().toArray()[0]; + + assertThat(rule.getErrorMessage(), is("This field is mandatory so you must enter data.")); + assertThat(rule.getType(), is("mandatoryValidationRule")); + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java new file mode 100644 index 00000000..a744cae3 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java @@ -0,0 +1,33 @@ +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class InputControlStateTest { + @Test + @Parameters({ + "id", + "uri", + "value", + "error", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = InputControlState.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java new file mode 100644 index 00000000..d531b5f8 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java @@ -0,0 +1,40 @@ +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class InputControlTest { + @Test + @Parameters({ + "id", + "label", + "mandatory", + "readOnly", + "type", + "uri", + "visible", + "masterDependencies", + "slaveDependencies", + "validationRules", + "state", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = InputControl.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java new file mode 100644 index 00000000..9867abeb --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java @@ -0,0 +1,32 @@ +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ValidationRuleTest { + @Test + @Parameters({ + "type", + "errorMessage", + "value", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ValidationRule.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file From 7e1106644654fb69e2270a2de1c90cc46f4f442f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 13:49:21 +0300 Subject: [PATCH 072/457] Implementing get input controls API --- .../android/sdk/network/api/BaseBuilder.java | 4 +- .../sdk/network/api/InputControlRestApi.java | 56 ++++++ ...nputControlResponseTypeAdapterFactory.java | 13 +- .../control/InputControlResponseTest.java | 4 +- .../api/InputControlRestApiTest.java | 67 ++++++++ .../integration/api/utils/JrsMetadata.java | 160 ++++++++++++++++++ .../api/utils/TestAuthenticator.java | 57 +++++++ 7 files changed, 344 insertions(+), 17 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index 98962f44..333ede41 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -34,7 +34,6 @@ * @since 2.0 */ abstract class BaseBuilder { - private final String mBaseUrl; private final RestAdapter.Builder mRestAdapterBuilder; private RestApiLog mLog = RestApiLog.NONE; private RestApiLogLevel mLogLevel = RestApiLogLevel.NONE; @@ -43,10 +42,9 @@ public BaseBuilder(String baseUrl){ if (baseUrl == null || baseUrl.length() == 0) { throw new IllegalArgumentException("Base url should not be null or empty"); } - mBaseUrl = baseUrl; mRestAdapterBuilder = new RestAdapter.Builder(); - mRestAdapterBuilder.setEndpoint(mBaseUrl); + mRestAdapterBuilder.setEndpoint(baseUrl); mRestAdapterBuilder.setErrorHandler(new retrofit.ErrorHandler() { @Override @SuppressWarnings("unchecked") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java new file mode 100644 index 00000000..ddd05504 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -0,0 +1,56 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; + +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.Path; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface InputControlRestApi { + + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reports{reportUnitURI}/inputControls") + InputControlResponse requestInputControls(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + + final class Builder extends AuthBaseBuilder { + public Builder(String baseUrl, String cookie) { + super(baseUrl, cookie); + } + + @Override + InputControlRestApi createApi() { + return getDefaultBuilder().build().create(InputControlRestApi.class); + } + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java index 810fccc0..b56eb329 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java @@ -50,8 +50,6 @@ protected JsonElement afterRead(JsonElement deserialized) { for (int i = 0; i < count; i++) { jsonControl = controls.get(i).getAsJsonObject(); - unwrapDependencies(jsonControl, "masterDependencies"); - unwrapDependencies(jsonControl, "slaveDependencies"); unwrapValidationRule(jsonControl); } } @@ -106,14 +104,5 @@ private void defineRuleValue(JsonObject tmp) { } } - private void unwrapDependencies(JsonObject jsonControl, String key) { - JsonObject jsonMasterDep; - JsonArray tempArray; - jsonMasterDep = jsonControl.getAsJsonObject(key); - if (jsonMasterDep != null) { - tempArray = jsonMasterDep.getAsJsonArray("controlId"); - jsonControl.remove(key); - jsonControl.add(key, tempArray); - } - } + } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java index 85bc3785..894cb371 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java @@ -37,7 +37,7 @@ public void valuesFieldShouldHaveSerializedNameAnnotationForFieldControls() thro @Test public void shouldProperlyAdaptMasterDependencies() { - String json = "{\"inputControl\" : [ {\"masterDependencies\":{\"controlId\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}}]}"; + String json = "{\"inputControl\" : [ {\"masterDependencies\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}]}"; InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); InputControl inputControl = response.getControls().get(0); @@ -48,7 +48,7 @@ public void shouldProperlyAdaptMasterDependencies() { @Test public void shouldProperlyAdaptSlaveDependencies() { - String json = "{\"inputControl\" : [ {\"slaveDependencies\":{\"controlId\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}}]}"; + String json = "{\"inputControl\" : [ {\"slaveDependencies\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}]}"; InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); InputControl inputControl = response.getControls().get(0); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java new file mode 100644 index 00000000..f8ef1aa9 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -0,0 +1,67 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api; + +import com.jaspersoft.android.sdk.network.api.InputControlRestApi; +import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNot.not; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class InputControlRestApiTest { + + private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo(); + private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private InputControlRestApi mRestApi; + + @Before + public void setup() { + mAuthenticator.authorize(); + String cookie = mAuthenticator.getCookie(); + mRestApi = new InputControlRestApi.Builder(mMetadata.getServerUrl(), cookie) + .setLog(TestLogger.get(this)) + .setLogLevel(RestApiLogLevel.FULL) + .build(); + } + + @Test + public void shouldProvideInputControlsList() { + InputControlResponse response = mRestApi.requestInputControls("/Reports/1._Geographic_Results_by_Segment_Report"); + assertThat(response.getControls(), is(not(empty()))); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java new file mode 100644 index 00000000..85bb0077 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java @@ -0,0 +1,160 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api.utils; + +import java.net.MalformedURLException; +import java.net.URL; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class JrsMetadata { + + private final String organization; + private final String serverUrl; + private final String username; + private final String password; + + private JrsMetadata(Builder builder) { + this.organization = builder.organization; + this.serverUrl = builder.serverUrl; + this.username = builder.username; + this.password = builder.password; + } + + public static JrsMetadata createMobileDemo() { + return builder() + .setOrganization("organization_1") + .setServerUrl("http://mobiledemo.jaspersoft.com/jasperserver-pro") + .setUsername("joeuser") + .setPassword("joeuser") + .build(); + } + + public static Builder builder() { + return new Builder(); + } + + public String getOrganization() { + return organization; + } + + public String getServerUrl() { + return serverUrl; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + @Override + public String toString() { + return "JrsMetadata{" + + ", organization='" + organization + '\'' + + ", serverUrl='" + serverUrl + '\'' + + ", username='" + username + '\'' + + ", password='" + password + '\'' + + '}'; + } + + public static class Builder { + private String organization; + private String serverUrl; + private String username; + private String password; + + + public Builder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public Builder setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + return this; + } + + public Builder setUsername(String username) { + this.username = username; + return this; + } + + public Builder setPassword(String pass) { + this.password = pass; + return this; + } + + public JrsMetadata build() { + checkValues(); + return new JrsMetadata(this); + } + + private void checkValues() { + assertPropertyNotNull(organization, "organization"); + assertPropertyNotEmpty(serverUrl, "serverUrl"); + assertPropertyNotEmpty(username, "username"); + assertPropertyNotEmpty(password, "password"); + serverUrl = trimUrl(serverUrl); + try { + new URL(serverUrl); + } catch (MalformedURLException e) { + throw new IllegalStateException(e); + } + } + + private void assertPropertyNotNull(String property, String propertyName) { + if (property == null) { + throw new IllegalStateException( + propertyName + " invalid should not be: " + String.valueOf(property)); + } + } + + private void assertPropertyNotEmpty(String property, String propertyName) { + if (isEmpty(property)) { + throw new IllegalStateException( + propertyName + " invalid should not be: " + String.valueOf(property)); + } + } + + private static String trimUrl(String url) { + if (!isEmpty(url) && url.endsWith("/")) { + url = url.substring(0, url.length() - 1); + } + return url; + } + + private static boolean isEmpty(String str) { + if (str == null || str.trim().length() == 0) + return true; + else + return false; + } + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java new file mode 100644 index 00000000..e35f304c --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java @@ -0,0 +1,57 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api.utils; + +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class TestAuthenticator { + + private final JrsMetadata mJrsMetadata; + private AuthResponse mAuthResponse; + + public TestAuthenticator(JrsMetadata jrsMetadata) { + mJrsMetadata = jrsMetadata; + } + + public static TestAuthenticator newInstance(JrsMetadata metadata) { + return new TestAuthenticator(metadata); + } + + public void authorize() { + if (mAuthResponse == null) { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mJrsMetadata.getServerUrl()).build(); + mAuthResponse = restApi.authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null); + } + } + + public String getCookie() { + return mAuthResponse.getToken(); + } +} From dc86924902fad7764d6d57eb5276ea4596bcd823 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 14:13:38 +0300 Subject: [PATCH 073/457] Implementing get input controls initial values API --- .../sdk/network/api/InputControlRestApi.java | 6 +++ .../control/InputControlValueResponse.java | 46 +++++++++++++++++++ .../api/InputControlRestApiTest.java | 7 +++ 3 files changed, 59 insertions(+) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlValueResponse.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index ddd05504..4115eab2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; import retrofit.http.GET; import retrofit.http.Headers; @@ -43,6 +44,11 @@ public interface InputControlRestApi { @GET("/rest_v2/reports{reportUnitURI}/inputControls") InputControlResponse requestInputControls(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reports{reportUnitURI}/inputControls/values") + InputControlValueResponse requestInputControlsInitialValues(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlValueResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlValueResponse.java new file mode 100644 index 00000000..5827f8e3 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlValueResponse.java @@ -0,0 +1,46 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.Collections; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class InputControlValueResponse { + + @Expose + @SerializedName(value = "inputControlState") + private List values = Collections.emptyList(); + + public List getValues() { + return values; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index f8ef1aa9..4ba1bcc6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.api.InputControlRestApi; import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -64,4 +65,10 @@ public void shouldProvideInputControlsList() { InputControlResponse response = mRestApi.requestInputControls("/Reports/1._Geographic_Results_by_Segment_Report"); assertThat(response.getControls(), is(not(empty()))); } + + @Test + public void shouldProvideInitialInputControlsValues() { + InputControlValueResponse response = mRestApi.requestInputControlsInitialValues("/Reports/1._Geographic_Results_by_Segment_Report"); + assertThat(response.getValues(), is(not(empty()))); + } } From b4db2e57d313a782ef279dc33299650c9de8cade Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 14:16:26 +0300 Subject: [PATCH 074/457] Separating impl from interface for 'InputControlRestApi' --- .../sdk/network/api/InputControlRestApi.java | 14 +--- .../network/api/InputControlRestApiImpl.java | 72 +++++++++++++++++++ 2 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 4115eab2..e386702b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -29,10 +29,6 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; -import retrofit.http.GET; -import retrofit.http.Headers; -import retrofit.http.Path; - /** * @author Tom Koptel * @since 2.0 @@ -40,14 +36,10 @@ public interface InputControlRestApi { @NonNull - @Headers("Accept: application/json") - @GET("/rest_v2/reports{reportUnitURI}/inputControls") - InputControlResponse requestInputControls(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + InputControlResponse requestInputControls(@NonNull String reportUri); @NonNull - @Headers("Accept: application/json") - @GET("/rest_v2/reports{reportUnitURI}/inputControls/values") - InputControlValueResponse requestInputControlsInitialValues(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { @@ -56,7 +48,7 @@ public Builder(String baseUrl, String cookie) { @Override InputControlRestApi createApi() { - return getDefaultBuilder().build().create(InputControlRestApi.class); + return new InputControlRestApiImpl(getDefaultBuilder().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java new file mode 100644 index 00000000..d531c0a4 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -0,0 +1,72 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; + +import retrofit.RestAdapter; +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.Path; + +/** + * @author Tom Koptel + * @since 2.2 + */ +final class InputControlRestApiImpl implements InputControlRestApi { + private final RestApi mRestApi; + + + InputControlRestApiImpl(RestAdapter restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } + + @NonNull + @Override + public InputControlResponse requestInputControls(@NonNull String reportUri) { + return mRestApi.requestInputControls(reportUri); + } + + @NonNull + @Override + public InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri) { + return mRestApi.requestInputControlsInitialValues(reportUri); + } + + private interface RestApi { + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reports{reportUnitURI}/inputControls") + InputControlResponse requestInputControls(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + + @NonNull + @Headers("Accept: application/json") + @GET("/rest_v2/reports{reportUnitURI}/inputControls/values") + InputControlValueResponse requestInputControlsInitialValues(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + } +} From e550a2fb45bbed6ff239f809348f4b4cb05e2376 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 14:53:01 +0300 Subject: [PATCH 075/457] Add exclude state and fresh data flags for input controls API --- .../sdk/network/api/InputControlRestApi.java | 16 ++++++++++ .../network/api/InputControlRestApiImpl.java | 26 ++++++++++++---- .../api/InputControlRestApiTest.java | 30 ++++++++++++++++--- .../integration/api/utils/JrsMetadata.java | 9 ++++++ 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index e386702b..898dd972 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -26,6 +26,7 @@ import android.support.annotation.NonNull; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; @@ -38,9 +39,24 @@ public interface InputControlRestApi { @NonNull InputControlResponse requestInputControls(@NonNull String reportUri); + /** + * Returns input controls for associated response. Options can be excluded by additional argument. + * + * ATTENTION: Exclude flag works only on JRS instances 6.0+ + * + * @param reportUri uri of report + * @param excludeState exclude field state which incorporates options values for control + * @return response object which wraps {@link InputControl} collection + */ + @NonNull + InputControlResponse requestInputControls(@NonNull String reportUri, boolean excludeState); + @NonNull InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri); + @NonNull + InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri, boolean freshData); + final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { super(baseUrl, cookie); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index d531c0a4..06f79302 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -33,6 +33,7 @@ import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.Path; +import retrofit.http.Query; /** * @author Tom Koptel @@ -41,7 +42,6 @@ final class InputControlRestApiImpl implements InputControlRestApi { private final RestApi mRestApi; - InputControlRestApiImpl(RestAdapter restAdapter) { mRestApi = restAdapter.create(RestApi.class); } @@ -49,24 +49,40 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override public InputControlResponse requestInputControls(@NonNull String reportUri) { - return mRestApi.requestInputControls(reportUri); + return mRestApi.requestInputControls(reportUri, null); + } + + @NonNull + @Override + public InputControlResponse requestInputControls(@NonNull String reportUri, boolean excludeState) { + return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); } @NonNull @Override public InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri) { - return mRestApi.requestInputControlsInitialValues(reportUri); + return mRestApi.requestInputControlsInitialValues(reportUri, false); + } + + @NonNull + @Override + public InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri, boolean freshData) { + return mRestApi.requestInputControlsInitialValues(reportUri, freshData); } private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reports{reportUnitURI}/inputControls") - InputControlResponse requestInputControls(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + InputControlResponse requestInputControls( + @NonNull @Path(value = "reportUnitURI", encode = false) String reportUri, + @Query("exclude") String state); @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reports{reportUnitURI}/inputControls/values") - InputControlValueResponse requestInputControlsInitialValues(@NonNull @Path(value = "reportUnitURI", encode = false) String reportUri); + InputControlValueResponse requestInputControlsInitialValues( + @NonNull @Path(value = "reportUnitURI", encode = false) String reportUri, + @Query("freshData") boolean freshData); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 4ba1bcc6..26c755b1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.api.InputControlRestApi; import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; import com.jaspersoft.android.sdk.test.TestLogger; @@ -38,6 +39,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.IsNot.not; /** @@ -45,8 +48,8 @@ * @since 2.0 */ public class InputControlRestApiTest { - - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo(); + private static final String REPORT_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; + private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); private InputControlRestApi mRestApi; @@ -62,13 +65,32 @@ public void setup() { @Test public void shouldProvideInputControlsList() { - InputControlResponse response = mRestApi.requestInputControls("/Reports/1._Geographic_Results_by_Segment_Report"); + InputControlResponse response = mRestApi.requestInputControls(REPORT_URI); + assertThat(response.getControls(), is(not(empty()))); + InputControl control = response.getControls().get(0); + assertThat(control.getState(), is(notNullValue())); + } + + /** + * TODO: Implement annotation to mark specific API tests. + */ + @Test + public void shouldProvideInputControlsListIfStateExcluded() { + InputControlResponse response = mRestApi.requestInputControls(REPORT_URI, true); assertThat(response.getControls(), is(not(empty()))); + InputControl control = response.getControls().get(0); + assertThat(control.getState(), is(nullValue())); } @Test public void shouldProvideInitialInputControlsValues() { - InputControlValueResponse response = mRestApi.requestInputControlsInitialValues("/Reports/1._Geographic_Results_by_Segment_Report"); + InputControlValueResponse response = mRestApi.requestInputControlsInitialValues(REPORT_URI); + assertThat(response.getValues(), is(not(empty()))); + } + + @Test + public void shouldProvideFreshInitialInputControlsValues() { + InputControlValueResponse response = mRestApi.requestInputControlsInitialValues(REPORT_URI, true); assertThat(response.getValues(), is(not(empty()))); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java index 85bb0077..4969cf71 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java @@ -54,6 +54,15 @@ public static JrsMetadata createMobileDemo() { .build(); } + public static JrsMetadata createMobileDemo2() { + return builder() + .setOrganization("organization_1") + .setServerUrl("http://mobiledemo2.jaspersoft.com/jasperserver-pro") + .setUsername("phoneuser") + .setPassword("phoneuser") + .build(); + } + public static Builder builder() { return new Builder(); } From 2f53903da4633c7099a466d8f313aa2f6856254f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 15:34:08 +0300 Subject: [PATCH 076/457] Add cascading API for input controls --- .../sdk/network/api/InputControlRestApi.java | 27 +- .../network/api/InputControlRestApiImpl.java | 33 + .../control/InputControlResponseTest.java | 15 + .../test/resources/json/all_resources.json | 7908 ++++++++++++++++- 4 files changed, 7910 insertions(+), 73 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 898dd972..bd934595 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -28,8 +28,12 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import java.util.Map; +import java.util.Set; + /** * @author Tom Koptel * @since 2.0 @@ -55,7 +59,28 @@ public interface InputControlRestApi { InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri); @NonNull - InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri, boolean freshData); + InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri, + boolean freshData); + @NonNull + InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues); + + /** + * Provides values for specified controls. This API helpful to + * delegate cascading resolving for the server, also should handle non-cascading cases + * + * @param reportUri uri of report + * @param controlsId collection of controls ids + * @param controlsValues collection of associated parameters client has provided + * @param freshData whether data should be retrieved from cache or not + * @return response object which wraps {@link InputControlState} collection + */ + @NonNull + InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues, + boolean freshData); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 06f79302..719af21c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -25,13 +25,19 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.text.TextUtils; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import java.util.Map; +import java.util.Set; + import retrofit.RestAdapter; +import retrofit.http.Body; import retrofit.http.GET; import retrofit.http.Headers; +import retrofit.http.POST; import retrofit.http.Path; import retrofit.http.Query; @@ -70,6 +76,24 @@ public InputControlValueResponse requestInputControlsInitialValues(@NonNull Stri return mRestApi.requestInputControlsInitialValues(reportUri, freshData); } + @NonNull + @Override + public InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues) { + return requestInputControlsValues(reportUri, controlsId, controlsValues, false); + } + + @NonNull + @Override + public InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues, + boolean freshData) { + String ids = TextUtils.join(";", controlsId); + return mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + } + private interface RestApi { @NonNull @Headers("Accept: application/json") @@ -84,5 +108,14 @@ InputControlResponse requestInputControls( InputControlValueResponse requestInputControlsInitialValues( @NonNull @Path(value = "reportUnitURI", encode = false) String reportUri, @Query("freshData") boolean freshData); + + @NonNull + @Headers("Accept: application/json") + @POST("/rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") + InputControlValueResponse requestInputControlsValues( + @NonNull @Path(value = "reportUnitURI", encode = false) String reportUri, + @NonNull @Path(value = "controlsId", encode = false) String ids, + @NonNull @Body Map> controlsValues, + @Query("freshData") boolean freshData); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java index 894cb371..30c7dcfb 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java @@ -7,6 +7,9 @@ import org.junit.Test; import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; import java.util.Set; import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; @@ -80,4 +83,16 @@ public void shouldProperlyAdaptMandatoryValidationRule() { assertThat(rule.getErrorMessage(), is("This field is mandatory so you must enter data.")); assertThat(rule.getType(), is("mandatoryValidationRule")); } + + @Test + public void test() { + Map> map = new HashMap>(){{ + put("key", new HashSet(){{ + add("1"); + }}); + }}; + + String a = mGson.toJson(map); + assertThat(a, is("{\"key\": [\"1\"]}")); + } } \ No newline at end of file diff --git a/client-network/src/test/resources/json/all_resources.json b/client-network/src/test/resources/json/all_resources.json index 7cc3df21..96ff0fa0 100644 --- a/client-network/src/test/resources/json/all_resources.json +++ b/client-network/src/test/resources/json/all_resources.json @@ -1,83 +1,7847 @@ { - "resourceLookup": [ + "inputControlState": [ { - "version": 2, - "permissionMask": 1, - "creationDate": "2015-06-05T07:21:11", - "updateDate": "2014-05-14T17:38:49", - "label": "01. Geographic Results by Segment", - "description": "Sample HTML5 multi-axis column chart from Domain showing Sales, Units, and $ Per Square Foot by Country and Store Type with various filters", - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment", - "resourceType": "adhocDataView" + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", + "id": "sales__product__product_name_1", + "options": [ + { + "selected": false, + "label": "ADJ Rosy Sunglasses", + "value": "ADJ Rosy Sunglasses" + }, + { + "selected": false, + "label": "Akron City Map", + "value": "Akron City Map" + }, + { + "selected": false, + "label": "Akron Eyeglass Screwdriver", + "value": "Akron Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "American Beef Bologna", + "value": "American Beef Bologna" + }, + { + "selected": false, + "label": "American Chicken Hot Dogs", + "value": "American Chicken Hot Dogs" + }, + { + "selected": false, + "label": "American Cole Slaw", + "value": "American Cole Slaw" + }, + { + "selected": false, + "label": "American Corned Beef", + "value": "American Corned Beef" + }, + { + "selected": false, + "label": "American Foot-Long Hot Dogs", + "value": "American Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "American Low Fat Bologna", + "value": "American Low Fat Bologna" + }, + { + "selected": false, + "label": "American Low Fat Cole Slaw", + "value": "American Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "American Pimento Loaf", + "value": "American Pimento Loaf" + }, + { + "selected": false, + "label": "American Potato Salad", + "value": "American Potato Salad" + }, + { + "selected": false, + "label": "American Roasted Chicken", + "value": "American Roasted Chicken" + }, + { + "selected": false, + "label": "American Sliced Chicken", + "value": "American Sliced Chicken" + }, + { + "selected": false, + "label": "American Sliced Ham", + "value": "American Sliced Ham" + }, + { + "selected": false, + "label": "American Sliced Turkey", + "value": "American Sliced Turkey" + }, + { + "selected": false, + "label": "American Turkey Hot Dogs", + "value": "American Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Amigo Lox", + "value": "Amigo Lox" + }, + { + "selected": false, + "label": "Amigo Scallops", + "value": "Amigo Scallops" + }, + { + "selected": false, + "label": "Applause Canned Mixed Fruit", + "value": "Applause Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Applause Canned Peaches", + "value": "Applause Canned Peaches" + }, + { + "selected": false, + "label": "Atomic Bubble Gum", + "value": "Atomic Bubble Gum" + }, + { + "selected": false, + "label": "Atomic Malted Milk Balls", + "value": "Atomic Malted Milk Balls" + }, + { + "selected": false, + "label": "Atomic Mint Chocolate Bar", + "value": "Atomic Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Atomic Mints", + "value": "Atomic Mints" + }, + { + "selected": false, + "label": "Atomic Semi-Sweet Chocolate Bar", + "value": "Atomic Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Atomic Spicy Mints", + "value": "Atomic Spicy Mints" + }, + { + "selected": false, + "label": "Atomic Tasty Candy Bar", + "value": "Atomic Tasty Candy Bar" + }, + { + "selected": false, + "label": "Atomic White Chocolate Bar", + "value": "Atomic White Chocolate Bar" + }, + { + "selected": false, + "label": "BBB Best Apple Butter", + "value": "BBB Best Apple Butter" + }, + { + "selected": false, + "label": "BBB Best Apple Jam", + "value": "BBB Best Apple Jam" + }, + { + "selected": false, + "label": "BBB Best Apple Jelly", + "value": "BBB Best Apple Jelly" + }, + { + "selected": false, + "label": "BBB Best Apple Preserves", + "value": "BBB Best Apple Preserves" + }, + { + "selected": false, + "label": "BBB Best Brown Sugar", + "value": "BBB Best Brown Sugar" + }, + { + "selected": false, + "label": "BBB Best Canola Oil", + "value": "BBB Best Canola Oil" + }, + { + "selected": false, + "label": "BBB Best Chunky Peanut Butter", + "value": "BBB Best Chunky Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best Columbian Coffee", + "value": "BBB Best Columbian Coffee" + }, + { + "selected": false, + "label": "BBB Best Corn Oil", + "value": "BBB Best Corn Oil" + }, + { + "selected": false, + "label": "BBB Best Creamy Peanut Butter", + "value": "BBB Best Creamy Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best Decaf Coffee", + "value": "BBB Best Decaf Coffee" + }, + { + "selected": false, + "label": "BBB Best Extra Chunky Peanut Butter", + "value": "BBB Best Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best French Roast Coffee", + "value": "BBB Best French Roast Coffee" + }, + { + "selected": false, + "label": "BBB Best Grape Jam", + "value": "BBB Best Grape Jam" + }, + { + "selected": false, + "label": "BBB Best Grape Jelly", + "value": "BBB Best Grape Jelly" + }, + { + "selected": false, + "label": "BBB Best Grape Preserves", + "value": "BBB Best Grape Preserves" + }, + { + "selected": false, + "label": "BBB Best Hot Chocolate", + "value": "BBB Best Hot Chocolate" + }, + { + "selected": false, + "label": "BBB Best Low Fat Apple Butter", + "value": "BBB Best Low Fat Apple Butter" + }, + { + "selected": false, + "label": "BBB Best Oregano", + "value": "BBB Best Oregano" + }, + { + "selected": false, + "label": "BBB Best Pepper", + "value": "BBB Best Pepper" + }, + { + "selected": false, + "label": "BBB Best Regular Coffee", + "value": "BBB Best Regular Coffee" + }, + { + "selected": false, + "label": "BBB Best Salt", + "value": "BBB Best Salt" + }, + { + "selected": false, + "label": "BBB Best Sesame Oil", + "value": "BBB Best Sesame Oil" + }, + { + "selected": false, + "label": "BBB Best Strawberry Jam", + "value": "BBB Best Strawberry Jam" + }, + { + "selected": false, + "label": "BBB Best Strawberry Jelly", + "value": "BBB Best Strawberry Jelly" + }, + { + "selected": false, + "label": "BBB Best Strawberry Preserves", + "value": "BBB Best Strawberry Preserves" + }, + { + "selected": false, + "label": "BBB Best Tomato Sauce", + "value": "BBB Best Tomato Sauce" + }, + { + "selected": false, + "label": "BBB Best Vegetable Oil", + "value": "BBB Best Vegetable Oil" + }, + { + "selected": false, + "label": "BBB Best White Sugar", + "value": "BBB Best White Sugar" + }, + { + "selected": false, + "label": "Best Choice Apple Fruit Roll", + "value": "Best Choice Apple Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Avocado Dip", + "value": "Best Choice Avocado Dip" + }, + { + "selected": false, + "label": "Best Choice BBQ Potato Chips", + "value": "Best Choice BBQ Potato Chips" + }, + { + "selected": false, + "label": "Best Choice Beef Jerky", + "value": "Best Choice Beef Jerky" + }, + { + "selected": false, + "label": "Best Choice Buttered Popcorn", + "value": "Best Choice Buttered Popcorn" + }, + { + "selected": false, + "label": "Best Choice Cheese Crackers", + "value": "Best Choice Cheese Crackers" + }, + { + "selected": false, + "label": "Best Choice Cheese Dip", + "value": "Best Choice Cheese Dip" + }, + { + "selected": false, + "label": "Best Choice Chocolate Chip Cookies", + "value": "Best Choice Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Best Choice Chocolate Donuts", + "value": "Best Choice Chocolate Donuts" + }, + { + "selected": false, + "label": "Best Choice Corn Chips", + "value": "Best Choice Corn Chips" + }, + { + "selected": false, + "label": "Best Choice Dried Apples", + "value": "Best Choice Dried Apples" + }, + { + "selected": false, + "label": "Best Choice Dried Apricots", + "value": "Best Choice Dried Apricots" + }, + { + "selected": false, + "label": "Best Choice Dried Dates", + "value": "Best Choice Dried Dates" + }, + { + "selected": false, + "label": "Best Choice Fondue Mix", + "value": "Best Choice Fondue Mix" + }, + { + "selected": false, + "label": "Best Choice Frosted Cookies", + "value": "Best Choice Frosted Cookies" + }, + { + "selected": false, + "label": "Best Choice Frosted Donuts", + "value": "Best Choice Frosted Donuts" + }, + { + "selected": false, + "label": "Best Choice Fudge Brownies", + "value": "Best Choice Fudge Brownies" + }, + { + "selected": false, + "label": "Best Choice Fudge Cookies", + "value": "Best Choice Fudge Cookies" + }, + { + "selected": false, + "label": "Best Choice Golden Raisins", + "value": "Best Choice Golden Raisins" + }, + { + "selected": false, + "label": "Best Choice Graham Crackers", + "value": "Best Choice Graham Crackers" + }, + { + "selected": false, + "label": "Best Choice Grape Fruit Roll", + "value": "Best Choice Grape Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Lemon Cookies", + "value": "Best Choice Lemon Cookies" + }, + { + "selected": false, + "label": "Best Choice Low Fat BBQ Chips", + "value": "Best Choice Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Best Choice Low Fat Chips", + "value": "Best Choice Low Fat Chips" + }, + { + "selected": false, + "label": "Best Choice Low Fat Cookies", + "value": "Best Choice Low Fat Cookies" + }, + { + "selected": false, + "label": "Best Choice Low Fat Popcorn", + "value": "Best Choice Low Fat Popcorn" + }, + { + "selected": false, + "label": "Best Choice Mini Donuts", + "value": "Best Choice Mini Donuts" + }, + { + "selected": false, + "label": "Best Choice No Salt Popcorn", + "value": "Best Choice No Salt Popcorn" + }, + { + "selected": false, + "label": "Best Choice Potato Chips", + "value": "Best Choice Potato Chips" + }, + { + "selected": false, + "label": "Best Choice Raisins", + "value": "Best Choice Raisins" + }, + { + "selected": false, + "label": "Best Choice Raspberry Fruit Roll", + "value": "Best Choice Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Salsa Dip", + "value": "Best Choice Salsa Dip" + }, + { + "selected": false, + "label": "Best Choice Salted Pretzels", + "value": "Best Choice Salted Pretzels" + }, + { + "selected": false, + "label": "Best Choice Sesame Crackers", + "value": "Best Choice Sesame Crackers" + }, + { + "selected": false, + "label": "Best Choice Strawberry Fruit Roll", + "value": "Best Choice Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Sugar Cookies", + "value": "Best Choice Sugar Cookies" + }, + { + "selected": false, + "label": "Best Corn Puffs", + "value": "Best Corn Puffs" + }, + { + "selected": false, + "label": "Best Grits", + "value": "Best Grits" + }, + { + "selected": false, + "label": "Best Oatmeal", + "value": "Best Oatmeal" + }, + { + "selected": false, + "label": "Best Wheat Puffs", + "value": "Best Wheat Puffs" + }, + { + "selected": false, + "label": "Better Beef Soup", + "value": "Better Beef Soup" + }, + { + "selected": false, + "label": "Better Canned Beets", + "value": "Better Canned Beets" + }, + { + "selected": false, + "label": "Better Canned Peas", + "value": "Better Canned Peas" + }, + { + "selected": false, + "label": "Better Canned String Beans", + "value": "Better Canned String Beans" + }, + { + "selected": false, + "label": "Better Canned Tomatos", + "value": "Better Canned Tomatos" + }, + { + "selected": false, + "label": "Better Canned Tuna in Oil", + "value": "Better Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Better Canned Tuna in Water", + "value": "Better Canned Tuna in Water" + }, + { + "selected": false, + "label": "Better Canned Yams", + "value": "Better Canned Yams" + }, + { + "selected": false, + "label": "Better Chicken Noodle Soup", + "value": "Better Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Better Chicken Ramen Soup", + "value": "Better Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Better Chicken Soup", + "value": "Better Chicken Soup" + }, + { + "selected": false, + "label": "Better Creamed Corn", + "value": "Better Creamed Corn" + }, + { + "selected": false, + "label": "Better Fancy Canned Anchovies", + "value": "Better Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Better Fancy Canned Clams", + "value": "Better Fancy Canned Clams" + }, + { + "selected": false, + "label": "Better Fancy Canned Oysters", + "value": "Better Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Better Fancy Canned Sardines", + "value": "Better Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Better Large Canned Shrimp", + "value": "Better Large Canned Shrimp" + }, + { + "selected": false, + "label": "Better Noodle Soup", + "value": "Better Noodle Soup" + }, + { + "selected": false, + "label": "Better Regular Ramen Soup", + "value": "Better Regular Ramen Soup" + }, + { + "selected": false, + "label": "Better Rice Soup", + "value": "Better Rice Soup" + }, + { + "selected": false, + "label": "Better Turkey Noodle Soup", + "value": "Better Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Better Vegetable Soup", + "value": "Better Vegetable Soup" + }, + { + "selected": false, + "label": "Big City Canned Mixed Fruit", + "value": "Big City Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Big City Canned Peaches", + "value": "Big City Canned Peaches" + }, + { + "selected": false, + "label": "Big Time Apple Cinnamon Waffles", + "value": "Big Time Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Big Time Beef TV Dinner", + "value": "Big Time Beef TV Dinner" + }, + { + "selected": false, + "label": "Big Time Blueberry Waffles", + "value": "Big Time Blueberry Waffles" + }, + { + "selected": false, + "label": "Big Time Chicken TV Dinner", + "value": "Big Time Chicken TV Dinner" + }, + { + "selected": false, + "label": "Big Time Fajita French Fries", + "value": "Big Time Fajita French Fries" + }, + { + "selected": false, + "label": "Big Time Frozen Broccoli", + "value": "Big Time Frozen Broccoli" + }, + { + "selected": false, + "label": "Big Time Frozen Carrots", + "value": "Big Time Frozen Carrots" + }, + { + "selected": false, + "label": "Big Time Frozen Cauliflower", + "value": "Big Time Frozen Cauliflower" + }, + { + "selected": false, + "label": "Big Time Frozen Cheese Pizza", + "value": "Big Time Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Breast", + "value": "Big Time Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Thighs", + "value": "Big Time Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Wings", + "value": "Big Time Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Big Time Frozen Corn", + "value": "Big Time Frozen Corn" + }, + { + "selected": false, + "label": "Big Time Frozen Mushroom Pizza", + "value": "Big Time Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Pancakes", + "value": "Big Time Frozen Pancakes" + }, + { + "selected": false, + "label": "Big Time Frozen Peas", + "value": "Big Time Frozen Peas" + }, + { + "selected": false, + "label": "Big Time Frozen Pepperoni Pizza", + "value": "Big Time Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Sausage Pizza", + "value": "Big Time Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Big Time Grape Popsicles", + "value": "Big Time Grape Popsicles" + }, + { + "selected": false, + "label": "Big Time Home Style French Fries", + "value": "Big Time Home Style French Fries" + }, + { + "selected": false, + "label": "Big Time Ice Cream", + "value": "Big Time Ice Cream" + }, + { + "selected": false, + "label": "Big Time Ice Cream Sandwich", + "value": "Big Time Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Big Time Lemon Popsicles", + "value": "Big Time Lemon Popsicles" + }, + { + "selected": false, + "label": "Big Time Lime Popsicles", + "value": "Big Time Lime Popsicles" + }, + { + "selected": false, + "label": "Big Time Low Fat French Fries", + "value": "Big Time Low Fat French Fries" + }, + { + "selected": false, + "label": "Big Time Low Fat Waffles", + "value": "Big Time Low Fat Waffles" + }, + { + "selected": false, + "label": "Big Time Orange Popsicles", + "value": "Big Time Orange Popsicles" + }, + { + "selected": false, + "label": "Big Time Pancake Mix", + "value": "Big Time Pancake Mix" + }, + { + "selected": false, + "label": "Big Time Popsicles", + "value": "Big Time Popsicles" + }, + { + "selected": false, + "label": "Big Time Turkey TV Dinner", + "value": "Big Time Turkey TV Dinner" + }, + { + "selected": false, + "label": "Big Time Waffles", + "value": "Big Time Waffles" + }, + { + "selected": false, + "label": "Bird Call 200 MG Acetominifen", + "value": "Bird Call 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Bird Call 200 MG Ibuprofen", + "value": "Bird Call 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Bird Call Angled Toothbrush", + "value": "Bird Call Angled Toothbrush" + }, + { + "selected": false, + "label": "Bird Call Apricot Shampoo", + "value": "Bird Call Apricot Shampoo" + }, + { + "selected": false, + "label": "Bird Call Buffered Aspirin", + "value": "Bird Call Buffered Aspirin" + }, + { + "selected": false, + "label": "Bird Call Childrens Aspirin", + "value": "Bird Call Childrens Aspirin" + }, + { + "selected": false, + "label": "Bird Call Childrens Cold Remedy", + "value": "Bird Call Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Bird Call Conditioning Shampoo", + "value": "Bird Call Conditioning Shampoo" + }, + { + "selected": false, + "label": "Bird Call Deodorant", + "value": "Bird Call Deodorant" + }, + { + "selected": false, + "label": "Bird Call Dishwasher Detergent", + "value": "Bird Call Dishwasher Detergent" + }, + { + "selected": false, + "label": "Bird Call Extra Moisture Shampoo", + "value": "Bird Call Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Bird Call HCL Nasal Spray", + "value": "Bird Call HCL Nasal Spray" + }, + { + "selected": false, + "label": "Bird Call Laundry Detergent", + "value": "Bird Call Laundry Detergent" + }, + { + "selected": false, + "label": "Bird Call Mint Mouthwash", + "value": "Bird Call Mint Mouthwash" + }, + { + "selected": false, + "label": "Bird Call Multi-Symptom Cold Remedy", + "value": "Bird Call Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Bird Call Silky Smooth Hair Conditioner", + "value": "Bird Call Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Bird Call Tartar Control Toothpaste", + "value": "Bird Call Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Bird Call Toothpaste", + "value": "Bird Call Toothpaste" + }, + { + "selected": false, + "label": "Bird Call Whitening Toothpast", + "value": "Bird Call Whitening Toothpast" + }, + { + "selected": false, + "label": "Black Tie City Map", + "value": "Black Tie City Map" + }, + { + "selected": false, + "label": "Black Tie Eyeglass Screwdriver", + "value": "Black Tie Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Blue Label Beef Soup", + "value": "Blue Label Beef Soup" + }, + { + "selected": false, + "label": "Blue Label Canned Beets", + "value": "Blue Label Canned Beets" + }, + { + "selected": false, + "label": "Blue Label Canned Peas", + "value": "Blue Label Canned Peas" + }, + { + "selected": false, + "label": "Blue Label Canned String Beans", + "value": "Blue Label Canned String Beans" + }, + { + "selected": false, + "label": "Blue Label Canned Tomatos", + "value": "Blue Label Canned Tomatos" + }, + { + "selected": false, + "label": "Blue Label Canned Tuna in Oil", + "value": "Blue Label Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Blue Label Canned Tuna in Water", + "value": "Blue Label Canned Tuna in Water" + }, + { + "selected": false, + "label": "Blue Label Canned Yams", + "value": "Blue Label Canned Yams" + }, + { + "selected": false, + "label": "Blue Label Chicken Noodle Soup", + "value": "Blue Label Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Chicken Ramen Soup", + "value": "Blue Label Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Blue Label Chicken Soup", + "value": "Blue Label Chicken Soup" + }, + { + "selected": false, + "label": "Blue Label Creamed Corn", + "value": "Blue Label Creamed Corn" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Anchovies", + "value": "Blue Label Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Clams", + "value": "Blue Label Fancy Canned Clams" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Oysters", + "value": "Blue Label Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Sardines", + "value": "Blue Label Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Blue Label Large Canned Shrimp", + "value": "Blue Label Large Canned Shrimp" + }, + { + "selected": false, + "label": "Blue Label Noodle Soup", + "value": "Blue Label Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Regular Ramen Soup", + "value": "Blue Label Regular Ramen Soup" + }, + { + "selected": false, + "label": "Blue Label Rice Soup", + "value": "Blue Label Rice Soup" + }, + { + "selected": false, + "label": "Blue Label Turkey Noodle Soup", + "value": "Blue Label Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Vegetable Soup", + "value": "Blue Label Vegetable Soup" + }, + { + "selected": false, + "label": "Blue Medal Egg Substitute", + "value": "Blue Medal Egg Substitute" + }, + { + "selected": false, + "label": "Blue Medal Large Brown Eggs", + "value": "Blue Medal Large Brown Eggs" + }, + { + "selected": false, + "label": "Blue Medal Large Eggs", + "value": "Blue Medal Large Eggs" + }, + { + "selected": false, + "label": "Blue Medal Small Brown Eggs", + "value": "Blue Medal Small Brown Eggs" + }, + { + "selected": false, + "label": "Blue Medal Small Eggs", + "value": "Blue Medal Small Eggs" + }, + { + "selected": false, + "label": "Booker 1% Milk", + "value": "Booker 1% Milk" + }, + { + "selected": false, + "label": "Booker 2% Milk", + "value": "Booker 2% Milk" + }, + { + "selected": false, + "label": "Booker Blueberry Yogurt", + "value": "Booker Blueberry Yogurt" + }, + { + "selected": false, + "label": "Booker Buttermilk", + "value": "Booker Buttermilk" + }, + { + "selected": false, + "label": "Booker Cheese Spread", + "value": "Booker Cheese Spread" + }, + { + "selected": false, + "label": "Booker Chocolate Milk", + "value": "Booker Chocolate Milk" + }, + { + "selected": false, + "label": "Booker Havarti Cheese", + "value": "Booker Havarti Cheese" + }, + { + "selected": false, + "label": "Booker Head Cheese", + "value": "Booker Head Cheese" + }, + { + "selected": false, + "label": "Booker Jack Cheese", + "value": "Booker Jack Cheese" + }, + { + "selected": false, + "label": "Booker Large Curd Cottage Cheese", + "value": "Booker Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Booker Low Fat Cottage Cheese", + "value": "Booker Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Booker Low Fat Sour Cream", + "value": "Booker Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Booker Low Fat String Cheese", + "value": "Booker Low Fat String Cheese" + }, + { + "selected": false, + "label": "Booker Mild Cheddar Cheese", + "value": "Booker Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Booker Muenster Cheese", + "value": "Booker Muenster Cheese" + }, + { + "selected": false, + "label": "Booker Sharp Cheddar Cheese", + "value": "Booker Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Booker Sour Cream", + "value": "Booker Sour Cream" + }, + { + "selected": false, + "label": "Booker Strawberry Yogurt", + "value": "Booker Strawberry Yogurt" + }, + { + "selected": false, + "label": "Booker String Cheese", + "value": "Booker String Cheese" + }, + { + "selected": false, + "label": "Booker Whole Milk", + "value": "Booker Whole Milk" + }, + { + "selected": false, + "label": "Bravo Beef Soup", + "value": "Bravo Beef Soup" + }, + { + "selected": false, + "label": "Bravo Canned Beets", + "value": "Bravo Canned Beets" + }, + { + "selected": false, + "label": "Bravo Canned Peas", + "value": "Bravo Canned Peas" + }, + { + "selected": false, + "label": "Bravo Canned String Beans", + "value": "Bravo Canned String Beans" + }, + { + "selected": false, + "label": "Bravo Canned Tomatos", + "value": "Bravo Canned Tomatos" + }, + { + "selected": false, + "label": "Bravo Canned Tuna in Oil", + "value": "Bravo Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Bravo Canned Tuna in Water", + "value": "Bravo Canned Tuna in Water" + }, + { + "selected": false, + "label": "Bravo Canned Yams", + "value": "Bravo Canned Yams" + }, + { + "selected": false, + "label": "Bravo Chicken Noodle Soup", + "value": "Bravo Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Chicken Ramen Soup", + "value": "Bravo Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Bravo Chicken Soup", + "value": "Bravo Chicken Soup" + }, + { + "selected": false, + "label": "Bravo Creamed Corn", + "value": "Bravo Creamed Corn" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Anchovies", + "value": "Bravo Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Clams", + "value": "Bravo Fancy Canned Clams" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Oysters", + "value": "Bravo Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Sardines", + "value": "Bravo Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Bravo Large Canned Shrimp", + "value": "Bravo Large Canned Shrimp" + }, + { + "selected": false, + "label": "Bravo Noodle Soup", + "value": "Bravo Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Regular Ramen Soup", + "value": "Bravo Regular Ramen Soup" + }, + { + "selected": false, + "label": "Bravo Rice Soup", + "value": "Bravo Rice Soup" + }, + { + "selected": false, + "label": "Bravo Turkey Noodle Soup", + "value": "Bravo Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Vegetable Soup", + "value": "Bravo Vegetable Soup" + }, + { + "selected": false, + "label": "Carlson 1% Milk", + "value": "Carlson 1% Milk" + }, + { + "selected": false, + "label": "Carlson 2% Milk", + "value": "Carlson 2% Milk" + }, + { + "selected": false, + "label": "Carlson Blueberry Yogurt", + "value": "Carlson Blueberry Yogurt" + }, + { + "selected": false, + "label": "Carlson Buttermilk", + "value": "Carlson Buttermilk" + }, + { + "selected": false, + "label": "Carlson Cheese Spread", + "value": "Carlson Cheese Spread" + }, + { + "selected": false, + "label": "Carlson Chocolate Milk", + "value": "Carlson Chocolate Milk" + }, + { + "selected": false, + "label": "Carlson Havarti Cheese", + "value": "Carlson Havarti Cheese" + }, + { + "selected": false, + "label": "Carlson Head Cheese", + "value": "Carlson Head Cheese" + }, + { + "selected": false, + "label": "Carlson Jack Cheese", + "value": "Carlson Jack Cheese" + }, + { + "selected": false, + "label": "Carlson Large Curd Cottage Cheese", + "value": "Carlson Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Carlson Low Fat Cottage Cheese", + "value": "Carlson Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Carlson Low Fat Sour Cream", + "value": "Carlson Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Carlson Low Fat String Cheese", + "value": "Carlson Low Fat String Cheese" + }, + { + "selected": false, + "label": "Carlson Mild Cheddar Cheese", + "value": "Carlson Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Carlson Muenster Cheese", + "value": "Carlson Muenster Cheese" + }, + { + "selected": false, + "label": "Carlson Sharp Cheddar Cheese", + "value": "Carlson Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Carlson Sour Cream", + "value": "Carlson Sour Cream" + }, + { + "selected": false, + "label": "Carlson Strawberry Yogurt", + "value": "Carlson Strawberry Yogurt" + }, + { + "selected": false, + "label": "Carlson String Cheese", + "value": "Carlson String Cheese" + }, + { + "selected": false, + "label": "Carlson Whole Milk", + "value": "Carlson Whole Milk" + }, + { + "selected": false, + "label": "Carrington Apple Cinnamon Waffles", + "value": "Carrington Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Carrington Beef TV Dinner", + "value": "Carrington Beef TV Dinner" + }, + { + "selected": false, + "label": "Carrington Blueberry Waffles", + "value": "Carrington Blueberry Waffles" + }, + { + "selected": false, + "label": "Carrington Chicken TV Dinner", + "value": "Carrington Chicken TV Dinner" + }, + { + "selected": false, + "label": "Carrington Fajita French Fries", + "value": "Carrington Fajita French Fries" + }, + { + "selected": false, + "label": "Carrington Frozen Broccoli", + "value": "Carrington Frozen Broccoli" + }, + { + "selected": false, + "label": "Carrington Frozen Carrots", + "value": "Carrington Frozen Carrots" + }, + { + "selected": false, + "label": "Carrington Frozen Cauliflower", + "value": "Carrington Frozen Cauliflower" + }, + { + "selected": false, + "label": "Carrington Frozen Cheese Pizza", + "value": "Carrington Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Breast", + "value": "Carrington Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Thighs", + "value": "Carrington Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Wings", + "value": "Carrington Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Carrington Frozen Corn", + "value": "Carrington Frozen Corn" + }, + { + "selected": false, + "label": "Carrington Frozen Mushroom Pizza", + "value": "Carrington Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Pancakes", + "value": "Carrington Frozen Pancakes" + }, + { + "selected": false, + "label": "Carrington Frozen Peas", + "value": "Carrington Frozen Peas" + }, + { + "selected": false, + "label": "Carrington Frozen Pepperoni Pizza", + "value": "Carrington Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Sausage Pizza", + "value": "Carrington Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Carrington Grape Popsicles", + "value": "Carrington Grape Popsicles" + }, + { + "selected": false, + "label": "Carrington Home Style French Fries", + "value": "Carrington Home Style French Fries" + }, + { + "selected": false, + "label": "Carrington Ice Cream", + "value": "Carrington Ice Cream" + }, + { + "selected": false, + "label": "Carrington Ice Cream Sandwich", + "value": "Carrington Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Carrington Lemon Popsicles", + "value": "Carrington Lemon Popsicles" + }, + { + "selected": false, + "label": "Carrington Lime Popsicles", + "value": "Carrington Lime Popsicles" + }, + { + "selected": false, + "label": "Carrington Low Fat French Fries", + "value": "Carrington Low Fat French Fries" + }, + { + "selected": false, + "label": "Carrington Low Fat Waffles", + "value": "Carrington Low Fat Waffles" + }, + { + "selected": false, + "label": "Carrington Orange Popsicles", + "value": "Carrington Orange Popsicles" + }, + { + "selected": false, + "label": "Carrington Pancake Mix", + "value": "Carrington Pancake Mix" + }, + { + "selected": false, + "label": "Carrington Popsicles", + "value": "Carrington Popsicles" + }, + { + "selected": false, + "label": "Carrington Turkey TV Dinner", + "value": "Carrington Turkey TV Dinner" + }, + { + "selected": false, + "label": "Carrington Waffles", + "value": "Carrington Waffles" + }, + { + "selected": false, + "label": "CDR Apple Butter", + "value": "CDR Apple Butter" + }, + { + "selected": false, + "label": "CDR Apple Jam", + "value": "CDR Apple Jam" + }, + { + "selected": false, + "label": "CDR Apple Jelly", + "value": "CDR Apple Jelly" + }, + { + "selected": false, + "label": "CDR Apple Preserves", + "value": "CDR Apple Preserves" + }, + { + "selected": false, + "label": "CDR Brown Sugar", + "value": "CDR Brown Sugar" + }, + { + "selected": false, + "label": "CDR Canola Oil", + "value": "CDR Canola Oil" + }, + { + "selected": false, + "label": "CDR Chunky Peanut Butter", + "value": "CDR Chunky Peanut Butter" + }, + { + "selected": false, + "label": "CDR Columbian Coffee", + "value": "CDR Columbian Coffee" + }, + { + "selected": false, + "label": "CDR Corn Oil", + "value": "CDR Corn Oil" + }, + { + "selected": false, + "label": "CDR Creamy Peanut Butter", + "value": "CDR Creamy Peanut Butter" + }, + { + "selected": false, + "label": "CDR Decaf Coffee", + "value": "CDR Decaf Coffee" + }, + { + "selected": false, + "label": "CDR Extra Chunky Peanut Butter", + "value": "CDR Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "CDR French Roast Coffee", + "value": "CDR French Roast Coffee" + }, + { + "selected": false, + "label": "CDR Grape Jam", + "value": "CDR Grape Jam" + }, + { + "selected": false, + "label": "CDR Grape Jelly", + "value": "CDR Grape Jelly" + }, + { + "selected": false, + "label": "CDR Grape Preserves", + "value": "CDR Grape Preserves" + }, + { + "selected": false, + "label": "CDR Hot Chocolate", + "value": "CDR Hot Chocolate" + }, + { + "selected": false, + "label": "CDR Low Fat Apple Butter", + "value": "CDR Low Fat Apple Butter" + }, + { + "selected": false, + "label": "CDR Oregano", + "value": "CDR Oregano" + }, + { + "selected": false, + "label": "CDR Pepper", + "value": "CDR Pepper" + }, + { + "selected": false, + "label": "CDR Regular Coffee", + "value": "CDR Regular Coffee" + }, + { + "selected": false, + "label": "CDR Salt", + "value": "CDR Salt" + }, + { + "selected": false, + "label": "CDR Sesame Oil", + "value": "CDR Sesame Oil" + }, + { + "selected": false, + "label": "CDR Strawberry Jam", + "value": "CDR Strawberry Jam" + }, + { + "selected": false, + "label": "CDR Strawberry Jelly", + "value": "CDR Strawberry Jelly" + }, + { + "selected": false, + "label": "CDR Strawberry Preserves", + "value": "CDR Strawberry Preserves" + }, + { + "selected": false, + "label": "CDR Tomato Sauce", + "value": "CDR Tomato Sauce" + }, + { + "selected": false, + "label": "CDR Vegetable Oil", + "value": "CDR Vegetable Oil" + }, + { + "selected": false, + "label": "CDR White Sugar", + "value": "CDR White Sugar" + }, + { + "selected": false, + "label": "Choice Bubble Gum", + "value": "Choice Bubble Gum" + }, + { + "selected": false, + "label": "Choice Malted Milk Balls", + "value": "Choice Malted Milk Balls" + }, + { + "selected": false, + "label": "Choice Mint Chocolate Bar", + "value": "Choice Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Choice Mints", + "value": "Choice Mints" + }, + { + "selected": false, + "label": "Choice Semi-Sweet Chocolate Bar", + "value": "Choice Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Choice Spicy Mints", + "value": "Choice Spicy Mints" + }, + { + "selected": false, + "label": "Choice Tasty Candy Bar", + "value": "Choice Tasty Candy Bar" + }, + { + "selected": false, + "label": "Choice White Chocolate Bar", + "value": "Choice White Chocolate Bar" + }, + { + "selected": false, + "label": "Club 1% Milk", + "value": "Club 1% Milk" + }, + { + "selected": false, + "label": "Club 2% Milk", + "value": "Club 2% Milk" + }, + { + "selected": false, + "label": "Club Blueberry Yogurt", + "value": "Club Blueberry Yogurt" + }, + { + "selected": false, + "label": "Club Buttermilk", + "value": "Club Buttermilk" + }, + { + "selected": false, + "label": "Club Cheese Spread", + "value": "Club Cheese Spread" + }, + { + "selected": false, + "label": "Club Chocolate Milk", + "value": "Club Chocolate Milk" + }, + { + "selected": false, + "label": "Club Havarti Cheese", + "value": "Club Havarti Cheese" + }, + { + "selected": false, + "label": "Club Head Cheese", + "value": "Club Head Cheese" + }, + { + "selected": false, + "label": "Club Jack Cheese", + "value": "Club Jack Cheese" + }, + { + "selected": false, + "label": "Club Large Curd Cottage Cheese", + "value": "Club Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Club Low Fat Cottage Cheese", + "value": "Club Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Club Low Fat Sour Cream", + "value": "Club Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Club Low Fat String Cheese", + "value": "Club Low Fat String Cheese" + }, + { + "selected": false, + "label": "Club Mild Cheddar Cheese", + "value": "Club Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Club Muenster Cheese", + "value": "Club Muenster Cheese" + }, + { + "selected": false, + "label": "Club Sharp Cheddar Cheese", + "value": "Club Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Club Sour Cream", + "value": "Club Sour Cream" + }, + { + "selected": false, + "label": "Club Strawberry Yogurt", + "value": "Club Strawberry Yogurt" + }, + { + "selected": false, + "label": "Club String Cheese", + "value": "Club String Cheese" + }, + { + "selected": false, + "label": "Club Whole Milk", + "value": "Club Whole Milk" + }, + { + "selected": false, + "label": "Colony Bagels", + "value": "Colony Bagels" + }, + { + "selected": false, + "label": "Colony Blueberry Muffins", + "value": "Colony Blueberry Muffins" + }, + { + "selected": false, + "label": "Colony Cranberry Muffins", + "value": "Colony Cranberry Muffins" + }, + { + "selected": false, + "label": "Colony English Muffins", + "value": "Colony English Muffins" + }, + { + "selected": false, + "label": "Colony Muffins", + "value": "Colony Muffins" + }, + { + "selected": false, + "label": "Colony Pumpernickel Bread", + "value": "Colony Pumpernickel Bread" + }, + { + "selected": false, + "label": "Colony Rye Bread", + "value": "Colony Rye Bread" + }, + { + "selected": false, + "label": "Colony Wheat Bread", + "value": "Colony Wheat Bread" + }, + { + "selected": false, + "label": "Colony White Bread", + "value": "Colony White Bread" + }, + { + "selected": false, + "label": "Colossal Manicotti", + "value": "Colossal Manicotti" + }, + { + "selected": false, + "label": "Colossal Ravioli", + "value": "Colossal Ravioli" + }, + { + "selected": false, + "label": "Colossal Rice Medly", + "value": "Colossal Rice Medly" + }, + { + "selected": false, + "label": "Colossal Spaghetti", + "value": "Colossal Spaghetti" + }, + { + "selected": false, + "label": "Colossal Thai Rice", + "value": "Colossal Thai Rice" + }, + { + "selected": false, + "label": "Consolidated 200 MG Acetominifen", + "value": "Consolidated 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Consolidated 200 MG Ibuprofen", + "value": "Consolidated 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Consolidated Angled Toothbrush", + "value": "Consolidated Angled Toothbrush" + }, + { + "selected": false, + "label": "Consolidated Apricot Shampoo", + "value": "Consolidated Apricot Shampoo" + }, + { + "selected": false, + "label": "Consolidated Buffered Aspirin", + "value": "Consolidated Buffered Aspirin" + }, + { + "selected": false, + "label": "Consolidated Childrens Aspirin", + "value": "Consolidated Childrens Aspirin" + }, + { + "selected": false, + "label": "Consolidated Childrens Cold Remedy", + "value": "Consolidated Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Consolidated Conditioning Shampoo", + "value": "Consolidated Conditioning Shampoo" + }, + { + "selected": false, + "label": "Consolidated Deodorant", + "value": "Consolidated Deodorant" + }, + { + "selected": false, + "label": "Consolidated Dishwasher Detergent", + "value": "Consolidated Dishwasher Detergent" + }, + { + "selected": false, + "label": "Consolidated Extra Moisture Shampoo", + "value": "Consolidated Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Consolidated HCL Nasal Spray", + "value": "Consolidated HCL Nasal Spray" + }, + { + "selected": false, + "label": "Consolidated Laundry Detergent", + "value": "Consolidated Laundry Detergent" + }, + { + "selected": false, + "label": "Consolidated Mint Mouthwash", + "value": "Consolidated Mint Mouthwash" + }, + { + "selected": false, + "label": "Consolidated Multi-Symptom Cold Remedy", + "value": "Consolidated Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Consolidated Silky Smooth Hair Conditioner", + "value": "Consolidated Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Consolidated Tartar Control Toothpaste", + "value": "Consolidated Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Consolidated Toothpaste", + "value": "Consolidated Toothpaste" + }, + { + "selected": false, + "label": "Consolidated Whitening Toothpast", + "value": "Consolidated Whitening Toothpast" + }, + { + "selected": false, + "label": "Cormorant 100 Watt Lightbulb", + "value": "Cormorant 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 25 Watt Lightbulb", + "value": "Cormorant 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 60 Watt Lightbulb", + "value": "Cormorant 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 75 Watt Lightbulb", + "value": "Cormorant 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant AAA-Size Batteries", + "value": "Cormorant AAA-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant AA-Size Batteries", + "value": "Cormorant AA-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant Bees Wax Candles", + "value": "Cormorant Bees Wax Candles" + }, + { + "selected": false, + "label": "Cormorant Copper Cleaner", + "value": "Cormorant Copper Cleaner" + }, + { + "selected": false, + "label": "Cormorant Copper Pot Scrubber", + "value": "Cormorant Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Cormorant Counter Cleaner", + "value": "Cormorant Counter Cleaner" + }, + { + "selected": false, + "label": "Cormorant C-Size Batteries", + "value": "Cormorant C-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant D-Size Batteries", + "value": "Cormorant D-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant Economy Toilet Brush", + "value": "Cormorant Economy Toilet Brush" + }, + { + "selected": false, + "label": "Cormorant Frying Pan", + "value": "Cormorant Frying Pan" + }, + { + "selected": false, + "label": "Cormorant Glass Cleaner", + "value": "Cormorant Glass Cleaner" + }, + { + "selected": false, + "label": "Cormorant Large Sponge", + "value": "Cormorant Large Sponge" + }, + { + "selected": false, + "label": "Cormorant Paper Cups", + "value": "Cormorant Paper Cups" + }, + { + "selected": false, + "label": "Cormorant Paper Plates", + "value": "Cormorant Paper Plates" + }, + { + "selected": false, + "label": "Cormorant Paper Towels", + "value": "Cormorant Paper Towels" + }, + { + "selected": false, + "label": "Cormorant Plastic Forks", + "value": "Cormorant Plastic Forks" + }, + { + "selected": false, + "label": "Cormorant Plastic Knives", + "value": "Cormorant Plastic Knives" + }, + { + "selected": false, + "label": "Cormorant Plastic Spoons", + "value": "Cormorant Plastic Spoons" + }, + { + "selected": false, + "label": "Cormorant Room Freshener", + "value": "Cormorant Room Freshener" + }, + { + "selected": false, + "label": "Cormorant Scented Tissue", + "value": "Cormorant Scented Tissue" + }, + { + "selected": false, + "label": "Cormorant Scented Toilet Tissue", + "value": "Cormorant Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Cormorant Scissors", + "value": "Cormorant Scissors" + }, + { + "selected": false, + "label": "Cormorant Screw Driver", + "value": "Cormorant Screw Driver" + }, + { + "selected": false, + "label": "Cormorant Silver Cleaner", + "value": "Cormorant Silver Cleaner" + }, + { + "selected": false, + "label": "Cormorant Soft Napkins", + "value": "Cormorant Soft Napkins" + }, + { + "selected": false, + "label": "Cormorant Tissues", + "value": "Cormorant Tissues" + }, + { + "selected": false, + "label": "Cormorant Toilet Bowl Cleaner", + "value": "Cormorant Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Cormorant Toilet Paper", + "value": "Cormorant Toilet Paper" + }, + { + "selected": false, + "label": "Curlew Lox", + "value": "Curlew Lox" + }, + { + "selected": false, + "label": "Curlew Scallops", + "value": "Curlew Scallops" + }, + { + "selected": false, + "label": "Cutting Edge Beef Bologna", + "value": "Cutting Edge Beef Bologna" + }, + { + "selected": false, + "label": "Cutting Edge Chicken Hot Dogs", + "value": "Cutting Edge Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Cutting Edge Cole Slaw", + "value": "Cutting Edge Cole Slaw" + }, + { + "selected": false, + "label": "Cutting Edge Corned Beef", + "value": "Cutting Edge Corned Beef" + }, + { + "selected": false, + "label": "Cutting Edge Foot-Long Hot Dogs", + "value": "Cutting Edge Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Cutting Edge Low Fat Bologna", + "value": "Cutting Edge Low Fat Bologna" + }, + { + "selected": false, + "label": "Cutting Edge Low Fat Cole Slaw", + "value": "Cutting Edge Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Cutting Edge Pimento Loaf", + "value": "Cutting Edge Pimento Loaf" + }, + { + "selected": false, + "label": "Cutting Edge Potato Salad", + "value": "Cutting Edge Potato Salad" + }, + { + "selected": false, + "label": "Cutting Edge Roasted Chicken", + "value": "Cutting Edge Roasted Chicken" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Chicken", + "value": "Cutting Edge Sliced Chicken" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Ham", + "value": "Cutting Edge Sliced Ham" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Turkey", + "value": "Cutting Edge Sliced Turkey" + }, + { + "selected": false, + "label": "Cutting Edge Turkey Hot Dogs", + "value": "Cutting Edge Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Denny 100 Watt Lightbulb", + "value": "Denny 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 25 Watt Lightbulb", + "value": "Denny 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 60 Watt Lightbulb", + "value": "Denny 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 75 Watt Lightbulb", + "value": "Denny 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny AAA-Size Batteries", + "value": "Denny AAA-Size Batteries" + }, + { + "selected": false, + "label": "Denny AA-Size Batteries", + "value": "Denny AA-Size Batteries" + }, + { + "selected": false, + "label": "Denny Bees Wax Candles", + "value": "Denny Bees Wax Candles" + }, + { + "selected": false, + "label": "Denny Copper Cleaner", + "value": "Denny Copper Cleaner" + }, + { + "selected": false, + "label": "Denny Copper Pot Scrubber", + "value": "Denny Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Denny Counter Cleaner", + "value": "Denny Counter Cleaner" + }, + { + "selected": false, + "label": "Denny C-Size Batteries", + "value": "Denny C-Size Batteries" + }, + { + "selected": false, + "label": "Denny D-Size Batteries", + "value": "Denny D-Size Batteries" + }, + { + "selected": false, + "label": "Denny Economy Toilet Brush", + "value": "Denny Economy Toilet Brush" + }, + { + "selected": false, + "label": "Denny Frying Pan", + "value": "Denny Frying Pan" + }, + { + "selected": false, + "label": "Denny Glass Cleaner", + "value": "Denny Glass Cleaner" + }, + { + "selected": false, + "label": "Denny Large Sponge", + "value": "Denny Large Sponge" + }, + { + "selected": false, + "label": "Denny Paper Cups", + "value": "Denny Paper Cups" + }, + { + "selected": false, + "label": "Denny Paper Plates", + "value": "Denny Paper Plates" + }, + { + "selected": false, + "label": "Denny Paper Towels", + "value": "Denny Paper Towels" + }, + { + "selected": false, + "label": "Denny Plastic Forks", + "value": "Denny Plastic Forks" + }, + { + "selected": false, + "label": "Denny Plastic Knives", + "value": "Denny Plastic Knives" + }, + { + "selected": false, + "label": "Denny Plastic Spoons", + "value": "Denny Plastic Spoons" + }, + { + "selected": false, + "label": "Denny Room Freshener", + "value": "Denny Room Freshener" + }, + { + "selected": false, + "label": "Denny Scented Tissue", + "value": "Denny Scented Tissue" + }, + { + "selected": false, + "label": "Denny Scented Toilet Tissue", + "value": "Denny Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Denny Scissors", + "value": "Denny Scissors" + }, + { + "selected": false, + "label": "Denny Screw Driver", + "value": "Denny Screw Driver" + }, + { + "selected": false, + "label": "Denny Silver Cleaner", + "value": "Denny Silver Cleaner" + }, + { + "selected": false, + "label": "Denny Soft Napkins", + "value": "Denny Soft Napkins" + }, + { + "selected": false, + "label": "Denny Tissues", + "value": "Denny Tissues" + }, + { + "selected": false, + "label": "Denny Toilet Bowl Cleaner", + "value": "Denny Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Denny Toilet Paper", + "value": "Denny Toilet Paper" + }, + { + "selected": false, + "label": "Discover Manicotti", + "value": "Discover Manicotti" + }, + { + "selected": false, + "label": "Discover Ravioli", + "value": "Discover Ravioli" + }, + { + "selected": false, + "label": "Discover Rice Medly", + "value": "Discover Rice Medly" + }, + { + "selected": false, + "label": "Discover Spaghetti", + "value": "Discover Spaghetti" + }, + { + "selected": false, + "label": "Discover Thai Rice", + "value": "Discover Thai Rice" + }, + { + "selected": false, + "label": "Dollar Monthly Auto Magazine", + "value": "Dollar Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Computer Magazine", + "value": "Dollar Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Fashion Magazine", + "value": "Dollar Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Home Magazine", + "value": "Dollar Monthly Home Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Sports Magazine", + "value": "Dollar Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Dual City Lox", + "value": "Dual City Lox" + }, + { + "selected": false, + "label": "Dual City Scallops", + "value": "Dual City Scallops" + }, + { + "selected": false, + "label": "Ebony Almonds", + "value": "Ebony Almonds" + }, + { + "selected": false, + "label": "Ebony Asparagus", + "value": "Ebony Asparagus" + }, + { + "selected": false, + "label": "Ebony Baby Onion", + "value": "Ebony Baby Onion" + }, + { + "selected": false, + "label": "Ebony Beets", + "value": "Ebony Beets" + }, + { + "selected": false, + "label": "Ebony Broccoli", + "value": "Ebony Broccoli" + }, + { + "selected": false, + "label": "Ebony Canned Peanuts", + "value": "Ebony Canned Peanuts" + }, + { + "selected": false, + "label": "Ebony Cantelope", + "value": "Ebony Cantelope" + }, + { + "selected": false, + "label": "Ebony Cauliflower", + "value": "Ebony Cauliflower" + }, + { + "selected": false, + "label": "Ebony Corn on the Cob", + "value": "Ebony Corn on the Cob" + }, + { + "selected": false, + "label": "Ebony Dried Mushrooms", + "value": "Ebony Dried Mushrooms" + }, + { + "selected": false, + "label": "Ebony Elephant Garlic", + "value": "Ebony Elephant Garlic" + }, + { + "selected": false, + "label": "Ebony Fancy Plums", + "value": "Ebony Fancy Plums" + }, + { + "selected": false, + "label": "Ebony Firm Tofu", + "value": "Ebony Firm Tofu" + }, + { + "selected": false, + "label": "Ebony Fresh Lima Beans", + "value": "Ebony Fresh Lima Beans" + }, + { + "selected": false, + "label": "Ebony Fuji Apples", + "value": "Ebony Fuji Apples" + }, + { + "selected": false, + "label": "Ebony Garlic", + "value": "Ebony Garlic" + }, + { + "selected": false, + "label": "Ebony Golden Delcious Apples", + "value": "Ebony Golden Delcious Apples" + }, + { + "selected": false, + "label": "Ebony Green Pepper", + "value": "Ebony Green Pepper" + }, + { + "selected": false, + "label": "Ebony Honey Dew", + "value": "Ebony Honey Dew" + }, + { + "selected": false, + "label": "Ebony Lemons", + "value": "Ebony Lemons" + }, + { + "selected": false, + "label": "Ebony Lettuce", + "value": "Ebony Lettuce" + }, + { + "selected": false, + "label": "Ebony Limes", + "value": "Ebony Limes" + }, + { + "selected": false, + "label": "Ebony Macintosh Apples", + "value": "Ebony Macintosh Apples" + }, + { + "selected": false, + "label": "Ebony Mandarin Oranges", + "value": "Ebony Mandarin Oranges" + }, + { + "selected": false, + "label": "Ebony Mixed Nuts", + "value": "Ebony Mixed Nuts" + }, + { + "selected": false, + "label": "Ebony Mushrooms", + "value": "Ebony Mushrooms" + }, + { + "selected": false, + "label": "Ebony New Potatos", + "value": "Ebony New Potatos" + }, + { + "selected": false, + "label": "Ebony Onions", + "value": "Ebony Onions" + }, + { + "selected": false, + "label": "Ebony Oranges", + "value": "Ebony Oranges" + }, + { + "selected": false, + "label": "Ebony Party Nuts", + "value": "Ebony Party Nuts" + }, + { + "selected": false, + "label": "Ebony Peaches", + "value": "Ebony Peaches" + }, + { + "selected": false, + "label": "Ebony Plums", + "value": "Ebony Plums" + }, + { + "selected": false, + "label": "Ebony Potatos", + "value": "Ebony Potatos" + }, + { + "selected": false, + "label": "Ebony Prepared Salad", + "value": "Ebony Prepared Salad" + }, + { + "selected": false, + "label": "Ebony Red Delcious Apples", + "value": "Ebony Red Delcious Apples" + }, + { + "selected": false, + "label": "Ebony Red Pepper", + "value": "Ebony Red Pepper" + }, + { + "selected": false, + "label": "Ebony Shitake Mushrooms", + "value": "Ebony Shitake Mushrooms" + }, + { + "selected": false, + "label": "Ebony Squash", + "value": "Ebony Squash" + }, + { + "selected": false, + "label": "Ebony Summer Squash", + "value": "Ebony Summer Squash" + }, + { + "selected": false, + "label": "Ebony Sweet Onion", + "value": "Ebony Sweet Onion" + }, + { + "selected": false, + "label": "Ebony Sweet Peas", + "value": "Ebony Sweet Peas" + }, + { + "selected": false, + "label": "Ebony Tangerines", + "value": "Ebony Tangerines" + }, + { + "selected": false, + "label": "Ebony Tomatos", + "value": "Ebony Tomatos" + }, + { + "selected": false, + "label": "Ebony Walnuts", + "value": "Ebony Walnuts" + }, + { + "selected": false, + "label": "Even Better 1% Milk", + "value": "Even Better 1% Milk" + }, + { + "selected": false, + "label": "Even Better 2% Milk", + "value": "Even Better 2% Milk" + }, + { + "selected": false, + "label": "Even Better Blueberry Yogurt", + "value": "Even Better Blueberry Yogurt" + }, + { + "selected": false, + "label": "Even Better Buttermilk", + "value": "Even Better Buttermilk" + }, + { + "selected": false, + "label": "Even Better Cheese Spread", + "value": "Even Better Cheese Spread" + }, + { + "selected": false, + "label": "Even Better Chocolate Milk", + "value": "Even Better Chocolate Milk" + }, + { + "selected": false, + "label": "Even Better Havarti Cheese", + "value": "Even Better Havarti Cheese" + }, + { + "selected": false, + "label": "Even Better Head Cheese", + "value": "Even Better Head Cheese" + }, + { + "selected": false, + "label": "Even Better Jack Cheese", + "value": "Even Better Jack Cheese" + }, + { + "selected": false, + "label": "Even Better Large Curd Cottage Cheese", + "value": "Even Better Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Even Better Low Fat Cottage Cheese", + "value": "Even Better Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Even Better Low Fat Sour Cream", + "value": "Even Better Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Even Better Low Fat String Cheese", + "value": "Even Better Low Fat String Cheese" + }, + { + "selected": false, + "label": "Even Better Mild Cheddar Cheese", + "value": "Even Better Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Even Better Muenster Cheese", + "value": "Even Better Muenster Cheese" + }, + { + "selected": false, + "label": "Even Better Sharp Cheddar Cheese", + "value": "Even Better Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Even Better Sour Cream", + "value": "Even Better Sour Cream" + }, + { + "selected": false, + "label": "Even Better Strawberry Yogurt", + "value": "Even Better Strawberry Yogurt" + }, + { + "selected": false, + "label": "Even Better String Cheese", + "value": "Even Better String Cheese" + }, + { + "selected": false, + "label": "Even Better Whole Milk", + "value": "Even Better Whole Milk" + }, + { + "selected": false, + "label": "Excellent Apple Drink", + "value": "Excellent Apple Drink" + }, + { + "selected": false, + "label": "Excellent Apple Juice", + "value": "Excellent Apple Juice" + }, + { + "selected": false, + "label": "Excellent Berry Juice", + "value": "Excellent Berry Juice" + }, + { + "selected": false, + "label": "Excellent Cola", + "value": "Excellent Cola" + }, + { + "selected": false, + "label": "Excellent Cranberry Juice", + "value": "Excellent Cranberry Juice" + }, + { + "selected": false, + "label": "Excellent Cream Soda", + "value": "Excellent Cream Soda" + }, + { + "selected": false, + "label": "Excellent Diet Cola", + "value": "Excellent Diet Cola" + }, + { + "selected": false, + "label": "Excellent Diet Soda", + "value": "Excellent Diet Soda" + }, + { + "selected": false, + "label": "Excellent Mango Drink", + "value": "Excellent Mango Drink" + }, + { + "selected": false, + "label": "Excellent Orange Juice", + "value": "Excellent Orange Juice" + }, + { + "selected": false, + "label": "Excellent Strawberry Drink", + "value": "Excellent Strawberry Drink" + }, + { + "selected": false, + "label": "Excel Monthly Auto Magazine", + "value": "Excel Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Computer Magazine", + "value": "Excel Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Fashion Magazine", + "value": "Excel Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Home Magazine", + "value": "Excel Monthly Home Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Sports Magazine", + "value": "Excel Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Fabulous Apple Drink", + "value": "Fabulous Apple Drink" + }, + { + "selected": false, + "label": "Fabulous Apple Juice", + "value": "Fabulous Apple Juice" + }, + { + "selected": false, + "label": "Fabulous Berry Juice", + "value": "Fabulous Berry Juice" + }, + { + "selected": false, + "label": "Fabulous Cola", + "value": "Fabulous Cola" + }, + { + "selected": false, + "label": "Fabulous Cranberry Juice", + "value": "Fabulous Cranberry Juice" + }, + { + "selected": false, + "label": "Fabulous Cream Soda", + "value": "Fabulous Cream Soda" + }, + { + "selected": false, + "label": "Fabulous Diet Cola", + "value": "Fabulous Diet Cola" + }, + { + "selected": false, + "label": "Fabulous Diet Soda", + "value": "Fabulous Diet Soda" + }, + { + "selected": false, + "label": "Fabulous Mango Drink", + "value": "Fabulous Mango Drink" + }, + { + "selected": false, + "label": "Fabulous Orange Juice", + "value": "Fabulous Orange Juice" + }, + { + "selected": false, + "label": "Fabulous Strawberry Drink", + "value": "Fabulous Strawberry Drink" + }, + { + "selected": false, + "label": "Fantastic Bagels", + "value": "Fantastic Bagels" + }, + { + "selected": false, + "label": "Fantastic Blueberry Muffins", + "value": "Fantastic Blueberry Muffins" + }, + { + "selected": false, + "label": "Fantastic Cranberry Muffins", + "value": "Fantastic Cranberry Muffins" + }, + { + "selected": false, + "label": "Fantastic English Muffins", + "value": "Fantastic English Muffins" + }, + { + "selected": false, + "label": "Fantastic Muffins", + "value": "Fantastic Muffins" + }, + { + "selected": false, + "label": "Fantastic Pumpernickel Bread", + "value": "Fantastic Pumpernickel Bread" + }, + { + "selected": false, + "label": "Fantastic Rye Bread", + "value": "Fantastic Rye Bread" + }, + { + "selected": false, + "label": "Fantastic Wheat Bread", + "value": "Fantastic Wheat Bread" + }, + { + "selected": false, + "label": "Fantastic White Bread", + "value": "Fantastic White Bread" + }, + { + "selected": false, + "label": "Fast Apple Fruit Roll", + "value": "Fast Apple Fruit Roll" + }, + { + "selected": false, + "label": "Fast Avocado Dip", + "value": "Fast Avocado Dip" + }, + { + "selected": false, + "label": "Fast BBQ Potato Chips", + "value": "Fast BBQ Potato Chips" + }, + { + "selected": false, + "label": "Fast Beef Jerky", + "value": "Fast Beef Jerky" + }, + { + "selected": false, + "label": "Fast Buttered Popcorn", + "value": "Fast Buttered Popcorn" + }, + { + "selected": false, + "label": "Fast Cheese Crackers", + "value": "Fast Cheese Crackers" + }, + { + "selected": false, + "label": "Fast Cheese Dip", + "value": "Fast Cheese Dip" + }, + { + "selected": false, + "label": "Fast Chocolate Chip Cookies", + "value": "Fast Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Fast Chocolate Donuts", + "value": "Fast Chocolate Donuts" + }, + { + "selected": false, + "label": "Fast Corn Chips", + "value": "Fast Corn Chips" + }, + { + "selected": false, + "label": "Fast Dried Apples", + "value": "Fast Dried Apples" + }, + { + "selected": false, + "label": "Fast Dried Apricots", + "value": "Fast Dried Apricots" + }, + { + "selected": false, + "label": "Fast Dried Dates", + "value": "Fast Dried Dates" + }, + { + "selected": false, + "label": "Fast Fondue Mix", + "value": "Fast Fondue Mix" + }, + { + "selected": false, + "label": "Fast Frosted Cookies", + "value": "Fast Frosted Cookies" + }, + { + "selected": false, + "label": "Fast Frosted Donuts", + "value": "Fast Frosted Donuts" + }, + { + "selected": false, + "label": "Fast Fudge Brownies", + "value": "Fast Fudge Brownies" + }, + { + "selected": false, + "label": "Fast Fudge Cookies", + "value": "Fast Fudge Cookies" + }, + { + "selected": false, + "label": "Fast Golden Raisins", + "value": "Fast Golden Raisins" + }, + { + "selected": false, + "label": "Fast Graham Crackers", + "value": "Fast Graham Crackers" + }, + { + "selected": false, + "label": "Fast Grape Fruit Roll", + "value": "Fast Grape Fruit Roll" + }, + { + "selected": false, + "label": "Fast Lemon Cookies", + "value": "Fast Lemon Cookies" + }, + { + "selected": false, + "label": "Fast Low Fat BBQ Chips", + "value": "Fast Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Fast Low Fat Chips", + "value": "Fast Low Fat Chips" + }, + { + "selected": false, + "label": "Fast Low Fat Cookies", + "value": "Fast Low Fat Cookies" + }, + { + "selected": false, + "label": "Fast Low Fat Popcorn", + "value": "Fast Low Fat Popcorn" + }, + { + "selected": false, + "label": "Fast Mini Donuts", + "value": "Fast Mini Donuts" + }, + { + "selected": false, + "label": "Fast No Salt Popcorn", + "value": "Fast No Salt Popcorn" + }, + { + "selected": false, + "label": "Fast Potato Chips", + "value": "Fast Potato Chips" + }, + { + "selected": false, + "label": "Fast Raisins", + "value": "Fast Raisins" + }, + { + "selected": false, + "label": "Fast Raspberry Fruit Roll", + "value": "Fast Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Fast Salsa Dip", + "value": "Fast Salsa Dip" + }, + { + "selected": false, + "label": "Fast Salted Pretzels", + "value": "Fast Salted Pretzels" + }, + { + "selected": false, + "label": "Fast Sesame Crackers", + "value": "Fast Sesame Crackers" + }, + { + "selected": false, + "label": "Fast Strawberry Fruit Roll", + "value": "Fast Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Fast Sugar Cookies", + "value": "Fast Sugar Cookies" + }, + { + "selected": false, + "label": "Faux Products 200 MG Acetominifen", + "value": "Faux Products 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Faux Products 200 MG Ibuprofen", + "value": "Faux Products 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Faux Products Angled Toothbrush", + "value": "Faux Products Angled Toothbrush" + }, + { + "selected": false, + "label": "Faux Products Apricot Shampoo", + "value": "Faux Products Apricot Shampoo" + }, + { + "selected": false, + "label": "Faux Products Buffered Aspirin", + "value": "Faux Products Buffered Aspirin" + }, + { + "selected": false, + "label": "Faux Products Childrens Aspirin", + "value": "Faux Products Childrens Aspirin" + }, + { + "selected": false, + "label": "Faux Products Childrens Cold Remedy", + "value": "Faux Products Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Faux Products Conditioning Shampoo", + "value": "Faux Products Conditioning Shampoo" + }, + { + "selected": false, + "label": "Faux Products Deodorant", + "value": "Faux Products Deodorant" + }, + { + "selected": false, + "label": "Faux Products Dishwasher Detergent", + "value": "Faux Products Dishwasher Detergent" + }, + { + "selected": false, + "label": "Faux Products Extra Moisture Shampoo", + "value": "Faux Products Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Faux Products HCL Nasal Spray", + "value": "Faux Products HCL Nasal Spray" + }, + { + "selected": false, + "label": "Faux Products Laundry Detergent", + "value": "Faux Products Laundry Detergent" + }, + { + "selected": false, + "label": "Faux Products Mint Mouthwash", + "value": "Faux Products Mint Mouthwash" + }, + { + "selected": false, + "label": "Faux Products Multi-Symptom Cold Remedy", + "value": "Faux Products Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Faux Products Silky Smooth Hair Conditioner", + "value": "Faux Products Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Faux Products Tartar Control Toothpaste", + "value": "Faux Products Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Faux Products Toothpaste", + "value": "Faux Products Toothpaste" + }, + { + "selected": false, + "label": "Faux Products Whitening Toothpast", + "value": "Faux Products Whitening Toothpast" + }, + { + "selected": false, + "label": "Footnote Extra Lean Hamburger", + "value": "Footnote Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Footnote Seasoned Hamburger", + "value": "Footnote Seasoned Hamburger" + }, + { + "selected": false, + "label": "Fort West Apple Fruit Roll", + "value": "Fort West Apple Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Avocado Dip", + "value": "Fort West Avocado Dip" + }, + { + "selected": false, + "label": "Fort West BBQ Potato Chips", + "value": "Fort West BBQ Potato Chips" + }, + { + "selected": false, + "label": "Fort West Beef Jerky", + "value": "Fort West Beef Jerky" + }, + { + "selected": false, + "label": "Fort West Buttered Popcorn", + "value": "Fort West Buttered Popcorn" + }, + { + "selected": false, + "label": "Fort West Cheese Crackers", + "value": "Fort West Cheese Crackers" + }, + { + "selected": false, + "label": "Fort West Cheese Dip", + "value": "Fort West Cheese Dip" + }, + { + "selected": false, + "label": "Fort West Chocolate Chip Cookies", + "value": "Fort West Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Fort West Chocolate Donuts", + "value": "Fort West Chocolate Donuts" + }, + { + "selected": false, + "label": "Fort West Corn Chips", + "value": "Fort West Corn Chips" + }, + { + "selected": false, + "label": "Fort West Dried Apples", + "value": "Fort West Dried Apples" + }, + { + "selected": false, + "label": "Fort West Dried Apricots", + "value": "Fort West Dried Apricots" + }, + { + "selected": false, + "label": "Fort West Dried Dates", + "value": "Fort West Dried Dates" + }, + { + "selected": false, + "label": "Fort West Fondue Mix", + "value": "Fort West Fondue Mix" + }, + { + "selected": false, + "label": "Fort West Frosted Cookies", + "value": "Fort West Frosted Cookies" + }, + { + "selected": false, + "label": "Fort West Frosted Donuts", + "value": "Fort West Frosted Donuts" + }, + { + "selected": false, + "label": "Fort West Fudge Brownies", + "value": "Fort West Fudge Brownies" + }, + { + "selected": false, + "label": "Fort West Fudge Cookies", + "value": "Fort West Fudge Cookies" + }, + { + "selected": false, + "label": "Fort West Golden Raisins", + "value": "Fort West Golden Raisins" + }, + { + "selected": false, + "label": "Fort West Graham Crackers", + "value": "Fort West Graham Crackers" + }, + { + "selected": false, + "label": "Fort West Grape Fruit Roll", + "value": "Fort West Grape Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Lemon Cookies", + "value": "Fort West Lemon Cookies" + }, + { + "selected": false, + "label": "Fort West Low Fat BBQ Chips", + "value": "Fort West Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Fort West Low Fat Chips", + "value": "Fort West Low Fat Chips" + }, + { + "selected": false, + "label": "Fort West Low Fat Cookies", + "value": "Fort West Low Fat Cookies" + }, + { + "selected": false, + "label": "Fort West Low Fat Popcorn", + "value": "Fort West Low Fat Popcorn" + }, + { + "selected": false, + "label": "Fort West Mini Donuts", + "value": "Fort West Mini Donuts" + }, + { + "selected": false, + "label": "Fort West No Salt Popcorn", + "value": "Fort West No Salt Popcorn" + }, + { + "selected": false, + "label": "Fort West Potato Chips", + "value": "Fort West Potato Chips" + }, + { + "selected": false, + "label": "Fort West Raisins", + "value": "Fort West Raisins" + }, + { + "selected": false, + "label": "Fort West Raspberry Fruit Roll", + "value": "Fort West Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Salsa Dip", + "value": "Fort West Salsa Dip" + }, + { + "selected": false, + "label": "Fort West Salted Pretzels", + "value": "Fort West Salted Pretzels" + }, + { + "selected": false, + "label": "Fort West Sesame Crackers", + "value": "Fort West Sesame Crackers" + }, + { + "selected": false, + "label": "Fort West Strawberry Fruit Roll", + "value": "Fort West Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Sugar Cookies", + "value": "Fort West Sugar Cookies" + }, + { + "selected": false, + "label": "Framton City Map", + "value": "Framton City Map" + }, + { + "selected": false, + "label": "Framton Eyeglass Screwdriver", + "value": "Framton Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Gauss Monthly Auto Magazine", + "value": "Gauss Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Computer Magazine", + "value": "Gauss Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Fashion Magazine", + "value": "Gauss Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Home Magazine", + "value": "Gauss Monthly Home Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Sports Magazine", + "value": "Gauss Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Genteel Extra Lean Hamburger", + "value": "Genteel Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Genteel Seasoned Hamburger", + "value": "Genteel Seasoned Hamburger" + }, + { + "selected": false, + "label": "Gerolli Extra Lean Hamburger", + "value": "Gerolli Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Gerolli Seasoned Hamburger", + "value": "Gerolli Seasoned Hamburger" + }, + { + "selected": false, + "label": "Giant Egg Substitute", + "value": "Giant Egg Substitute" + }, + { + "selected": false, + "label": "Giant Large Brown Eggs", + "value": "Giant Large Brown Eggs" + }, + { + "selected": false, + "label": "Giant Large Eggs", + "value": "Giant Large Eggs" + }, + { + "selected": false, + "label": "Giant Small Brown Eggs", + "value": "Giant Small Brown Eggs" + }, + { + "selected": false, + "label": "Giant Small Eggs", + "value": "Giant Small Eggs" + }, + { + "selected": false, + "label": "Golden Apple Cinnamon Waffles", + "value": "Golden Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Golden Beef TV Dinner", + "value": "Golden Beef TV Dinner" + }, + { + "selected": false, + "label": "Golden Blueberry Waffles", + "value": "Golden Blueberry Waffles" + }, + { + "selected": false, + "label": "Golden Chicken TV Dinner", + "value": "Golden Chicken TV Dinner" + }, + { + "selected": false, + "label": "Golden Fajita French Fries", + "value": "Golden Fajita French Fries" + }, + { + "selected": false, + "label": "Golden Frozen Broccoli", + "value": "Golden Frozen Broccoli" + }, + { + "selected": false, + "label": "Golden Frozen Carrots", + "value": "Golden Frozen Carrots" + }, + { + "selected": false, + "label": "Golden Frozen Cauliflower", + "value": "Golden Frozen Cauliflower" + }, + { + "selected": false, + "label": "Golden Frozen Cheese Pizza", + "value": "Golden Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Breast", + "value": "Golden Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Thighs", + "value": "Golden Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Wings", + "value": "Golden Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Golden Frozen Corn", + "value": "Golden Frozen Corn" + }, + { + "selected": false, + "label": "Golden Frozen Mushroom Pizza", + "value": "Golden Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Pancakes", + "value": "Golden Frozen Pancakes" + }, + { + "selected": false, + "label": "Golden Frozen Peas", + "value": "Golden Frozen Peas" + }, + { + "selected": false, + "label": "Golden Frozen Pepperoni Pizza", + "value": "Golden Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Sausage Pizza", + "value": "Golden Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Golden Grape Popsicles", + "value": "Golden Grape Popsicles" + }, + { + "selected": false, + "label": "Golden Home Style French Fries", + "value": "Golden Home Style French Fries" + }, + { + "selected": false, + "label": "Golden Ice Cream", + "value": "Golden Ice Cream" + }, + { + "selected": false, + "label": "Golden Ice Cream Sandwich", + "value": "Golden Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Golden Lemon Popsicles", + "value": "Golden Lemon Popsicles" + }, + { + "selected": false, + "label": "Golden Lime Popsicles", + "value": "Golden Lime Popsicles" + }, + { + "selected": false, + "label": "Golden Low Fat French Fries", + "value": "Golden Low Fat French Fries" + }, + { + "selected": false, + "label": "Golden Low Fat Waffles", + "value": "Golden Low Fat Waffles" + }, + { + "selected": false, + "label": "Golden Orange Popsicles", + "value": "Golden Orange Popsicles" + }, + { + "selected": false, + "label": "Golden Pancake Mix", + "value": "Golden Pancake Mix" + }, + { + "selected": false, + "label": "Golden Popsicles", + "value": "Golden Popsicles" + }, + { + "selected": false, + "label": "Golden Turkey TV Dinner", + "value": "Golden Turkey TV Dinner" + }, + { + "selected": false, + "label": "Golden Waffles", + "value": "Golden Waffles" + }, + { + "selected": false, + "label": "Good Chablis Wine", + "value": "Good Chablis Wine" + }, + { + "selected": false, + "label": "Good Chardonnay", + "value": "Good Chardonnay" + }, + { + "selected": false, + "label": "Good Chardonnay Wine", + "value": "Good Chardonnay Wine" + }, + { + "selected": false, + "label": "Good Imported Beer", + "value": "Good Imported Beer" + }, + { + "selected": false, + "label": "Good Light Beer", + "value": "Good Light Beer" + }, + { + "selected": false, + "label": "Good Light Wine", + "value": "Good Light Wine" + }, + { + "selected": false, + "label": "Good Merlot Wine", + "value": "Good Merlot Wine" + }, + { + "selected": false, + "label": "Good White Zinfandel Wine", + "value": "Good White Zinfandel Wine" + }, + { + "selected": false, + "label": "Gorilla 1% Milk", + "value": "Gorilla 1% Milk" + }, + { + "selected": false, + "label": "Gorilla 2% Milk", + "value": "Gorilla 2% Milk" + }, + { + "selected": false, + "label": "Gorilla Blueberry Yogurt", + "value": "Gorilla Blueberry Yogurt" + }, + { + "selected": false, + "label": "Gorilla Buttermilk", + "value": "Gorilla Buttermilk" + }, + { + "selected": false, + "label": "Gorilla Cheese Spread", + "value": "Gorilla Cheese Spread" + }, + { + "selected": false, + "label": "Gorilla Chocolate Milk", + "value": "Gorilla Chocolate Milk" + }, + { + "selected": false, + "label": "Gorilla Havarti Cheese", + "value": "Gorilla Havarti Cheese" + }, + { + "selected": false, + "label": "Gorilla Head Cheese", + "value": "Gorilla Head Cheese" + }, + { + "selected": false, + "label": "Gorilla Jack Cheese", + "value": "Gorilla Jack Cheese" + }, + { + "selected": false, + "label": "Gorilla Large Curd Cottage Cheese", + "value": "Gorilla Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Gorilla Low Fat Cottage Cheese", + "value": "Gorilla Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Gorilla Low Fat Sour Cream", + "value": "Gorilla Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Gorilla Low Fat String Cheese", + "value": "Gorilla Low Fat String Cheese" + }, + { + "selected": false, + "label": "Gorilla Mild Cheddar Cheese", + "value": "Gorilla Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Gorilla Muenster Cheese", + "value": "Gorilla Muenster Cheese" + }, + { + "selected": false, + "label": "Gorilla Sharp Cheddar Cheese", + "value": "Gorilla Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Gorilla Sour Cream", + "value": "Gorilla Sour Cream" + }, + { + "selected": false, + "label": "Gorilla Strawberry Yogurt", + "value": "Gorilla Strawberry Yogurt" + }, + { + "selected": false, + "label": "Gorilla String Cheese", + "value": "Gorilla String Cheese" + }, + { + "selected": false, + "label": "Gorilla Whole Milk", + "value": "Gorilla Whole Milk" + }, + { + "selected": false, + "label": "Great Bagels", + "value": "Great Bagels" + }, + { + "selected": false, + "label": "Great Blueberry Muffins", + "value": "Great Blueberry Muffins" + }, + { + "selected": false, + "label": "Great Cranberry Muffins", + "value": "Great Cranberry Muffins" + }, + { + "selected": false, + "label": "Great English Muffins", + "value": "Great English Muffins" + }, + { + "selected": false, + "label": "Great Muffins", + "value": "Great Muffins" + }, + { + "selected": false, + "label": "Great Pumpernickel Bread", + "value": "Great Pumpernickel Bread" + }, + { + "selected": false, + "label": "Great Rye Bread", + "value": "Great Rye Bread" + }, + { + "selected": false, + "label": "Great Wheat Bread", + "value": "Great Wheat Bread" + }, + { + "selected": false, + "label": "Great White Bread", + "value": "Great White Bread" + }, + { + "selected": false, + "label": "Green Ribbon Canned Mixed Fruit", + "value": "Green Ribbon Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Green Ribbon Canned Peaches", + "value": "Green Ribbon Canned Peaches" + }, + { + "selected": false, + "label": "Gulf Coast Bubble Gum", + "value": "Gulf Coast Bubble Gum" + }, + { + "selected": false, + "label": "Gulf Coast Malted Milk Balls", + "value": "Gulf Coast Malted Milk Balls" + }, + { + "selected": false, + "label": "Gulf Coast Mint Chocolate Bar", + "value": "Gulf Coast Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Gulf Coast Mints", + "value": "Gulf Coast Mints" + }, + { + "selected": false, + "label": "Gulf Coast Semi-Sweet Chocolate Bar", + "value": "Gulf Coast Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Gulf Coast Spicy Mints", + "value": "Gulf Coast Spicy Mints" + }, + { + "selected": false, + "label": "Gulf Coast Tasty Candy Bar", + "value": "Gulf Coast Tasty Candy Bar" + }, + { + "selected": false, + "label": "Gulf Coast White Chocolate Bar", + "value": "Gulf Coast White Chocolate Bar" + }, + { + "selected": false, + "label": "Hermanos Almonds", + "value": "Hermanos Almonds" + }, + { + "selected": false, + "label": "Hermanos Asparagus", + "value": "Hermanos Asparagus" + }, + { + "selected": false, + "label": "Hermanos Baby Onion", + "value": "Hermanos Baby Onion" + }, + { + "selected": false, + "label": "Hermanos Beets", + "value": "Hermanos Beets" + }, + { + "selected": false, + "label": "Hermanos Broccoli", + "value": "Hermanos Broccoli" + }, + { + "selected": false, + "label": "Hermanos Canned Peanuts", + "value": "Hermanos Canned Peanuts" + }, + { + "selected": false, + "label": "Hermanos Cantelope", + "value": "Hermanos Cantelope" + }, + { + "selected": false, + "label": "Hermanos Cauliflower", + "value": "Hermanos Cauliflower" + }, + { + "selected": false, + "label": "Hermanos Corn on the Cob", + "value": "Hermanos Corn on the Cob" + }, + { + "selected": false, + "label": "Hermanos Dried Mushrooms", + "value": "Hermanos Dried Mushrooms" + }, + { + "selected": false, + "label": "Hermanos Elephant Garlic", + "value": "Hermanos Elephant Garlic" + }, + { + "selected": false, + "label": "Hermanos Fancy Plums", + "value": "Hermanos Fancy Plums" + }, + { + "selected": false, + "label": "Hermanos Firm Tofu", + "value": "Hermanos Firm Tofu" + }, + { + "selected": false, + "label": "Hermanos Fresh Lima Beans", + "value": "Hermanos Fresh Lima Beans" + }, + { + "selected": false, + "label": "Hermanos Fuji Apples", + "value": "Hermanos Fuji Apples" + }, + { + "selected": false, + "label": "Hermanos Garlic", + "value": "Hermanos Garlic" + }, + { + "selected": false, + "label": "Hermanos Golden Delcious Apples", + "value": "Hermanos Golden Delcious Apples" + }, + { + "selected": false, + "label": "Hermanos Green Pepper", + "value": "Hermanos Green Pepper" + }, + { + "selected": false, + "label": "Hermanos Honey Dew", + "value": "Hermanos Honey Dew" + }, + { + "selected": false, + "label": "Hermanos Lemons", + "value": "Hermanos Lemons" + }, + { + "selected": false, + "label": "Hermanos Lettuce", + "value": "Hermanos Lettuce" + }, + { + "selected": false, + "label": "Hermanos Limes", + "value": "Hermanos Limes" + }, + { + "selected": false, + "label": "Hermanos Macintosh Apples", + "value": "Hermanos Macintosh Apples" + }, + { + "selected": false, + "label": "Hermanos Mandarin Oranges", + "value": "Hermanos Mandarin Oranges" + }, + { + "selected": false, + "label": "Hermanos Mixed Nuts", + "value": "Hermanos Mixed Nuts" + }, + { + "selected": false, + "label": "Hermanos Mushrooms", + "value": "Hermanos Mushrooms" + }, + { + "selected": false, + "label": "Hermanos New Potatos", + "value": "Hermanos New Potatos" + }, + { + "selected": false, + "label": "Hermanos Onions", + "value": "Hermanos Onions" + }, + { + "selected": false, + "label": "Hermanos Oranges", + "value": "Hermanos Oranges" + }, + { + "selected": false, + "label": "Hermanos Party Nuts", + "value": "Hermanos Party Nuts" + }, + { + "selected": false, + "label": "Hermanos Peaches", + "value": "Hermanos Peaches" + }, + { + "selected": false, + "label": "Hermanos Plums", + "value": "Hermanos Plums" + }, + { + "selected": false, + "label": "Hermanos Potatos", + "value": "Hermanos Potatos" + }, + { + "selected": false, + "label": "Hermanos Prepared Salad", + "value": "Hermanos Prepared Salad" + }, + { + "selected": false, + "label": "Hermanos Red Delcious Apples", + "value": "Hermanos Red Delcious Apples" + }, + { + "selected": false, + "label": "Hermanos Red Pepper", + "value": "Hermanos Red Pepper" + }, + { + "selected": false, + "label": "Hermanos Shitake Mushrooms", + "value": "Hermanos Shitake Mushrooms" + }, + { + "selected": false, + "label": "Hermanos Squash", + "value": "Hermanos Squash" + }, + { + "selected": false, + "label": "Hermanos Summer Squash", + "value": "Hermanos Summer Squash" + }, + { + "selected": false, + "label": "Hermanos Sweet Onion", + "value": "Hermanos Sweet Onion" + }, + { + "selected": false, + "label": "Hermanos Sweet Peas", + "value": "Hermanos Sweet Peas" + }, + { + "selected": false, + "label": "Hermanos Tangerines", + "value": "Hermanos Tangerines" + }, + { + "selected": false, + "label": "Hermanos Tomatos", + "value": "Hermanos Tomatos" + }, + { + "selected": false, + "label": "Hermanos Walnuts", + "value": "Hermanos Walnuts" + }, + { + "selected": false, + "label": "High Quality 100 Watt Lightbulb", + "value": "High Quality 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 25 Watt Lightbulb", + "value": "High Quality 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 60 Watt Lightbulb", + "value": "High Quality 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 75 Watt Lightbulb", + "value": "High Quality 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality AAA-Size Batteries", + "value": "High Quality AAA-Size Batteries" + }, + { + "selected": false, + "label": "High Quality AA-Size Batteries", + "value": "High Quality AA-Size Batteries" + }, + { + "selected": false, + "label": "High Quality Bees Wax Candles", + "value": "High Quality Bees Wax Candles" + }, + { + "selected": false, + "label": "High Quality Copper Cleaner", + "value": "High Quality Copper Cleaner" + }, + { + "selected": false, + "label": "High Quality Copper Pot Scrubber", + "value": "High Quality Copper Pot Scrubber" + }, + { + "selected": false, + "label": "High Quality Counter Cleaner", + "value": "High Quality Counter Cleaner" + }, + { + "selected": false, + "label": "High Quality C-Size Batteries", + "value": "High Quality C-Size Batteries" + }, + { + "selected": false, + "label": "High Quality D-Size Batteries", + "value": "High Quality D-Size Batteries" + }, + { + "selected": false, + "label": "High Quality Economy Toilet Brush", + "value": "High Quality Economy Toilet Brush" + }, + { + "selected": false, + "label": "High Quality Frying Pan", + "value": "High Quality Frying Pan" + }, + { + "selected": false, + "label": "High Quality Glass Cleaner", + "value": "High Quality Glass Cleaner" + }, + { + "selected": false, + "label": "High Quality Large Sponge", + "value": "High Quality Large Sponge" + }, + { + "selected": false, + "label": "High Quality Paper Cups", + "value": "High Quality Paper Cups" + }, + { + "selected": false, + "label": "High Quality Paper Plates", + "value": "High Quality Paper Plates" + }, + { + "selected": false, + "label": "High Quality Paper Towels", + "value": "High Quality Paper Towels" + }, + { + "selected": false, + "label": "High Quality Plastic Forks", + "value": "High Quality Plastic Forks" + }, + { + "selected": false, + "label": "High Quality Plastic Knives", + "value": "High Quality Plastic Knives" + }, + { + "selected": false, + "label": "High Quality Plastic Spoons", + "value": "High Quality Plastic Spoons" + }, + { + "selected": false, + "label": "High Quality Room Freshener", + "value": "High Quality Room Freshener" + }, + { + "selected": false, + "label": "High Quality Scented Tissue", + "value": "High Quality Scented Tissue" + }, + { + "selected": false, + "label": "High Quality Scented Toilet Tissue", + "value": "High Quality Scented Toilet Tissue" + }, + { + "selected": false, + "label": "High Quality Scissors", + "value": "High Quality Scissors" + }, + { + "selected": false, + "label": "High Quality Screw Driver", + "value": "High Quality Screw Driver" + }, + { + "selected": false, + "label": "High Quality Silver Cleaner", + "value": "High Quality Silver Cleaner" + }, + { + "selected": false, + "label": "High Quality Soft Napkins", + "value": "High Quality Soft Napkins" + }, + { + "selected": false, + "label": "High Quality Tissues", + "value": "High Quality Tissues" + }, + { + "selected": false, + "label": "High Quality Toilet Bowl Cleaner", + "value": "High Quality Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "High Quality Toilet Paper", + "value": "High Quality Toilet Paper" + }, + { + "selected": false, + "label": "High Top Almonds", + "value": "High Top Almonds" + }, + { + "selected": false, + "label": "High Top Asparagus", + "value": "High Top Asparagus" + }, + { + "selected": false, + "label": "High Top Baby Onion", + "value": "High Top Baby Onion" + }, + { + "selected": false, + "label": "High Top Beets", + "value": "High Top Beets" + }, + { + "selected": false, + "label": "High Top Broccoli", + "value": "High Top Broccoli" + }, + { + "selected": false, + "label": "High Top Canned Peanuts", + "value": "High Top Canned Peanuts" + }, + { + "selected": false, + "label": "High Top Cantelope", + "value": "High Top Cantelope" + }, + { + "selected": false, + "label": "High Top Cauliflower", + "value": "High Top Cauliflower" + }, + { + "selected": false, + "label": "High Top Corn on the Cob", + "value": "High Top Corn on the Cob" + }, + { + "selected": false, + "label": "High Top Dried Mushrooms", + "value": "High Top Dried Mushrooms" + }, + { + "selected": false, + "label": "High Top Elephant Garlic", + "value": "High Top Elephant Garlic" + }, + { + "selected": false, + "label": "High Top Fancy Plums", + "value": "High Top Fancy Plums" + }, + { + "selected": false, + "label": "High Top Firm Tofu", + "value": "High Top Firm Tofu" + }, + { + "selected": false, + "label": "High Top Fresh Lima Beans", + "value": "High Top Fresh Lima Beans" + }, + { + "selected": false, + "label": "High Top Fuji Apples", + "value": "High Top Fuji Apples" + }, + { + "selected": false, + "label": "High Top Garlic", + "value": "High Top Garlic" + }, + { + "selected": false, + "label": "High Top Golden Delcious Apples", + "value": "High Top Golden Delcious Apples" + }, + { + "selected": false, + "label": "High Top Green Pepper", + "value": "High Top Green Pepper" + }, + { + "selected": false, + "label": "High Top Honey Dew", + "value": "High Top Honey Dew" + }, + { + "selected": false, + "label": "High Top Lemons", + "value": "High Top Lemons" + }, + { + "selected": false, + "label": "High Top Lettuce", + "value": "High Top Lettuce" + }, + { + "selected": false, + "label": "High Top Limes", + "value": "High Top Limes" + }, + { + "selected": false, + "label": "High Top Macintosh Apples", + "value": "High Top Macintosh Apples" + }, + { + "selected": false, + "label": "High Top Mandarin Oranges", + "value": "High Top Mandarin Oranges" + }, + { + "selected": false, + "label": "High Top Mixed Nuts", + "value": "High Top Mixed Nuts" + }, + { + "selected": false, + "label": "High Top Mushrooms", + "value": "High Top Mushrooms" + }, + { + "selected": false, + "label": "High Top New Potatos", + "value": "High Top New Potatos" + }, + { + "selected": false, + "label": "High Top Onions", + "value": "High Top Onions" + }, + { + "selected": false, + "label": "High Top Oranges", + "value": "High Top Oranges" + }, + { + "selected": false, + "label": "High Top Party Nuts", + "value": "High Top Party Nuts" + }, + { + "selected": false, + "label": "High Top Peaches", + "value": "High Top Peaches" + }, + { + "selected": false, + "label": "High Top Plums", + "value": "High Top Plums" + }, + { + "selected": false, + "label": "High Top Potatos", + "value": "High Top Potatos" + }, + { + "selected": false, + "label": "High Top Prepared Salad", + "value": "High Top Prepared Salad" + }, + { + "selected": false, + "label": "High Top Red Delcious Apples", + "value": "High Top Red Delcious Apples" + }, + { + "selected": false, + "label": "High Top Red Pepper", + "value": "High Top Red Pepper" + }, + { + "selected": false, + "label": "High Top Shitake Mushrooms", + "value": "High Top Shitake Mushrooms" + }, + { + "selected": false, + "label": "High Top Squash", + "value": "High Top Squash" + }, + { + "selected": false, + "label": "High Top Summer Squash", + "value": "High Top Summer Squash" + }, + { + "selected": false, + "label": "High Top Sweet Onion", + "value": "High Top Sweet Onion" + }, + { + "selected": false, + "label": "High Top Sweet Peas", + "value": "High Top Sweet Peas" + }, + { + "selected": false, + "label": "High Top Tangerines", + "value": "High Top Tangerines" + }, + { + "selected": false, + "label": "High Top Tomatos", + "value": "High Top Tomatos" + }, + { + "selected": false, + "label": "High Top Walnuts", + "value": "High Top Walnuts" + }, + { + "selected": false, + "label": "Hilltop 200 MG Acetominifen", + "value": "Hilltop 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Hilltop 200 MG Ibuprofen", + "value": "Hilltop 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Hilltop Angled Toothbrush", + "value": "Hilltop Angled Toothbrush" + }, + { + "selected": false, + "label": "Hilltop Apricot Shampoo", + "value": "Hilltop Apricot Shampoo" + }, + { + "selected": false, + "label": "Hilltop Buffered Aspirin", + "value": "Hilltop Buffered Aspirin" + }, + { + "selected": false, + "label": "Hilltop Childrens Aspirin", + "value": "Hilltop Childrens Aspirin" + }, + { + "selected": false, + "label": "Hilltop Childrens Cold Remedy", + "value": "Hilltop Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Hilltop Conditioning Shampoo", + "value": "Hilltop Conditioning Shampoo" + }, + { + "selected": false, + "label": "Hilltop Deodorant", + "value": "Hilltop Deodorant" + }, + { + "selected": false, + "label": "Hilltop Dishwasher Detergent", + "value": "Hilltop Dishwasher Detergent" + }, + { + "selected": false, + "label": "Hilltop Extra Moisture Shampoo", + "value": "Hilltop Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Hilltop HCL Nasal Spray", + "value": "Hilltop HCL Nasal Spray" + }, + { + "selected": false, + "label": "Hilltop Laundry Detergent", + "value": "Hilltop Laundry Detergent" + }, + { + "selected": false, + "label": "Hilltop Mint Mouthwash", + "value": "Hilltop Mint Mouthwash" + }, + { + "selected": false, + "label": "Hilltop Multi-Symptom Cold Remedy", + "value": "Hilltop Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Hilltop Silky Smooth Hair Conditioner", + "value": "Hilltop Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Hilltop Tartar Control Toothpaste", + "value": "Hilltop Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Hilltop Toothpaste", + "value": "Hilltop Toothpaste" + }, + { + "selected": false, + "label": "Hilltop Whitening Toothpast", + "value": "Hilltop Whitening Toothpast" + }, + { + "selected": false, + "label": "Horatio Apple Fruit Roll", + "value": "Horatio Apple Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Avocado Dip", + "value": "Horatio Avocado Dip" + }, + { + "selected": false, + "label": "Horatio BBQ Potato Chips", + "value": "Horatio BBQ Potato Chips" + }, + { + "selected": false, + "label": "Horatio Beef Jerky", + "value": "Horatio Beef Jerky" + }, + { + "selected": false, + "label": "Horatio Buttered Popcorn", + "value": "Horatio Buttered Popcorn" + }, + { + "selected": false, + "label": "Horatio Cheese Crackers", + "value": "Horatio Cheese Crackers" + }, + { + "selected": false, + "label": "Horatio Cheese Dip", + "value": "Horatio Cheese Dip" + }, + { + "selected": false, + "label": "Horatio Chocolate Chip Cookies", + "value": "Horatio Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Horatio Chocolate Donuts", + "value": "Horatio Chocolate Donuts" + }, + { + "selected": false, + "label": "Horatio Corn Chips", + "value": "Horatio Corn Chips" + }, + { + "selected": false, + "label": "Horatio Dried Apples", + "value": "Horatio Dried Apples" + }, + { + "selected": false, + "label": "Horatio Dried Apricots", + "value": "Horatio Dried Apricots" + }, + { + "selected": false, + "label": "Horatio Dried Dates", + "value": "Horatio Dried Dates" + }, + { + "selected": false, + "label": "Horatio Fondue Mix", + "value": "Horatio Fondue Mix" + }, + { + "selected": false, + "label": "Horatio Frosted Cookies", + "value": "Horatio Frosted Cookies" + }, + { + "selected": false, + "label": "Horatio Frosted Donuts", + "value": "Horatio Frosted Donuts" + }, + { + "selected": false, + "label": "Horatio Fudge Brownies", + "value": "Horatio Fudge Brownies" + }, + { + "selected": false, + "label": "Horatio Fudge Cookies", + "value": "Horatio Fudge Cookies" + }, + { + "selected": false, + "label": "Horatio Golden Raisins", + "value": "Horatio Golden Raisins" + }, + { + "selected": false, + "label": "Horatio Graham Crackers", + "value": "Horatio Graham Crackers" + }, + { + "selected": false, + "label": "Horatio Grape Fruit Roll", + "value": "Horatio Grape Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Lemon Cookies", + "value": "Horatio Lemon Cookies" + }, + { + "selected": false, + "label": "Horatio Low Fat BBQ Chips", + "value": "Horatio Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Horatio Low Fat Chips", + "value": "Horatio Low Fat Chips" + }, + { + "selected": false, + "label": "Horatio Low Fat Cookies", + "value": "Horatio Low Fat Cookies" + }, + { + "selected": false, + "label": "Horatio Low Fat Popcorn", + "value": "Horatio Low Fat Popcorn" + }, + { + "selected": false, + "label": "Horatio Mini Donuts", + "value": "Horatio Mini Donuts" + }, + { + "selected": false, + "label": "Horatio No Salt Popcorn", + "value": "Horatio No Salt Popcorn" + }, + { + "selected": false, + "label": "Horatio Potato Chips", + "value": "Horatio Potato Chips" + }, + { + "selected": false, + "label": "Horatio Raisins", + "value": "Horatio Raisins" + }, + { + "selected": false, + "label": "Horatio Raspberry Fruit Roll", + "value": "Horatio Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Salsa Dip", + "value": "Horatio Salsa Dip" + }, + { + "selected": false, + "label": "Horatio Salted Pretzels", + "value": "Horatio Salted Pretzels" + }, + { + "selected": false, + "label": "Horatio Sesame Crackers", + "value": "Horatio Sesame Crackers" + }, + { + "selected": false, + "label": "Horatio Strawberry Fruit Roll", + "value": "Horatio Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Sugar Cookies", + "value": "Horatio Sugar Cookies" + }, + { + "selected": false, + "label": "Imagine Apple Cinnamon Waffles", + "value": "Imagine Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Imagine Beef TV Dinner", + "value": "Imagine Beef TV Dinner" + }, + { + "selected": false, + "label": "Imagine Blueberry Waffles", + "value": "Imagine Blueberry Waffles" + }, + { + "selected": false, + "label": "Imagine Chicken TV Dinner", + "value": "Imagine Chicken TV Dinner" + }, + { + "selected": false, + "label": "Imagine Fajita French Fries", + "value": "Imagine Fajita French Fries" + }, + { + "selected": false, + "label": "Imagine Frozen Broccoli", + "value": "Imagine Frozen Broccoli" + }, + { + "selected": false, + "label": "Imagine Frozen Carrots", + "value": "Imagine Frozen Carrots" + }, + { + "selected": false, + "label": "Imagine Frozen Cauliflower", + "value": "Imagine Frozen Cauliflower" + }, + { + "selected": false, + "label": "Imagine Frozen Cheese Pizza", + "value": "Imagine Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Breast", + "value": "Imagine Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Thighs", + "value": "Imagine Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Wings", + "value": "Imagine Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Imagine Frozen Corn", + "value": "Imagine Frozen Corn" + }, + { + "selected": false, + "label": "Imagine Frozen Mushroom Pizza", + "value": "Imagine Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Pancakes", + "value": "Imagine Frozen Pancakes" + }, + { + "selected": false, + "label": "Imagine Frozen Peas", + "value": "Imagine Frozen Peas" + }, + { + "selected": false, + "label": "Imagine Frozen Pepperoni Pizza", + "value": "Imagine Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Sausage Pizza", + "value": "Imagine Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Imagine Grape Popsicles", + "value": "Imagine Grape Popsicles" + }, + { + "selected": false, + "label": "Imagine Home Style French Fries", + "value": "Imagine Home Style French Fries" + }, + { + "selected": false, + "label": "Imagine Ice Cream", + "value": "Imagine Ice Cream" + }, + { + "selected": false, + "label": "Imagine Ice Cream Sandwich", + "value": "Imagine Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Imagine Lemon Popsicles", + "value": "Imagine Lemon Popsicles" + }, + { + "selected": false, + "label": "Imagine Lime Popsicles", + "value": "Imagine Lime Popsicles" + }, + { + "selected": false, + "label": "Imagine Low Fat French Fries", + "value": "Imagine Low Fat French Fries" + }, + { + "selected": false, + "label": "Imagine Low Fat Waffles", + "value": "Imagine Low Fat Waffles" + }, + { + "selected": false, + "label": "Imagine Orange Popsicles", + "value": "Imagine Orange Popsicles" + }, + { + "selected": false, + "label": "Imagine Pancake Mix", + "value": "Imagine Pancake Mix" + }, + { + "selected": false, + "label": "Imagine Popsicles", + "value": "Imagine Popsicles" + }, + { + "selected": false, + "label": "Imagine Turkey TV Dinner", + "value": "Imagine Turkey TV Dinner" + }, + { + "selected": false, + "label": "Imagine Waffles", + "value": "Imagine Waffles" + }, + { + "selected": false, + "label": "James Bay City Map", + "value": "James Bay City Map" + }, + { + "selected": false, + "label": "James Bay Eyeglass Screwdriver", + "value": "James Bay Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Jardon Manicotti", + "value": "Jardon Manicotti" + }, + { + "selected": false, + "label": "Jardon Ravioli", + "value": "Jardon Ravioli" + }, + { + "selected": false, + "label": "Jardon Rice Medly", + "value": "Jardon Rice Medly" + }, + { + "selected": false, + "label": "Jardon Spaghetti", + "value": "Jardon Spaghetti" + }, + { + "selected": false, + "label": "Jardon Thai Rice", + "value": "Jardon Thai Rice" + }, + { + "selected": false, + "label": "Jeffers Corn Puffs", + "value": "Jeffers Corn Puffs" + }, + { + "selected": false, + "label": "Jeffers Grits", + "value": "Jeffers Grits" + }, + { + "selected": false, + "label": "Jeffers Oatmeal", + "value": "Jeffers Oatmeal" + }, + { + "selected": false, + "label": "Jeffers Wheat Puffs", + "value": "Jeffers Wheat Puffs" + }, + { + "selected": false, + "label": "Johnson Corn Puffs", + "value": "Johnson Corn Puffs" + }, + { + "selected": false, + "label": "Johnson Grits", + "value": "Johnson Grits" + }, + { + "selected": false, + "label": "Johnson Oatmeal", + "value": "Johnson Oatmeal" + }, + { + "selected": false, + "label": "Johnson Wheat Puffs", + "value": "Johnson Wheat Puffs" + }, + { + "selected": false, + "label": "Jumbo Egg Substitute", + "value": "Jumbo Egg Substitute" + }, + { + "selected": false, + "label": "Jumbo Large Brown Eggs", + "value": "Jumbo Large Brown Eggs" + }, + { + "selected": false, + "label": "Jumbo Large Eggs", + "value": "Jumbo Large Eggs" + }, + { + "selected": false, + "label": "Jumbo Small Brown Eggs", + "value": "Jumbo Small Brown Eggs" + }, + { + "selected": false, + "label": "Jumbo Small Eggs", + "value": "Jumbo Small Eggs" + }, + { + "selected": false, + "label": "Just Right Beef Soup", + "value": "Just Right Beef Soup" + }, + { + "selected": false, + "label": "Just Right Canned Beets", + "value": "Just Right Canned Beets" + }, + { + "selected": false, + "label": "Just Right Canned Peas", + "value": "Just Right Canned Peas" + }, + { + "selected": false, + "label": "Just Right Canned String Beans", + "value": "Just Right Canned String Beans" + }, + { + "selected": false, + "label": "Just Right Canned Tomatos", + "value": "Just Right Canned Tomatos" + }, + { + "selected": false, + "label": "Just Right Canned Tuna in Oil", + "value": "Just Right Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Just Right Canned Tuna in Water", + "value": "Just Right Canned Tuna in Water" + }, + { + "selected": false, + "label": "Just Right Canned Yams", + "value": "Just Right Canned Yams" + }, + { + "selected": false, + "label": "Just Right Chicken Noodle Soup", + "value": "Just Right Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Chicken Ramen Soup", + "value": "Just Right Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Just Right Chicken Soup", + "value": "Just Right Chicken Soup" + }, + { + "selected": false, + "label": "Just Right Creamed Corn", + "value": "Just Right Creamed Corn" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Anchovies", + "value": "Just Right Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Clams", + "value": "Just Right Fancy Canned Clams" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Oysters", + "value": "Just Right Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Sardines", + "value": "Just Right Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Just Right Large Canned Shrimp", + "value": "Just Right Large Canned Shrimp" + }, + { + "selected": false, + "label": "Just Right Noodle Soup", + "value": "Just Right Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Regular Ramen Soup", + "value": "Just Right Regular Ramen Soup" + }, + { + "selected": false, + "label": "Just Right Rice Soup", + "value": "Just Right Rice Soup" + }, + { + "selected": false, + "label": "Just Right Turkey Noodle Soup", + "value": "Just Right Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Vegetable Soup", + "value": "Just Right Vegetable Soup" + }, + { + "selected": false, + "label": "King Rosy Sunglasses", + "value": "King Rosy Sunglasses" + }, + { + "selected": false, + "label": "Kiwi Lox", + "value": "Kiwi Lox" + }, + { + "selected": false, + "label": "Kiwi Scallops", + "value": "Kiwi Scallops" + }, + { + "selected": false, + "label": "Lake Beef Bologna", + "value": "Lake Beef Bologna" + }, + { + "selected": false, + "label": "Lake Chicken Hot Dogs", + "value": "Lake Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Lake Cole Slaw", + "value": "Lake Cole Slaw" + }, + { + "selected": false, + "label": "Lake Corned Beef", + "value": "Lake Corned Beef" + }, + { + "selected": false, + "label": "Lake Foot-Long Hot Dogs", + "value": "Lake Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Lake Low Fat Bologna", + "value": "Lake Low Fat Bologna" + }, + { + "selected": false, + "label": "Lake Low Fat Cole Slaw", + "value": "Lake Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Lake Pimento Loaf", + "value": "Lake Pimento Loaf" + }, + { + "selected": false, + "label": "Lake Potato Salad", + "value": "Lake Potato Salad" + }, + { + "selected": false, + "label": "Lake Roasted Chicken", + "value": "Lake Roasted Chicken" + }, + { + "selected": false, + "label": "Lake Sliced Chicken", + "value": "Lake Sliced Chicken" + }, + { + "selected": false, + "label": "Lake Sliced Ham", + "value": "Lake Sliced Ham" + }, + { + "selected": false, + "label": "Lake Sliced Turkey", + "value": "Lake Sliced Turkey" + }, + { + "selected": false, + "label": "Lake Turkey Hot Dogs", + "value": "Lake Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Landslide Apple Butter", + "value": "Landslide Apple Butter" + }, + { + "selected": false, + "label": "Landslide Apple Jam", + "value": "Landslide Apple Jam" + }, + { + "selected": false, + "label": "Landslide Apple Jelly", + "value": "Landslide Apple Jelly" + }, + { + "selected": false, + "label": "Landslide Apple Preserves", + "value": "Landslide Apple Preserves" + }, + { + "selected": false, + "label": "Landslide Brown Sugar", + "value": "Landslide Brown Sugar" + }, + { + "selected": false, + "label": "Landslide Canola Oil", + "value": "Landslide Canola Oil" + }, + { + "selected": false, + "label": "Landslide Chunky Peanut Butter", + "value": "Landslide Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Landslide Columbian Coffee", + "value": "Landslide Columbian Coffee" + }, + { + "selected": false, + "label": "Landslide Corn Oil", + "value": "Landslide Corn Oil" + }, + { + "selected": false, + "label": "Landslide Creamy Peanut Butter", + "value": "Landslide Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Landslide Decaf Coffee", + "value": "Landslide Decaf Coffee" + }, + { + "selected": false, + "label": "Landslide Extra Chunky Peanut Butter", + "value": "Landslide Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Landslide French Roast Coffee", + "value": "Landslide French Roast Coffee" + }, + { + "selected": false, + "label": "Landslide Grape Jam", + "value": "Landslide Grape Jam" + }, + { + "selected": false, + "label": "Landslide Grape Jelly", + "value": "Landslide Grape Jelly" + }, + { + "selected": false, + "label": "Landslide Grape Preserves", + "value": "Landslide Grape Preserves" + }, + { + "selected": false, + "label": "Landslide Hot Chocolate", + "value": "Landslide Hot Chocolate" + }, + { + "selected": false, + "label": "Landslide Low Fat Apple Butter", + "value": "Landslide Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Landslide Oregano", + "value": "Landslide Oregano" + }, + { + "selected": false, + "label": "Landslide Pepper", + "value": "Landslide Pepper" + }, + { + "selected": false, + "label": "Landslide Regular Coffee", + "value": "Landslide Regular Coffee" + }, + { + "selected": false, + "label": "Landslide Salt", + "value": "Landslide Salt" + }, + { + "selected": false, + "label": "Landslide Sesame Oil", + "value": "Landslide Sesame Oil" + }, + { + "selected": false, + "label": "Landslide Strawberry Jam", + "value": "Landslide Strawberry Jam" + }, + { + "selected": false, + "label": "Landslide Strawberry Jelly", + "value": "Landslide Strawberry Jelly" + }, + { + "selected": false, + "label": "Landslide Strawberry Preserves", + "value": "Landslide Strawberry Preserves" + }, + { + "selected": false, + "label": "Landslide Tomato Sauce", + "value": "Landslide Tomato Sauce" + }, + { + "selected": false, + "label": "Landslide Vegetable Oil", + "value": "Landslide Vegetable Oil" + }, + { + "selected": false, + "label": "Landslide White Sugar", + "value": "Landslide White Sugar" + }, + { + "selected": false, + "label": "Medalist Manicotti", + "value": "Medalist Manicotti" + }, + { + "selected": false, + "label": "Medalist Ravioli", + "value": "Medalist Ravioli" + }, + { + "selected": false, + "label": "Medalist Rice Medly", + "value": "Medalist Rice Medly" + }, + { + "selected": false, + "label": "Medalist Spaghetti", + "value": "Medalist Spaghetti" + }, + { + "selected": false, + "label": "Medalist Thai Rice", + "value": "Medalist Thai Rice" + }, + { + "selected": false, + "label": "Mighty Good Monthly Auto Magazine", + "value": "Mighty Good Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Computer Magazine", + "value": "Mighty Good Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Fashion Magazine", + "value": "Mighty Good Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Home Magazine", + "value": "Mighty Good Monthly Home Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Sports Magazine", + "value": "Mighty Good Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Modell Bagels", + "value": "Modell Bagels" + }, + { + "selected": false, + "label": "Modell Blueberry Muffins", + "value": "Modell Blueberry Muffins" + }, + { + "selected": false, + "label": "Modell Cranberry Muffins", + "value": "Modell Cranberry Muffins" + }, + { + "selected": false, + "label": "Modell English Muffins", + "value": "Modell English Muffins" + }, + { + "selected": false, + "label": "Modell Muffins", + "value": "Modell Muffins" + }, + { + "selected": false, + "label": "Modell Pumpernickel Bread", + "value": "Modell Pumpernickel Bread" + }, + { + "selected": false, + "label": "Modell Rye Bread", + "value": "Modell Rye Bread" + }, + { + "selected": false, + "label": "Modell Wheat Bread", + "value": "Modell Wheat Bread" + }, + { + "selected": false, + "label": "Modell White Bread", + "value": "Modell White Bread" + }, + { + "selected": false, + "label": "Moms Beef Bologna", + "value": "Moms Beef Bologna" + }, + { + "selected": false, + "label": "Moms Chicken Hot Dogs", + "value": "Moms Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Moms Cole Slaw", + "value": "Moms Cole Slaw" + }, + { + "selected": false, + "label": "Moms Corned Beef", + "value": "Moms Corned Beef" + }, + { + "selected": false, + "label": "Moms Foot-Long Hot Dogs", + "value": "Moms Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Moms Low Fat Bologna", + "value": "Moms Low Fat Bologna" + }, + { + "selected": false, + "label": "Moms Low Fat Cole Slaw", + "value": "Moms Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Moms Pimento Loaf", + "value": "Moms Pimento Loaf" + }, + { + "selected": false, + "label": "Moms Potato Salad", + "value": "Moms Potato Salad" + }, + { + "selected": false, + "label": "Moms Roasted Chicken", + "value": "Moms Roasted Chicken" + }, + { + "selected": false, + "label": "Moms Sliced Chicken", + "value": "Moms Sliced Chicken" + }, + { + "selected": false, + "label": "Moms Sliced Ham", + "value": "Moms Sliced Ham" + }, + { + "selected": false, + "label": "Moms Sliced Turkey", + "value": "Moms Sliced Turkey" + }, + { + "selected": false, + "label": "Moms Turkey Hot Dogs", + "value": "Moms Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Monarch Manicotti", + "value": "Monarch Manicotti" + }, + { + "selected": false, + "label": "Monarch Ravioli", + "value": "Monarch Ravioli" + }, + { + "selected": false, + "label": "Monarch Rice Medly", + "value": "Monarch Rice Medly" + }, + { + "selected": false, + "label": "Monarch Spaghetti", + "value": "Monarch Spaghetti" + }, + { + "selected": false, + "label": "Monarch Thai Rice", + "value": "Monarch Thai Rice" + }, + { + "selected": false, + "label": "Musial Bubble Gum", + "value": "Musial Bubble Gum" + }, + { + "selected": false, + "label": "Musial Malted Milk Balls", + "value": "Musial Malted Milk Balls" + }, + { + "selected": false, + "label": "Musial Mint Chocolate Bar", + "value": "Musial Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Musial Mints", + "value": "Musial Mints" + }, + { + "selected": false, + "label": "Musial Semi-Sweet Chocolate Bar", + "value": "Musial Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Musial Spicy Mints", + "value": "Musial Spicy Mints" + }, + { + "selected": false, + "label": "Musial Tasty Candy Bar", + "value": "Musial Tasty Candy Bar" + }, + { + "selected": false, + "label": "Musial White Chocolate Bar", + "value": "Musial White Chocolate Bar" + }, + { + "selected": false, + "label": "National Egg Substitute", + "value": "National Egg Substitute" + }, + { + "selected": false, + "label": "National Large Brown Eggs", + "value": "National Large Brown Eggs" + }, + { + "selected": false, + "label": "National Large Eggs", + "value": "National Large Eggs" + }, + { + "selected": false, + "label": "National Small Brown Eggs", + "value": "National Small Brown Eggs" + }, + { + "selected": false, + "label": "National Small Eggs", + "value": "National Small Eggs" + }, + { + "selected": false, + "label": "Nationeel Apple Fruit Roll", + "value": "Nationeel Apple Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Avocado Dip", + "value": "Nationeel Avocado Dip" + }, + { + "selected": false, + "label": "Nationeel BBQ Potato Chips", + "value": "Nationeel BBQ Potato Chips" + }, + { + "selected": false, + "label": "Nationeel Beef Jerky", + "value": "Nationeel Beef Jerky" + }, + { + "selected": false, + "label": "Nationeel Buttered Popcorn", + "value": "Nationeel Buttered Popcorn" + }, + { + "selected": false, + "label": "Nationeel Cheese Crackers", + "value": "Nationeel Cheese Crackers" + }, + { + "selected": false, + "label": "Nationeel Cheese Dip", + "value": "Nationeel Cheese Dip" + }, + { + "selected": false, + "label": "Nationeel Chocolate Chip Cookies", + "value": "Nationeel Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Nationeel Chocolate Donuts", + "value": "Nationeel Chocolate Donuts" + }, + { + "selected": false, + "label": "Nationeel Corn Chips", + "value": "Nationeel Corn Chips" + }, + { + "selected": false, + "label": "Nationeel Dried Apples", + "value": "Nationeel Dried Apples" + }, + { + "selected": false, + "label": "Nationeel Dried Apricots", + "value": "Nationeel Dried Apricots" + }, + { + "selected": false, + "label": "Nationeel Dried Dates", + "value": "Nationeel Dried Dates" + }, + { + "selected": false, + "label": "Nationeel Fondue Mix", + "value": "Nationeel Fondue Mix" + }, + { + "selected": false, + "label": "Nationeel Frosted Cookies", + "value": "Nationeel Frosted Cookies" + }, + { + "selected": false, + "label": "Nationeel Frosted Donuts", + "value": "Nationeel Frosted Donuts" + }, + { + "selected": false, + "label": "Nationeel Fudge Brownies", + "value": "Nationeel Fudge Brownies" + }, + { + "selected": false, + "label": "Nationeel Fudge Cookies", + "value": "Nationeel Fudge Cookies" + }, + { + "selected": false, + "label": "Nationeel Golden Raisins", + "value": "Nationeel Golden Raisins" + }, + { + "selected": false, + "label": "Nationeel Graham Crackers", + "value": "Nationeel Graham Crackers" + }, + { + "selected": false, + "label": "Nationeel Grape Fruit Roll", + "value": "Nationeel Grape Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Lemon Cookies", + "value": "Nationeel Lemon Cookies" + }, + { + "selected": false, + "label": "Nationeel Low Fat BBQ Chips", + "value": "Nationeel Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Nationeel Low Fat Chips", + "value": "Nationeel Low Fat Chips" + }, + { + "selected": false, + "label": "Nationeel Low Fat Cookies", + "value": "Nationeel Low Fat Cookies" + }, + { + "selected": false, + "label": "Nationeel Low Fat Popcorn", + "value": "Nationeel Low Fat Popcorn" + }, + { + "selected": false, + "label": "Nationeel Mini Donuts", + "value": "Nationeel Mini Donuts" + }, + { + "selected": false, + "label": "Nationeel No Salt Popcorn", + "value": "Nationeel No Salt Popcorn" + }, + { + "selected": false, + "label": "Nationeel Potato Chips", + "value": "Nationeel Potato Chips" + }, + { + "selected": false, + "label": "Nationeel Raisins", + "value": "Nationeel Raisins" + }, + { + "selected": false, + "label": "Nationeel Raspberry Fruit Roll", + "value": "Nationeel Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Salsa Dip", + "value": "Nationeel Salsa Dip" + }, + { + "selected": false, + "label": "Nationeel Salted Pretzels", + "value": "Nationeel Salted Pretzels" + }, + { + "selected": false, + "label": "Nationeel Sesame Crackers", + "value": "Nationeel Sesame Crackers" + }, + { + "selected": false, + "label": "Nationeel Strawberry Fruit Roll", + "value": "Nationeel Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Sugar Cookies", + "value": "Nationeel Sugar Cookies" + }, + { + "selected": false, + "label": "Pearl Chablis Wine", + "value": "Pearl Chablis Wine" + }, + { + "selected": false, + "label": "Pearl Chardonnay", + "value": "Pearl Chardonnay" + }, + { + "selected": false, + "label": "Pearl Chardonnay Wine", + "value": "Pearl Chardonnay Wine" + }, + { + "selected": false, + "label": "Pearl Imported Beer", + "value": "Pearl Imported Beer" + }, + { + "selected": false, + "label": "Pearl Light Beer", + "value": "Pearl Light Beer" + }, + { + "selected": false, + "label": "Pearl Light Wine", + "value": "Pearl Light Wine" + }, + { + "selected": false, + "label": "Pearl Merlot Wine", + "value": "Pearl Merlot Wine" + }, + { + "selected": false, + "label": "Pearl White Zinfandel Wine", + "value": "Pearl White Zinfandel Wine" + }, + { + "selected": false, + "label": "PigTail Apple Cinnamon Waffles", + "value": "PigTail Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "PigTail Beef TV Dinner", + "value": "PigTail Beef TV Dinner" + }, + { + "selected": false, + "label": "PigTail Blueberry Waffles", + "value": "PigTail Blueberry Waffles" + }, + { + "selected": false, + "label": "PigTail Chicken TV Dinner", + "value": "PigTail Chicken TV Dinner" + }, + { + "selected": false, + "label": "PigTail Fajita French Fries", + "value": "PigTail Fajita French Fries" + }, + { + "selected": false, + "label": "PigTail Frozen Broccoli", + "value": "PigTail Frozen Broccoli" + }, + { + "selected": false, + "label": "PigTail Frozen Carrots", + "value": "PigTail Frozen Carrots" + }, + { + "selected": false, + "label": "PigTail Frozen Cauliflower", + "value": "PigTail Frozen Cauliflower" + }, + { + "selected": false, + "label": "PigTail Frozen Cheese Pizza", + "value": "PigTail Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Breast", + "value": "PigTail Frozen Chicken Breast" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Thighs", + "value": "PigTail Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Wings", + "value": "PigTail Frozen Chicken Wings" + }, + { + "selected": false, + "label": "PigTail Frozen Corn", + "value": "PigTail Frozen Corn" + }, + { + "selected": false, + "label": "PigTail Frozen Mushroom Pizza", + "value": "PigTail Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Pancakes", + "value": "PigTail Frozen Pancakes" + }, + { + "selected": false, + "label": "PigTail Frozen Peas", + "value": "PigTail Frozen Peas" + }, + { + "selected": false, + "label": "PigTail Frozen Pepperoni Pizza", + "value": "PigTail Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Sausage Pizza", + "value": "PigTail Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "PigTail Grape Popsicles", + "value": "PigTail Grape Popsicles" + }, + { + "selected": false, + "label": "PigTail Home Style French Fries", + "value": "PigTail Home Style French Fries" + }, + { + "selected": false, + "label": "PigTail Ice Cream", + "value": "PigTail Ice Cream" + }, + { + "selected": false, + "label": "PigTail Ice Cream Sandwich", + "value": "PigTail Ice Cream Sandwich" + }, + { + "selected": false, + "label": "PigTail Lemon Popsicles", + "value": "PigTail Lemon Popsicles" + }, + { + "selected": false, + "label": "PigTail Lime Popsicles", + "value": "PigTail Lime Popsicles" + }, + { + "selected": false, + "label": "PigTail Low Fat French Fries", + "value": "PigTail Low Fat French Fries" + }, + { + "selected": false, + "label": "PigTail Low Fat Waffles", + "value": "PigTail Low Fat Waffles" + }, + { + "selected": false, + "label": "PigTail Orange Popsicles", + "value": "PigTail Orange Popsicles" + }, + { + "selected": false, + "label": "PigTail Pancake Mix", + "value": "PigTail Pancake Mix" + }, + { + "selected": false, + "label": "PigTail Popsicles", + "value": "PigTail Popsicles" + }, + { + "selected": false, + "label": "PigTail Turkey TV Dinner", + "value": "PigTail Turkey TV Dinner" + }, + { + "selected": false, + "label": "PigTail Waffles", + "value": "PigTail Waffles" + }, + { + "selected": false, + "label": "Plato Apple Butter", + "value": "Plato Apple Butter" + }, + { + "selected": false, + "label": "Plato Apple Jam", + "value": "Plato Apple Jam" + }, + { + "selected": false, + "label": "Plato Apple Jelly", + "value": "Plato Apple Jelly" + }, + { + "selected": false, + "label": "Plato Apple Preserves", + "value": "Plato Apple Preserves" + }, + { + "selected": false, + "label": "Plato Brown Sugar", + "value": "Plato Brown Sugar" + }, + { + "selected": false, + "label": "Plato Canola Oil", + "value": "Plato Canola Oil" + }, + { + "selected": false, + "label": "Plato Chunky Peanut Butter", + "value": "Plato Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Plato Columbian Coffee", + "value": "Plato Columbian Coffee" + }, + { + "selected": false, + "label": "Plato Corn Oil", + "value": "Plato Corn Oil" + }, + { + "selected": false, + "label": "Plato Creamy Peanut Butter", + "value": "Plato Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Plato Decaf Coffee", + "value": "Plato Decaf Coffee" + }, + { + "selected": false, + "label": "Plato Extra Chunky Peanut Butter", + "value": "Plato Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Plato French Roast Coffee", + "value": "Plato French Roast Coffee" + }, + { + "selected": false, + "label": "Plato Grape Jam", + "value": "Plato Grape Jam" + }, + { + "selected": false, + "label": "Plato Grape Jelly", + "value": "Plato Grape Jelly" + }, + { + "selected": false, + "label": "Plato Grape Preserves", + "value": "Plato Grape Preserves" + }, + { + "selected": false, + "label": "Plato Hot Chocolate", + "value": "Plato Hot Chocolate" + }, + { + "selected": false, + "label": "Plato Low Fat Apple Butter", + "value": "Plato Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Plato Oregano", + "value": "Plato Oregano" + }, + { + "selected": false, + "label": "Plato Pepper", + "value": "Plato Pepper" + }, + { + "selected": false, + "label": "Plato Regular Coffee", + "value": "Plato Regular Coffee" + }, + { + "selected": false, + "label": "Plato Salt", + "value": "Plato Salt" + }, + { + "selected": false, + "label": "Plato Sesame Oil", + "value": "Plato Sesame Oil" + }, + { + "selected": false, + "label": "Plato Strawberry Jam", + "value": "Plato Strawberry Jam" + }, + { + "selected": false, + "label": "Plato Strawberry Jelly", + "value": "Plato Strawberry Jelly" + }, + { + "selected": false, + "label": "Plato Strawberry Preserves", + "value": "Plato Strawberry Preserves" + }, + { + "selected": false, + "label": "Plato Tomato Sauce", + "value": "Plato Tomato Sauce" + }, + { + "selected": false, + "label": "Plato Vegetable Oil", + "value": "Plato Vegetable Oil" + }, + { + "selected": false, + "label": "Plato White Sugar", + "value": "Plato White Sugar" + }, + { + "selected": false, + "label": "Pleasant Beef Soup", + "value": "Pleasant Beef Soup" + }, + { + "selected": false, + "label": "Pleasant Canned Beets", + "value": "Pleasant Canned Beets" + }, + { + "selected": false, + "label": "Pleasant Canned Peas", + "value": "Pleasant Canned Peas" + }, + { + "selected": false, + "label": "Pleasant Canned String Beans", + "value": "Pleasant Canned String Beans" + }, + { + "selected": false, + "label": "Pleasant Canned Tomatos", + "value": "Pleasant Canned Tomatos" + }, + { + "selected": false, + "label": "Pleasant Canned Tuna in Oil", + "value": "Pleasant Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Pleasant Canned Tuna in Water", + "value": "Pleasant Canned Tuna in Water" + }, + { + "selected": false, + "label": "Pleasant Canned Yams", + "value": "Pleasant Canned Yams" + }, + { + "selected": false, + "label": "Pleasant Chicken Noodle Soup", + "value": "Pleasant Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Chicken Ramen Soup", + "value": "Pleasant Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Pleasant Chicken Soup", + "value": "Pleasant Chicken Soup" + }, + { + "selected": false, + "label": "Pleasant Creamed Corn", + "value": "Pleasant Creamed Corn" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Anchovies", + "value": "Pleasant Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Clams", + "value": "Pleasant Fancy Canned Clams" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Oysters", + "value": "Pleasant Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Sardines", + "value": "Pleasant Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Pleasant Large Canned Shrimp", + "value": "Pleasant Large Canned Shrimp" + }, + { + "selected": false, + "label": "Pleasant Noodle Soup", + "value": "Pleasant Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Regular Ramen Soup", + "value": "Pleasant Regular Ramen Soup" + }, + { + "selected": false, + "label": "Pleasant Rice Soup", + "value": "Pleasant Rice Soup" + }, + { + "selected": false, + "label": "Pleasant Turkey Noodle Soup", + "value": "Pleasant Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Vegetable Soup", + "value": "Pleasant Vegetable Soup" + }, + { + "selected": false, + "label": "Portsmouth Chablis Wine", + "value": "Portsmouth Chablis Wine" + }, + { + "selected": false, + "label": "Portsmouth Chardonnay", + "value": "Portsmouth Chardonnay" + }, + { + "selected": false, + "label": "Portsmouth Chardonnay Wine", + "value": "Portsmouth Chardonnay Wine" + }, + { + "selected": false, + "label": "Portsmouth Imported Beer", + "value": "Portsmouth Imported Beer" + }, + { + "selected": false, + "label": "Portsmouth Light Beer", + "value": "Portsmouth Light Beer" + }, + { + "selected": false, + "label": "Portsmouth Light Wine", + "value": "Portsmouth Light Wine" + }, + { + "selected": false, + "label": "Portsmouth Merlot Wine", + "value": "Portsmouth Merlot Wine" + }, + { + "selected": false, + "label": "Portsmouth White Zinfandel Wine", + "value": "Portsmouth White Zinfandel Wine" + }, + { + "selected": false, + "label": "Prelude Rosy Sunglasses", + "value": "Prelude Rosy Sunglasses" + }, + { + "selected": false, + "label": "Queen City Map", + "value": "Queen City Map" + }, + { + "selected": false, + "label": "Queen Eyeglass Screwdriver", + "value": "Queen Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Quick Extra Lean Hamburger", + "value": "Quick Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Quick Seasoned Hamburger", + "value": "Quick Seasoned Hamburger" + }, + { + "selected": false, + "label": "Radius Corn Puffs", + "value": "Radius Corn Puffs" + }, + { + "selected": false, + "label": "Radius Grits", + "value": "Radius Grits" + }, + { + "selected": false, + "label": "Radius Oatmeal", + "value": "Radius Oatmeal" + }, + { + "selected": false, + "label": "Radius Wheat Puffs", + "value": "Radius Wheat Puffs" + }, + { + "selected": false, + "label": "Red Spade Beef Bologna", + "value": "Red Spade Beef Bologna" + }, + { + "selected": false, + "label": "Red Spade Chicken Hot Dogs", + "value": "Red Spade Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Red Spade Cole Slaw", + "value": "Red Spade Cole Slaw" + }, + { + "selected": false, + "label": "Red Spade Corned Beef", + "value": "Red Spade Corned Beef" + }, + { + "selected": false, + "label": "Red Spade Foot-Long Hot Dogs", + "value": "Red Spade Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Red Spade Low Fat Bologna", + "value": "Red Spade Low Fat Bologna" + }, + { + "selected": false, + "label": "Red Spade Low Fat Cole Slaw", + "value": "Red Spade Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Red Spade Pimento Loaf", + "value": "Red Spade Pimento Loaf" + }, + { + "selected": false, + "label": "Red Spade Potato Salad", + "value": "Red Spade Potato Salad" + }, + { + "selected": false, + "label": "Red Spade Roasted Chicken", + "value": "Red Spade Roasted Chicken" + }, + { + "selected": false, + "label": "Red Spade Sliced Chicken", + "value": "Red Spade Sliced Chicken" + }, + { + "selected": false, + "label": "Red Spade Sliced Ham", + "value": "Red Spade Sliced Ham" + }, + { + "selected": false, + "label": "Red Spade Sliced Turkey", + "value": "Red Spade Sliced Turkey" + }, + { + "selected": false, + "label": "Red Spade Turkey Hot Dogs", + "value": "Red Spade Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Red Wing 100 Watt Lightbulb", + "value": "Red Wing 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 25 Watt Lightbulb", + "value": "Red Wing 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 60 Watt Lightbulb", + "value": "Red Wing 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 75 Watt Lightbulb", + "value": "Red Wing 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing AAA-Size Batteries", + "value": "Red Wing AAA-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing AA-Size Batteries", + "value": "Red Wing AA-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing Bees Wax Candles", + "value": "Red Wing Bees Wax Candles" + }, + { + "selected": false, + "label": "Red Wing Copper Cleaner", + "value": "Red Wing Copper Cleaner" + }, + { + "selected": false, + "label": "Red Wing Copper Pot Scrubber", + "value": "Red Wing Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Red Wing Counter Cleaner", + "value": "Red Wing Counter Cleaner" + }, + { + "selected": false, + "label": "Red Wing C-Size Batteries", + "value": "Red Wing C-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing D-Size Batteries", + "value": "Red Wing D-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing Economy Toilet Brush", + "value": "Red Wing Economy Toilet Brush" + }, + { + "selected": false, + "label": "Red Wing Frying Pan", + "value": "Red Wing Frying Pan" + }, + { + "selected": false, + "label": "Red Wing Glass Cleaner", + "value": "Red Wing Glass Cleaner" + }, + { + "selected": false, + "label": "Red Wing Large Sponge", + "value": "Red Wing Large Sponge" + }, + { + "selected": false, + "label": "Red Wing Paper Cups", + "value": "Red Wing Paper Cups" + }, + { + "selected": false, + "label": "Red Wing Paper Plates", + "value": "Red Wing Paper Plates" + }, + { + "selected": false, + "label": "Red Wing Paper Towels", + "value": "Red Wing Paper Towels" + }, + { + "selected": false, + "label": "Red Wing Plastic Forks", + "value": "Red Wing Plastic Forks" + }, + { + "selected": false, + "label": "Red Wing Plastic Knives", + "value": "Red Wing Plastic Knives" + }, + { + "selected": false, + "label": "Red Wing Plastic Spoons", + "value": "Red Wing Plastic Spoons" + }, + { + "selected": false, + "label": "Red Wing Room Freshener", + "value": "Red Wing Room Freshener" + }, + { + "selected": false, + "label": "Red Wing Scented Tissue", + "value": "Red Wing Scented Tissue" + }, + { + "selected": false, + "label": "Red Wing Scented Toilet Tissue", + "value": "Red Wing Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Red Wing Scissors", + "value": "Red Wing Scissors" + }, + { + "selected": false, + "label": "Red Wing Screw Driver", + "value": "Red Wing Screw Driver" + }, + { + "selected": false, + "label": "Red Wing Silver Cleaner", + "value": "Red Wing Silver Cleaner" + }, + { + "selected": false, + "label": "Red Wing Soft Napkins", + "value": "Red Wing Soft Napkins" + }, + { + "selected": false, + "label": "Red Wing Tissues", + "value": "Red Wing Tissues" + }, + { + "selected": false, + "label": "Red Wing Toilet Bowl Cleaner", + "value": "Red Wing Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Red Wing Toilet Paper", + "value": "Red Wing Toilet Paper" + }, + { + "selected": false, + "label": "Robust Monthly Auto Magazine", + "value": "Robust Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Computer Magazine", + "value": "Robust Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Fashion Magazine", + "value": "Robust Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Home Magazine", + "value": "Robust Monthly Home Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Sports Magazine", + "value": "Robust Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Shady Lake Manicotti", + "value": "Shady Lake Manicotti" + }, + { + "selected": false, + "label": "Shady Lake Ravioli", + "value": "Shady Lake Ravioli" + }, + { + "selected": false, + "label": "Shady Lake Rice Medly", + "value": "Shady Lake Rice Medly" + }, + { + "selected": false, + "label": "Shady Lake Spaghetti", + "value": "Shady Lake Spaghetti" + }, + { + "selected": false, + "label": "Shady Lake Thai Rice", + "value": "Shady Lake Thai Rice" + }, + { + "selected": false, + "label": "Ship Shape Extra Lean Hamburger", + "value": "Ship Shape Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Ship Shape Seasoned Hamburger", + "value": "Ship Shape Seasoned Hamburger" + }, + { + "selected": false, + "label": "Skinner Apple Drink", + "value": "Skinner Apple Drink" + }, + { + "selected": false, + "label": "Skinner Apple Juice", + "value": "Skinner Apple Juice" + }, + { + "selected": false, + "label": "Skinner Berry Juice", + "value": "Skinner Berry Juice" + }, + { + "selected": false, + "label": "Skinner Cola", + "value": "Skinner Cola" + }, + { + "selected": false, + "label": "Skinner Cranberry Juice", + "value": "Skinner Cranberry Juice" + }, + { + "selected": false, + "label": "Skinner Cream Soda", + "value": "Skinner Cream Soda" + }, + { + "selected": false, + "label": "Skinner Diet Cola", + "value": "Skinner Diet Cola" + }, + { + "selected": false, + "label": "Skinner Diet Soda", + "value": "Skinner Diet Soda" + }, + { + "selected": false, + "label": "Skinner Mango Drink", + "value": "Skinner Mango Drink" + }, + { + "selected": false, + "label": "Skinner Orange Juice", + "value": "Skinner Orange Juice" + }, + { + "selected": false, + "label": "Skinner Strawberry Drink", + "value": "Skinner Strawberry Drink" + }, + { + "selected": false, + "label": "Special Corn Puffs", + "value": "Special Corn Puffs" + }, + { + "selected": false, + "label": "Special Grits", + "value": "Special Grits" + }, + { + "selected": false, + "label": "Special Oatmeal", + "value": "Special Oatmeal" + }, + { + "selected": false, + "label": "Special Wheat Puffs", + "value": "Special Wheat Puffs" + }, + { + "selected": false, + "label": "Sphinx Bagels", + "value": "Sphinx Bagels" + }, + { + "selected": false, + "label": "Sphinx Blueberry Muffins", + "value": "Sphinx Blueberry Muffins" + }, + { + "selected": false, + "label": "Sphinx Cranberry Muffins", + "value": "Sphinx Cranberry Muffins" + }, + { + "selected": false, + "label": "Sphinx English Muffins", + "value": "Sphinx English Muffins" + }, + { + "selected": false, + "label": "Sphinx Muffins", + "value": "Sphinx Muffins" + }, + { + "selected": false, + "label": "Sphinx Pumpernickel Bread", + "value": "Sphinx Pumpernickel Bread" + }, + { + "selected": false, + "label": "Sphinx Rye Bread", + "value": "Sphinx Rye Bread" + }, + { + "selected": false, + "label": "Sphinx Wheat Bread", + "value": "Sphinx Wheat Bread" + }, + { + "selected": false, + "label": "Sphinx White Bread", + "value": "Sphinx White Bread" + }, + { + "selected": false, + "label": "Steady 200 MG Acetominifen", + "value": "Steady 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Steady 200 MG Ibuprofen", + "value": "Steady 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Steady Angled Toothbrush", + "value": "Steady Angled Toothbrush" + }, + { + "selected": false, + "label": "Steady Apricot Shampoo", + "value": "Steady Apricot Shampoo" + }, + { + "selected": false, + "label": "Steady Buffered Aspirin", + "value": "Steady Buffered Aspirin" + }, + { + "selected": false, + "label": "Steady Childrens Aspirin", + "value": "Steady Childrens Aspirin" + }, + { + "selected": false, + "label": "Steady Childrens Cold Remedy", + "value": "Steady Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Steady Conditioning Shampoo", + "value": "Steady Conditioning Shampoo" + }, + { + "selected": false, + "label": "Steady Deodorant", + "value": "Steady Deodorant" + }, + { + "selected": false, + "label": "Steady Dishwasher Detergent", + "value": "Steady Dishwasher Detergent" + }, + { + "selected": false, + "label": "Steady Extra Moisture Shampoo", + "value": "Steady Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Steady HCL Nasal Spray", + "value": "Steady HCL Nasal Spray" + }, + { + "selected": false, + "label": "Steady Laundry Detergent", + "value": "Steady Laundry Detergent" + }, + { + "selected": false, + "label": "Steady Mint Mouthwash", + "value": "Steady Mint Mouthwash" + }, + { + "selected": false, + "label": "Steady Multi-Symptom Cold Remedy", + "value": "Steady Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Steady Silky Smooth Hair Conditioner", + "value": "Steady Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Steady Tartar Control Toothpaste", + "value": "Steady Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Steady Toothpaste", + "value": "Steady Toothpaste" + }, + { + "selected": false, + "label": "Steady Whitening Toothpast", + "value": "Steady Whitening Toothpast" + }, + { + "selected": false, + "label": "Sunset 100 Watt Lightbulb", + "value": "Sunset 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 25 Watt Lightbulb", + "value": "Sunset 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 60 Watt Lightbulb", + "value": "Sunset 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 75 Watt Lightbulb", + "value": "Sunset 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset AAA-Size Batteries", + "value": "Sunset AAA-Size Batteries" + }, + { + "selected": false, + "label": "Sunset AA-Size Batteries", + "value": "Sunset AA-Size Batteries" + }, + { + "selected": false, + "label": "Sunset Bees Wax Candles", + "value": "Sunset Bees Wax Candles" + }, + { + "selected": false, + "label": "Sunset Copper Cleaner", + "value": "Sunset Copper Cleaner" + }, + { + "selected": false, + "label": "Sunset Copper Pot Scrubber", + "value": "Sunset Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Sunset Counter Cleaner", + "value": "Sunset Counter Cleaner" + }, + { + "selected": false, + "label": "Sunset C-Size Batteries", + "value": "Sunset C-Size Batteries" + }, + { + "selected": false, + "label": "Sunset D-Size Batteries", + "value": "Sunset D-Size Batteries" + }, + { + "selected": false, + "label": "Sunset Economy Toilet Brush", + "value": "Sunset Economy Toilet Brush" + }, + { + "selected": false, + "label": "Sunset Frying Pan", + "value": "Sunset Frying Pan" + }, + { + "selected": false, + "label": "Sunset Glass Cleaner", + "value": "Sunset Glass Cleaner" + }, + { + "selected": false, + "label": "Sunset Large Sponge", + "value": "Sunset Large Sponge" + }, + { + "selected": false, + "label": "Sunset Paper Cups", + "value": "Sunset Paper Cups" + }, + { + "selected": false, + "label": "Sunset Paper Plates", + "value": "Sunset Paper Plates" + }, + { + "selected": false, + "label": "Sunset Paper Towels", + "value": "Sunset Paper Towels" + }, + { + "selected": false, + "label": "Sunset Plastic Forks", + "value": "Sunset Plastic Forks" + }, + { + "selected": false, + "label": "Sunset Plastic Knives", + "value": "Sunset Plastic Knives" + }, + { + "selected": false, + "label": "Sunset Plastic Spoons", + "value": "Sunset Plastic Spoons" + }, + { + "selected": false, + "label": "Sunset Room Freshener", + "value": "Sunset Room Freshener" + }, + { + "selected": false, + "label": "Sunset Scented Tissue", + "value": "Sunset Scented Tissue" + }, + { + "selected": false, + "label": "Sunset Scented Toilet Tissue", + "value": "Sunset Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Sunset Scissors", + "value": "Sunset Scissors" + }, + { + "selected": false, + "label": "Sunset Screw Driver", + "value": "Sunset Screw Driver" + }, + { + "selected": false, + "label": "Sunset Silver Cleaner", + "value": "Sunset Silver Cleaner" + }, + { + "selected": false, + "label": "Sunset Soft Napkins", + "value": "Sunset Soft Napkins" + }, + { + "selected": false, + "label": "Sunset Tissues", + "value": "Sunset Tissues" + }, + { + "selected": false, + "label": "Sunset Toilet Bowl Cleaner", + "value": "Sunset Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Sunset Toilet Paper", + "value": "Sunset Toilet Paper" + }, + { + "selected": false, + "label": "Super Apple Butter", + "value": "Super Apple Butter" + }, + { + "selected": false, + "label": "Super Apple Jam", + "value": "Super Apple Jam" + }, + { + "selected": false, + "label": "Super Apple Jelly", + "value": "Super Apple Jelly" + }, + { + "selected": false, + "label": "Super Apple Preserves", + "value": "Super Apple Preserves" + }, + { + "selected": false, + "label": "Super Brown Sugar", + "value": "Super Brown Sugar" + }, + { + "selected": false, + "label": "Super Canola Oil", + "value": "Super Canola Oil" + }, + { + "selected": false, + "label": "Super Chunky Peanut Butter", + "value": "Super Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Super Columbian Coffee", + "value": "Super Columbian Coffee" + }, + { + "selected": false, + "label": "Super Corn Oil", + "value": "Super Corn Oil" + }, + { + "selected": false, + "label": "Super Creamy Peanut Butter", + "value": "Super Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Super Decaf Coffee", + "value": "Super Decaf Coffee" + }, + { + "selected": false, + "label": "Super Extra Chunky Peanut Butter", + "value": "Super Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Super French Roast Coffee", + "value": "Super French Roast Coffee" + }, + { + "selected": false, + "label": "Super Grape Jam", + "value": "Super Grape Jam" + }, + { + "selected": false, + "label": "Super Grape Jelly", + "value": "Super Grape Jelly" + }, + { + "selected": false, + "label": "Super Grape Preserves", + "value": "Super Grape Preserves" + }, + { + "selected": false, + "label": "Super Hot Chocolate", + "value": "Super Hot Chocolate" + }, + { + "selected": false, + "label": "Super Low Fat Apple Butter", + "value": "Super Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Super Oregano", + "value": "Super Oregano" + }, + { + "selected": false, + "label": "Super Pepper", + "value": "Super Pepper" + }, + { + "selected": false, + "label": "Super Regular Coffee", + "value": "Super Regular Coffee" + }, + { + "selected": false, + "label": "Super Salt", + "value": "Super Salt" + }, + { + "selected": false, + "label": "Super Sesame Oil", + "value": "Super Sesame Oil" + }, + { + "selected": false, + "label": "Super Strawberry Jam", + "value": "Super Strawberry Jam" + }, + { + "selected": false, + "label": "Super Strawberry Jelly", + "value": "Super Strawberry Jelly" + }, + { + "selected": false, + "label": "Super Strawberry Preserves", + "value": "Super Strawberry Preserves" + }, + { + "selected": false, + "label": "Super Tomato Sauce", + "value": "Super Tomato Sauce" + }, + { + "selected": false, + "label": "Super Vegetable Oil", + "value": "Super Vegetable Oil" + }, + { + "selected": false, + "label": "Super White Sugar", + "value": "Super White Sugar" + }, + { + "selected": false, + "label": "Swell Canned Mixed Fruit", + "value": "Swell Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Swell Canned Peaches", + "value": "Swell Canned Peaches" + }, + { + "selected": false, + "label": "Symphony Rosy Sunglasses", + "value": "Symphony Rosy Sunglasses" + }, + { + "selected": false, + "label": "Tell Tale Almonds", + "value": "Tell Tale Almonds" + }, + { + "selected": false, + "label": "Tell Tale Asparagus", + "value": "Tell Tale Asparagus" + }, + { + "selected": false, + "label": "Tell Tale Baby Onion", + "value": "Tell Tale Baby Onion" + }, + { + "selected": false, + "label": "Tell Tale Beets", + "value": "Tell Tale Beets" + }, + { + "selected": false, + "label": "Tell Tale Broccoli", + "value": "Tell Tale Broccoli" + }, + { + "selected": false, + "label": "Tell Tale Canned Peanuts", + "value": "Tell Tale Canned Peanuts" + }, + { + "selected": false, + "label": "Tell Tale Cantelope", + "value": "Tell Tale Cantelope" + }, + { + "selected": false, + "label": "Tell Tale Cauliflower", + "value": "Tell Tale Cauliflower" + }, + { + "selected": false, + "label": "Tell Tale Corn on the Cob", + "value": "Tell Tale Corn on the Cob" + }, + { + "selected": false, + "label": "Tell Tale Dried Mushrooms", + "value": "Tell Tale Dried Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale Elephant Garlic", + "value": "Tell Tale Elephant Garlic" + }, + { + "selected": false, + "label": "Tell Tale Fancy Plums", + "value": "Tell Tale Fancy Plums" + }, + { + "selected": false, + "label": "Tell Tale Firm Tofu", + "value": "Tell Tale Firm Tofu" + }, + { + "selected": false, + "label": "Tell Tale Fresh Lima Beans", + "value": "Tell Tale Fresh Lima Beans" + }, + { + "selected": false, + "label": "Tell Tale Fuji Apples", + "value": "Tell Tale Fuji Apples" + }, + { + "selected": false, + "label": "Tell Tale Garlic", + "value": "Tell Tale Garlic" + }, + { + "selected": false, + "label": "Tell Tale Golden Delcious Apples", + "value": "Tell Tale Golden Delcious Apples" + }, + { + "selected": false, + "label": "Tell Tale Green Pepper", + "value": "Tell Tale Green Pepper" + }, + { + "selected": false, + "label": "Tell Tale Honey Dew", + "value": "Tell Tale Honey Dew" + }, + { + "selected": false, + "label": "Tell Tale Lemons", + "value": "Tell Tale Lemons" + }, + { + "selected": false, + "label": "Tell Tale Lettuce", + "value": "Tell Tale Lettuce" + }, + { + "selected": false, + "label": "Tell Tale Limes", + "value": "Tell Tale Limes" + }, + { + "selected": false, + "label": "Tell Tale Macintosh Apples", + "value": "Tell Tale Macintosh Apples" + }, + { + "selected": false, + "label": "Tell Tale Mandarin Oranges", + "value": "Tell Tale Mandarin Oranges" + }, + { + "selected": false, + "label": "Tell Tale Mixed Nuts", + "value": "Tell Tale Mixed Nuts" + }, + { + "selected": false, + "label": "Tell Tale Mushrooms", + "value": "Tell Tale Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale New Potatos", + "value": "Tell Tale New Potatos" + }, + { + "selected": false, + "label": "Tell Tale Onions", + "value": "Tell Tale Onions" + }, + { + "selected": false, + "label": "Tell Tale Oranges", + "value": "Tell Tale Oranges" + }, + { + "selected": false, + "label": "Tell Tale Party Nuts", + "value": "Tell Tale Party Nuts" + }, + { + "selected": false, + "label": "Tell Tale Peaches", + "value": "Tell Tale Peaches" + }, + { + "selected": false, + "label": "Tell Tale Plums", + "value": "Tell Tale Plums" + }, + { + "selected": false, + "label": "Tell Tale Potatos", + "value": "Tell Tale Potatos" + }, + { + "selected": false, + "label": "Tell Tale Prepared Salad", + "value": "Tell Tale Prepared Salad" + }, + { + "selected": false, + "label": "Tell Tale Red Delcious Apples", + "value": "Tell Tale Red Delcious Apples" + }, + { + "selected": false, + "label": "Tell Tale Red Pepper", + "value": "Tell Tale Red Pepper" + }, + { + "selected": false, + "label": "Tell Tale Shitake Mushrooms", + "value": "Tell Tale Shitake Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale Squash", + "value": "Tell Tale Squash" + }, + { + "selected": false, + "label": "Tell Tale Summer Squash", + "value": "Tell Tale Summer Squash" + }, + { + "selected": false, + "label": "Tell Tale Sweet Onion", + "value": "Tell Tale Sweet Onion" + }, + { + "selected": false, + "label": "Tell Tale Sweet Peas", + "value": "Tell Tale Sweet Peas" + }, + { + "selected": false, + "label": "Tell Tale Tangerines", + "value": "Tell Tale Tangerines" + }, + { + "selected": false, + "label": "Tell Tale Tomatos", + "value": "Tell Tale Tomatos" + }, + { + "selected": false, + "label": "Tell Tale Walnuts", + "value": "Tell Tale Walnuts" + }, + { + "selected": false, + "label": "Thresher Bubble Gum", + "value": "Thresher Bubble Gum" + }, + { + "selected": false, + "label": "Thresher Malted Milk Balls", + "value": "Thresher Malted Milk Balls" + }, + { + "selected": false, + "label": "Thresher Mint Chocolate Bar", + "value": "Thresher Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Thresher Mints", + "value": "Thresher Mints" + }, + { + "selected": false, + "label": "Thresher Semi-Sweet Chocolate Bar", + "value": "Thresher Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Thresher Spicy Mints", + "value": "Thresher Spicy Mints" + }, + { + "selected": false, + "label": "Thresher Tasty Candy Bar", + "value": "Thresher Tasty Candy Bar" + }, + { + "selected": false, + "label": "Thresher White Chocolate Bar", + "value": "Thresher White Chocolate Bar" + }, + { + "selected": false, + "label": "Tip Top Lox", + "value": "Tip Top Lox" + }, + { + "selected": false, + "label": "Tip Top Scallops", + "value": "Tip Top Scallops" + }, + { + "selected": false, + "label": "Token Apple Drink", + "value": "Token Apple Drink" + }, + { + "selected": false, + "label": "Token Apple Juice", + "value": "Token Apple Juice" + }, + { + "selected": false, + "label": "Token Berry Juice", + "value": "Token Berry Juice" + }, + { + "selected": false, + "label": "Token Cola", + "value": "Token Cola" + }, + { + "selected": false, + "label": "Token Cranberry Juice", + "value": "Token Cranberry Juice" + }, + { + "selected": false, + "label": "Token Cream Soda", + "value": "Token Cream Soda" + }, + { + "selected": false, + "label": "Token Diet Cola", + "value": "Token Diet Cola" + }, + { + "selected": false, + "label": "Token Diet Soda", + "value": "Token Diet Soda" + }, + { + "selected": false, + "label": "Token Mango Drink", + "value": "Token Mango Drink" + }, + { + "selected": false, + "label": "Token Orange Juice", + "value": "Token Orange Juice" + }, + { + "selected": false, + "label": "Token Strawberry Drink", + "value": "Token Strawberry Drink" + }, + { + "selected": false, + "label": "Top Measure Chablis Wine", + "value": "Top Measure Chablis Wine" + }, + { + "selected": false, + "label": "Top Measure Chardonnay", + "value": "Top Measure Chardonnay" + }, + { + "selected": false, + "label": "Top Measure Chardonnay Wine", + "value": "Top Measure Chardonnay Wine" + }, + { + "selected": false, + "label": "Top Measure Imported Beer", + "value": "Top Measure Imported Beer" + }, + { + "selected": false, + "label": "Top Measure Light Beer", + "value": "Top Measure Light Beer" + }, + { + "selected": false, + "label": "Top Measure Light Wine", + "value": "Top Measure Light Wine" + }, + { + "selected": false, + "label": "Top Measure Merlot Wine", + "value": "Top Measure Merlot Wine" + }, + { + "selected": false, + "label": "Top Measure White Zinfandel Wine", + "value": "Top Measure White Zinfandel Wine" + }, + { + "selected": false, + "label": "Toretti Rosy Sunglasses", + "value": "Toretti Rosy Sunglasses" + }, + { + "selected": false, + "label": "Toucan Canned Mixed Fruit", + "value": "Toucan Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Toucan Canned Peaches", + "value": "Toucan Canned Peaches" + }, + { + "selected": false, + "label": "Tri-State Almonds", + "value": "Tri-State Almonds" + }, + { + "selected": false, + "label": "Tri-State Asparagus", + "value": "Tri-State Asparagus" + }, + { + "selected": false, + "label": "Tri-State Baby Onion", + "value": "Tri-State Baby Onion" + }, + { + "selected": false, + "label": "Tri-State Beets", + "value": "Tri-State Beets" + }, + { + "selected": false, + "label": "Tri-State Broccoli", + "value": "Tri-State Broccoli" + }, + { + "selected": false, + "label": "Tri-State Canned Peanuts", + "value": "Tri-State Canned Peanuts" + }, + { + "selected": false, + "label": "Tri-State Cantelope", + "value": "Tri-State Cantelope" + }, + { + "selected": false, + "label": "Tri-State Cauliflower", + "value": "Tri-State Cauliflower" + }, + { + "selected": false, + "label": "Tri-State Corn on the Cob", + "value": "Tri-State Corn on the Cob" + }, + { + "selected": false, + "label": "Tri-State Dried Mushrooms", + "value": "Tri-State Dried Mushrooms" + }, + { + "selected": false, + "label": "Tri-State Elephant Garlic", + "value": "Tri-State Elephant Garlic" + }, + { + "selected": false, + "label": "Tri-State Fancy Plums", + "value": "Tri-State Fancy Plums" + }, + { + "selected": false, + "label": "Tri-State Firm Tofu", + "value": "Tri-State Firm Tofu" + }, + { + "selected": false, + "label": "Tri-State Fresh Lima Beans", + "value": "Tri-State Fresh Lima Beans" + }, + { + "selected": false, + "label": "Tri-State Fuji Apples", + "value": "Tri-State Fuji Apples" + }, + { + "selected": false, + "label": "Tri-State Garlic", + "value": "Tri-State Garlic" + }, + { + "selected": false, + "label": "Tri-State Golden Delcious Apples", + "value": "Tri-State Golden Delcious Apples" + }, + { + "selected": false, + "label": "Tri-State Green Pepper", + "value": "Tri-State Green Pepper" + }, + { + "selected": false, + "label": "Tri-State Honey Dew", + "value": "Tri-State Honey Dew" + }, + { + "selected": false, + "label": "Tri-State Lemons", + "value": "Tri-State Lemons" + }, + { + "selected": false, + "label": "Tri-State Lettuce", + "value": "Tri-State Lettuce" + }, + { + "selected": false, + "label": "Tri-State Limes", + "value": "Tri-State Limes" + }, + { + "selected": false, + "label": "Tri-State Macintosh Apples", + "value": "Tri-State Macintosh Apples" + }, + { + "selected": false, + "label": "Tri-State Mandarin Oranges", + "value": "Tri-State Mandarin Oranges" + }, + { + "selected": false, + "label": "Tri-State Mixed Nuts", + "value": "Tri-State Mixed Nuts" + }, + { + "selected": false, + "label": "Tri-State Mushrooms", + "value": "Tri-State Mushrooms" + }, + { + "selected": false, + "label": "Tri-State New Potatos", + "value": "Tri-State New Potatos" + }, + { + "selected": false, + "label": "Tri-State Onions", + "value": "Tri-State Onions" + }, + { + "selected": false, + "label": "Tri-State Oranges", + "value": "Tri-State Oranges" + }, + { + "selected": false, + "label": "Tri-State Party Nuts", + "value": "Tri-State Party Nuts" + }, + { + "selected": false, + "label": "Tri-State Peaches", + "value": "Tri-State Peaches" + }, + { + "selected": false, + "label": "Tri-State Plums", + "value": "Tri-State Plums" + }, + { + "selected": false, + "label": "Tri-State Potatos", + "value": "Tri-State Potatos" + }, + { + "selected": false, + "label": "Tri-State Prepared Salad", + "value": "Tri-State Prepared Salad" + }, + { + "selected": false, + "label": "Tri-State Red Delcious Apples", + "value": "Tri-State Red Delcious Apples" + }, + { + "selected": false, + "label": "Tri-State Red Pepper", + "value": "Tri-State Red Pepper" + }, + { + "selected": false, + "label": "Tri-State Shitake Mushrooms", + "value": "Tri-State Shitake Mushrooms" + }, + { + "selected": false, + "label": "Tri-State Squash", + "value": "Tri-State Squash" + }, + { + "selected": false, + "label": "Tri-State Summer Squash", + "value": "Tri-State Summer Squash" + }, + { + "selected": false, + "label": "Tri-State Sweet Onion", + "value": "Tri-State Sweet Onion" + }, + { + "selected": false, + "label": "Tri-State Sweet Peas", + "value": "Tri-State Sweet Peas" + }, + { + "selected": false, + "label": "Tri-State Tangerines", + "value": "Tri-State Tangerines" + }, + { + "selected": false, + "label": "Tri-State Tomatos", + "value": "Tri-State Tomatos" + }, + { + "selected": false, + "label": "Tri-State Walnuts", + "value": "Tri-State Walnuts" + }, + { + "selected": false, + "label": "Urban Egg Substitute", + "value": "Urban Egg Substitute" + }, + { + "selected": false, + "label": "Urban Large Brown Eggs", + "value": "Urban Large Brown Eggs" + }, + { + "selected": false, + "label": "Urban Large Eggs", + "value": "Urban Large Eggs" + }, + { + "selected": false, + "label": "Urban Small Brown Eggs", + "value": "Urban Small Brown Eggs" + }, + { + "selected": false, + "label": "Urban Small Eggs", + "value": "Urban Small Eggs" + }, + { + "selected": false, + "label": "Walrus Chablis Wine", + "value": "Walrus Chablis Wine" + }, + { + "selected": false, + "label": "Walrus Chardonnay", + "value": "Walrus Chardonnay" + }, + { + "selected": false, + "label": "Walrus Chardonnay Wine", + "value": "Walrus Chardonnay Wine" + }, + { + "selected": false, + "label": "Walrus Imported Beer", + "value": "Walrus Imported Beer" + }, + { + "selected": false, + "label": "Walrus Light Beer", + "value": "Walrus Light Beer" + }, + { + "selected": false, + "label": "Walrus Light Wine", + "value": "Walrus Light Wine" + }, + { + "selected": false, + "label": "Walrus Merlot Wine", + "value": "Walrus Merlot Wine" + }, + { + "selected": false, + "label": "Walrus White Zinfandel Wine", + "value": "Walrus White Zinfandel Wine" + }, + { + "selected": false, + "label": "Washington Apple Drink", + "value": "Washington Apple Drink" + }, + { + "selected": false, + "label": "Washington Apple Juice", + "value": "Washington Apple Juice" + }, + { + "selected": false, + "label": "Washington Berry Juice", + "value": "Washington Berry Juice" + }, + { + "selected": false, + "label": "Washington Cola", + "value": "Washington Cola" + }, + { + "selected": false, + "label": "Washington Cranberry Juice", + "value": "Washington Cranberry Juice" + }, + { + "selected": false, + "label": "Washington Cream Soda", + "value": "Washington Cream Soda" + }, + { + "selected": false, + "label": "Washington Diet Cola", + "value": "Washington Diet Cola" + }, + { + "selected": false, + "label": "Washington Diet Soda", + "value": "Washington Diet Soda" + }, + { + "selected": false, + "label": "Washington Mango Drink", + "value": "Washington Mango Drink" + }, + { + "selected": false, + "label": "Washington Orange Juice", + "value": "Washington Orange Juice" + }, + { + "selected": false, + "label": "Washington Strawberry Drink", + "value": "Washington Strawberry Drink" + } + ] }, { - "version": 2, - "permissionMask": 1, - "creationDate": "2015-06-05T07:21:12", - "updateDate": "2014-04-25T16:06:57", - "label": "03. Store Segment Performance Report", - "description": "Sample OLAP chart with HTML5 Grouped Bar chart and Filter. Created from an Ad Hoc View.", - "uri": "/public/Samples/Reports/03._Store_Segment_Performance_Report", - "resourceType": "reportUnit" + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", + "id": "sales__product__recyclable_package_1", + "options": [ + { + "selected": true, + "label": "true", + "value": "true" + }, + { + "selected": true, + "label": "false", + "value": "false" + } + ] }, { - "version": 1, - "permissionMask": 1, - "creationDate": "2015-06-05T07:21:37", - "updateDate": "2015-05-04T21:05:55", - "label": "1. Supermart Dashboard", - "description": "Sample containing 5 Dashlets and Filter wiring. One Dashlet is a report with hyperlinks, the other Dashlets are defined as part of the Dashboard.", - "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard", - "resourceType": "dashboard" + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", + "id": "sales__product__low_fat_1", + "options": [ + { + "selected": true, + "label": "true", + "value": "true" + }, + { + "selected": true, + "label": "false", + "value": "false" + } + ] }, { - "version": 1, - "permissionMask": 1, - "creationDate": "2015-06-05T07:21:39", - "updateDate": "2015-04-20T20:46:58", - "label": "3.1 Sales Metrics", - "description": "Sample containing Sales related data, hyperlinks, and a hidden filter for embedded Visualize.js demo.", - "uri": "/public/Samples/Dashboards/3.1_Sales_Metrics", - "resourceType": "legacyDashboard" - }, - { - "version": 2, - "permissionMask": 1, - "creationDate": "2015-06-04T13:26:23", - "updateDate": "2015-05-27T22:03:29", - "label": "A4 Landscape", - "uri": "/public/templates/a4_landscape.510.jrxml", - "resourceType": "file" - }, - { - "version": 0, - "permissionMask": 1, - "creationDate": "2015-01-13T01:00:33", - "updateDate": "2014-12-18T09:59:47", - "label": "Ad Hoc Components", - "description": "Ad Hoc Components", - "uri": "/public/adhoc", - "resourceType": "folder" - }, - { - "version": 2, - "permissionMask": 1, - "creationDate": "2015-06-04T13:26:25", - "updateDate": "2015-05-27T22:03:38", - "label": "Audit Archive Domain", - "description": "Use this domain to build audit archive reports", - "uri": "/public/audit/domains/AuditArchiveDomain", - "resourceType": "semanticLayerDataSource" - }, - { - "version": 2, - "permissionMask": 1, - "creationDate": "2015-06-04T13:26:24", - "updateDate": "2015-05-27T22:03:36", - "label": "Audit Data Source", - "description": "Audit Data Source", - "uri": "/public/audit/datasources/AuditDataSource", - "resourceType": "jndiJdbcDataSource" + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", + "id": "sales_fact_ALL__store_sales_2013_1", + "value": "19" } ] } \ No newline at end of file From 9b0602f7f74084ca20727a086077142aa4654537 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 16:02:15 +0300 Subject: [PATCH 077/457] Simplify API for consuming input controls --- client-network/build.gradle | 17 ++++------ .../sdk/network/api/InputControlRestApi.java | 19 ++++++----- .../network/api/InputControlRestApiImpl.java | 32 ++++++++++++------- .../entity/control/InputControlResponse.java | 6 ++-- .../control/InputControlResponseTest.java | 8 ++--- .../api/InputControlRestApiTest.java | 27 +++++++++------- 6 files changed, 58 insertions(+), 51 deletions(-) diff --git a/client-network/build.gradle b/client-network/build.gradle index 1596c987..1aa46dd5 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -36,25 +36,20 @@ dependencies { compile 'com.android.support:support-annotations:22.2.0' compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' compile 'com.squareup.retrofit:retrofit:1.9.0' - - testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' } - testCompile 'org.hamcrest:hamcrest-integration:1.3' - testCompile("org.mockito:mockito-core:1.10.19") { + testCompile('org.mockito:mockito-core:1.10.19') { exclude group: 'org.hamcrest' exclude group: 'org.objenesis' } - testCompile('org.powermock:powermock-api-mockito:1.6.2') { exclude group: 'org.mockito' } - testCompile('org.powermock:powermock-module-junit4:1.6.2') - - testCompile('org.robolectric:shadows-support-v4:3.0') - testCompile('org.robolectric:shadows-httpclient:3.0') - testCompile('com.squareup.okhttp:mockwebserver:2.4.0') - + testCompile 'org.powermock:powermock-module-junit4:1.6.2' + testCompile 'org.robolectric:shadows-support-v4:3.0' + testCompile 'org.robolectric:shadows-httpclient:3.0' + testCompile 'com.squareup.okhttp:mockwebserver:2.4.0' + testCompile project(':js-android-sdk-client') } \ No newline at end of file diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index bd934595..89afd9a9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -27,10 +27,9 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import java.util.List; import java.util.Map; import java.util.Set; @@ -41,7 +40,7 @@ public interface InputControlRestApi { @NonNull - InputControlResponse requestInputControls(@NonNull String reportUri); + List requestInputControls(@NonNull String reportUri); /** * Returns input controls for associated response. Options can be excluded by additional argument. @@ -50,19 +49,19 @@ public interface InputControlRestApi { * * @param reportUri uri of report * @param excludeState exclude field state which incorporates options values for control - * @return response object which wraps {@link InputControl} collection + * @return unmodifiable list of {@link InputControl} */ @NonNull - InputControlResponse requestInputControls(@NonNull String reportUri, boolean excludeState); + List requestInputControls(@NonNull String reportUri, boolean excludeState); @NonNull - InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri); + List requestInputControlsInitialValues(@NonNull String reportUri); @NonNull - InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri, + List requestInputControlsInitialValues(@NonNull String reportUri, boolean freshData); @NonNull - InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + List requestInputControlsValues(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues); @@ -74,10 +73,10 @@ InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, * @param controlsId collection of controls ids * @param controlsValues collection of associated parameters client has provided * @param freshData whether data should be retrieved from cache or not - * @return response object which wraps {@link InputControlState} collection + * @return unmodifiable list of {@link InputControlState} */ @NonNull - InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + List requestInputControlsValues(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues, boolean freshData); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 719af21c..dc1b9a9f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -27,9 +27,13 @@ import android.support.annotation.NonNull; import android.text.TextUtils; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; @@ -54,31 +58,35 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override - public InputControlResponse requestInputControls(@NonNull String reportUri) { - return mRestApi.requestInputControls(reportUri, null); + public List requestInputControls(@NonNull String reportUri) { + return requestInputControls(reportUri, false); } @NonNull @Override - public InputControlResponse requestInputControls(@NonNull String reportUri, boolean excludeState) { - return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); + public List requestInputControls(@NonNull String reportUri, boolean excludeState) { + InputControlResponse response = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); + List controls = response.getValues(); + return Collections.unmodifiableList(controls); } @NonNull @Override - public InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri) { - return mRestApi.requestInputControlsInitialValues(reportUri, false); + public List requestInputControlsInitialValues(@NonNull String reportUri) { + return requestInputControlsInitialValues(reportUri, false); } @NonNull @Override - public InputControlValueResponse requestInputControlsInitialValues(@NonNull String reportUri, boolean freshData) { - return mRestApi.requestInputControlsInitialValues(reportUri, freshData); + public List requestInputControlsInitialValues(@NonNull String reportUri, boolean freshData) { + InputControlValueResponse response = mRestApi.requestInputControlsInitialValues(reportUri, freshData); + List states = response.getValues(); + return Collections.unmodifiableList(states); } @NonNull @Override - public InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + public List requestInputControlsValues(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues) { return requestInputControlsValues(reportUri, controlsId, controlsValues, false); @@ -86,12 +94,14 @@ public InputControlValueResponse requestInputControlsValues(@NonNull String repo @NonNull @Override - public InputControlValueResponse requestInputControlsValues(@NonNull String reportUri, + public List requestInputControlsValues(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues, boolean freshData) { String ids = TextUtils.join(";", controlsId); - return mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + InputControlValueResponse response = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + List states = response.getValues(); + return Collections.unmodifiableList(states); } private interface RestApi { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java index 36a21a34..5cf1b468 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java @@ -38,9 +38,9 @@ public final class InputControlResponse { @Expose @SerializedName(value = "inputControl") - private List mControls = Collections.emptyList(); + private List mValues = Collections.emptyList(); - public List getControls() { - return mControls; + public List getValues() { + return mValues; } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java index 30c7dcfb..c321ad4a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java @@ -43,7 +43,7 @@ public void shouldProperlyAdaptMasterDependencies() { String json = "{\"inputControl\" : [ {\"masterDependencies\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}]}"; InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); - InputControl inputControl = response.getControls().get(0); + InputControl inputControl = response.getValues().get(0); Set deps = inputControl.getMasterDependencies(); assertThat(deps, hasItem("Cascading_state_multi_select")); @@ -54,7 +54,7 @@ public void shouldProperlyAdaptSlaveDependencies() { String json = "{\"inputControl\" : [ {\"slaveDependencies\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}]}"; InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); - InputControl inputControl = response.getControls().get(0); + InputControl inputControl = response.getValues().get(0); Set deps = inputControl.getSlaveDependencies(); assertThat(deps, hasItem("Cascading_state_multi_select")); @@ -65,7 +65,7 @@ public void shouldProperlyAdaptDateTimeValidationRule() { String json = "{\"inputControl\" : [ {\"validationRules\" : [ { \"dateTimeFormatValidationRule\" : { \"errorMessage\" : \"This field is mandatory so you must enter data.\", \"format\": \"YYYY-mm-dd\" } }]} ]}"; InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); - InputControl inputControl = response.getControls().get(0); + InputControl inputControl = response.getValues().get(0); ValidationRule rule = (ValidationRule) inputControl.getValidationRules().toArray()[0]; assertThat(rule.getErrorMessage(), is("This field is mandatory so you must enter data.")); @@ -77,7 +77,7 @@ public void shouldProperlyAdaptMandatoryValidationRule() { String json = "{\"inputControl\" : [ {\"validationRules\" : [ { \"mandatoryValidationRule\" : { \"errorMessage\" : \"This field is mandatory so you must enter data.\" } }]} ]}"; InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); - InputControl inputControl = response.getControls().get(0); + InputControl inputControl = response.getValues().get(0); ValidationRule rule = (ValidationRule) inputControl.getValidationRules().toArray()[0]; assertThat(rule.getErrorMessage(), is("This field is mandatory so you must enter data.")); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 26c755b1..e559beaf 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -27,8 +27,7 @@ import com.jaspersoft.android.sdk.network.api.InputControlRestApi; import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; -import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -36,6 +35,8 @@ import org.junit.Before; import org.junit.Test; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; @@ -65,9 +66,10 @@ public void setup() { @Test public void shouldProvideInputControlsList() { - InputControlResponse response = mRestApi.requestInputControls(REPORT_URI); - assertThat(response.getControls(), is(not(empty()))); - InputControl control = response.getControls().get(0); + List response = mRestApi.requestInputControls(REPORT_URI); + assertThat(response, is(not(empty()))); + + InputControl control = response.get(0); assertThat(control.getState(), is(notNullValue())); } @@ -76,21 +78,22 @@ public void shouldProvideInputControlsList() { */ @Test public void shouldProvideInputControlsListIfStateExcluded() { - InputControlResponse response = mRestApi.requestInputControls(REPORT_URI, true); - assertThat(response.getControls(), is(not(empty()))); - InputControl control = response.getControls().get(0); + List response = mRestApi.requestInputControls(REPORT_URI, true); + assertThat(response, is(not(empty()))); + + InputControl control = response.get(0); assertThat(control.getState(), is(nullValue())); } @Test public void shouldProvideInitialInputControlsValues() { - InputControlValueResponse response = mRestApi.requestInputControlsInitialValues(REPORT_URI); - assertThat(response.getValues(), is(not(empty()))); + List response = mRestApi.requestInputControlsInitialValues(REPORT_URI); + assertThat(response, is(not(empty()))); } @Test public void shouldProvideFreshInitialInputControlsValues() { - InputControlValueResponse response = mRestApi.requestInputControlsInitialValues(REPORT_URI, true); - assertThat(response.getValues(), is(not(empty()))); + List response = mRestApi.requestInputControlsInitialValues(REPORT_URI, true); + assertThat(response, is(not(empty()))); } } From 5660b046a91664996db64ee993e45945016521aa Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Sep 2015 16:04:29 +0300 Subject: [PATCH 078/457] Refactor api method names --- .../sdk/network/api/InputControlRestApi.java | 20 ++++++++--------- .../network/api/InputControlRestApiImpl.java | 22 +++++++++---------- .../api/InputControlRestApiTest.java | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 89afd9a9..820ae9c0 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -55,15 +55,15 @@ public interface InputControlRestApi { List requestInputControls(@NonNull String reportUri, boolean excludeState); @NonNull - List requestInputControlsInitialValues(@NonNull String reportUri); + List requestInputControlsInitialStates(@NonNull String reportUri); @NonNull - List requestInputControlsInitialValues(@NonNull String reportUri, - boolean freshData); + List requestInputControlsInitialStates(@NonNull String reportUri, + boolean freshData); @NonNull - List requestInputControlsValues(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues); + List requestInputControlsStates(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues); /** * Provides values for specified controls. This API helpful to @@ -76,10 +76,10 @@ List requestInputControlsValues(@NonNull String reportUri, * @return unmodifiable list of {@link InputControlState} */ @NonNull - List requestInputControlsValues(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues, - boolean freshData); + List requestInputControlsStates(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues, + boolean freshData); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index dc1b9a9f..f2047375 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -72,13 +72,13 @@ public List requestInputControls(@NonNull String reportUri, boolea @NonNull @Override - public List requestInputControlsInitialValues(@NonNull String reportUri) { - return requestInputControlsInitialValues(reportUri, false); + public List requestInputControlsInitialStates(@NonNull String reportUri) { + return requestInputControlsInitialStates(reportUri, false); } @NonNull @Override - public List requestInputControlsInitialValues(@NonNull String reportUri, boolean freshData) { + public List requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { InputControlValueResponse response = mRestApi.requestInputControlsInitialValues(reportUri, freshData); List states = response.getValues(); return Collections.unmodifiableList(states); @@ -86,18 +86,18 @@ public List requestInputControlsInitialValues(@NonNull String @NonNull @Override - public List requestInputControlsValues(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues) { - return requestInputControlsValues(reportUri, controlsId, controlsValues, false); + public List requestInputControlsStates(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues) { + return requestInputControlsStates(reportUri, controlsId, controlsValues, false); } @NonNull @Override - public List requestInputControlsValues(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues, - boolean freshData) { + public List requestInputControlsStates(@NonNull String reportUri, + @NonNull Set controlsId, + @NonNull Map> controlsValues, + boolean freshData) { String ids = TextUtils.join(";", controlsId); InputControlValueResponse response = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); List states = response.getValues(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index e559beaf..9d5767bf 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -87,13 +87,13 @@ public void shouldProvideInputControlsListIfStateExcluded() { @Test public void shouldProvideInitialInputControlsValues() { - List response = mRestApi.requestInputControlsInitialValues(REPORT_URI); + List response = mRestApi.requestInputControlsInitialStates(REPORT_URI); assertThat(response, is(not(empty()))); } @Test public void shouldProvideFreshInitialInputControlsValues() { - List response = mRestApi.requestInputControlsInitialValues(REPORT_URI, true); + List response = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); assertThat(response, is(not(empty()))); } } From 9f346194d115d01bf1a3ee0a84d4080dbf6e0ada Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Sep 2015 11:33:08 +0300 Subject: [PATCH 079/457] Add few TODO notions to api package --- .../sdk/network/api/InputControlRestApi.java | 4 ++++ .../sdk/network/api/ReportExportRestApi.java | 13 ++++++++++++- .../android/sdk/network/api/ServerRestApi.java | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 820ae9c0..8cb967fa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -60,6 +60,10 @@ public interface InputControlRestApi { @NonNull List requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData); + + /** + * TODO: 1. consider to flatten controls id parameter. + */ @NonNull List requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index f31f276c..2766f318 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -37,16 +37,27 @@ * @since 2.0 */ public interface ReportExportRestApi { - + /** + * TODO: refactor name 'runExecution' -> 'runExportExecution' + */ @NonNull ReportExportExecutionResponse runExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + /** + * TODO: refactor name 'checkExecutionStatus' -> 'checkExportExecutionStatus' + */ @NonNull ExecutionStatusResponse checkExecutionStatus(@NonNull String executionId, @NonNull String exportId); + /** + * TODO: refactor name 'requestOutput' -> 'requestExportOutput' + */ @NonNull ExportResourceResponse requestOutput(@NonNull String executionId, @NonNull String exportId); + /** + * TODO: refactor name 'requestAttachment' -> 'requestExportAttachment' + */ @NonNull ExportInput requestAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 4566334e..f35647fa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -39,6 +39,9 @@ * @since 2.0 */ public interface ServerRestApi { + /** + * TODO: refactor to 'getServerInfo' -> 'requestServerInfo' + */ @NonNull @Headers("Accept: application/json") @GET(value = "/rest_v2/serverInfo") From a397a2d729a28f3b155baf919c8ffadea1f48b19 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Sep 2015 11:50:36 +0300 Subject: [PATCH 080/457] Refactor API methods/fix broken tests --- .../sdk/network/api/ReportExportRestApi.java | 21 +++++------------- .../network/api/ReportExportRestApiImpl.java | 10 ++++----- .../sdk/network/api/ServerRestApi.java | 6 ++--- .../network/api/ReportExportRestApiTest.java | 22 +++++++++---------- .../sdk/network/api/ServerRestApiTest.java | 4 ++-- .../control/InputControlResponseTest.java | 18 ++------------- .../api/ReportExecutionRestApiTest.java | 7 ------ .../api/ReportExportRestApiTest.java | 18 +++------------ .../api/RepositoryRestApiTest.java | 12 ---------- .../test/integration/api/ServerRestTest.java | 16 ++------------ 10 files changed, 32 insertions(+), 102 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 2766f318..aea9931f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -37,29 +37,18 @@ * @since 2.0 */ public interface ReportExportRestApi { - /** - * TODO: refactor name 'runExecution' -> 'runExportExecution' - */ + @NonNull - ReportExportExecutionResponse runExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + ReportExportExecutionResponse runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); - /** - * TODO: refactor name 'checkExecutionStatus' -> 'checkExportExecutionStatus' - */ @NonNull - ExecutionStatusResponse checkExecutionStatus(@NonNull String executionId, @NonNull String exportId); + ExecutionStatusResponse checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); - /** - * TODO: refactor name 'requestOutput' -> 'requestExportOutput' - */ @NonNull - ExportResourceResponse requestOutput(@NonNull String executionId, @NonNull String exportId); + ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId); - /** - * TODO: refactor name 'requestAttachment' -> 'requestExportAttachment' - */ @NonNull - ExportInput requestAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); + ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index f7da90d6..6d29ef13 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -53,20 +53,20 @@ public ReportExportRestApiImpl(RestAdapter restAdapter) { @NonNull @Override - public ReportExportExecutionResponse runExecution(@NonNull String executionId, - @NonNull ExecutionRequestOptions executionOptions) { + public ReportExportExecutionResponse runExportExecution(@NonNull String executionId, + @NonNull ExecutionRequestOptions executionOptions) { return mRestApi.runReportExportExecution(executionId, executionOptions); } @NonNull @Override - public ExecutionStatusResponse checkExecutionStatus(@NonNull String executionId, @NonNull String exportId) { + public ExecutionStatusResponse checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId) { return mRestApi.checkReportExportStatus(executionId, exportId); } @NonNull @Override - public ExportResourceResponse requestOutput(@NonNull String executionId, @NonNull String exportId) { + public ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId) { Response response = mRestApi.requestReportExportOutput(executionId, exportId); RetrofitExportInput exportInput = new RetrofitExportInput(response.getBody()); HeaderUtil headerUtil = HeaderUtil.wrap(response); @@ -77,7 +77,7 @@ public ExportResourceResponse requestOutput(@NonNull String executionId, @NonNul @NonNull @Override - public ExportInput requestAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId) { + public ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId) { Response response = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); ExportInput input = new RetrofitExportInput(response.getBody()); return input; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index f35647fa..7e3d17c3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -39,13 +39,11 @@ * @since 2.0 */ public interface ServerRestApi { - /** - * TODO: refactor to 'getServerInfo' -> 'requestServerInfo' - */ + @NonNull @Headers("Accept: application/json") @GET(value = "/rest_v2/serverInfo") - ServerInfoResponse getServerInfo(); + ServerInfoResponse requestServerInfo(); final class Builder extends BaseBuilder { public Builder(String baseUrl) { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index be8bf3d5..10dd26ec 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -86,7 +86,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runExecution("any_id", ExecutionRequestOptions.newInstance()); + restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.newInstance()); } @Test @@ -94,7 +94,7 @@ public void pathParameterShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); - restApiUnderTest.runExecution(null, ExecutionRequestOptions.newInstance()); + restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.newInstance()); } @Test @@ -102,7 +102,7 @@ public void bodyShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Body parameter value must not be null."); - restApiUnderTest.runExecution("any_id", null); + restApiUnderTest.runExportExecution("any_id", null); } @Test @@ -110,7 +110,7 @@ public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); - restApiUnderTest.checkExecutionStatus(null, "any_id"); + restApiUnderTest.checkExportExecutionStatus(null, "any_id"); } @Test @@ -118,7 +118,7 @@ public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"exportId\" value must not be null."); - restApiUnderTest.checkExecutionStatus("any_id", null); + restApiUnderTest.checkExportExecutionStatus("any_id", null); } @Test @@ -126,7 +126,7 @@ public void executionIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); - restApiUnderTest.requestAttachment(null, "any_id", "any_id"); + restApiUnderTest.requestExportAttachment(null, "any_id", "any_id"); } @Test @@ -134,7 +134,7 @@ public void exportIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"exportId\" value must not be null."); - restApiUnderTest.requestAttachment("any_id", null, "any_id"); + restApiUnderTest.requestExportAttachment("any_id", null, "any_id"); } @Test @@ -142,7 +142,7 @@ public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(RestError.class); mExpectedException.expectMessage("Path parameter \"attachmentId\" value must not be null."); - restApiUnderTest.requestAttachment("any_id", "any_id", null); + restApiUnderTest.requestExportAttachment("any_id", "any_id", null); } @Test @@ -152,7 +152,7 @@ public void requestForOutputShouldParsePagesFromHeader() { .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - ExportResourceResponse resource = restApiUnderTest.requestOutput("any_id", "any_id"); + ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); assertThat(resource.getPages(), is("1-10")); } @@ -163,7 +163,7 @@ public void requestForOutputShouldParseIsFinalHeader() { .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - ExportResourceResponse resource = restApiUnderTest.requestOutput("any_id", "any_id"); + ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); assertThat(resource.isFinal(), is(true)); } @@ -173,7 +173,7 @@ public void requestForAttachmentShouldBeWrappedInsideInput() throws IOException .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - ExportInput resource = restApiUnderTest.requestAttachment("any_id", "any_id", "any_id"); + ExportInput resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java index b2cb7c46..9d398318 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -50,7 +50,7 @@ public void shouldThroughRestErrorForHttpError() { mWebMockRule.enqueue(create500Response()); ServerRestApi restApi = new ServerRestApi.Builder(mWebMockRule.getRootUrl()).build(); - restApi.getServerInfo(); + restApi.requestServerInfo(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java index c321ad4a..54450b9e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java @@ -7,9 +7,6 @@ import org.junit.Test; import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; import java.util.Set; import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; @@ -28,13 +25,13 @@ public class InputControlResponseTest { @Test public void shouldHaveExposeAnnotationForFieldControls() throws NoSuchFieldException { - Field field = InputControlResponse.class.getDeclaredField("mControls"); + Field field = InputControlResponse.class.getDeclaredField("mValues"); assertThat(field, hasAnnotation(Expose.class)); } @Test public void valuesFieldShouldHaveSerializedNameAnnotationForFieldControls() throws NoSuchFieldException { - Field field = InputControlResponse.class.getDeclaredField("mControls"); + Field field = InputControlResponse.class.getDeclaredField("mValues"); assertThat(field, hasSerializedName("inputControl")); } @@ -84,15 +81,4 @@ public void shouldProperlyAdaptMandatoryValidationRule() { assertThat(rule.getType(), is("mandatoryValidationRule")); } - @Test - public void test() { - Map> map = new HashMap>(){{ - put("key", new HashSet(){{ - add("1"); - }}); - }}; - - String a = mGson.toJson(map); - assertThat(a, is("{\"key\": [\"1\"]}")); - } } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 7143dccf..13821c1b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -57,8 +57,6 @@ * @author Tom Koptel * @since 2.0 */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) public class ReportExecutionRestApiTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; @@ -66,11 +64,6 @@ public class ReportExecutionRestApiTest { AuthResponse mAuthResponse; ReportExecutionRestApi mApi; - @Before - public void setup() { - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - } - @Test public void shouldStartReportExecution() { ReportExecutionDetailsResponse response = startExecution(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 34370878..0fb7e2fc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -39,12 +39,7 @@ import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; -import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.httpclient.FakeHttp; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -54,8 +49,6 @@ * @author Tom Koptel * @since 2.0 */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) public class ReportExportRestApiTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; String reportUri = "/public/Samples/Reports/AllAccounts"; @@ -63,11 +56,6 @@ public class ReportExportRestApiTest { ReportExecutionRestApi mExecApi; ReportExportRestApi mExportApi; - @Before - public void setup() { - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - } - @Test public void runExportRequestShouldReturnResult() { ReportExecutionDetailsResponse exec = startExecution(); @@ -79,7 +67,7 @@ public void runExportRequestShouldReturnResult() { public void checkExportRequestStatusShouldReturnResult() { ReportExecutionDetailsResponse exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - ExecutionStatusResponse response = getApi().checkExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); + ExecutionStatusResponse response = getApi().checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); assertThat(response, is(notNullValue())); } @@ -87,7 +75,7 @@ public void checkExportRequestStatusShouldReturnResult() { public void requestExportOutputShouldReturnResult() { ReportExecutionDetailsResponse exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - ExportResourceResponse output = getApi().requestOutput(exec.getExecutionId(), execDetails.getExportId()); + ExportResourceResponse output = getApi().requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); assertThat(output.getExportInput(), is(notNullValue())); assertThat(output.getPages(), is("1-2")); assertThat(output.isFinal(), is(false)); @@ -98,7 +86,7 @@ private ReportExportExecutionResponse startExportExecution(ReportExecutionDetail ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() .withPages("1-2") .withOutputFormat("PDF"); - return getApi().runExecution(exec.getExecutionId(), options); + return getApi().runExportExecution(exec.getExecutionId(), options); } @NonNull diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 39cde67a..aa7a32f8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -34,12 +34,7 @@ import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; -import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; @@ -53,18 +48,11 @@ * @author Tom Koptel * @since 2.0 */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) public class RepositoryRestApiTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; AuthResponse mAuthResponse; - @Before - public void setup() { - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - } - @Test public void shouldRequestListOfResources() throws IOException { RepositoryRestApi api = createApi(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 1e619c42..15050999 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -26,16 +26,11 @@ import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.test.TestLogger; -import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; @@ -47,24 +42,17 @@ * @author Tom Koptel * @since 2.0 */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) public class ServerRestTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; - @Before - public void setup() { - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - } - @Test public void shouldRequestServerInfo() throws IOException { ServerRestApi api = new ServerRestApi.Builder(mobileDemo2) .setLog(TestLogger.get(this)) .setLogLevel(RestApiLogLevel.FULL) .build(); - ServerInfoResponse response = api.getServerInfo(); + ServerInfoResponse response = api.requestServerInfo(); assertThat(response, is(notNullValue())); } } From 74f11bc34290831c61af43f3cc6314c07cd0989f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Sep 2015 11:57:53 +0300 Subject: [PATCH 081/457] Ignore flaky tests --- .../network/api/ReportExecutionRestApi.java | 5 ++- .../api/ReportExecutionRestApiTest.java | 34 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 6ddf007b..7f204dee 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -54,6 +54,9 @@ public interface ReportExecutionRestApi { boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params); + /** + * TODO: API is broken requires investigation before release + */ @NonNull ReportExecutionSearchResponse searchReportExecution(Map params); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 13821c1b..65c2560f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -36,12 +36,8 @@ import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; -import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.httpclient.FakeHttp; import java.util.Collections; import java.util.HashMap; @@ -59,8 +55,9 @@ */ public class ReportExecutionRestApiTest { - String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; - String reportUri = "/public/Samples/Reports/AllAccounts"; + private final String MOBILE_DEMO2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + private final String REPORT_URI1 = "/public/Samples/Reports/AllAccounts"; + private final String REPORT_URI2 = "/public/Samples/Reports/ProfitDetailReport"; AuthResponse mAuthResponse; ReportExecutionRestApi mApi; @@ -71,8 +68,11 @@ public void shouldStartReportExecution() { assertThat(response.getStatus(), is(notNullValue())); } - @Test - public void shouldCancelReportExecution() { + /** + * TODO: TEST IS FLAKY provide workaround + */ + @Ignore + public void shouldCancelReportExecution() throws InterruptedException { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse response = startExecution(); boolean cancelled = api.cancelReportExecution(response.getExecutionId()); @@ -98,7 +98,10 @@ public void shouldCheckReportExecutionStatus() { assertThat(response.getStatus(), is(notNullValue())); } - @Test + /** + * TODO: API is broken requires investigation before release + */ + @Ignore public void searchForExecutionShouldReturnResult() { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); @@ -121,13 +124,18 @@ public void updateOfParametersForExecutionShouldReturnResult() { @NonNull private ReportExecutionDetailsResponse startExecution() { - ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(reportUri); + return startExecution(REPORT_URI1); + } + + @NonNull + private ReportExecutionDetailsResponse startExecution(String uri) { + ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); return getApi().runReportExecution(executionRequestOptions); } private ReportExecutionRestApi getApi() { if (mApi == null) { - mApi = new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) + mApi = new ReportExecutionRestApi.Builder(MOBILE_DEMO2, getAuthResponse().getToken()) .setLog(TestLogger.get(this)) .setLogLevel(RestApiLogLevel.FULL) .build(); @@ -137,7 +145,7 @@ private ReportExecutionRestApi getApi() { private AuthResponse getAuthResponse() { if (mAuthResponse == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(MOBILE_DEMO2).build(); mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null); } return mAuthResponse; From 8426a5a7d3247583265bb54596492bd3a3b60a87 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 3 Sep 2015 15:51:09 +0300 Subject: [PATCH 082/457] Initial migration to Retrofit 2.0 --- client-network/build.gradle | 7 +- .../sdk/network/api/AuthBaseBuilder.java | 22 +--- .../{SafeHeader.java => AuthInterceptor.java} | 50 ++++---- .../sdk/network/api/AuthResponseFactory.java | 12 +- .../network/api/AuthenticationRestApi.java | 9 +- .../api/AuthenticationRestApiImpl.java | 77 +++++++------ .../android/sdk/network/api/BaseBuilder.java | 53 ++++++--- .../android/sdk/network/api/HeaderUtil.java | 69 ----------- .../sdk/network/api/InputControlRestApi.java | 17 +-- .../network/api/InputControlRestApiImpl.java | 49 ++++---- .../network/api/ReportExecutionRestApi.java | 12 +- .../api/ReportExecutionRestApiImpl.java | 79 +++++++------ .../sdk/network/api/ReportExportRestApi.java | 6 +- .../network/api/ReportExportRestApiImpl.java | 57 ++++++---- .../sdk/network/api/RepositoryRestApi.java | 13 +-- .../network/api/RepositoryRestApiImpl.java | 79 +++++++------ .../sdk/network/api/RestApiLogLevel.java | 8 +- .../sdk/network/api/RetrofitExportInput.java | 19 ++-- .../sdk/network/api/ServerRestApi.java | 12 +- .../api/{RetrofitLog.java => Utils.java} | 22 ++-- .../network/entity/export/ExportInput.java | 12 ++ .../sdk/network/exception/ErrorHandler.java | 3 +- .../sdk/network/exception/RestError.java | 56 ++++----- .../exception/RetrofitErrorHandler.java | 33 +++--- .../main/java/retrofit/ResponseEntity.java | 49 -------- .../java/retrofit/RestAdapterWrapper.java | 104 ----------------- .../network/api/AuthResponseFactoryTest.java | 18 +-- .../sdk/network/api/HeaderUtilTest.java | 82 -------------- .../api/ReportExecutionRestApiTest.java | 20 ++-- .../network/api/RetrofitExportInputTest.java | 14 +-- .../sdk/network/api/SafeHeaderTest.java | 107 ------------------ .../api/InputControlRestApiTest.java | 45 +++++--- .../api/ReportExecutionRestApiTest.java | 33 ++++-- .../api/ReportExportRestApiTest.java | 27 ++++- .../api/RepositoryRestApiTest.java | 15 ++- .../test/integration/api/ServerRestTest.java | 6 +- 36 files changed, 488 insertions(+), 808 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{SafeHeader.java => AuthInterceptor.java} (57%) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{RetrofitLog.java => Utils.java} (75%) delete mode 100644 client-network/src/main/java/retrofit/ResponseEntity.java delete mode 100644 client-network/src/main/java/retrofit/RestAdapterWrapper.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/HeaderUtilTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/SafeHeaderTest.java diff --git a/client-network/build.gradle b/client-network/build.gradle index 1aa46dd5..54ba5cf4 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -34,8 +34,12 @@ android { dependencies { compile 'com.android.support:support-annotations:22.2.0' + + compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' + compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' + compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' - compile 'com.squareup.retrofit:retrofit:1.9.0' + testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' } @@ -52,4 +56,5 @@ dependencies { testCompile 'org.robolectric:shadows-httpclient:3.0' testCompile 'com.squareup.okhttp:mockwebserver:2.4.0' testCompile project(':js-android-sdk-client') + compile 'com.squareup.okhttp:okhttp:2.4.0' } \ No newline at end of file diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java index 5a8dbaa6..677c144c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java @@ -24,12 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; - -import retrofit.RequestInterceptor; -import retrofit.RestAdapter; -import retrofit.converter.GsonConverter; - /** * @author Tom Koptel * @since 2.0 @@ -43,21 +37,11 @@ public AuthBaseBuilder(String baseUrl, String cookie) { throw new IllegalArgumentException("Cookie should not be null or empty"); } mCookie = cookie; + setupAuthenticator(); } - @Override - public RestAdapter.Builder getDefaultBuilder() { - RestAdapter.Builder builder = super.getDefaultBuilder(); - - builder.setConverter(new GsonConverter(GsonFactory.create())); - builder.setRequestInterceptor(new RequestInterceptor() { - @Override - public void intercept(RequestFacade request) { - request.addHeader("Cookie", getCookie()); - } - }); - - return builder; + private void setupAuthenticator() { + getClient().interceptors().add(AuthInterceptor.newInstance(mCookie)); } public String getCookie() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/SafeHeader.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java similarity index 57% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/SafeHeader.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java index 404b121b..b23b5c66 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/SafeHeader.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java @@ -24,46 +24,36 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import com.squareup.okhttp.Interceptor; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; -import retrofit.client.Header; +import java.io.IOException; + +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; /** * @author Tom Koptel * @since 2.0 */ -final class SafeHeader { - private final Header mHeader; - - SafeHeader(@Nullable Header header) { - mHeader = header; - } +final class AuthInterceptor implements Interceptor { + private final String mToken; - public int asInt() { - if (mHeader == null) { - return 0; - } - try { - return Integer.parseInt(mHeader.getValue()); - } catch (NumberFormatException ex) { - return 0; - } + AuthInterceptor(String token) { + mToken = token; } - public boolean asBoolean() { - return mHeader != null && Boolean.parseBoolean(mHeader.getValue()); + public static AuthInterceptor newInstance(String token) { + checkNotNull(token, "Token should not be null"); + return new AuthInterceptor(token); } - @NonNull - public String asString() { - if (mHeader == null) { - return ""; - } - String value = mHeader.getValue(); - if (value == null) { - return ""; - } - return value; + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + Request compressedRequest = originalRequest.newBuilder() + .header("Cookie", "mToken") + .build(); + return chain.proceed(compressedRequest); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java index 533ec2dd..0c70e91f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java @@ -26,12 +26,10 @@ import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import retrofit.client.Header; -import retrofit.client.Response; +import retrofit.Response; /** * @author Tom Koptel @@ -45,13 +43,7 @@ final class AuthResponseFactory { } public static AuthResponse create(Response response) { - List
headers = response.getHeaders(); - List parts = new ArrayList<>(); - for (Header header : headers) { - if (header.getName().equals("Set-Cookie")) { - parts.add(header.getValue()); - } - } + List parts = response.headers().values("Set-Cookie"); AuthResponseFactory responseFactory = new AuthResponseFactory(parts); return responseFactory.create(); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index c4b5568c..ccb83098 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -32,9 +32,6 @@ import java.util.Map; -import retrofit.RestAdapter; -import retrofit.client.OkClient; - /** * @author Tom Koptel * @since 2.0 @@ -53,13 +50,11 @@ public Builder(String baseUrl) { @Override AuthenticationRestApi createApi() { - RestAdapter.Builder builder = getDefaultBuilder(); - OkHttpClient httpClient = new OkHttpClient(); + OkHttpClient httpClient = getClient(); httpClient.setFollowRedirects(false); - builder.setClient(new OkClient(httpClient)); - return new AuthenticationRestApiImpl(builder.build()); + return new AuthenticationRestApiImpl(getDefaultBuilder().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 865ff2d9..1f99c249 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,16 +27,14 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.squareup.okhttp.HttpUrl; -import java.util.List; +import java.io.IOException; import java.util.Map; -import retrofit.RestAdapter; -import retrofit.RetrofitError; -import retrofit.client.Header; -import retrofit.client.Response; +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; import retrofit.http.Headers; import retrofit.http.Multipart; import retrofit.http.POST; @@ -50,7 +48,7 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { private final RestApi mRestApi; - AuthenticationRestApiImpl(RestAdapter restAdapter) { + AuthenticationRestApiImpl(Retrofit restAdapter) { mRestApi = restAdapter.create(RestApi.class); } @@ -61,32 +59,37 @@ public AuthResponse authenticate(@NonNull String username, String organization, Map params) { try { - Response response = mRestApi.authenticate(username, password, organization, params); + Call call = mRestApi.authenticate(username, password, organization, params); + Response response = call.execute(); return createAuthResponse(response); - } catch (RestError error) { - RetrofitError retrofitError = extractRetrofitError(error); - if (retrofitError.getKind() == RetrofitError.Kind.HTTP) { - Response response = retrofitError.getResponse(); - if (containsRedirect(response)) { - String location = retrieveLocation(response); - - if (locationPointsToSuccess(location)) { - return createAuthResponse(response); - } else { - throw error; - } - } else { - throw error; - } - } else { - throw error; - } + // TODO handle CA case here +// } catch (RestError error) { +// RetrofitError retrofitError = extractRetrofitError(error); +// if (retrofitError.getKind() == RetrofitError.Kind.HTTP) { +// Response response = retrofitError.getResponse(); +// if (containsRedirect(response)) { +// String location = retrieveLocation(response); +// +// if (locationPointsToSuccess(location)) { +// return createAuthResponse(response); +// } else { +// throw error; +// } +// } else { +// throw error; +// } +// } else { +// throw error; +// } + } catch (IOException e) { + // Due to Undefined error handling mechanism we forced to rethrow IO + throw new RuntimeException(e); } } - - private RetrofitError extractRetrofitError(RestError error) { - return (RetrofitError) error.getCause(); - } +// +// private RetrofitError extractRetrofitError(RestError error) { +// return (RetrofitError) error.getCause(); +// } private boolean locationPointsToSuccess(String location) { HttpUrl url = HttpUrl.parse(location); @@ -96,17 +99,13 @@ private boolean locationPointsToSuccess(String location) { @NonNull private String retrieveLocation(Response response) { - List
headers = response.getHeaders(); - for (Header header : headers) { - if (header.getName().equals("Location")) { - return header.getValue(); - } - } - throw new IllegalStateException("Missing 'Location' header"); + String location = response.headers().get("Location"); + Utils.checkNotNull(location, "Missing 'Location' header"); + return location; } private boolean containsRedirect(Response response) { - int status = response.getStatus(); + int status = response.code(); return status >= 300 && status < 400; } @@ -118,7 +117,7 @@ interface RestApi { @Multipart @Headers({"Accept:application/json"}) @POST(value = "/j_spring_security_check") - Response authenticate(@Part(value = "j_username") String username, + Call authenticate(@Part(value = "j_username") String username, @Part(value = "j_password") String password, @Part(value = "orgId ") String organization, @PartMap Map params); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index 333ede41..439bdd64 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -24,34 +24,46 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.exception.ErrorHandler; +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; +import com.squareup.okhttp.OkHttpClient; -import retrofit.RestAdapter; -import retrofit.RetrofitError; +import retrofit.GsonConverterFactory; +import retrofit.Retrofit; /** * @author Tom Koptel * @since 2.0 */ abstract class BaseBuilder { - private final RestAdapter.Builder mRestAdapterBuilder; + private final Retrofit.Builder mRestAdapterBuilder; + private final OkHttpClient mOkHttpClient; + private RestApiLog mLog = RestApiLog.NONE; private RestApiLogLevel mLogLevel = RestApiLogLevel.NONE; - public BaseBuilder(String baseUrl){ if (baseUrl == null || baseUrl.length() == 0) { throw new IllegalArgumentException("Base url should not be null or empty"); } - mRestAdapterBuilder = new RestAdapter.Builder(); + mOkHttpClient = new OkHttpClient(); + mRestAdapterBuilder = new Retrofit.Builder(); + + mRestAdapterBuilder.client(mOkHttpClient); + mRestAdapterBuilder.baseUrl(baseUrl); - mRestAdapterBuilder.setEndpoint(baseUrl); - mRestAdapterBuilder.setErrorHandler(new retrofit.ErrorHandler() { - @Override - @SuppressWarnings("unchecked") - public Throwable handleError(RetrofitError cause) { - return ErrorHandler.DEFAULT.handleError(cause); - } - }); + Gson configuredGson = GsonFactory.create(); + mRestAdapterBuilder.addConverterFactory(GsonConverterFactory.create(configuredGson)); + + /* + TODO: Resolve error handling. It is still not clear what API will look like + */ +// mRestAdapterBuilder.setErrorHandler(new retrofit.ErrorHandler() { +// @Override +// @SuppressWarnings("unchecked") +// public Throwable handleError(RetrofitError cause) { +// return ErrorHandler.DEFAULT.handleError(cause); +// } +// }); } @SuppressWarnings("unchecked") @@ -66,15 +78,22 @@ public SubBuilder setLogLevel(RestApiLogLevel logLevel) { return (SubBuilder) this; } - RestAdapter.Builder getDefaultBuilder() { + Retrofit.Builder getDefaultBuilder() { return mRestAdapterBuilder; } + OkHttpClient getClient() { + return mOkHttpClient; + } + abstract API createApi(); public API build() { - mRestAdapterBuilder.setLog(new RetrofitLog(mLog)); - mRestAdapterBuilder.setLogLevel(RestApiLogLevel.toRetrofitLog(mLogLevel)); + /* + TODO: Resolve log handling. Fallback to OkHttp interceptor https://github.com/square/okhttp/wiki/Interceptors + */ +// mRestAdapterBuilder.setLog(new RetrofitLog(mLog)); +// mRestAdapterBuilder.setLogLevel(RestApiLogLevel.toRetrofitLog(mLogLevel)); return createApi(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java deleted file mode 100644 index 9d7307a7..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/HeaderUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import android.support.annotation.NonNull; - -import java.util.ArrayList; -import java.util.List; - -import retrofit.client.Header; -import retrofit.client.Response; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class HeaderUtil { - private final List
mHeaders; - - HeaderUtil(@NonNull List
headers) { - mHeaders = headers; - } - - public static HeaderUtil wrap(@NonNull Response response) { - return new HeaderUtil(response.getHeaders()); - } - - @NonNull - public SafeHeader getFirstHeader(String name) { - List
headers = findHeaders(name); - if (headers.isEmpty()) { - return new SafeHeader(null); - } else { - return new SafeHeader(headers.get(0)); - } - } - - private List
findHeaders(String name) { - List
result = new ArrayList<>(); - for (Header header : mHeaders) { - if (header.getName().equals(name)) { - result.add(header); - } - } - return result; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 8cb967fa..73a84e0b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -27,12 +27,15 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; -import java.util.List; import java.util.Map; import java.util.Set; +import retrofit.Call; + /** * @author Tom Koptel * @since 2.0 @@ -40,7 +43,7 @@ public interface InputControlRestApi { @NonNull - List requestInputControls(@NonNull String reportUri); + Call requestInputControls(@NonNull String reportUri); /** * Returns input controls for associated response. Options can be excluded by additional argument. @@ -52,20 +55,20 @@ public interface InputControlRestApi { * @return unmodifiable list of {@link InputControl} */ @NonNull - List requestInputControls(@NonNull String reportUri, boolean excludeState); + Call requestInputControls(@NonNull String reportUri, boolean excludeState); @NonNull - List requestInputControlsInitialStates(@NonNull String reportUri); + Call requestInputControlsInitialStates(@NonNull String reportUri); @NonNull - List requestInputControlsInitialStates(@NonNull String reportUri, + Call requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData); /** * TODO: 1. consider to flatten controls id parameter. */ @NonNull - List requestInputControlsStates(@NonNull String reportUri, + Call requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues); @@ -80,7 +83,7 @@ List requestInputControlsStates(@NonNull String reportUri, * @return unmodifiable list of {@link InputControlState} */ @NonNull - List requestInputControlsStates(@NonNull String reportUri, + Call requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues, boolean freshData); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index f2047375..7c8e303e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,17 +27,14 @@ import android.support.annotation.NonNull; import android.text.TextUtils; -import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; -import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; -import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Set; -import retrofit.RestAdapter; +import retrofit.Call; +import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; import retrofit.http.Headers; @@ -52,41 +49,37 @@ final class InputControlRestApiImpl implements InputControlRestApi { private final RestApi mRestApi; - InputControlRestApiImpl(RestAdapter restAdapter) { + InputControlRestApiImpl(Retrofit restAdapter) { mRestApi = restAdapter.create(RestApi.class); } @NonNull @Override - public List requestInputControls(@NonNull String reportUri) { + public Call requestInputControls(@NonNull String reportUri) { return requestInputControls(reportUri, false); } @NonNull @Override - public List requestInputControls(@NonNull String reportUri, boolean excludeState) { - InputControlResponse response = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); - List controls = response.getValues(); - return Collections.unmodifiableList(controls); + public Call requestInputControls(@NonNull String reportUri, boolean excludeState) { + return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); } @NonNull @Override - public List requestInputControlsInitialStates(@NonNull String reportUri) { + public Call requestInputControlsInitialStates(@NonNull String reportUri) { return requestInputControlsInitialStates(reportUri, false); } @NonNull @Override - public List requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { - InputControlValueResponse response = mRestApi.requestInputControlsInitialValues(reportUri, freshData); - List states = response.getValues(); - return Collections.unmodifiableList(states); + public Call requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { + return mRestApi.requestInputControlsInitialValues(reportUri, freshData); } @NonNull @Override - public List requestInputControlsStates(@NonNull String reportUri, + public Call requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues) { return requestInputControlsStates(reportUri, controlsId, controlsValues, false); @@ -94,37 +87,35 @@ public List requestInputControlsStates(@NonNull String report @NonNull @Override - public List requestInputControlsStates(@NonNull String reportUri, + public Call requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues, boolean freshData) { String ids = TextUtils.join(";", controlsId); - InputControlValueResponse response = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); - List states = response.getValues(); - return Collections.unmodifiableList(states); + return mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); } private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reports{reportUnitURI}/inputControls") - InputControlResponse requestInputControls( - @NonNull @Path(value = "reportUnitURI", encode = false) String reportUri, + Call requestInputControls( + @NonNull @Path(value = "reportUnitURI", encoded = false) String reportUri, @Query("exclude") String state); @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reports{reportUnitURI}/inputControls/values") - InputControlValueResponse requestInputControlsInitialValues( - @NonNull @Path(value = "reportUnitURI", encode = false) String reportUri, + Call requestInputControlsInitialValues( + @NonNull @Path(value = "reportUnitURI", encoded = false) String reportUri, @Query("freshData") boolean freshData); @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") - InputControlValueResponse requestInputControlsValues( - @NonNull @Path(value = "reportUnitURI", encode = false) String reportUri, - @NonNull @Path(value = "controlsId", encode = false) String ids, + Call requestInputControlsValues( + @NonNull @Path(value = "reportUnitURI", encoded = false) String reportUri, + @NonNull @Path(value = "controlsId", encoded = false) String ids, @NonNull @Body Map> controlsValues, @Query("freshData") boolean freshData); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 7f204dee..1cfaaed8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -26,15 +26,17 @@ import android.support.annotation.NonNull; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; import java.util.Collection; import java.util.Map; +import retrofit.Call; + /** * @author Tom Koptel * @since 2.0 @@ -42,13 +44,13 @@ public interface ReportExecutionRestApi { @NonNull - ReportExecutionDetailsResponse runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); + Call runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); @NonNull - ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId); + Call requestReportExecutionDetails(@NonNull String executionId); @NonNull - ExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId); + Call requestReportExecutionStatus(@NonNull String executionId); boolean cancelReportExecution(@NonNull String executionId); @@ -58,7 +60,7 @@ public interface ReportExecutionRestApi { * TODO: API is broken requires investigation before release */ @NonNull - ReportExecutionSearchResponse searchReportExecution(Map params); + Call searchReportExecution(Map params); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 248b3209..80bd82f0 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -33,13 +33,13 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; +import java.io.IOException; import java.util.Collection; import java.util.Map; -import retrofit.ResponseEntity; -import retrofit.RestAdapter; -import retrofit.RestAdapterWrapper; -import retrofit.client.Response; +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; import retrofit.http.Headers; @@ -55,89 +55,104 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { private final RestApi mRestApi; - private final RestAdapterWrapper mRestAdapterWrapper; - ReportExecutionRestApiImpl(RestAdapter restAdapter) { + ReportExecutionRestApiImpl(Retrofit restAdapter) { mRestApi = restAdapter.create(RestApi.class); - mRestAdapterWrapper = RestAdapterWrapper.wrap(restAdapter); } @NonNull @Override - public ReportExecutionDetailsResponse runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions) { + public Call runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions) { return mRestApi.runReportExecution(executionOptions); } @NonNull @Override - public ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId) { + public Call requestReportExecutionDetails(@NonNull String executionId) { return mRestApi.requestReportExecutionDetails(executionId); } @NonNull @Override - public ExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId) { + public Call requestReportExecutionStatus(@NonNull String executionId) { return mRestApi.requestReportExecutionStatus(executionId); } @Override public boolean cancelReportExecution(@NonNull String executionId) { - Response response = mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()); - int status = response.getStatus(); - return status != 204; + Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()); + // TODO in order to wrap response we need use CallAdapter approach + try { + Response response = call.execute(); + int status = response.code(); + return status != 204; + } catch (IOException e) { + // We need to wrap response in call. For now we will rethrow error + throw new RuntimeException(e); + } } @Override public boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params) { - Response response = mRestApi.updateReportExecution(executionId, params); - int status = response.getStatus(); - return status == 204; + Call call = mRestApi.updateReportExecution(executionId, params); + Response response = null; + // TODO in order to wrap response we need use CallAdapter approach + try { + response = call.execute(); + int status = response.code(); + return status == 204; + } catch (IOException e) { + // We need to wrap response in call. For now we will rethrow error + throw new RuntimeException(e); + } } @NonNull @Override - public ReportExecutionSearchResponse searchReportExecution(Map params) { - Response response = mRestApi.searchReportExecution(params); - int status = response.getStatus(); - if (status == 204) { - return ReportExecutionSearchResponse.empty(); - } else { - ResponseEntity responseEntity = - mRestAdapterWrapper.produce(response, ReportExecutionSearchResponse.class); - return responseEntity.getEntity(); - } + public Call searchReportExecution(Map params) { + return mRestApi.searchReportExecution(params); + +// TODO we need to use CallAdapater in order to wrap our response in call object +// int status = response.getStatus(); +// if (status == 204) { +// return ReportExecutionSearchResponse.empty(); +// } else { +// ResponseEntity responseEntity = +// mRestAdapterWrapper.produce(response, ReportExecutionSearchResponse.class); +// return responseEntity.getEntity(); +// } } interface RestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions") - ReportExecutionDetailsResponse runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); + Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions/{executionId}") - ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull @Path(value = "executionId", encode = false) String executionId); + Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = false) String executionId); @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions/{executionId}/status") - ExecutionStatusResponse requestReportExecutionStatus(@NonNull @Path(value = "executionId", encode = false) String executionId); + Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = false) String executionId); @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions/{executionId}/parameters") - Response updateReportExecution(@NonNull @Path(value = "executionId", encode = false) String executionId, + Call updateReportExecution(@NonNull @Path(value = "executionId", encoded = false) String executionId, @NonNull @Body Collection params); @NonNull @Headers("Accept: application/json") @PUT("/rest_v2/reportExecutions/{executionId}/status") - Response cancelReportExecution(@NonNull @Path(value = "executionId", encode = false) String executionId, + Call cancelReportExecution(@NonNull @Path(value = "executionId", encoded = false) String executionId, @NonNull @Body ExecutionStatusResponse statusResponse); @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions") - Response searchReportExecution(@Nullable @QueryMap(encodeValues = false) Map params); + Call searchReportExecution(@Nullable @QueryMap(encoded = false) Map params); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index aea9931f..74c7a59b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -32,6 +32,8 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import retrofit.Call; + /** * @author Tom Koptel * @since 2.0 @@ -39,10 +41,10 @@ public interface ReportExportRestApi { @NonNull - ReportExportExecutionResponse runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + Call runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); @NonNull - ExecutionStatusResponse checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); + Call checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); @NonNull ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index 6d29ef13..c6ce9cdd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -31,9 +31,13 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.squareup.okhttp.ResponseBody; -import retrofit.RestAdapter; -import retrofit.client.Response; +import java.io.IOException; + +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; import retrofit.http.Headers; @@ -47,53 +51,68 @@ final class ReportExportRestApiImpl implements ReportExportRestApi { private final RestApi mRestApi; - public ReportExportRestApiImpl(RestAdapter restAdapter) { + public ReportExportRestApiImpl(Retrofit restAdapter) { mRestApi = restAdapter.create(RestApi.class); } @NonNull @Override - public ReportExportExecutionResponse runExportExecution(@NonNull String executionId, - @NonNull ExecutionRequestOptions executionOptions) { + public Call runExportExecution(@NonNull String executionId, + @NonNull ExecutionRequestOptions executionOptions) { return mRestApi.runReportExportExecution(executionId, executionOptions); } @NonNull @Override - public ExecutionStatusResponse checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId) { + public Call checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId) { return mRestApi.checkReportExportStatus(executionId, exportId); } @NonNull @Override public ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId) { - Response response = mRestApi.requestReportExportOutput(executionId, exportId); - RetrofitExportInput exportInput = new RetrofitExportInput(response.getBody()); - HeaderUtil headerUtil = HeaderUtil.wrap(response); - String pages = headerUtil.getFirstHeader("report-pages").asString(); - boolean isFinal = headerUtil.getFirstHeader("output-final").asBoolean(); - return ExportResourceResponse.create(exportInput, pages, isFinal); + Call call = mRestApi.requestReportExportOutput(executionId, exportId); + // TODO in order to wrap response we need use CallAdapter approach + try { + Response response = call.execute(); + com.squareup.okhttp.Headers headers = response.headers(); + + RetrofitExportInput exportInput = new RetrofitExportInput(response.body()); + String pages = headers.get("report-pages"); + boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); + + return ExportResourceResponse.create(exportInput, pages, isFinal); + } catch (IOException e) { + // We need to wrap response in call. For now we will rethrow error + throw new RuntimeException(e); + } } @NonNull @Override public ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId) { - Response response = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); - ExportInput input = new RetrofitExportInput(response.getBody()); - return input; + Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); + // TODO in order to wrap response we need use CallAdapter approach + try { + Response response = call.execute(); + return new RetrofitExportInput(response.body()); + } catch (IOException e) { + // We need to wrap response in call. For now we will rethrow error + throw new RuntimeException(e); + } } private interface RestApi { @NonNull @Headers("Accept: application/json") @POST("/rest_v2/reportExecutions/{executionId}/exports") - ReportExportExecutionResponse runReportExportExecution(@NonNull @Path("executionId") String executionId, + Call runReportExportExecution(@NonNull @Path("executionId") String executionId, @NonNull @Body ExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") - ExecutionStatusResponse checkReportExportStatus(@NonNull @Path("executionId") String executionId, + Call checkReportExportStatus(@NonNull @Path("executionId") String executionId, @NonNull @Path("exportId") String exportId); /** @@ -101,12 +120,12 @@ ExecutionStatusResponse checkReportExportStatus(@NonNull @Path("executionId") St */ @NonNull @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") - Response requestReportExportOutput(@NonNull @Path("executionId") String executionId, + Call requestReportExportOutput(@NonNull @Path("executionId") String executionId, @NonNull @Path("exportId") String exportId); @NonNull @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") - Response requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, + Call requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, @NonNull @Path("exportId") String exportId, @NonNull @Path("attachmentId") String attachmentId); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index c0112816..3692f907 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -35,7 +35,7 @@ import java.util.Map; -import retrofit.RestAdapter; +import retrofit.Call; /** * @author Tom Koptel @@ -46,16 +46,16 @@ public interface RepositoryRestApi { ResourceSearchResponse searchResources(@Nullable Map searchParams); @NonNull - ReportLookupResponse requestReportResource(@NonNull String resourceUri); + Call requestReportResource(@NonNull String resourceUri); @NonNull - DashboardLookupResponse requestDashboardResource(@NonNull String resourceUri); + Call requestDashboardResource(@NonNull String resourceUri); @NonNull - LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull String resourceUri); + Call requestLegacyDashboardResource(@NonNull String resourceUri); @NonNull - FolderLookupResponse requestFolderResource(@NonNull String resourceUri); + Call requestFolderResource(@NonNull String resourceUri); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { @@ -64,8 +64,7 @@ public Builder(String baseUrl, String cookie) { @Override RepositoryRestApi createApi() { - RestAdapter restAdapter = getDefaultBuilder().build(); - return new RepositoryRestApiImpl(restAdapter); + return new RepositoryRestApiImpl(getDefaultBuilder().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index c15d57ef..7e2ff5b6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -33,12 +33,12 @@ import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import java.io.IOException; import java.util.Map; -import retrofit.ResponseEntity; -import retrofit.RestAdapter; -import retrofit.RestAdapterWrapper; -import retrofit.client.Response; +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.Path; @@ -50,61 +50,66 @@ */ final class RepositoryRestApiImpl implements RepositoryRestApi { private final RestApi mRestApi; - private final RestAdapterWrapper mRestAdapterWrapper; - RepositoryRestApiImpl(RestAdapter restAdapter) { + RepositoryRestApiImpl(Retrofit restAdapter) { mRestApi = restAdapter.create(RestApi.class); - mRestAdapterWrapper = RestAdapterWrapper.wrap(restAdapter); } @NonNull @Override public ResourceSearchResponse searchResources(@Nullable Map searchParams) { - Response response = mRestApi.searchResources(searchParams); - int status = response.getStatus(); - if (status == 204) { - return ResourceSearchResponse.empty(); - } else { - ResponseEntity responseEntity = - mRestAdapterWrapper.produce(response, ResourceSearchResponse.class); - ResourceSearchResponse entity = responseEntity.getEntity(); - - HeaderUtil headerUtil = HeaderUtil.wrap(response); - int resultCount = headerUtil.getFirstHeader("Result-Count").asInt(); - int totalCount = headerUtil.getFirstHeader("Total-Count").asInt(); - int startIndex = headerUtil.getFirstHeader("Start-Index").asInt(); - int nextOffset = headerUtil.getFirstHeader("Next-Offset").asInt(); - - entity.setResultCount(resultCount); - entity.setTotalCount(totalCount); - entity.setStartIndex(startIndex); - entity.setNextOffset(nextOffset); - - return entity; + Call call = mRestApi.searchResources(searchParams); + // TODO in order to wrap response we need use CallAdapter approach + try { + Response response = call.execute(); + int status = response.code(); + + if (status == 204) { + return ResourceSearchResponse.empty(); + } else { + ResourceSearchResponse entity = response.body(); + com.squareup.okhttp.Headers headers = response.headers(); + + int resultCount = Integer.valueOf(headers.get("Result-Count")); + int totalCount = Integer.valueOf(headers.get("Total-Count")); + int startIndex = Integer.valueOf(headers.get("Start-Index")); + int nextOffset = Integer.valueOf(headers.get("Next-Offset")); + + entity.setResultCount(resultCount); + entity.setTotalCount(totalCount); + entity.setStartIndex(startIndex); + entity.setNextOffset(nextOffset); + + return entity; + } + + } catch (IOException e) { + // We need to wrap response in call. For now we will rethrow error + throw new RuntimeException(e); } } @NonNull @Override - public ReportLookupResponse requestReportResource(@NonNull String resourceUri) { + public Call requestReportResource(@NonNull String resourceUri) { return mRestApi.requestReportResource(resourceUri); } @NonNull @Override - public DashboardLookupResponse requestDashboardResource(@NonNull String resourceUri) { + public Call requestDashboardResource(@NonNull String resourceUri) { return mRestApi.requestDashboardResource(resourceUri); } @NonNull @Override - public LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull String resourceUri) { + public Call requestLegacyDashboardResource(@NonNull String resourceUri) { return mRestApi.requestLegacyDashboardResource(resourceUri); } @NonNull @Override - public FolderLookupResponse requestFolderResource(@NonNull String resourceUri) { + public Call requestFolderResource(@NonNull String resourceUri) { return mRestApi.requestFolderResource(resourceUri); } @@ -112,26 +117,26 @@ private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("/rest_v2/resources") - Response searchResources(@Nullable @QueryMap Map searchParams); + Call searchResources(@Nullable @QueryMap Map searchParams); @NonNull @Headers("Accept: application/repository.reportUnit+json") @GET("/rest_v2/resources{resourceUri}") - ReportLookupResponse requestReportResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + Call requestReportResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); @NonNull @Headers("Accept: application/repository.dashboard+json") @GET("/rest_v2/resources{resourceUri}") - DashboardLookupResponse requestDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + Call requestDashboardResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); @NonNull @Headers("Accept: application/repository.legacyDashboard+json") @GET("/rest_v2/resources{resourceUri}") - LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + Call requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); @NonNull @Headers("Accept: application/repository.folder+json") @GET("/rest_v2/resources{resourceUri}") - FolderLookupResponse requestFolderResource(@NonNull @Path(value = "resourceUri", encode = false) String resourceUri); + Call requestFolderResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java index 24c22752..682f9694 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import retrofit.RestAdapter; - /** * @author Tom Koptel * @since 2.0 @@ -46,7 +44,7 @@ public enum RestApiLogLevel { */ FULL; - static RestAdapter.LogLevel toRetrofitLog(RestApiLogLevel logLevel) { - return RestAdapter.LogLevel.valueOf(logLevel.name()); - } +// static RestAdapter.LogLevel toRetrofitLog(RestApiLogLevel logLevel) { +// return RestAdapter.LogLevel.valueOf(logLevel.name()); +// } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java index 48b08b69..e0c37009 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java @@ -25,35 +25,38 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.export.ExportInput; +import com.squareup.okhttp.ResponseBody; import java.io.IOException; import java.io.InputStream; -import retrofit.mime.TypedInput; - /** * @author Tom Koptel * @since 2.0 */ final class RetrofitExportInput implements ExportInput { - private final TypedInput mDelegate; + private final ResponseBody mResponse; - public RetrofitExportInput(TypedInput input) { - mDelegate = input; + public RetrofitExportInput(ResponseBody input) { + mResponse = input; } @Override public String getMimeType() { - return mDelegate.mimeType(); + return mResponse.contentType().type(); } @Override public long getLength() { - return mDelegate.length(); + try { + return mResponse.contentLength(); + } catch (IOException e) { + return -1; + } } @Override public InputStream getStream() throws IOException { - return mDelegate.in(); + return mResponse.byteStream(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 7e3d17c3..0e67e319 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -27,10 +27,8 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; -import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; -import retrofit.RestAdapter; -import retrofit.converter.GsonConverter; +import retrofit.Call; import retrofit.http.GET; import retrofit.http.Headers; @@ -43,7 +41,7 @@ public interface ServerRestApi { @NonNull @Headers("Accept: application/json") @GET(value = "/rest_v2/serverInfo") - ServerInfoResponse requestServerInfo(); + Call requestServerInfo(); final class Builder extends BaseBuilder { public Builder(String baseUrl) { @@ -52,11 +50,7 @@ public Builder(String baseUrl) { @Override ServerRestApi createApi() { - RestAdapter.Builder builder = getDefaultBuilder(); - builder.setConverter(new GsonConverter(GsonFactory.create())); - RestAdapter restAdapter = builder.build(); - - return restAdapter.create(ServerRestApi.class); + return getDefaultBuilder().build().create(ServerRestApi.class); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitLog.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java similarity index 75% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitLog.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java index adb874ce..4a079dd8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitLog.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,21 +24,17 @@ package com.jaspersoft.android.sdk.network.api; -import retrofit.RestAdapter; - /** * @author Tom Koptel - * @since 2.0 + * @since 2.2 */ -final class RetrofitLog implements RestAdapter.Log { - private final RestApiLog delegate; - - RetrofitLog(RestApiLog log) { - delegate = log; +final class Utils { + static T checkNotNull(T object, String message) { + if (object == null) { + throw new NullPointerException(message); + } + return object; } - @Override - public void log(String message) { - delegate.log(message); - } + private Utils() {} } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java index b7cc0019..e2dd0974 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java @@ -33,6 +33,18 @@ */ public interface ExportInput { String getMimeType(); + + /** + * TODO ??? do we need this + * @return -1 whether content length undefined + */ long getLength(); + + /** + * Client responsible for closing stream + * + * @return raw stream of bytes of corresponding file + * @throws IOException + */ InputStream getStream() throws IOException; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java index 6dc857f5..774392e4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java @@ -1,11 +1,12 @@ package com.jaspersoft.android.sdk.network.exception; /** + * TODO we need resolve error issues * @author Tom Koptel * @since 2.0 */ public interface ErrorHandler { - ErrorHandler DEFAULT = new RetrofitErrorHandler(); +// ErrorHandler DEFAULT = new RetrofitErrorHandler(); Throwable handleError(ERROR cause); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java index 61a78431..b7f1ce98 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java @@ -25,39 +25,41 @@ package com.jaspersoft.android.sdk.network.exception; -import retrofit.RetrofitError; +//import retrofit.RetrofitError; /** + * TODO we need resolve error issues + * * @author Tom Koptel * @since 2.0 */ public final class RestError extends RuntimeException { - private final Kind mKind; - - RestError(String message, RetrofitError error, Kind kind) { - super(message, error); - mKind = kind; - } - - static RestError createNetworkError(RetrofitError error) { - return new RestError(error.getMessage(), error, Kind.NETWORK); - } - - static RestError createHttpError(RetrofitError error) { - return new RestError(error.getMessage(), error, Kind.HTTP); - } - - static RestError createUnexpectedError(RetrofitError error) { - return new RestError(error.getMessage(), error, Kind.UNEXPECTED); - } +// private final Kind mKind; - public Kind getKind() { - return mKind; - } +// RestError(String message, RetrofitError error, Kind kind) { +// super(message, error); +// mKind = kind; +// } +// +// static RestError createNetworkError(RetrofitError error) { +// return new RestError(error.getMessage(), error, Kind.NETWORK); +// } +// +// static RestError createHttpError(RetrofitError error) { +// return new RestError(error.getMessage(), error, Kind.HTTP); +// } +// +// static RestError createUnexpectedError(RetrofitError error) { +// return new RestError(error.getMessage(), error, Kind.UNEXPECTED); +// } - public enum Kind { - NETWORK, - HTTP, - UNEXPECTED - } +// public Kind getKind() { +// return mKind; +// } +// +// public enum Kind { +// NETWORK, +// HTTP, +// UNEXPECTED +// } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java index 8072d74d..f7b5c204 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java @@ -24,24 +24,25 @@ package com.jaspersoft.android.sdk.network.exception; -import retrofit.*; - /** + * TODO we need resolve error issues + * * @author Tom Koptel * @since 2.0 */ -final class RetrofitErrorHandler implements ErrorHandler { - @Override - public Throwable handleError(RetrofitError error) { - switch (error.getKind()) { - case HTTP: - return RestError.createHttpError(error); - case NETWORK: - return RestError.createNetworkError(error); - case UNEXPECTED: - return RestError.createUnexpectedError(error); - default: - throw error; - } - } +final class RetrofitErrorHandler { +// implements ErrorHandler { +// @Override +// public Throwable handleError(RetrofitError error) { +// switch (error.getKind()) { +// case HTTP: +// return RestError.createHttpError(error); +// case NETWORK: +// return RestError.createNetworkError(error); +// case UNEXPECTED: +// return RestError.createUnexpectedError(error); +// default: +// throw error; +// } +// } } diff --git a/client-network/src/main/java/retrofit/ResponseEntity.java b/client-network/src/main/java/retrofit/ResponseEntity.java deleted file mode 100644 index 9fd05b93..00000000 --- a/client-network/src/main/java/retrofit/ResponseEntity.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package retrofit; - -import retrofit.client.Response; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ResponseEntity { - private final Entity mEntity; - private final Response mResponse; - - public ResponseEntity(Entity entity, Response response) { - mEntity = entity; - mResponse = response; - } - - public Entity getEntity() { - return mEntity; - } - - public Response getResponse() { - return mResponse; - } -} diff --git a/client-network/src/main/java/retrofit/RestAdapterWrapper.java b/client-network/src/main/java/retrofit/RestAdapterWrapper.java deleted file mode 100644 index 0bef113b..00000000 --- a/client-network/src/main/java/retrofit/RestAdapterWrapper.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package retrofit; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -import retrofit.client.Response; -import retrofit.converter.ConversionException; -import retrofit.converter.Converter; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class RestAdapterWrapper { - private final Converter converter; - private final RestAdapter restAdapter; - volatile RestAdapter.LogLevel logLevel; - private final RestAdapter.Log log; - - private RestAdapterWrapper(RestAdapter restAdapter) { - this.restAdapter = restAdapter; - this.converter = restAdapter.converter; - this.log = restAdapter.log; - this.logLevel = restAdapter.logLevel; - } - - public static RestAdapterWrapper wrap(RestAdapter restAdapter) { - return new RestAdapterWrapper(restAdapter); - } - - public RestAdapter getRestAdapter() { - return restAdapter; - } - - @SuppressWarnings("unchecked") - public ResponseEntity produce(Response response, Class type) { - String url = response.getUrl(); - try { - ExceptionCatchingTypedInput wrapped = new ExceptionCatchingTypedInput(response.getBody()); - try { - Object convert = converter.fromBody(wrapped, type); - Entity enity = (Entity) convert; - return new ResponseEntity(enity, response); - } catch (ConversionException e) { - // If the underlying input stream threw an exception, propagate that rather than - // indicating that it was a conversion exception. - if (wrapped.threwException()) { - throw wrapped.getThrownException(); - } - - // The response body was partially read by the converter. Replace it with null. - response = Utils.replaceResponseBody(response, null); - - throw RetrofitError.conversionError(response.getUrl(), response, converter, type, e); - } - } catch (RetrofitError e) { - throw e; // Pass through our own errors. - } catch (IOException e) { - if (logLevel.log()) { - logException(e, url); - } - throw RetrofitError.networkError(url, e); - } catch (Throwable t) { - if (logLevel.log()) { - logException(t, url); - } - throw RetrofitError.unexpectedError(url, t); - } - } - - /** Log an exception that occurred during the processing of a request or response. */ - void logException(Throwable t, String url) { - log.log(String.format("---- ERROR %s", url != null ? url : "")); - StringWriter sw = new StringWriter(); - t.printStackTrace(new PrintWriter(sw)); - log.log(sw.toString()); - log.log("---- END ERROR"); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java index 9909e892..48080c65 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.squareup.okhttp.Headers; import org.junit.Before; import org.junit.Test; @@ -34,10 +35,10 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; -import retrofit.client.Header; -import retrofit.client.Response; +import retrofit.Response; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @@ -60,10 +61,13 @@ public void setup() { @Test public void shouldExtractTokenFromNetworkResponse() { - when(mResponse.getHeaders()).thenReturn(new ArrayList
() {{ - add(new Header("Set-Cookie", "cookie1")); - add(new Header("Set-Cookie", "cookie2")); - }}); + Map headersRaw = new HashMap<>(); + headersRaw.put("Set-Cookie", "cookie1"); + headersRaw.put("Set-Cookie", "cookie2"); + + Headers headers = Headers.of(headersRaw); + when(mResponse.headers()).thenReturn(headers); + AuthResponse response = AuthResponseFactory.create(mResponse); assertThat(response.getToken(), is("cookie1;cookie2")); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/HeaderUtilTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/HeaderUtilTest.java deleted file mode 100644 index 4f7cc315..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/HeaderUtilTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import com.jaspersoft.android.sdk.network.api.HeaderUtil; -import com.jaspersoft.android.sdk.network.api.SafeHeader; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.ArrayList; -import java.util.Collections; - -import retrofit.client.Header; -import retrofit.client.Response; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(Response.class) -public class HeaderUtilTest { - @Mock - Response mResponse; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Test - @SuppressWarnings("unchecked") - public void shouldReturnSafeHeaderIfSearchResultWasEmpty() { - when(mResponse.getHeaders()).thenReturn(Collections.EMPTY_LIST); - HeaderUtil util = HeaderUtil.wrap(mResponse); - SafeHeader safeHeader = util.getFirstHeader("name"); - assertThat(safeHeader, is(notNullValue())); - } - - @Test - public void shouldReturnSafeHeaderForSuccessfulSearch() { - when(mResponse.getHeaders()).thenReturn(new ArrayList
(){{ - add(new Header("name", "value")); - }}); - HeaderUtil util = HeaderUtil.wrap(mResponse); - SafeHeader safeHeader = util.getFirstHeader("name"); - assertThat(safeHeader, is(notNullValue())); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index f7d54157..b1a72c6b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -38,8 +38,12 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import java.io.IOException; import java.util.Collections; +import retrofit.Call; +import retrofit.Response; + import static org.hamcrest.Matchers.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -142,23 +146,23 @@ public void responseShouldBeCancelledIfResponseIs200() { } @Test - public void executionSearchResponseShouldBeEmptyIfResponseIs204() { + public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws IOException { mWebMockRule.enqueue(create204Response()); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(null); - - assertThat(response.getItems(), is(empty())); + Call call = restApiUnderTest.searchReportExecution(null); + Response response = call.execute(); + assertThat(response.body().getItems(), is(empty())); } @Test - public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() { + public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOException { MockResponse mockResponse = create200Response(); mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(null); - - assertThat(response.getItems(), is(not(empty()))); + Call call = restApiUnderTest.searchReportExecution(null); + Response response = call.execute(); + assertThat(response.body().getItems(), is(not(empty()))); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java index 94054cff..0e6b7803 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.RetrofitExportInput; +import com.squareup.okhttp.ResponseBody; import org.junit.Before; import org.junit.Test; @@ -33,8 +33,6 @@ import java.io.IOException; -import retrofit.mime.TypedInput; - import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -44,7 +42,7 @@ */ public class RetrofitExportInputTest { @Mock - TypedInput mTypedInput; + ResponseBody mTypedInput; private RetrofitExportInput objectUnderTest; @@ -57,18 +55,18 @@ public void setup() { @Test public void shouldDelegateMimeType() { objectUnderTest.getMimeType(); - verify(mTypedInput, times(1)).mimeType(); + verify(mTypedInput, times(1)).contentType(); } @Test - public void shouldDelegateLengrh() { + public void shouldDelegateLengrh() throws IOException { objectUnderTest.getLength(); - verify(mTypedInput, times(1)).length(); + verify(mTypedInput, times(1)).contentLength(); } @Test public void shouldDelegateInputStream() throws IOException { objectUnderTest.getStream(); - verify(mTypedInput, times(1)).in(); + verify(mTypedInput, times(1)).byteStream(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/SafeHeaderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/SafeHeaderTest.java deleted file mode 100644 index 20f0bb57..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/SafeHeaderTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import org.junit.Test; - -import retrofit.client.Header; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class SafeHeaderTest { - - @Test - public void forNullHeaderShouldAlwaysReturnSafeValueIfStringRequested() { - SafeHeader safeHeader = new SafeHeader(null); - assertThat(safeHeader.asString(), is(notNullValue())); - assertThat(safeHeader.asString(), is("")); - } - - @Test - public void forNullHeaderShouldAlwaysReturnSafeHeaderIfIntRequested() { - SafeHeader safeHeader = new SafeHeader(null); - assertThat(safeHeader.asInt(), is(0)); - } - - @Test - public void forNullHeaderShouldAlwaysReturnSafeHeaderIfBooleanRequested() { - SafeHeader safeHeader = new SafeHeader(null); - assertThat(safeHeader.asBoolean(), is(false)); - } - - @Test - public void forNumberExceptionReturnsZero() { - SafeHeader safeHeader = new SafeHeader(new Header("any", "NUN")); - assertThat(safeHeader.asInt(), is(0)); - } - - @Test - public void forBooleanParseExceptionReturnsFalse() { - SafeHeader safeHeader = new SafeHeader(new Header("any", "NOT_A_BOOL")); - assertThat(safeHeader.asBoolean(), is(false)); - } - - @Test - public void forMissingValueInHeaderReturnsSafeObjectIfStringRequested() { - SafeHeader safeHeader = new SafeHeader(new Header("any", null)); - assertThat(safeHeader.asString(), is("")); - } - - @Test - public void forMissingValueInHeaderReturnsSafeObjectIfIntRequested() { - SafeHeader safeHeader = new SafeHeader(new Header("any", null)); - assertThat(safeHeader.asInt(), is(0)); - } - - @Test - public void forMissingValueInHeaderReturnsSafeObjectIfBooleanRequested() { - SafeHeader safeHeader = new SafeHeader(new Header("any", null)); - assertThat(safeHeader.asBoolean(), is(false)); - } - - @Test - public void shouldReturnParseIntFromValidHeader() { - SafeHeader safeHeader = new SafeHeader(new Header("any", "100")); - assertThat(safeHeader.asInt(), is(100)); - } - - @Test - public void shouldReturnParseStringFromValidHeader() { - SafeHeader safeHeader = new SafeHeader(new Header("any", "value")); - assertThat(safeHeader.asString(), is("value")); - } - - @Test - public void shouldReturnParseBooleanFromValidHeader() { - SafeHeader safeHeader = new SafeHeader(new Header("any", "true")); - assertThat(safeHeader.asBoolean(), is(true)); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 9d5767bf..15ad9247 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,7 +27,8 @@ import com.jaspersoft.android.sdk.network.api.InputControlRestApi; import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -35,8 +36,12 @@ import org.junit.Before; import org.junit.Test; +import java.io.IOException; import java.util.List; +import retrofit.Call; +import retrofit.Response; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; @@ -65,11 +70,14 @@ public void setup() { } @Test - public void shouldProvideInputControlsList() { - List response = mRestApi.requestInputControls(REPORT_URI); - assertThat(response, is(not(empty()))); + public void shouldProvideInputControlsList() throws IOException { + Call call = mRestApi.requestInputControls(REPORT_URI); + Response response = call.execute(); + + List controls = response.body().getValues(); + assertThat(response.body().getValues(), is(not(empty()))); - InputControl control = response.get(0); + InputControl control = controls.get(0); assertThat(control.getState(), is(notNullValue())); } @@ -77,23 +85,28 @@ public void shouldProvideInputControlsList() { * TODO: Implement annotation to mark specific API tests. */ @Test - public void shouldProvideInputControlsListIfStateExcluded() { - List response = mRestApi.requestInputControls(REPORT_URI, true); - assertThat(response, is(not(empty()))); + public void shouldProvideInputControlsListIfStateExcluded() throws IOException { + Call call = mRestApi.requestInputControls(REPORT_URI, true); + Response response = call.execute(); + + List controls = response.body().getValues(); + assertThat(response.body().getValues(), is(not(empty()))); - InputControl control = response.get(0); + InputControl control = controls.get(0); assertThat(control.getState(), is(nullValue())); } @Test - public void shouldProvideInitialInputControlsValues() { - List response = mRestApi.requestInputControlsInitialStates(REPORT_URI); - assertThat(response, is(not(empty()))); + public void shouldProvideInitialInputControlsValues() throws IOException { + Call call = mRestApi.requestInputControlsInitialStates(REPORT_URI); + Response response = call.execute(); + assertThat(response.body().getValues(), is(not(empty()))); } @Test - public void shouldProvideFreshInitialInputControlsValues() { - List response = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); - assertThat(response, is(not(empty()))); + public void shouldProvideFreshInitialInputControlsValues() throws IOException { + Call call = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); + Response response = call.execute(); + assertThat(response.body().getValues(), is(not(empty()))); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 65c2560f..941d3849 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -39,10 +39,14 @@ import org.junit.Ignore; import org.junit.Test; +import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import retrofit.Call; +import retrofit.Response; + import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -80,37 +84,40 @@ public void shouldCancelReportExecution() throws InterruptedException { } @Test - public void shouldReturnReportExecutionDetails() { + public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - ReportExecutionDetailsResponse response = api.requestReportExecutionDetails(executionResponse.getExecutionId()); - assertThat(response.getExecutionId(), is(executionId)); + Call call = api.requestReportExecutionDetails(executionResponse.getExecutionId()); + Response response = call.execute(); + assertThat(response.body().getExecutionId(), is(executionId)); } @Test - public void shouldCheckReportExecutionStatus() { + public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); - ExecutionStatusResponse response = api.requestReportExecutionStatus(executionResponse.getExecutionId()); - assertThat(response.getStatus(), is(notNullValue())); + Call call = api.requestReportExecutionStatus(executionResponse.getExecutionId()); + Response response = call.execute(); + assertThat(response.body().getStatus(), is(notNullValue())); } /** * TODO: API is broken requires investigation before release */ @Ignore - public void searchForExecutionShouldReturnResult() { + public void searchForExecutionShouldReturnResult() throws IOException { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); - ReportExecutionSearchResponse searchResponse = api.searchReportExecution(params); - assertThat(searchResponse.getItems(), is(not(empty()))); + Call call = api.searchReportExecution(params); + Response response = call.execute(); + assertThat(response.body().getItems(), is(not(empty()))); } @Test @@ -130,7 +137,13 @@ private ReportExecutionDetailsResponse startExecution() { @NonNull private ReportExecutionDetailsResponse startExecution(String uri) { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); - return getApi().runReportExecution(executionRequestOptions); + Call call = getApi().runReportExecution(executionRequestOptions); + try { + Response response = call.execute(); + return response.body(); + } catch (IOException e) { + throw new RuntimeException(e); + } } private ReportExecutionRestApi getApi() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 0fb7e2fc..7aa6be4d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -41,6 +41,11 @@ import org.junit.Test; +import java.io.IOException; + +import retrofit.Call; +import retrofit.Response; + import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -64,10 +69,11 @@ public void runExportRequestShouldReturnResult() { } @Test - public void checkExportRequestStatusShouldReturnResult() { + public void checkExportRequestStatusShouldReturnResult() throws IOException { ReportExecutionDetailsResponse exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - ExecutionStatusResponse response = getApi().checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); + Call call = getApi().checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); + Response response = call.execute(); assertThat(response, is(notNullValue())); } @@ -86,13 +92,26 @@ private ReportExportExecutionResponse startExportExecution(ReportExecutionDetail ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() .withPages("1-2") .withOutputFormat("PDF"); - return getApi().runExportExecution(exec.getExecutionId(), options); + Call call = getApi().runExportExecution(exec.getExecutionId(), options); + try { + Response response = call.execute(); + return response.body(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } } @NonNull private ReportExecutionDetailsResponse startExecution() { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(reportUri); - return getReportExecApi().runReportExecution(executionRequestOptions); + Call call = getReportExecApi().runReportExecution(executionRequestOptions); + + try { + Response response = call.execute(); + return response.body(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } } private ReportExportRestApi getApi() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index aa7a32f8..da7ea3a3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -38,6 +38,9 @@ import java.io.IOException; +import retrofit.Call; +import retrofit.Response; + import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -64,7 +67,9 @@ public void shouldRequestListOfResources() throws IOException { @Test public void shouldRequestReport() throws IOException { RepositoryRestApi api = createApi(); - ReportLookupResponse report = api.requestReportResource("/public/Samples/Reports/AllAccounts"); + Call call = api.requestReportResource("/public/Samples/Reports/AllAccounts"); + Response response = call.execute(); + ReportLookupResponse report = response.body(); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @@ -72,7 +77,9 @@ public void shouldRequestReport() throws IOException { @Test public void shouldRequestDashboard() throws IOException { RepositoryRestApi api = createApi(); - DashboardLookupResponse dashboard = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); + Call call = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); + Response response = call.execute(); + DashboardLookupResponse dashboard = response.body(); assertThat(dashboard, is(notNullValue())); assertThat(dashboard.getFoundations(), is(not(empty()))); } @@ -80,7 +87,9 @@ public void shouldRequestDashboard() throws IOException { @Test public void shouldRequestRootFolder() throws IOException { RepositoryRestApi api = createApi(); - FolderLookupResponse folder = api.requestFolderResource("/"); + Call call = api.requestFolderResource("/"); + Response response = call.execute(); + FolderLookupResponse folder = response.body(); assertThat(folder, is(notNullValue())); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 15050999..581adb91 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -34,6 +34,9 @@ import java.io.IOException; +import retrofit.Call; +import retrofit.Response; + import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -52,7 +55,8 @@ public void shouldRequestServerInfo() throws IOException { .setLog(TestLogger.get(this)) .setLogLevel(RestApiLogLevel.FULL) .build(); - ServerInfoResponse response = api.requestServerInfo(); + Call call = api.requestServerInfo(); + Response response = call.execute(); assertThat(response, is(notNullValue())); } } From 42f7c167065a5afba186eed8ccce3d5f699bf667 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 3 Sep 2015 17:23:51 +0300 Subject: [PATCH 083/457] Wraping retrofit call in observable --- .../sdk/network/api/AuthResponseFactory.java | 2 +- .../network/api/AuthenticationRestApi.java | 3 +- .../api/AuthenticationRestApiImpl.java | 75 ++++++++++--------- .../network/entity/server/AuthResponse.java | 29 ++++++- .../network/operation/PendingOperation.java | 34 +++++++++ .../android/sdk/network/operation/Result.java | 33 ++++++++ .../sdk/network/operation/ResultCallback.java | 33 ++++++++ .../android/sdk/network/operation/Status.java | 51 +++++++++++++ 8 files changed, 221 insertions(+), 39 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/ResultCallback.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Status.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java index 0c70e91f..7109620f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java @@ -50,7 +50,7 @@ public static AuthResponse create(Response response) { private AuthResponse create() { String cookie = joinCookieParts().toString(); - return new AuthResponse(cookie); + return AuthResponse.createSuccessResponse(cookie); } private StringBuilder joinCookieParts() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index ccb83098..794eb97d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -28,6 +28,7 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.operation.PendingOperation; import com.squareup.okhttp.OkHttpClient; import java.util.Map; @@ -38,7 +39,7 @@ */ public interface AuthenticationRestApi { @NonNull - AuthResponse authenticate(@NonNull String username, + PendingOperation authenticate(@NonNull String username, @NonNull String password, @Nullable String organization, @Nullable Map params); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 1f99c249..dcd1ba25 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,12 +27,15 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.operation.PendingOperation; +import com.jaspersoft.android.sdk.network.operation.ResultCallback; import com.squareup.okhttp.HttpUrl; import java.io.IOException; import java.util.Map; import retrofit.Call; +import retrofit.Callback; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.Headers; @@ -54,38 +57,42 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { @NonNull @Override - public AuthResponse authenticate(@NonNull String username, - @NonNull String password, - String organization, - Map params) { - try { - Call call = mRestApi.authenticate(username, password, organization, params); - Response response = call.execute(); - return createAuthResponse(response); - // TODO handle CA case here -// } catch (RestError error) { -// RetrofitError retrofitError = extractRetrofitError(error); -// if (retrofitError.getKind() == RetrofitError.Kind.HTTP) { -// Response response = retrofitError.getResponse(); -// if (containsRedirect(response)) { -// String location = retrieveLocation(response); -// -// if (locationPointsToSuccess(location)) { -// return createAuthResponse(response); -// } else { -// throw error; -// } -// } else { -// throw error; -// } -// } else { -// throw error; -// } - } catch (IOException e) { - // Due to Undefined error handling mechanism we forced to rethrow IO - throw new RuntimeException(e); - } + public PendingOperation authenticate(@NonNull final String username, + @NonNull final String password, + final String organization, + final Map params) { + + final Call call = mRestApi.authenticate(username, password, organization, params); + PendingOperation responsePendingOperation = new PendingOperation() { + @Override + public AuthResponse execute() { + try { + Response response = call.execute(); + return AuthResponseFactory.create(response); + } catch (IOException e) { + return AuthResponse.createFailResponse(e); + } + } + + @Override + public void enqueue(final ResultCallback callback) { + call.enqueue(new Callback() { + @Override + public void onResponse(Response response) { + callback.onResult(AuthResponseFactory.create(response)); + } + + @Override + public void onFailure(Throwable t) { + callback.onResult(AuthResponse.createFailResponse(t)); + } + }); + } + }; + + return responsePendingOperation; } + // // private RetrofitError extractRetrofitError(RestError error) { // return (RetrofitError) error.getCause(); @@ -118,8 +125,8 @@ interface RestApi { @Headers({"Accept:application/json"}) @POST(value = "/j_spring_security_check") Call authenticate(@Part(value = "j_username") String username, - @Part(value = "j_password") String password, - @Part(value = "orgId ") String organization, - @PartMap Map params); + @Part(value = "j_password") String password, + @Part(value = "orgId ") String organization, + @PartMap Map params); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java index 5fd338ba..2f1e47c4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,15 +24,33 @@ package com.jaspersoft.android.sdk.network.entity.server; +import com.jaspersoft.android.sdk.network.operation.Result; +import com.jaspersoft.android.sdk.network.operation.Status; + /** * @author Tom Koptel * @since 2.0 */ -public final class AuthResponse { +public final class AuthResponse implements Result { private final String mToken; + private final Status mStatus; + + private AuthResponse(Status status) { + mToken = null; + mStatus = status; + } - public AuthResponse(String token) { + private AuthResponse(String token) { mToken = token; + mStatus = Status.success(); + } + + public static AuthResponse createSuccessResponse(String token) { + return new AuthResponse(token); + } + + public static AuthResponse createFailResponse(Throwable throwable) { + return new AuthResponse(Status.error(throwable)); } public String getToken() { @@ -45,4 +63,9 @@ public String toString() { "mToken='" + mToken + '\'' + '}'; } + + @Override + public Status getStatus() { + return null; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java new file mode 100644 index 00000000..cc256739 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.operation; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public interface PendingOperation { + RESULT execute(); + void enqueue(ResultCallback callback); +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java new file mode 100644 index 00000000..9398d79f --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.operation; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public interface Result { + Status getStatus(); +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/ResultCallback.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/ResultCallback.java new file mode 100644 index 00000000..0692f156 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/ResultCallback.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.operation; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public interface ResultCallback { + void onResult(RESULT result); +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Status.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Status.java new file mode 100644 index 00000000..9601ead2 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Status.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.operation; + +/** + * @author Tom Koptel + * @since 2.2 + */ +public final class Status { + public static Status SUCCESS = new Status(null); + + private final Throwable mThrowable; + + private Status(Throwable throwable) { + mThrowable = throwable; + } + + public static Status error(Throwable throwable) { + return new Status(throwable); + } + + public static Status success() { + return SUCCESS; + } + + public boolean isSuccess() { + return mThrowable == null; + } +} From d2f9196fba08552b00c66602b1becc803cbc20f1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 4 Sep 2015 16:46:59 +0300 Subject: [PATCH 084/457] Fix AuthenticationRestApi --- client-network/build.gradle | 1 + .../sdk/network/api/AuthResponseFactory.java | 2 +- .../network/api/AuthenticationRestApi.java | 22 ++- .../api/AuthenticationRestApiImpl.java | 158 ++++++++++-------- .../android/sdk/network/api/BaseBuilder.java | 3 + .../sdk/network/exception/RestError.java | 85 ++++++---- .../exception/RetrofitErrorHandler.java | 2 +- .../network/api/AuthResponseFactoryTest.java | 6 +- .../api/AuthenticationRestApiTest.java | 15 +- .../api/AuthenticationRestApiTest.java | 14 +- .../api/ReportExecutionRestApiTest.java | 3 +- .../api/ReportExportRestApiTest.java | 3 +- .../api/RepositoryRestApiTest.java | 9 +- .../api/utils/TestAuthenticator.java | 6 +- 14 files changed, 187 insertions(+), 142 deletions(-) diff --git a/client-network/build.gradle b/client-network/build.gradle index 54ba5cf4..e08bfcda 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -37,6 +37,7 @@ dependencies { compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' + compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java index 7109620f..2bd4fbec 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java @@ -25,11 +25,11 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.squareup.okhttp.Response; import java.util.Iterator; import java.util.List; -import retrofit.Response; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index 794eb97d..2b27898f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -28,34 +28,32 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.operation.PendingOperation; -import com.squareup.okhttp.OkHttpClient; import java.util.Map; +import rx.Observable; + /** * @author Tom Koptel * @since 2.0 */ public interface AuthenticationRestApi { @NonNull - PendingOperation authenticate(@NonNull String username, + Observable authenticate(@NonNull String username, @NonNull String password, @Nullable String organization, @Nullable Map params); - final class Builder extends BaseBuilder { + final class Builder { + private final String mBaseUrl; + public Builder(String baseUrl) { - super(baseUrl); + Utils.checkNotNull(baseUrl, "Base url should not be null"); + mBaseUrl = baseUrl; } - @Override - AuthenticationRestApi createApi() { - - OkHttpClient httpClient = getClient(); - httpClient.setFollowRedirects(false); - - return new AuthenticationRestApiImpl(getDefaultBuilder().build()); + public AuthenticationRestApi build() { + return new AuthenticationRestApiImpl(mBaseUrl); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index dcd1ba25..d48bcb31 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,106 +27,116 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.operation.PendingOperation; -import com.jaspersoft.android.sdk.network.operation.ResultCallback; +import com.jaspersoft.android.sdk.network.exception.RestError; +import com.squareup.okhttp.Call; +import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; import java.io.IOException; import java.util.Map; +import java.util.Set; -import retrofit.Call; -import retrofit.Callback; -import retrofit.Response; -import retrofit.Retrofit; -import retrofit.http.Headers; -import retrofit.http.Multipart; -import retrofit.http.POST; -import retrofit.http.Part; -import retrofit.http.PartMap; +import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel * @since 2.0 */ final class AuthenticationRestApiImpl implements AuthenticationRestApi { - private final RestApi mRestApi; + private final String mBaseUrl; - AuthenticationRestApiImpl(Retrofit restAdapter) { - mRestApi = restAdapter.create(RestApi.class); + AuthenticationRestApiImpl(String baseUrl) { + mBaseUrl = baseUrl; } @NonNull @Override - public PendingOperation authenticate(@NonNull final String username, - @NonNull final String password, - final String organization, - final Map params) { - - final Call call = mRestApi.authenticate(username, password, organization, params); - PendingOperation responsePendingOperation = new PendingOperation() { + public Observable authenticate(@NonNull final String username, + @NonNull final String password, + final String organization, + final Map params) { + return Observable.defer(new Func0>() { @Override - public AuthResponse execute() { + public Observable call() { + OkHttpClient okHttpClient = new OkHttpClient(); + okHttpClient.setFollowRedirects(false); + Request request = createAuthRequest(username, password, organization, params); + Call call = okHttpClient.newCall(request); try { - Response response = call.execute(); - return AuthResponseFactory.create(response); + com.squareup.okhttp.Response response = call.execute(); + int statusCode = response.code(); + if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request + AuthResponse authResponse = AuthResponseFactory.create(response); + return Observable.just(authResponse); + } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request + String location = response.headers().get("Location"); + if (location == null) { + return Observable.error(new IllegalStateException("Location HEADER is missing please contact JRS admin")); + } + HttpUrl url = HttpUrl.parse(location); + String errorQueryParameter = url.queryParameter("error"); + if (errorQueryParameter == null) { + AuthResponse authResponse = AuthResponseFactory.create(response); + return Observable.just(authResponse); + } else { + com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() + .protocol(response.protocol()) + .request(response.request()) + .headers(response.headers()) + .body(response.body()) + .code(401) + .build(); + Throwable error = RestError.httpError(request.urlString(), response401); + return Observable.error(error); + } + } else if (statusCode == 401) { + com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() + .protocol(response.protocol()) + .request(response.request()) + .headers(response.headers()) + .body(response.body()) + .code(401) + .build(); + Throwable error = RestError.httpError(request.urlString(), response401); + return Observable.error(error); + } else { + Throwable error = RestError.httpError(request.urlString(), response); + return Observable.error(error); + } } catch (IOException e) { - return AuthResponse.createFailResponse(e); + return Observable.error(RestError.networkError(request.urlString(), e)); } } - - @Override - public void enqueue(final ResultCallback callback) { - call.enqueue(new Callback() { - @Override - public void onResponse(Response response) { - callback.onResult(AuthResponseFactory.create(response)); - } - - @Override - public void onFailure(Throwable t) { - callback.onResult(AuthResponse.createFailResponse(t)); - } - }); - } - }; - - return responsePendingOperation; + }); } -// -// private RetrofitError extractRetrofitError(RestError error) { -// return (RetrofitError) error.getCause(); -// } - - private boolean locationPointsToSuccess(String location) { - HttpUrl url = HttpUrl.parse(location); - String errorQueryParameter = url.queryParameter("error"); - return errorQueryParameter == null; - } + private Request createAuthRequest( + @NonNull final String username, + @NonNull final String password, + final String organization, + final Map params) { - @NonNull - private String retrieveLocation(Response response) { - String location = response.headers().get("Location"); - Utils.checkNotNull(location, "Missing 'Location' header"); - return location; - } + OkHttpClient client = new OkHttpClient(); + client.setFollowRedirects(false); - private boolean containsRedirect(Response response) { - int status = response.code(); - return status >= 300 && status < 400; - } + FormEncodingBuilder formBody = new FormEncodingBuilder() + .add("j_username", username) + .add("j_password", password) + .add("orgId", organization); - private AuthResponse createAuthResponse(Response response) { - return AuthResponseFactory.create(response); - } + if (params != null) { + Set> entrySet = params.entrySet(); + for (Map.Entry entry : entrySet) { + formBody.add(entry.getKey(), entry.getValue()); + } + } - interface RestApi { - @Multipart - @Headers({"Accept:application/json"}) - @POST(value = "/j_spring_security_check") - Call authenticate(@Part(value = "j_username") String username, - @Part(value = "j_password") String password, - @Part(value = "orgId ") String organization, - @PartMap Map params); + return new Request.Builder() + .url(mBaseUrl + "/j_spring_security_check") + .post(formBody.build()) + .build(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index 439bdd64..bf9bd754 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -30,6 +30,7 @@ import retrofit.GsonConverterFactory; import retrofit.Retrofit; +import retrofit.RxJavaCallAdapterFactory; /** * @author Tom Koptel @@ -41,6 +42,7 @@ abstract class BaseBuilder { private RestApiLog mLog = RestApiLog.NONE; private RestApiLogLevel mLogLevel = RestApiLogLevel.NONE; + public BaseBuilder(String baseUrl){ if (baseUrl == null || baseUrl.length() == 0) { throw new IllegalArgumentException("Base url should not be null or empty"); @@ -53,6 +55,7 @@ public BaseBuilder(String baseUrl){ Gson configuredGson = GsonFactory.create(); mRestAdapterBuilder.addConverterFactory(GsonConverterFactory.create(configuredGson)); + mRestAdapterBuilder.addCallAdapterFactory(RxJavaCallAdapterFactory.create()); /* TODO: Resolve error handling. It is still not clear what API will look like diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java index b7f1ce98..e0af343e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java @@ -27,6 +27,8 @@ //import retrofit.RetrofitError; +import java.io.IOException; + /** * TODO we need resolve error issues * @@ -34,32 +36,59 @@ * @since 2.0 */ public final class RestError extends RuntimeException { -// private final Kind mKind; - -// RestError(String message, RetrofitError error, Kind kind) { -// super(message, error); -// mKind = kind; -// } -// -// static RestError createNetworkError(RetrofitError error) { -// return new RestError(error.getMessage(), error, Kind.NETWORK); -// } -// -// static RestError createHttpError(RetrofitError error) { -// return new RestError(error.getMessage(), error, Kind.HTTP); -// } -// -// static RestError createUnexpectedError(RetrofitError error) { -// return new RestError(error.getMessage(), error, Kind.UNEXPECTED); -// } - -// public Kind getKind() { -// return mKind; -// } -// -// public enum Kind { -// NETWORK, -// HTTP, -// UNEXPECTED -// } + public static RestError networkError(String url, IOException exception) { + return new RestError(exception.getMessage(), url, null, Kind.NETWORK, + exception); + } + + public static RestError httpError(String url, com.squareup.okhttp.Response response) { + String message = response.code() + " " + response.message(); + return new RestError(message, url, response, Kind.HTTP, null); + } + + public static RestError unexpectedError(String url, Throwable exception) { + return new RestError(exception.getMessage(), url, null, Kind.UNEXPECTED, + exception); + } + + private final String url; + private final com.squareup.okhttp.Response response; + private final Kind kind; + + RestError(String message, String url, com.squareup.okhttp.Response response,Kind kind, Throwable exception) { + super(message, exception); + this.url = url; + this.response = response; + this.kind = kind; + } + + /** HTTP status code. */ + public int code() { + return response.code(); + } + + /** HTTP status message. */ + public String message() { + return response.message(); + } + + public com.squareup.okhttp.Response response() { + return response; + } + + public String urlString() { + return url; + } + + public Kind kind() { + return kind; + } + + public enum Kind { + NETWORK, + HTTP, + UNEXPECTED; + + } + } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java index f7b5c204..c48a200f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java @@ -34,7 +34,7 @@ final class RetrofitErrorHandler { // implements ErrorHandler { // @Override // public Throwable handleError(RetrofitError error) { -// switch (error.getKind()) { +// switch (error.kind()) { // case HTTP: // return RestError.createHttpError(error); // case NETWORK: diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java index 48080c65..711efbbd 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java @@ -38,8 +38,6 @@ import java.util.HashMap; import java.util.Map; -import retrofit.Response; - import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.powermock.api.mockito.PowerMockito.when; @@ -49,10 +47,10 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({Response.class}) +@PrepareForTest({com.squareup.okhttp.Response.class}) public class AuthResponseFactoryTest { @Mock - Response mResponse; + com.squareup.okhttp.Response mResponse; @Before public void setup() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index 610c59f3..44f7c0b4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -34,6 +34,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import rx.Observable; + import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -60,7 +62,7 @@ public void setup() { @Test public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { - mExpectedException.expect(IllegalArgumentException.class); + mExpectedException.expect(NullPointerException.class); new AuthenticationRestApi.Builder(null).build(); } @@ -70,7 +72,8 @@ public void shouldReturnResponseForSuccessRedirect() { mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", "null", null); + Observable obs = mRestApi.authenticate("joeuser", "joeuser", "null", null); + AuthResponse response = obs.toBlocking().first(); assertThat(response.getToken(), is(notNullValue())); } @@ -82,7 +85,7 @@ public void shouldRiseErrorForErrorRedirect() { mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_ERROR); mWebMockRule.enqueue(mockResponse); - mRestApi.authenticate("joeuser", "joeuser", "null", null); + mRestApi.authenticate("joeuser", "joeuser", "null", null).toBlocking().first(); } @Test @@ -92,18 +95,18 @@ public void shouldRiseErrorForHttpException() { MockResponse mockResponse = create500Response(); mWebMockRule.enqueue(mockResponse); - mRestApi.authenticate("joeuser", "joeuser", "null", null); + mRestApi.authenticate("joeuser", "joeuser", "null", null).toBlocking().first(); } @Test public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() { mExpectedException.expect(IllegalStateException.class); - mExpectedException.expectMessage("Missing 'Location' header"); + mExpectedException.expectMessage("Location HEADER is missing please contact JRS admin"); MockResponse mockResponse = create302Response(); mWebMockRule.enqueue(mockResponse); - mRestApi.authenticate("joeuser", "joeuser", "null", null); + mRestApi.authenticate("joeuser", "joeuser", "null", null).toBlocking().first(); } private MockResponse create302Response() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 133998c1..76530290 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -24,10 +24,8 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import org.junit.Before; import org.junit.Test; @@ -35,6 +33,8 @@ import java.io.IOException; +import rx.Observable; + import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -54,10 +54,10 @@ public void setup() { @Test public void shouldReturnResponseForSpringRequest() throws IOException { AuthenticationRestApi authApi = new AuthenticationRestApi.Builder(mobileDemo2) - .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) +// .setLog(TestLogger.get(this)) +// .setLogLevel(RestApiLogLevel.FULL) .build(); - AuthResponse response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); - assertThat(response.getToken(), is(notNullValue())); + Observable response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); + assertThat(response.toBlocking().first().getToken(), is(notNullValue())); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 941d3849..9e7abf44 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -159,7 +159,8 @@ private ReportExecutionRestApi getApi() { private AuthResponse getAuthResponse() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(MOBILE_DEMO2).build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null) + .toBlocking().first(); } return mAuthResponse; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 7aa6be4d..cddab757 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -137,7 +137,8 @@ private ReportExecutionRestApi getReportExecApi() { private AuthResponse getAuthResponse() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null) + .toBlocking().first(); } return mAuthResponse; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index da7ea3a3..8cf1fd2c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -26,13 +26,11 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Test; @@ -100,10 +98,11 @@ private RepositoryRestApi createApi() { private AuthResponse getAuthResponse() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2) - .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) +// .setLog(TestLogger.get(this)) +// .setLogLevel(RestApiLogLevel.FULL) .build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null); + mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null) + .toBlocking().first(); } return mAuthResponse; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java index e35f304c..14249502 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -47,7 +47,9 @@ public static TestAuthenticator newInstance(JrsMetadata metadata) { public void authorize() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mJrsMetadata.getServerUrl()).build(); - mAuthResponse = restApi.authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null); + mAuthResponse = restApi + .authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null) + .toBlocking().first(); } } From 51c67dbce9ae71a4cea78674ddf1d13ddd5b5c19 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 11:17:21 +0300 Subject: [PATCH 085/457] Restoring log option within API --- .../android/sdk/network/api/BaseBuilder.java | 13 +---- ...iLogLevel.java => LoggingInterceptor.java} | 53 +++++++++++-------- .../api/InputControlRestApiTest.java | 2 - .../api/ReportExecutionRestApiTest.java | 2 - .../api/ReportExportRestApiTest.java | 3 -- .../test/integration/api/ServerRestTest.java | 2 - 6 files changed, 33 insertions(+), 42 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{RestApiLogLevel.java => LoggingInterceptor.java} (52%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index bf9bd754..dcc8ad45 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -41,7 +41,6 @@ abstract class BaseBuilder { private final OkHttpClient mOkHttpClient; private RestApiLog mLog = RestApiLog.NONE; - private RestApiLogLevel mLogLevel = RestApiLogLevel.NONE; public BaseBuilder(String baseUrl){ if (baseUrl == null || baseUrl.length() == 0) { @@ -75,12 +74,6 @@ public SubBuilder setLog(RestApiLog log) { return (SubBuilder) this; } - @SuppressWarnings("unchecked") - public SubBuilder setLogLevel(RestApiLogLevel logLevel) { - mLogLevel = logLevel; - return (SubBuilder) this; - } - Retrofit.Builder getDefaultBuilder() { return mRestAdapterBuilder; } @@ -92,11 +85,7 @@ OkHttpClient getClient() { abstract API createApi(); public API build() { - /* - TODO: Resolve log handling. Fallback to OkHttp interceptor https://github.com/square/okhttp/wiki/Interceptors - */ -// mRestAdapterBuilder.setLog(new RetrofitLog(mLog)); -// mRestAdapterBuilder.setLogLevel(RestApiLogLevel.toRetrofitLog(mLogLevel)); + mOkHttpClient.interceptors().add(new LoggingInterceptor(mLog)); return createApi(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java similarity index 52% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index 682f9694..9cfd33dd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLogLevel.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -24,27 +24,38 @@ package com.jaspersoft.android.sdk.network.api; +import com.squareup.okhttp.Interceptor; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + +import java.io.IOException; + /** * @author Tom Koptel - * @since 2.0 + * @since 2.2 */ -public enum RestApiLogLevel { - /** No logging. */ - NONE, - /** Log only the request method and URL and the response status code and execution time. */ - BASIC, - /** Log the basic information along with request and response headers. */ - HEADERS, - /** Log the basic information along with request and response objects via toString(). */ - HEADERS_AND_ARGS, - /** - * Log the headers, body, and metadata for both requests and responses. - *

- * Note: This requires that the entire request and response body be buffered in memory! - */ - FULL; - -// static RestAdapter.LogLevel toRetrofitLog(RestApiLogLevel logLevel) { -// return RestAdapter.LogLevel.valueOf(logLevel.name()); -// } -} +final class LoggingInterceptor implements Interceptor { + private final RestApiLog logger; + + public LoggingInterceptor(RestApiLog logger) { + this.logger = logger; + } + + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Request request = chain.request(); + logger.log(String.format("Request info. %s", request.toString())); + + long t1 = System.nanoTime(); + logger.log(String.format("Sending request %s on %s%n%s", + request.url(), chain.connection(), request.headers())); + + Response response = chain.proceed(request); + + long t2 = System.nanoTime(); + logger.log(String.format("Received response for %s in %.1fms%n%s", + response.request().url(), (t2 - t1) / 1e6d, response.headers())); + + return response; + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 15ad9247..0669064d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.InputControlRestApi; -import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; @@ -65,7 +64,6 @@ public void setup() { String cookie = mAuthenticator.getCookie(); mRestApi = new InputControlRestApi.Builder(mMetadata.getServerUrl(), cookie) .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 9e7abf44..2f62e380 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; @@ -150,7 +149,6 @@ private ReportExecutionRestApi getApi() { if (mApi == null) { mApi = new ReportExecutionRestApi.Builder(MOBILE_DEMO2, getAuthResponse().getToken()) .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) .build(); } return mApi; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index cddab757..a83f4ab8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -29,7 +29,6 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; @@ -118,7 +117,6 @@ private ReportExportRestApi getApi() { if (mExportApi == null) { mExportApi = new ReportExportRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) .build(); } return mExportApi; @@ -128,7 +126,6 @@ private ReportExecutionRestApi getReportExecApi() { if (mExecApi == null) { mExecApi = new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) .build(); } return mExecApi; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 581adb91..59d0af35 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.RestApiLogLevel; import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.test.TestLogger; @@ -53,7 +52,6 @@ public class ServerRestTest { public void shouldRequestServerInfo() throws IOException { ServerRestApi api = new ServerRestApi.Builder(mobileDemo2) .setLog(TestLogger.get(this)) - .setLogLevel(RestApiLogLevel.FULL) .build(); Call call = api.requestServerInfo(); Response response = call.execute(); From 8e62b4a5d67a8427dd9acad5d046a24fcdb15d39 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 11:46:03 +0300 Subject: [PATCH 086/457] Migrate input controls API to observable --- .../sdk/network/api/AuthInterceptor.java | 2 +- .../api/AuthenticationRestApiImpl.java | 6 ++-- .../sdk/network/api/InputControlRestApi.java | 14 ++++---- .../network/api/InputControlRestApiImpl.java | 34 +++++++++---------- .../sdk/network/api/LoggingInterceptor.java | 22 ++++++++++-- .../api/InputControlRestApiTest.java | 29 +++++++--------- .../integration/api/utils/JrsMetadata.java | 8 ++--- 7 files changed, 65 insertions(+), 50 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java index b23b5c66..e97d91a3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java @@ -52,7 +52,7 @@ public static AuthInterceptor newInstance(String token) { public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); Request compressedRequest = originalRequest.newBuilder() - .header("Cookie", "mToken") + .header("Cookie", mToken) .build(); return chain.proceed(compressedRequest); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 70a75404..f3d9b18e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -126,9 +126,11 @@ private Request createAuthRequest( formBody.add(entry.getKey(), entry.getValue()); } } - + /** + * Constructs url http[s]://some.jrs/j_spring_security_check + */ return new Request.Builder() - .url(mBaseUrl + "/j_spring_security_check") + .url(mBaseUrl + "j_spring_security_check") .post(formBody.build()) .build(); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 73a84e0b..b4ebdcbe 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -34,7 +34,7 @@ import java.util.Map; import java.util.Set; -import retrofit.Call; +import rx.Observable; /** * @author Tom Koptel @@ -43,7 +43,7 @@ public interface InputControlRestApi { @NonNull - Call requestInputControls(@NonNull String reportUri); + Observable requestInputControls(@NonNull String reportUri); /** * Returns input controls for associated response. Options can be excluded by additional argument. @@ -55,20 +55,20 @@ public interface InputControlRestApi { * @return unmodifiable list of {@link InputControl} */ @NonNull - Call requestInputControls(@NonNull String reportUri, boolean excludeState); + Observable requestInputControls(@NonNull String reportUri, boolean excludeState); @NonNull - Call requestInputControlsInitialStates(@NonNull String reportUri); + Observable requestInputControlsInitialStates(@NonNull String reportUri); @NonNull - Call requestInputControlsInitialStates(@NonNull String reportUri, + Observable requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData); /** * TODO: 1. consider to flatten controls id parameter. */ @NonNull - Call requestInputControlsStates(@NonNull String reportUri, + Observable requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues); @@ -83,7 +83,7 @@ Call requestInputControlsStates(@NonNull String repor * @return unmodifiable list of {@link InputControlState} */ @NonNull - Call requestInputControlsStates(@NonNull String reportUri, + Observable requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues, boolean freshData); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 7c8e303e..66efacfe 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -33,7 +33,6 @@ import java.util.Map; import java.util.Set; -import retrofit.Call; import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; @@ -41,6 +40,7 @@ import retrofit.http.POST; import retrofit.http.Path; import retrofit.http.Query; +import rx.Observable; /** * @author Tom Koptel @@ -55,31 +55,31 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override - public Call requestInputControls(@NonNull String reportUri) { + public Observable requestInputControls(@NonNull String reportUri) { return requestInputControls(reportUri, false); } @NonNull @Override - public Call requestInputControls(@NonNull String reportUri, boolean excludeState) { + public Observable requestInputControls(@NonNull String reportUri, boolean excludeState) { return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); } @NonNull @Override - public Call requestInputControlsInitialStates(@NonNull String reportUri) { + public Observable requestInputControlsInitialStates(@NonNull String reportUri) { return requestInputControlsInitialStates(reportUri, false); } @NonNull @Override - public Call requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { + public Observable requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { return mRestApi.requestInputControlsInitialValues(reportUri, freshData); } @NonNull @Override - public Call requestInputControlsStates(@NonNull String reportUri, + public Observable requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues) { return requestInputControlsStates(reportUri, controlsId, controlsValues, false); @@ -87,7 +87,7 @@ public Call requestInputControlsStates(@NonNull Strin @NonNull @Override - public Call requestInputControlsStates(@NonNull String reportUri, + public Observable requestInputControlsStates(@NonNull String reportUri, @NonNull Set controlsId, @NonNull Map> controlsValues, boolean freshData) { @@ -98,24 +98,24 @@ public Call requestInputControlsStates(@NonNull Strin private interface RestApi { @NonNull @Headers("Accept: application/json") - @GET("/rest_v2/reports{reportUnitURI}/inputControls") - Call requestInputControls( - @NonNull @Path(value = "reportUnitURI", encoded = false) String reportUri, + @GET("rest_v2/reports{reportUnitURI}/inputControls") + Observable requestInputControls( + @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("exclude") String state); @NonNull @Headers("Accept: application/json") - @GET("/rest_v2/reports{reportUnitURI}/inputControls/values") - Call requestInputControlsInitialValues( - @NonNull @Path(value = "reportUnitURI", encoded = false) String reportUri, + @GET("rest_v2/reports{reportUnitURI}/inputControls/values") + Observable requestInputControlsInitialValues( + @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("freshData") boolean freshData); @NonNull @Headers("Accept: application/json") - @POST("/rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") - Call requestInputControlsValues( - @NonNull @Path(value = "reportUnitURI", encoded = false) String reportUri, - @NonNull @Path(value = "controlsId", encoded = false) String ids, + @POST("rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") + Observable requestInputControlsValues( + @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, + @NonNull @Path(value = "controlsId", encoded = true) String ids, @NonNull @Body Map> controlsValues, @Query("freshData") boolean freshData); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index 9cfd33dd..c2d2b6e6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -30,6 +30,8 @@ import java.io.IOException; +import okio.Buffer; + /** * @author Tom Koptel * @since 2.2 @@ -44,7 +46,6 @@ public LoggingInterceptor(RestApiLog logger) { @Override public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); - logger.log(String.format("Request info. %s", request.toString())); long t1 = System.nanoTime(); logger.log(String.format("Sending request %s on %s%n%s", @@ -53,9 +54,24 @@ public Response intercept(Interceptor.Chain chain) throws IOException { Response response = chain.proceed(request); long t2 = System.nanoTime(); - logger.log(String.format("Received response for %s in %.1fms%n%s", - response.request().url(), (t2 - t1) / 1e6d, response.headers())); + logger.log(String.format("Received response for %s in %.1fms%n%sBody: \n%s", + response.request().url(), (t2 - t1) / 1e6d, response.headers(), bodyToString(request))); return response; } + + private static String bodyToString(final Request request){ + try { + final Request copy = request.newBuilder().build(); + final Buffer buffer = new Buffer(); + if (copy.body() != null) { + copy.body().writeTo(buffer); + return buffer.readUtf8(); + } else { + return "No Body"; + } + } catch (final IOException e) { + return String.format("", e.getMessage()); + } + } } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 0669064d..9ee90787 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -38,8 +38,7 @@ import java.io.IOException; import java.util.List; -import retrofit.Call; -import retrofit.Response; +import rx.Observable; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; @@ -69,11 +68,10 @@ public void setup() { @Test public void shouldProvideInputControlsList() throws IOException { - Call call = mRestApi.requestInputControls(REPORT_URI); - Response response = call.execute(); + Observable call = mRestApi.requestInputControls(REPORT_URI); - List controls = response.body().getValues(); - assertThat(response.body().getValues(), is(not(empty()))); + List controls = call.toBlocking().first().getValues(); + assertThat(controls, is(not(empty()))); InputControl control = controls.get(0); assertThat(control.getState(), is(notNullValue())); @@ -84,11 +82,10 @@ public void shouldProvideInputControlsList() throws IOException { */ @Test public void shouldProvideInputControlsListIfStateExcluded() throws IOException { - Call call = mRestApi.requestInputControls(REPORT_URI, true); - Response response = call.execute(); + Observable call = mRestApi.requestInputControls(REPORT_URI, true); - List controls = response.body().getValues(); - assertThat(response.body().getValues(), is(not(empty()))); + List controls = call.toBlocking().first().getValues(); + assertThat(controls, is(not(empty()))); InputControl control = controls.get(0); assertThat(control.getState(), is(nullValue())); @@ -96,15 +93,15 @@ public void shouldProvideInputControlsListIfStateExcluded() throws IOException { @Test public void shouldProvideInitialInputControlsValues() throws IOException { - Call call = mRestApi.requestInputControlsInitialStates(REPORT_URI); - Response response = call.execute(); - assertThat(response.body().getValues(), is(not(empty()))); + Observable call = mRestApi.requestInputControlsInitialStates(REPORT_URI); + InputControlValueResponse response = call.toBlocking().first(); + assertThat(response.getValues(), is(not(empty()))); } @Test public void shouldProvideFreshInitialInputControlsValues() throws IOException { - Call call = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); - Response response = call.execute(); - assertThat(response.body().getValues(), is(not(empty()))); + Observable call = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); + InputControlValueResponse response = call.toBlocking().first(); + assertThat(response.getValues(), is(not(empty()))); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java index 4969cf71..7abcc6a5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java @@ -130,7 +130,7 @@ private void checkValues() { assertPropertyNotEmpty(serverUrl, "serverUrl"); assertPropertyNotEmpty(username, "username"); assertPropertyNotEmpty(password, "password"); - serverUrl = trimUrl(serverUrl); + serverUrl = resolveUrl(serverUrl); try { new URL(serverUrl); } catch (MalformedURLException e) { @@ -152,9 +152,9 @@ private void assertPropertyNotEmpty(String property, String propertyName) { } } - private static String trimUrl(String url) { - if (!isEmpty(url) && url.endsWith("/")) { - url = url.substring(0, url.length() - 1); + private static String resolveUrl(String url) { + if (!isEmpty(url) && !url.endsWith("/")) { + url = url + "/"; } return url; } From 8ca36873c38960b657b6d46d8fd39e2b51cc56a0 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 12:24:53 +0300 Subject: [PATCH 087/457] Migrate report execution API to observable --- .../network/api/ReportExecutionRestApi.java | 16 +-- .../api/ReportExecutionRestApiImpl.java | 116 +++++++++--------- .../android/sdk/network/api/Utils.java | 6 + .../api/ReportExecutionRestApiTest.java | 59 +++++---- .../api/ReportExecutionRestApiTest.java | 36 +++--- .../api/ReportExportRestApiTest.java | 11 +- 6 files changed, 127 insertions(+), 117 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 1cfaaed8..98c7c7d2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -35,7 +35,7 @@ import java.util.Collection; import java.util.Map; -import retrofit.Call; +import rx.Observable; /** * @author Tom Koptel @@ -44,23 +44,25 @@ public interface ReportExecutionRestApi { @NonNull - Call runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); + Observable runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); @NonNull - Call requestReportExecutionDetails(@NonNull String executionId); + Observable requestReportExecutionDetails(@NonNull String executionId); @NonNull - Call requestReportExecutionStatus(@NonNull String executionId); + Observable requestReportExecutionStatus(@NonNull String executionId); - boolean cancelReportExecution(@NonNull String executionId); + @NonNull + Observable cancelReportExecution(@NonNull String executionId); - boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params); + @NonNull + Observable updateReportExecution(@NonNull String executionId, @NonNull Collection params); /** * TODO: API is broken requires investigation before release */ @NonNull - Call searchReportExecution(Map params); + Observable searchReportExecution(Map params); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 80bd82f0..203d0ba5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -27,17 +27,15 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; -import java.io.IOException; import java.util.Collection; import java.util.Map; -import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.Body; @@ -47,6 +45,11 @@ import retrofit.http.PUT; import retrofit.http.Path; import retrofit.http.QueryMap; +import rx.Observable; +import rx.functions.Func1; + +import static com.jaspersoft.android.sdk.network.api.Utils.checkArgument; +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; /** * @author Tom Koptel @@ -62,97 +65,100 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NonNull @Override - public Call runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions) { + public Observable runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) { + checkNotNull(executionOptions, "Execution options should not be null"); return mRestApi.runReportExecution(executionOptions); } @NonNull @Override - public Call requestReportExecutionDetails(@NonNull String executionId) { + public Observable requestReportExecutionDetails(@Nullable String executionId) { + checkNotNull(executionId, "Execution id should not be null"); return mRestApi.requestReportExecutionDetails(executionId); } @NonNull @Override - public Call requestReportExecutionStatus(@NonNull String executionId) { + public Observable requestReportExecutionStatus(@Nullable String executionId) { + checkNotNull(executionId, "Execution id should not be null"); return mRestApi.requestReportExecutionStatus(executionId); } + @NonNull @Override - public boolean cancelReportExecution(@NonNull String executionId) { - Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()); - // TODO in order to wrap response we need use CallAdapter approach - try { - Response response = call.execute(); - int status = response.code(); - return status != 204; - } catch (IOException e) { - // We need to wrap response in call. For now we will rethrow error - throw new RuntimeException(e); - } + public Observable cancelReportExecution(@Nullable String executionId) { + checkNotNull(executionId, "Execution id should not be null"); + return mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()) + .flatMap(new Func1, Observable>() { + @Override + public Observable call(Response response) { + int status = response.code(); + return Observable.just(status != 204); + } + }); } + @NonNull @Override - public boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params) { - Call call = mRestApi.updateReportExecution(executionId, params); - Response response = null; - // TODO in order to wrap response we need use CallAdapter approach - try { - response = call.execute(); - int status = response.code(); - return status == 204; - } catch (IOException e) { - // We need to wrap response in call. For now we will rethrow error - throw new RuntimeException(e); - } + public Observable updateReportExecution(@Nullable String executionId, @Nullable Collection params) { + checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(params, "Execution params id should not be null"); + return mRestApi.updateReportExecution(executionId, params).flatMap(new Func1, Observable>() { + @Override + public Observable call(Response response) { + int status = response.code(); + return Observable.just(status == 204); + } + }); } @NonNull @Override - public Call searchReportExecution(Map params) { - return mRestApi.searchReportExecution(params); - -// TODO we need to use CallAdapater in order to wrap our response in call object -// int status = response.getStatus(); -// if (status == 204) { -// return ReportExecutionSearchResponse.empty(); -// } else { -// ResponseEntity responseEntity = -// mRestAdapterWrapper.produce(response, ReportExecutionSearchResponse.class); -// return responseEntity.getEntity(); -// } + public Observable searchReportExecution(@Nullable Map params) { + checkNotNull(params, "Search params should not be null"); + checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); + return mRestApi.searchReportExecution(params) + .flatMap(new Func1>() { + @Override + public Observable call(ReportExecutionSearchResponse response) { + if (response == null) { + return Observable.just(ReportExecutionSearchResponse.empty()); + } + return Observable.just(response); + } + }); } interface RestApi { @NonNull @Headers("Accept: application/json") - @POST("/rest_v2/reportExecutions") - Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); + @POST("rest_v2/reportExecutions") + Observable runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") - @GET("/rest_v2/reportExecutions/{executionId}") - Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = false) String executionId); + @GET("rest_v2/reportExecutions/{executionId}") + Observable requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId); @NonNull @Headers("Accept: application/json") - @GET("/rest_v2/reportExecutions/{executionId}/status") - Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = false) String executionId); + @GET("rest_v2/reportExecutions/{executionId}/status") + Observable requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId); @NonNull @Headers("Accept: application/json") - @POST("/rest_v2/reportExecutions/{executionId}/parameters") - Call updateReportExecution(@NonNull @Path(value = "executionId", encoded = false) String executionId, - @NonNull @Body Collection params); + @POST("rest_v2/reportExecutions/{executionId}/parameters") + Observable> updateReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, + @NonNull @Body Collection params); @NonNull @Headers("Accept: application/json") - @PUT("/rest_v2/reportExecutions/{executionId}/status") - Call cancelReportExecution(@NonNull @Path(value = "executionId", encoded = false) String executionId, - @NonNull @Body ExecutionStatusResponse statusResponse); + @PUT("rest_v2/reportExecutions/{executionId}/status") + Observable> cancelReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, + @NonNull @Body ExecutionStatusResponse statusResponse); @Headers("Accept: application/json") - @GET("/rest_v2/reportExecutions") - Call searchReportExecution(@Nullable @QueryMap(encoded = false) Map params); + @GET("rest_v2/reportExecutions") + Observable searchReportExecution(@Nullable @QueryMap(encoded = true) Map params); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java index 4a079dd8..5d2a8bfb 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java @@ -36,5 +36,11 @@ static T checkNotNull(T object, String message) { return object; } + static void checkArgument(boolean condition, String message) { + if (condition) { + throw new IllegalArgumentException(message); + } + } + private Utils() {} } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index b1a72c6b..1b32df28 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -40,9 +40,10 @@ import java.io.IOException; import java.util.Collections; +import java.util.HashMap; +import java.util.Map; -import retrofit.Call; -import retrofit.Response; +import rx.Observable; import static org.hamcrest.Matchers.empty; import static org.hamcrest.core.Is.is; @@ -55,6 +56,11 @@ */ public class ReportExecutionRestApiTest { + private static final Map SEARCH_PARAMS = new HashMap(); + static { + SEARCH_PARAMS.put("key", "value"); + } + @ResourceFile("json/cancelled_report_response.json") TestResource cancelledResponse; @ResourceFile("json/search_execution_response.json") @@ -90,46 +96,46 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri")); + restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri")).toBlocking().first(); } @Test public void bodyParameterShouldNotBeNullForRunReportExecution() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Body parameter value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runReportExecution(null); + restApiUnderTest.runReportExecution(null).toBlocking().first(); } @Test public void pathParameterShouldNotBeNullForRequestExecutionDetails() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionDetails(null); + restApiUnderTest.requestReportExecutionDetails(null).toBlocking().first(); } @Test public void pathParameterShouldNotBeNullForRequestExecutionStatus() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionStatus(null); + restApiUnderTest.requestReportExecutionStatus(null).toBlocking().first(); } @Test public void pathParameterShouldNotBeNullForCancelRequestExecution() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.cancelReportExecution(null); + restApiUnderTest.cancelReportExecution(null).toBlocking().first(); } @Test public void responseShouldNotBeCancelledIfResponseIs204() { mWebMockRule.enqueue(create204Response()); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id").toBlocking().first(); assertThat(cancelled, is(false)); } @@ -140,7 +146,7 @@ public void responseShouldBeCancelledIfResponseIs200() { response.setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id").toBlocking().first(); assertThat(cancelled, is(true)); } @@ -149,9 +155,8 @@ public void responseShouldBeCancelledIfResponseIs200() { public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws IOException { mWebMockRule.enqueue(create204Response()); - Call call = restApiUnderTest.searchReportExecution(null); - Response response = call.execute(); - assertThat(response.body().getItems(), is(empty())); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS).toBlocking().first(); + assertThat(response.getItems(), is(empty())); } @Test @@ -160,9 +165,8 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOEx mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); - Call call = restApiUnderTest.searchReportExecution(null); - Response response = call.execute(); - assertThat(response.body().getItems(), is(not(empty()))); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS).toBlocking().first(); + assertThat(response.getItems(), is(not(empty()))); } @Test @@ -170,17 +174,18 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOEx public void executionUpdateRequestShouldBeSuccessIfResponseIs204() { mWebMockRule.enqueue(create204Response()); - boolean response = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_LIST); + Observable call = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_LIST); + boolean response = call.toBlocking().first(); assertThat(response, is(true)); } @Test public void bodyParameterShouldNotBeNullForExecutionUpdate() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Body parameter value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution params id should not be null"); - restApiUnderTest.updateReportExecution("any_id", null); + restApiUnderTest.updateReportExecution("any_id", null).toBlocking().first(); } private MockResponse create200Response() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 2f62e380..e93554dc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -43,8 +43,7 @@ import java.util.HashMap; import java.util.Map; -import retrofit.Call; -import retrofit.Response; +import rx.Observable; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; @@ -78,7 +77,8 @@ public void shouldStartReportExecution() { public void shouldCancelReportExecution() throws InterruptedException { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse response = startExecution(); - boolean cancelled = api.cancelReportExecution(response.getExecutionId()); + Observable call = api.cancelReportExecution(response.getExecutionId()); + boolean cancelled = call.toBlocking().first(); assertThat(cancelled, is(true)); } @@ -88,9 +88,9 @@ public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionDetailsResponse executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - Call call = api.requestReportExecutionDetails(executionResponse.getExecutionId()); - Response response = call.execute(); - assertThat(response.body().getExecutionId(), is(executionId)); + Observable call = api.requestReportExecutionDetails(executionResponse.getExecutionId()); + ReportExecutionDetailsResponse response = call.toBlocking().first(); + assertThat(response.getExecutionId(), is(executionId)); } @Test @@ -98,9 +98,9 @@ public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); - Call call = api.requestReportExecutionStatus(executionResponse.getExecutionId()); - Response response = call.execute(); - assertThat(response.body().getStatus(), is(notNullValue())); + Observable call = api.requestReportExecutionStatus(executionResponse.getExecutionId()); + ExecutionStatusResponse response = call.toBlocking().first(); + assertThat(response.getStatus(), is(notNullValue())); } /** @@ -114,9 +114,9 @@ public void searchForExecutionShouldReturnResult() throws IOException { Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); - Call call = api.searchReportExecution(params); - Response response = call.execute(); - assertThat(response.body().getItems(), is(not(empty()))); + Observable call = api.searchReportExecution(params); + ReportExecutionSearchResponse response = call.toBlocking().first(); + assertThat(response.getItems(), is(not(empty()))); } @Test @@ -124,7 +124,8 @@ public void updateOfParametersForExecutionShouldReturnResult() { ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); - boolean success = api.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); + Observable call = api.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); + boolean success = call.toBlocking().first(); assertThat(success, is(true)); } @@ -136,13 +137,8 @@ private ReportExecutionDetailsResponse startExecution() { @NonNull private ReportExecutionDetailsResponse startExecution(String uri) { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); - Call call = getApi().runReportExecution(executionRequestOptions); - try { - Response response = call.execute(); - return response.body(); - } catch (IOException e) { - throw new RuntimeException(e); - } + Observable call = getApi().runReportExecution(executionRequestOptions); + return call.toBlocking().first(); } private ReportExecutionRestApi getApi() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index a83f4ab8..b477d058 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -44,6 +44,7 @@ import retrofit.Call; import retrofit.Response; +import rx.Observable; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -103,14 +104,8 @@ private ReportExportExecutionResponse startExportExecution(ReportExecutionDetail @NonNull private ReportExecutionDetailsResponse startExecution() { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(reportUri); - Call call = getReportExecApi().runReportExecution(executionRequestOptions); - - try { - Response response = call.execute(); - return response.body(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } + Observable call = getReportExecApi().runReportExecution(executionRequestOptions); + return call.toBlocking().first(); } private ReportExportRestApi getApi() { From 380a34bf9e57184825f3d6f88c924a3ab0c0b356 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 14:08:15 +0300 Subject: [PATCH 088/457] Migrate report export API to Observable --- .../android/sdk/network/api/BaseBuilder.java | 1 - .../sdk/network/api/GsonConverterFactory.java | 111 ++++++++++++++++++ .../sdk/network/api/LoggingInterceptor.java | 4 +- .../sdk/network/api/ReportExportRestApi.java | 10 +- .../network/api/ReportExportRestApiImpl.java | 103 +++++++++------- .../execution/ExecutionRequestOptions.java | 3 +- .../network/api/ReportExportRestApiTest.java | 39 +++--- .../api/ReportExportRestApiTest.java | 86 ++++++-------- 8 files changed, 238 insertions(+), 119 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index dcc8ad45..b59b9ada 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import com.squareup.okhttp.OkHttpClient; -import retrofit.GsonConverterFactory; import retrofit.Retrofit; import retrofit.RxJavaCallAdapterFactory; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java new file mode 100644 index 00000000..4be6f7fa --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java @@ -0,0 +1,111 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.google.gson.Gson; +import com.squareup.okhttp.MediaType; +import com.squareup.okhttp.RequestBody; +import com.squareup.okhttp.ResponseBody; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.Writer; +import java.lang.reflect.Type; +import java.nio.charset.Charset; + +import okio.Buffer; +import retrofit.Converter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class GsonConverterFactory implements Converter.Factory { + /** + * Create an instance using a default {@link Gson} instance for conversion. Encoding to JSON and + * decoding from JSON (when no charset is specified by a header) will use UTF-8. + */ + public static GsonConverterFactory create() { + return create(new Gson()); + } + + /** + * Create an instance using {@code gson} for conversion. Encoding to JSON and + * decoding from JSON (when no charset is specified by a header) will use UTF-8. + */ + public static GsonConverterFactory create(Gson gson) { + return new GsonConverterFactory(gson); + } + + private final Gson gson; + + private GsonConverterFactory(Gson gson) { + if (gson == null) throw new NullPointerException("gson == null"); + this.gson = gson; + } + + /** Create a converter for {@code type}. */ + @Override public Converter get(Type type) { + return new GsonConverter<>(type, gson); + } + + private static class GsonConverter implements Converter { + private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8"); + private static final Charset UTF_8 = Charset.forName("UTF-8"); + + private final Gson mGson; + private final Type mType; + + GsonConverter(Type type, Gson gson) { + mType = type; + mGson = gson; + } + + @Override public T fromBody(ResponseBody body) throws IOException { + Reader in = body.charStream(); + try { + return mGson.fromJson(in, mType); + } finally { + try { + in.close(); + } catch (IOException ignored) { + } + } + } + + @Override public RequestBody toBody(T value) { + Buffer buffer = new Buffer(); + Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8); + try { + mGson.toJson(value, mType, writer); + writer.flush(); + } catch (IOException e) { + throw new AssertionError(e); // Writing to Buffer does no I/O. + } + return RequestBody.create(MEDIA_TYPE, buffer.readByteString()); + } + } +} \ No newline at end of file diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index c2d2b6e6..b664fa3b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -48,8 +48,8 @@ public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); long t1 = System.nanoTime(); - logger.log(String.format("Sending request %s on %s%n%s", - request.url(), chain.connection(), request.headers())); + logger.log(String.format("Sending request %s on %s%n%s \nWith body: \n%s", + request.url(), chain.connection(), request.headers(), bodyToString(request))); Response response = chain.proceed(request); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 74c7a59b..3b89c6d7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -32,7 +32,7 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import retrofit.Call; +import rx.Observable; /** * @author Tom Koptel @@ -41,16 +41,16 @@ public interface ReportExportRestApi { @NonNull - Call runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + Observable runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); @NonNull - Call checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); + Observable checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); @NonNull - ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId); + Observable requestExportOutput(@NonNull String executionId, @NonNull String exportId); @NonNull - ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); + Observable requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index c6ce9cdd..415b83a2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; @@ -33,9 +34,6 @@ import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; import com.squareup.okhttp.ResponseBody; -import java.io.IOException; - -import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.Body; @@ -43,6 +41,10 @@ import retrofit.http.Headers; import retrofit.http.POST; import retrofit.http.Path; +import rx.Observable; +import rx.functions.Func1; + +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; /** * @author Tom Koptel @@ -57,76 +59,87 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @NonNull @Override - public Call runExportExecution(@NonNull String executionId, - @NonNull ExecutionRequestOptions executionOptions) { + public Observable runExportExecution(@Nullable String executionId, + @Nullable ExecutionRequestOptions executionOptions) { + checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(executionOptions, "Execution options should not be null"); + return mRestApi.runReportExportExecution(executionId, executionOptions); } @NonNull @Override - public Call checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId) { + public Observable checkExportExecutionStatus(@Nullable String executionId, @Nullable String exportId) { + checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(exportId, "Export id should not be null"); + return mRestApi.checkReportExportStatus(executionId, exportId); } @NonNull @Override - public ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId) { - Call call = mRestApi.requestReportExportOutput(executionId, exportId); - // TODO in order to wrap response we need use CallAdapter approach - try { - Response response = call.execute(); - com.squareup.okhttp.Headers headers = response.headers(); - - RetrofitExportInput exportInput = new RetrofitExportInput(response.body()); - String pages = headers.get("report-pages"); - boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); - - return ExportResourceResponse.create(exportInput, pages, isFinal); - } catch (IOException e) { - // We need to wrap response in call. For now we will rethrow error - throw new RuntimeException(e); - } + public Observable requestExportOutput(@Nullable String executionId, @Nullable String exportId) { + checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(exportId, "Export id should not be null"); + + return mRestApi.requestReportExportOutput(executionId, exportId).flatMap(new Func1, Observable>() { + @Override + public Observable call(Response rawResponse) { + com.squareup.okhttp.Headers headers = rawResponse.headers(); + + RetrofitExportInput exportInput = new RetrofitExportInput(rawResponse.body()); + String pages = headers.get("report-pages"); + boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); + + ExportResourceResponse response = ExportResourceResponse.create(exportInput, pages, isFinal); + return Observable.just(response); + } + }); } @NonNull @Override - public ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId) { - Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); - // TODO in order to wrap response we need use CallAdapter approach - try { - Response response = call.execute(); - return new RetrofitExportInput(response.body()); - } catch (IOException e) { - // We need to wrap response in call. For now we will rethrow error - throw new RuntimeException(e); - } + public Observable requestExportAttachment(@Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) { + checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(exportId, "Export id should not be null"); + checkNotNull(attachmentId, "Attachment id should not be null"); + + return mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId) + .flatMap(new Func1, Observable>() { + @Override + public Observable call(Response rawResponse) { + ResponseBody body = rawResponse.body(); + ExportInput response = new RetrofitExportInput(body); + return Observable.just(response); + } + }); } private interface RestApi { @NonNull @Headers("Accept: application/json") - @POST("/rest_v2/reportExecutions/{executionId}/exports") - Call runReportExportExecution(@NonNull @Path("executionId") String executionId, - @NonNull @Body ExecutionRequestOptions executionOptions); + @POST("rest_v2/reportExecutions/{executionId}/exports") + Observable runReportExportExecution(@NonNull @Path("executionId") String executionId, + @NonNull @Body ExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") - @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") - Call checkReportExportStatus(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId); + @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") + Observable checkReportExportStatus(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId); /** * 'suppressContentDisposition' used due to security implications this header has */ @NonNull - @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") - Call requestReportExportOutput(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId); + @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") + Observable> requestReportExportOutput(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId); @NonNull - @GET("/rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") - Call requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId, - @NonNull @Path("attachmentId") String attachmentId); + @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") + Observable> requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId, + @NonNull @Path("attachmentId") String attachmentId); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 0ac879f7..678ab4e8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -224,7 +224,6 @@ public String toString() { ", anchor='" + anchor + '\'' + ", transformerKey='" + transformerKey + '\'' + ", attachmentsPrefix='" + attachmentsPrefix + '\'' + - ", parameters=" + Arrays.toString(parameters.getReportParameters().toArray()) + '}'; } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index 10dd26ec..d075fc0c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -42,6 +42,8 @@ import java.io.IOException; import java.io.InputStream; +import rx.Observable; + import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -91,56 +93,56 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { @Test public void pathParameterShouldNotBeNullForRunRequestExecution() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution id should not be null"); restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.newInstance()); } @Test public void bodyShouldNotBeNullForRunRequestExecution() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Body parameter value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution options should not be null"); restApiUnderTest.runExportExecution("any_id", null); } @Test public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution id should not be null"); restApiUnderTest.checkExportExecutionStatus(null, "any_id"); } @Test public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"exportId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Export id should not be null"); restApiUnderTest.checkExportExecutionStatus("any_id", null); } @Test public void executionIdParameterShouldNotBeNullForAttachmentRequest() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"executionId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution id should not be null"); restApiUnderTest.requestExportAttachment(null, "any_id", "any_id"); } @Test public void exportIdParameterShouldNotBeNullForAttachmentRequest() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"exportId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Export id should not be null"); restApiUnderTest.requestExportAttachment("any_id", null, "any_id"); } @Test public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { - mExpectedException.expect(RestError.class); - mExpectedException.expectMessage("Path parameter \"attachmentId\" value must not be null."); + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Attachment id should not be null"); restApiUnderTest.requestExportAttachment("any_id", "any_id", null); } @@ -152,7 +154,8 @@ public void requestForOutputShouldParsePagesFromHeader() { .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); + Observable call = restApiUnderTest.requestExportOutput("any_id", "any_id"); + ExportResourceResponse resource = call.toBlocking().first(); assertThat(resource.getPages(), is("1-10")); } @@ -163,7 +166,8 @@ public void requestForOutputShouldParseIsFinalHeader() { .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); + Observable call = restApiUnderTest.requestExportOutput("any_id", "any_id"); + ExportResourceResponse resource = call.toBlocking().first(); assertThat(resource.isFinal(), is(true)); } @@ -173,7 +177,8 @@ public void requestForAttachmentShouldBeWrappedInsideInput() throws IOException .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - ExportInput resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); + Observable call = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); + ExportInput resource = call.toBlocking().first(); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index b477d058..c62b012a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -26,7 +26,6 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; @@ -35,15 +34,15 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; +import org.junit.Before; import org.junit.Test; import java.io.IOException; -import retrofit.Call; -import retrofit.Response; import rx.Observable; import static org.hamcrest.core.Is.is; @@ -55,11 +54,31 @@ * @since 2.0 */ public class ReportExportRestApiTest { - String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; - String reportUri = "/public/Samples/Reports/AllAccounts"; - AuthResponse mAuthResponse; + private static final String REPORT_URI = "/public/Samples/Reports/AllAccounts"; + ReportExecutionRestApi mExecApi; - ReportExportRestApi mExportApi; + ReportExportRestApi apiUnderTest; + + private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); + private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + + @Before + public void setup() { + mAuthenticator.authorize(); + String cookie = mAuthenticator.getCookie(); + + if (mExecApi == null) { + mExecApi = new ReportExecutionRestApi.Builder(mMetadata.getServerUrl(), cookie) + .setLog(TestLogger.get(this)) + .build(); + } + + if (apiUnderTest == null) { + apiUnderTest = new ReportExportRestApi.Builder(mMetadata.getServerUrl(), cookie) + .setLog(TestLogger.get(this)) + .build(); + } + } @Test public void runExportRequestShouldReturnResult() { @@ -72,8 +91,8 @@ public void runExportRequestShouldReturnResult() { public void checkExportRequestStatusShouldReturnResult() throws IOException { ReportExecutionDetailsResponse exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - Call call = getApi().checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); - Response response = call.execute(); + Observable call = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); + ExecutionStatusResponse response = call.toBlocking().first(); assertThat(response, is(notNullValue())); } @@ -81,57 +100,30 @@ public void checkExportRequestStatusShouldReturnResult() throws IOException { public void requestExportOutputShouldReturnResult() { ReportExecutionDetailsResponse exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - ExportResourceResponse output = getApi().requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); + Observable call = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); + ExportResourceResponse output = call.toBlocking().first(); + assertThat(output.getExportInput(), is(notNullValue())); assertThat(output.getPages(), is("1-2")); assertThat(output.isFinal(), is(false)); } + /** + * Helper methods + */ @NonNull private ReportExportExecutionResponse startExportExecution(ReportExecutionDetailsResponse exec) { ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() .withPages("1-2") .withOutputFormat("PDF"); - Call call = getApi().runExportExecution(exec.getExecutionId(), options); - try { - Response response = call.execute(); - return response.body(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } + Observable call = apiUnderTest.runExportExecution(exec.getExecutionId(), options); + return call.toBlocking().first(); } @NonNull private ReportExecutionDetailsResponse startExecution() { - ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(reportUri); - Observable call = getReportExecApi().runReportExecution(executionRequestOptions); + ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); + Observable call = mExecApi.runReportExecution(executionRequestOptions); return call.toBlocking().first(); } - - private ReportExportRestApi getApi() { - if (mExportApi == null) { - mExportApi = new ReportExportRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) - .setLog(TestLogger.get(this)) - .build(); - } - return mExportApi; - } - - private ReportExecutionRestApi getReportExecApi() { - if (mExecApi == null) { - mExecApi = new ReportExecutionRestApi.Builder(mobileDemo2, getAuthResponse().getToken()) - .setLog(TestLogger.get(this)) - .build(); - } - return mExecApi; - } - - private AuthResponse getAuthResponse() { - if (mAuthResponse == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2).build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null) - .toBlocking().first(); - } - return mAuthResponse; - } } From 1251dbc9d64381fea00a260dec6dcf60fb980ff2 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 14:32:01 +0300 Subject: [PATCH 089/457] Migrate repository API to Observable --- .../sdk/network/api/LoggingInterceptor.java | 8 +- .../sdk/network/api/RepositoryRestApi.java | 12 +-- .../network/api/RepositoryRestApiImpl.java | 92 ++++++++++--------- .../android/sdk/network/api/Utils.java | 9 ++ .../network/api/RepositoryRestApiTest.java | 49 +++++++++- .../api/RepositoryRestApiTest.java | 73 +++++++-------- 6 files changed, 142 insertions(+), 101 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index b664fa3b..b9796abe 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -48,14 +48,14 @@ public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); long t1 = System.nanoTime(); - logger.log(String.format("Sending request %s on %s%n%s \nWith body: \n%s", + logger.log(String.format("Sending request %s on %s%n%sWith body: \n%s", request.url(), chain.connection(), request.headers(), bodyToString(request))); Response response = chain.proceed(request); long t2 = System.nanoTime(); - logger.log(String.format("Received response for %s in %.1fms%n%sBody: \n%s", - response.request().url(), (t2 - t1) / 1e6d, response.headers(), bodyToString(request))); + logger.log(String.format("Received response for %s in %.1fms%n%s", + response.request().url(), (t2 - t1) / 1e6d, response.headers())); return response; } @@ -71,7 +71,7 @@ private static String bodyToString(final Request request){ return "No Body"; } } catch (final IOException e) { - return String.format("", e.getMessage()); + return String.format("", e.getMessage()); } } } \ No newline at end of file diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 3692f907..e4fe9a23 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -35,7 +35,7 @@ import java.util.Map; -import retrofit.Call; +import rx.Observable; /** * @author Tom Koptel @@ -43,19 +43,19 @@ */ public interface RepositoryRestApi { @NonNull - ResourceSearchResponse searchResources(@Nullable Map searchParams); + Observable searchResources(@Nullable Map searchParams); @NonNull - Call requestReportResource(@NonNull String resourceUri); + Observable requestReportResource(@NonNull String resourceUri); @NonNull - Call requestDashboardResource(@NonNull String resourceUri); + Observable requestDashboardResource(@NonNull String resourceUri); @NonNull - Call requestLegacyDashboardResource(@NonNull String resourceUri); + Observable requestLegacyDashboardResource(@NonNull String resourceUri); @NonNull - Call requestFolderResource(@NonNull String resourceUri); + Observable requestFolderResource(@NonNull String resourceUri); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 7e2ff5b6..d7845e9b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -33,16 +33,19 @@ import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; -import java.io.IOException; import java.util.Map; -import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.Path; import retrofit.http.QueryMap; +import rx.Observable; +import rx.functions.Func1; + +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; +import static com.jaspersoft.android.sdk.network.api.Utils.headerToInt; /** * @author Tom Koptel @@ -57,86 +60,85 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NonNull @Override - public ResourceSearchResponse searchResources(@Nullable Map searchParams) { - Call call = mRestApi.searchResources(searchParams); - // TODO in order to wrap response we need use CallAdapter approach - try { - Response response = call.execute(); - int status = response.code(); - - if (status == 204) { - return ResourceSearchResponse.empty(); - } else { - ResourceSearchResponse entity = response.body(); - com.squareup.okhttp.Headers headers = response.headers(); - - int resultCount = Integer.valueOf(headers.get("Result-Count")); - int totalCount = Integer.valueOf(headers.get("Total-Count")); - int startIndex = Integer.valueOf(headers.get("Start-Index")); - int nextOffset = Integer.valueOf(headers.get("Next-Offset")); - - entity.setResultCount(resultCount); - entity.setTotalCount(totalCount); - entity.setStartIndex(startIndex); - entity.setNextOffset(nextOffset); - - return entity; + public Observable searchResources(@Nullable Map searchParams) { + return mRestApi.searchResources(searchParams).flatMap(new Func1, Observable>() { + @Override + public Observable call(Response rawResponse) { + int status = rawResponse.code(); + ResourceSearchResponse entity; + if (status == 204) { + entity = ResourceSearchResponse.empty(); + } else { + entity = rawResponse.body(); + com.squareup.okhttp.Headers headers = rawResponse.headers(); + + int resultCount = headerToInt(headers, "Result-Count"); + int totalCount = headerToInt(headers, "Total-Count"); + int startIndex = headerToInt(headers, "Start-Index"); + int nextOffset = headerToInt(headers, "Next-Offset"); + + entity.setResultCount(resultCount); + entity.setTotalCount(totalCount); + entity.setStartIndex(startIndex); + entity.setNextOffset(nextOffset); + } + return Observable.just(entity); } - - } catch (IOException e) { - // We need to wrap response in call. For now we will rethrow error - throw new RuntimeException(e); - } + }); } @NonNull @Override - public Call requestReportResource(@NonNull String resourceUri) { + public Observable requestReportResource(@Nullable String resourceUri) { + checkNotNull(resourceUri, "Report uri should not be null"); return mRestApi.requestReportResource(resourceUri); } @NonNull @Override - public Call requestDashboardResource(@NonNull String resourceUri) { + public Observable requestDashboardResource(@Nullable String resourceUri) { + checkNotNull(resourceUri, "Dashboard uri should not be null"); return mRestApi.requestDashboardResource(resourceUri); } @NonNull @Override - public Call requestLegacyDashboardResource(@NonNull String resourceUri) { + public Observable requestLegacyDashboardResource(@Nullable String resourceUri) { + checkNotNull(resourceUri, "Legacy dashboard uri should not be null"); return mRestApi.requestLegacyDashboardResource(resourceUri); } @NonNull @Override - public Call requestFolderResource(@NonNull String resourceUri) { + public Observable requestFolderResource(@Nullable String resourceUri) { + checkNotNull(resourceUri, "Folder uri should not be null"); return mRestApi.requestFolderResource(resourceUri); } private interface RestApi { @NonNull @Headers("Accept: application/json") - @GET("/rest_v2/resources") - Call searchResources(@Nullable @QueryMap Map searchParams); + @GET("rest_v2/resources") + Observable> searchResources(@Nullable @QueryMap Map searchParams); @NonNull @Headers("Accept: application/repository.reportUnit+json") - @GET("/rest_v2/resources{resourceUri}") - Call requestReportResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); + @GET("rest_v2/resources{resourceUri}") + Observable requestReportResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.dashboard+json") - @GET("/rest_v2/resources{resourceUri}") - Call requestDashboardResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); + @GET("rest_v2/resources{resourceUri}") + Observable requestDashboardResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.legacyDashboard+json") - @GET("/rest_v2/resources{resourceUri}") - Call requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); + @GET("rest_v2/resources{resourceUri}") + Observable requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.folder+json") - @GET("/rest_v2/resources{resourceUri}") - Call requestFolderResource(@NonNull @Path(value = "resourceUri", encoded = false) String resourceUri); + @GET("rest_v2/resources{resourceUri}") + Observable requestFolderResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java index 5d2a8bfb..8d95940b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java @@ -42,5 +42,14 @@ static void checkArgument(boolean condition, String message) { } } + static int headerToInt(com.squareup.okhttp.Headers headers, String key) { + String header = headers.get(key); + if (header == null) { + return 0; + } else { + return Integer.valueOf(header); + } + } + private Utils() {} } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index 0e4067fa..a2132c36 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -37,6 +37,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import rx.Observable; + import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -76,7 +78,8 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { public void shouldReturnEmptyResponseForNoContentResponse() { mWebMockRule.enqueue(create204Response()); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + Observable call = restApiUnderTest.searchResources(null); + ResourceSearchResponse response = call.toBlocking().first(); assertThat(response.getResources(), is(empty())); } @@ -100,7 +103,8 @@ public void requestForSearchShouldParseHeaderResultCount() { .addHeader("Result-Count", "100"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + Observable call = restApiUnderTest.searchResources(null); + ResourceSearchResponse response = call.toBlocking().first(); assertThat(response.getResultCount(), is(100)); } @@ -111,7 +115,8 @@ public void requestForSearchShouldParseHeaderTotalCount() { .addHeader("Total-Count", "1000"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + Observable call = restApiUnderTest.searchResources(null); + ResourceSearchResponse response = call.toBlocking().first(); assertThat(response.getTotalCount(), is(1000)); } @Test @@ -121,7 +126,8 @@ public void requestForSearchShouldParseHeaderStartIndex() { .addHeader("Start-Index", "5"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + Observable call = restApiUnderTest.searchResources(null); + ResourceSearchResponse response = call.toBlocking().first(); assertThat(response.getStartIndex(), is(5)); } @@ -132,10 +138,43 @@ public void requestForSearchShouldParseHeaderNextOffset() { .addHeader("Next-Offset", "10"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + Observable call = restApiUnderTest.searchResources(null); + ResourceSearchResponse response = call.toBlocking().first(); assertThat(response.getNextOffset(), is(10)); } + @Test + public void requestForReportResourceShouldNotAcceptNullUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report uri should not be null"); + + restApiUnderTest.requestReportResource(null); + } + + @Test + public void requestForDashboardResourceShouldNotAcceptNullUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Dashboard uri should not be null"); + + restApiUnderTest.requestDashboardResource(null); + } + + @Test + public void requestForLegacyDashboardResourceShouldNotAcceptNullUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Legacy dashboard uri should not be null"); + + restApiUnderTest.requestLegacyDashboardResource(null); + } + + @Test + public void requestForFolderResourceShouldNotAcceptNullUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Folder uri should not be null"); + + restApiUnderTest.requestFolderResource(null); + } + private MockResponse create200Response() { return new MockResponse() .setStatus("HTTP/1.1 200 Ok"); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 8cf1fd2c..15dad566 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,20 +24,19 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; +import org.junit.Before; import org.junit.Test; -import java.io.IOException; - -import retrofit.Call; -import retrofit.Response; +import rx.Observable; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; @@ -51,59 +50,51 @@ */ public class RepositoryRestApiTest { - String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; - AuthResponse mAuthResponse; + private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); + private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private RepositoryRestApi api; + + @Before + public void setup() { + mAuthenticator.authorize(); + String cookie = mAuthenticator.getCookie(); + + if (api == null) { + api = new RepositoryRestApi.Builder(mMetadata.getServerUrl(), cookie) + .setLog(TestLogger.get(this)) + .build(); + } + } @Test - public void shouldRequestListOfResources() throws IOException { - RepositoryRestApi api = createApi(); - ResourceSearchResponse resourceSearchResponse = api.searchResources(null); + public void shouldRequestListOfResources() { + Observable call = api.searchResources(null); + ResourceSearchResponse resourceSearchResponse = call.toBlocking().first(); assertThat(resourceSearchResponse, is(notNullValue())); assertThat(resourceSearchResponse.getResources(), is(not(empty()))); } @Test - public void shouldRequestReport() throws IOException { - RepositoryRestApi api = createApi(); - Call call = api.requestReportResource("/public/Samples/Reports/AllAccounts"); - Response response = call.execute(); - ReportLookupResponse report = response.body(); + public void shouldRequestReport() { + Observable call = api.requestReportResource("/public/Samples/Reports/AllAccounts"); + ReportLookupResponse report = call.toBlocking().first(); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @Test - public void shouldRequestDashboard() throws IOException { - RepositoryRestApi api = createApi(); - Call call = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); - Response response = call.execute(); - DashboardLookupResponse dashboard = response.body(); + public void shouldRequestDashboard() { + Observable call = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); + DashboardLookupResponse dashboard = call.toBlocking().first(); assertThat(dashboard, is(notNullValue())); assertThat(dashboard.getFoundations(), is(not(empty()))); } @Test - public void shouldRequestRootFolder() throws IOException { - RepositoryRestApi api = createApi(); - Call call = api.requestFolderResource("/"); - Response response = call.execute(); - FolderLookupResponse folder = response.body(); + public void shouldRequestRootFolder() { + Observable call = api.requestFolderResource("/"); + FolderLookupResponse folder = call.toBlocking().first(); assertThat(folder, is(notNullValue())); } - private RepositoryRestApi createApi() { - return new RepositoryRestApi.Builder(mobileDemo2, getAuthResponse().getToken()).build(); - } - - private AuthResponse getAuthResponse() { - if (mAuthResponse == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mobileDemo2) -// .setLog(TestLogger.get(this)) -// .setLogLevel(RestApiLogLevel.FULL) - .build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null) - .toBlocking().first(); - } - return mAuthResponse; - } } \ No newline at end of file From c8811b988c25d11a0cbf1011d9bc132cd10b44b4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 15:08:07 +0300 Subject: [PATCH 090/457] Migrate server API to Observable --- .../jaspersoft/android/sdk/network/api/ServerRestApi.java | 6 +++--- .../android/sdk/network/api/ServerRestApiTest.java | 2 +- .../android/sdk/test/integration/api/ServerRestTest.java | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 0e67e319..92a03d8a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -28,9 +28,9 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; -import retrofit.Call; import retrofit.http.GET; import retrofit.http.Headers; +import rx.Observable; /** * @author Tom Koptel @@ -40,8 +40,8 @@ public interface ServerRestApi { @NonNull @Headers("Accept: application/json") - @GET(value = "/rest_v2/serverInfo") - Call requestServerInfo(); + @GET(value = "rest_v2/serverInfo") + Observable requestServerInfo(); final class Builder extends BaseBuilder { public Builder(String baseUrl) { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java index 9d398318..45a2b0a3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java @@ -50,7 +50,7 @@ public void shouldThroughRestErrorForHttpError() { mWebMockRule.enqueue(create500Response()); ServerRestApi restApi = new ServerRestApi.Builder(mWebMockRule.getRootUrl()).build(); - restApi.requestServerInfo(); + restApi.requestServerInfo().toBlocking().first(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 59d0af35..cb48ef15 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -33,8 +33,7 @@ import java.io.IOException; -import retrofit.Call; -import retrofit.Response; +import rx.Observable; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -53,8 +52,8 @@ public void shouldRequestServerInfo() throws IOException { ServerRestApi api = new ServerRestApi.Builder(mobileDemo2) .setLog(TestLogger.get(this)) .build(); - Call call = api.requestServerInfo(); - Response response = call.execute(); + Observable call = api.requestServerInfo(); + ServerInfoResponse response = call.toBlocking().first(); assertThat(response, is(notNullValue())); } } From a3d41b68fe7901cd8c059f08cf9c195dd814fedb Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 15:41:08 +0300 Subject: [PATCH 091/457] Fix crashed tests witihin API package --- .../network/api/AuthResponseFactoryTest.java | 38 ++++++++----------- .../network/api/RetrofitExportInputTest.java | 19 ++++++++-- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java index 711efbbd..41634413 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java @@ -25,48 +25,42 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.squareup.okhttp.Headers; +import com.squareup.okhttp.Protocol; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.HashMap; -import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.powermock.api.mockito.PowerMockito.when; /** * @author Tom Koptel * @since 2.0 */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({com.squareup.okhttp.Response.class}) public class AuthResponseFactoryTest { - @Mock - com.squareup.okhttp.Response mResponse; + + private Request mRequest; @Before public void setup() { - MockitoAnnotations.initMocks(this); + mRequest = new Request.Builder() + .url("http://localhost") + .build(); } @Test public void shouldExtractTokenFromNetworkResponse() { - Map headersRaw = new HashMap<>(); - headersRaw.put("Set-Cookie", "cookie1"); - headersRaw.put("Set-Cookie", "cookie2"); - - Headers headers = Headers.of(headersRaw); - when(mResponse.headers()).thenReturn(headers); + Response mockResponse = new Response.Builder() + .addHeader("Set-Cookie", "cookie1") + .addHeader("Set-Cookie", "cookie2") + .code(200) + .protocol(Protocol.HTTP_1_1) + .request(mRequest) + .build(); - AuthResponse response = AuthResponseFactory.create(mResponse); + AuthResponse response = AuthResponseFactory.create(mockResponse); assertThat(response.getToken(), is("cookie1;cookie2")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java index 0e6b7803..69b8de46 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java @@ -24,48 +24,61 @@ package com.jaspersoft.android.sdk.network.api; +import com.squareup.okhttp.MediaType; import com.squareup.okhttp.ResponseBody; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.io.IOException; +import java.io.InputStream; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ResponseBody.class}) public class RetrofitExportInputTest { - @Mock - ResponseBody mTypedInput; private RetrofitExportInput objectUnderTest; + private ResponseBody mTypedInput; + @Mock + private InputStream input; @Before public void setup() { MockitoAnnotations.initMocks(this); + mTypedInput = PowerMockito.mock(ResponseBody.class); objectUnderTest = new RetrofitExportInput(mTypedInput); } @Test public void shouldDelegateMimeType() { + when(mTypedInput.contentType()).thenReturn(MediaType.parse("multipart/form-data")); objectUnderTest.getMimeType(); verify(mTypedInput, times(1)).contentType(); } @Test - public void shouldDelegateLengrh() throws IOException { + public void shouldDelegateLength() throws IOException { objectUnderTest.getLength(); verify(mTypedInput, times(1)).contentLength(); } @Test public void shouldDelegateInputStream() throws IOException { + when(mTypedInput.byteStream()).thenReturn(input); objectUnderTest.getStream(); verify(mTypedInput, times(1)).byteStream(); } From 41af4b015385f4664b69ae6145f3e60a39e028cf Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 16:30:13 +0300 Subject: [PATCH 092/457] Generifying rest errors --- .../api/AuthenticationRestApiImpl.java | 8 +- .../network/api/InputControlRestApiImpl.java | 28 ++++--- .../api/ReportExecutionRestApiImpl.java | 38 ++++++---- .../network/api/ReportExportRestApiImpl.java | 35 +++++---- .../network/api/RepositoryRestApiImpl.java | 73 ++++++++++++------- .../RestErrorAdapter.java} | 28 ++++++- .../sdk/network/api/ServerRestApi.java | 2 +- .../ServerRestApiImpl.java} | 40 ++++++---- .../network/entity/server/AuthResponse.java | 20 +---- .../sdk/network/exception/ErrorHandler.java | 12 --- .../sdk/network/exception/RestError.java | 32 ++++---- .../exception/RetrofitErrorHandler.java | 48 ------------ .../network/operation/PendingOperation.java | 34 --------- .../android/sdk/network/operation/Result.java | 33 --------- .../network/api/InputControlRestApiTest.java | 11 +++ .../network/api/ReportExportRestApiTest.java | 5 +- .../network/api/RepositoryRestApiTest.java | 3 +- 17 files changed, 196 insertions(+), 254 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{operation/ResultCallback.java => api/RestErrorAdapter.java} (52%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{operation/Status.java => api/ServerRestApiImpl.java} (54%) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index f3d9b18e..2e8872ab 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -89,18 +89,18 @@ public Observable call() { .body(response.body()) .code(401) .build(); - Throwable error = RestError.httpError(request.urlString(), response401); + Throwable error = RestError.httpError(response401); return Observable.error(error); } } else if (statusCode == 401) { - Throwable error = RestError.httpError(request.urlString(), response); + Throwable error = RestError.httpError(response); return Observable.error(error); } else { - Throwable error = RestError.httpError(request.urlString(), response); + Throwable error = RestError.httpError(response); return Observable.error(error); } } catch (IOException e) { - return Observable.error(RestError.networkError(request.urlString(), e)); + return Observable.error(RestError.networkError(e)); } } }); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 66efacfe..122e8c1c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -56,43 +56,49 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override public Observable requestInputControls(@NonNull String reportUri) { - return requestInputControls(reportUri, false); + return requestInputControls(reportUri, false) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestInputControls(@NonNull String reportUri, boolean excludeState) { - return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); + return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestInputControlsInitialStates(@NonNull String reportUri) { - return requestInputControlsInitialStates(reportUri, false); + return requestInputControlsInitialStates(reportUri, false) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { - return mRestApi.requestInputControlsInitialValues(reportUri, freshData); + return mRestApi.requestInputControlsInitialValues(reportUri, freshData) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestInputControlsStates(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues) { - return requestInputControlsStates(reportUri, controlsId, controlsValues, false); + @NonNull Set controlsId, + @NonNull Map> controlsValues) { + return requestInputControlsStates(reportUri, controlsId, controlsValues, false) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestInputControlsStates(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues, - boolean freshData) { + @NonNull Set controlsId, + @NonNull Map> controlsValues, + boolean freshData) { String ids = TextUtils.join(";", controlsId); - return mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + return mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData) + .onErrorResumeNext(RestErrorAdapter.get()); } private interface RestApi { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 203d0ba5..9c5e6fdc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -67,21 +67,25 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @Override public Observable runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) { checkNotNull(executionOptions, "Execution options should not be null"); - return mRestApi.runReportExecution(executionOptions); + return mRestApi.runReportExecution(executionOptions) + .onErrorResumeNext(RestErrorAdapter.get()); + } @NonNull @Override public Observable requestReportExecutionDetails(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - return mRestApi.requestReportExecutionDetails(executionId); + return mRestApi.requestReportExecutionDetails(executionId) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestReportExecutionStatus(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - return mRestApi.requestReportExecutionStatus(executionId); + return mRestApi.requestReportExecutionStatus(executionId) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @@ -95,7 +99,9 @@ public Observable call(Response response) { int status = response.code(); return Observable.just(status != 204); } - }); + }) + .onErrorResumeNext(RestErrorAdapter.get()); + } @NonNull @@ -103,13 +109,16 @@ public Observable call(Response response) { public Observable updateReportExecution(@Nullable String executionId, @Nullable Collection params) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(params, "Execution params id should not be null"); - return mRestApi.updateReportExecution(executionId, params).flatMap(new Func1, Observable>() { - @Override - public Observable call(Response response) { - int status = response.code(); - return Observable.just(status == 204); - } - }); + return mRestApi.updateReportExecution(executionId, params) + .flatMap(new Func1, Observable>() { + @Override + public Observable call(Response response) { + int status = response.code(); + return Observable.just(status == 204); + } + }) + .onErrorResumeNext(RestErrorAdapter.get()); + } @NonNull @@ -126,7 +135,8 @@ public Observable call(ReportExecutionSearchRespo } return Observable.just(response); } - }); + }) + .onErrorResumeNext(RestErrorAdapter.get()); } interface RestApi { @@ -149,13 +159,13 @@ interface RestApi { @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/parameters") Observable> updateReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body Collection params); + @NonNull @Body Collection params); @NonNull @Headers("Accept: application/json") @PUT("rest_v2/reportExecutions/{executionId}/status") Observable> cancelReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body ExecutionStatusResponse statusResponse); + @NonNull @Body ExecutionStatusResponse statusResponse); @Headers("Accept: application/json") @GET("rest_v2/reportExecutions") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index 415b83a2..bb5968d4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -64,7 +64,8 @@ public Observable runExportExecution(@Nullable St checkNotNull(executionId, "Execution id should not be null"); checkNotNull(executionOptions, "Execution options should not be null"); - return mRestApi.runReportExportExecution(executionId, executionOptions); + return mRestApi.runReportExportExecution(executionId, executionOptions) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @@ -73,7 +74,8 @@ public Observable checkExportExecutionStatus(@Nullable checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); - return mRestApi.checkReportExportStatus(executionId, exportId); + return mRestApi.checkReportExportStatus(executionId, exportId) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @@ -82,19 +84,21 @@ public Observable requestExportOutput(@Nullable String e checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); - return mRestApi.requestReportExportOutput(executionId, exportId).flatMap(new Func1, Observable>() { - @Override - public Observable call(Response rawResponse) { - com.squareup.okhttp.Headers headers = rawResponse.headers(); + return mRestApi.requestReportExportOutput(executionId, exportId) + .flatMap(new Func1, Observable>() { + @Override + public Observable call(Response rawResponse) { + com.squareup.okhttp.Headers headers = rawResponse.headers(); - RetrofitExportInput exportInput = new RetrofitExportInput(rawResponse.body()); - String pages = headers.get("report-pages"); - boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); + RetrofitExportInput exportInput = new RetrofitExportInput(rawResponse.body()); + String pages = headers.get("report-pages"); + boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); - ExportResourceResponse response = ExportResourceResponse.create(exportInput, pages, isFinal); - return Observable.just(response); - } - }); + ExportResourceResponse response = ExportResourceResponse.create(exportInput, pages, isFinal); + return Observable.just(response); + } + }) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @@ -109,10 +113,11 @@ public Observable requestExportAttachment(@Nullable String executio @Override public Observable call(Response rawResponse) { ResponseBody body = rawResponse.body(); - ExportInput response = new RetrofitExportInput(body); + ExportInput response = new RetrofitExportInput(body); return Observable.just(response); } - }); + }) + .onErrorResumeNext(RestErrorAdapter.get()); } private interface RestApi { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index d7845e9b..2bc0b0ce 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -35,6 +35,7 @@ import java.util.Map; +import retrofit.HttpException; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; @@ -61,58 +62,74 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NonNull @Override public Observable searchResources(@Nullable Map searchParams) { - return mRestApi.searchResources(searchParams).flatMap(new Func1, Observable>() { - @Override - public Observable call(Response rawResponse) { - int status = rawResponse.code(); - ResourceSearchResponse entity; - if (status == 204) { - entity = ResourceSearchResponse.empty(); - } else { - entity = rawResponse.body(); - com.squareup.okhttp.Headers headers = rawResponse.headers(); - - int resultCount = headerToInt(headers, "Result-Count"); - int totalCount = headerToInt(headers, "Total-Count"); - int startIndex = headerToInt(headers, "Start-Index"); - int nextOffset = headerToInt(headers, "Next-Offset"); - - entity.setResultCount(resultCount); - entity.setTotalCount(totalCount); - entity.setStartIndex(startIndex); - entity.setNextOffset(nextOffset); - } - return Observable.just(entity); - } - }); + return mRestApi.searchResources(searchParams) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + // If we user Response return type we need manually handle 500 errors + if (response.isSuccess()) { + return Observable.just(response); + } + return Observable.error(new HttpException(response)); + } + }) + .flatMap(new Func1, Observable>() { + @Override + public Observable call(Response rawResponse) { + int status = rawResponse.code(); + ResourceSearchResponse entity; + if (status == 204) { + entity = ResourceSearchResponse.empty(); + } else { + entity = rawResponse.body(); + com.squareup.okhttp.Headers headers = rawResponse.headers(); + + int resultCount = headerToInt(headers, "Result-Count"); + int totalCount = headerToInt(headers, "Total-Count"); + int startIndex = headerToInt(headers, "Start-Index"); + int nextOffset = headerToInt(headers, "Next-Offset"); + + entity.setResultCount(resultCount); + entity.setTotalCount(totalCount); + entity.setStartIndex(startIndex); + entity.setNextOffset(nextOffset); + } + return Observable.just(entity); + } + }) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestReportResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Report uri should not be null"); - return mRestApi.requestReportResource(resourceUri); + return mRestApi.requestReportResource(resourceUri) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestDashboardResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Dashboard uri should not be null"); - return mRestApi.requestDashboardResource(resourceUri); + return mRestApi.requestDashboardResource(resourceUri) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestLegacyDashboardResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Legacy dashboard uri should not be null"); - return mRestApi.requestLegacyDashboardResource(resourceUri); + return mRestApi.requestLegacyDashboardResource(resourceUri) + .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override public Observable requestFolderResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Folder uri should not be null"); - return mRestApi.requestFolderResource(resourceUri); + return mRestApi.requestFolderResource(resourceUri) + .onErrorResumeNext(RestErrorAdapter.get()); } private interface RestApi { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/ResultCallback.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java similarity index 52% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/ResultCallback.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java index 0692f156..873d9b84 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/ResultCallback.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java @@ -22,12 +22,32 @@ * . */ -package com.jaspersoft.android.sdk.network.operation; +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.exception.RestError; + +import retrofit.HttpException; +import rx.Observable; +import rx.functions.Func1; /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ -public interface ResultCallback { - void onResult(RESULT result); +final class RestErrorAdapter { + private RestErrorAdapter() {} + + public static Func1> get() { + return new Func1>() { + @Override + public Observable call(Throwable throwable) { + Class exceptionClass = throwable.getClass(); + if (HttpException.class.isAssignableFrom(exceptionClass)) { + HttpException httpException = (HttpException) throwable; + return Observable.error(RestError.httpError(httpException.response().raw())); + } + return Observable.error(RestError.unexpectedError(throwable)); + } + }; + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 92a03d8a..ff3d1031 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -50,7 +50,7 @@ public Builder(String baseUrl) { @Override ServerRestApi createApi() { - return getDefaultBuilder().build().create(ServerRestApi.class); + return new ServerRestApiImpl(getDefaultBuilder().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Status.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java similarity index 54% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Status.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java index 9601ead2..01f48372 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Status.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java @@ -22,30 +22,40 @@ * . */ -package com.jaspersoft.android.sdk.network.operation; +package com.jaspersoft.android.sdk.network.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; + +import retrofit.Retrofit; +import retrofit.http.GET; +import retrofit.http.Headers; +import rx.Observable; /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ -public final class Status { - public static Status SUCCESS = new Status(null); +final class ServerRestApiImpl implements ServerRestApi { - private final Throwable mThrowable; - - private Status(Throwable throwable) { - mThrowable = throwable; - } + private final RestApi mApi; - public static Status error(Throwable throwable) { - return new Status(throwable); + public ServerRestApiImpl(Retrofit retrofit) { + mApi = retrofit.create(RestApi.class); } - public static Status success() { - return SUCCESS; + @NonNull + @Override + public Observable requestServerInfo() { + return mApi.requestServerInfo() + .onErrorResumeNext(RestErrorAdapter.get()); } - public boolean isSuccess() { - return mThrowable == null; + private interface RestApi { + @NonNull + @Headers("Accept: application/json") + @GET(value = "rest_v2/serverInfo") + Observable requestServerInfo(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java index 2f1e47c4..28003469 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java @@ -24,35 +24,22 @@ package com.jaspersoft.android.sdk.network.entity.server; -import com.jaspersoft.android.sdk.network.operation.Result; -import com.jaspersoft.android.sdk.network.operation.Status; - /** * @author Tom Koptel * @since 2.0 */ -public final class AuthResponse implements Result { +public final class AuthResponse { private final String mToken; - private final Status mStatus; - private AuthResponse(Status status) { - mToken = null; - mStatus = status; - } private AuthResponse(String token) { mToken = token; - mStatus = Status.success(); } public static AuthResponse createSuccessResponse(String token) { return new AuthResponse(token); } - public static AuthResponse createFailResponse(Throwable throwable) { - return new AuthResponse(Status.error(throwable)); - } - public String getToken() { return mToken; } @@ -63,9 +50,4 @@ public String toString() { "mToken='" + mToken + '\'' + '}'; } - - @Override - public Status getStatus() { - return null; - } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java deleted file mode 100644 index 774392e4..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/ErrorHandler.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.jaspersoft.android.sdk.network.exception; - -/** - * TODO we need resolve error issues - * @author Tom Koptel - * @since 2.0 - */ -public interface ErrorHandler { -// ErrorHandler DEFAULT = new RetrofitErrorHandler(); - - Throwable handleError(ERROR cause); -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java index e0af343e..a8cf9083 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java @@ -30,34 +30,33 @@ import java.io.IOException; /** - * TODO we need resolve error issues + * Wrapper around exceptions which could pop up during request processing. + * Motivation behind class was to incapsulate 3-d party errors in generic interface. * * @author Tom Koptel * @since 2.0 */ public final class RestError extends RuntimeException { - public static RestError networkError(String url, IOException exception) { - return new RestError(exception.getMessage(), url, null, Kind.NETWORK, + public static RestError networkError(IOException exception) { + return new RestError(exception.getMessage(), null, Kind.NETWORK, exception); } - public static RestError httpError(String url, com.squareup.okhttp.Response response) { + public static RestError httpError(com.squareup.okhttp.Response response) { String message = response.code() + " " + response.message(); - return new RestError(message, url, response, Kind.HTTP, null); + return new RestError(message, response, Kind.HTTP, null); } - public static RestError unexpectedError(String url, Throwable exception) { - return new RestError(exception.getMessage(), url, null, Kind.UNEXPECTED, + public static RestError unexpectedError(Throwable exception) { + return new RestError(exception.getMessage(), null, Kind.UNEXPECTED, exception); } - private final String url; private final com.squareup.okhttp.Response response; private final Kind kind; - RestError(String message, String url, com.squareup.okhttp.Response response,Kind kind, Throwable exception) { + RestError(String message, com.squareup.okhttp.Response response,Kind kind, Throwable exception) { super(message, exception); - this.url = url; this.response = response; this.kind = kind; } @@ -77,18 +76,23 @@ public com.squareup.okhttp.Response response() { } public String urlString() { - return url; + return response.request().urlString(); } public Kind kind() { return kind; } + /** Identifies the event kind which triggered a {@link RestError}. */ public enum Kind { + /** An {@link IOException} occurred while communicating to the server. */ NETWORK, + /** A non-200 HTTP status code was received from the server. */ HTTP, - UNEXPECTED; - + /** + * An internal error occurred while attempting to execute a request. It is best practice to + * re-throw this exception so your application crashes. + */ + UNEXPECTED } - } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java deleted file mode 100644 index c48a200f..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RetrofitErrorHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.exception; - -/** - * TODO we need resolve error issues - * - * @author Tom Koptel - * @since 2.0 - */ -final class RetrofitErrorHandler { -// implements ErrorHandler { -// @Override -// public Throwable handleError(RetrofitError error) { -// switch (error.kind()) { -// case HTTP: -// return RestError.createHttpError(error); -// case NETWORK: -// return RestError.createNetworkError(error); -// case UNEXPECTED: -// return RestError.createUnexpectedError(error); -// default: -// throw error; -// } -// } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java deleted file mode 100644 index cc256739..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/PendingOperation.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.operation; - -/** - * @author Tom Koptel - * @since 2.2 - */ -public interface PendingOperation { - RESULT execute(); - void enqueue(ResultCallback callback); -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java deleted file mode 100644 index 9398d79f..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/operation/Result.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.operation; - -/** - * @author Tom Koptel - * @since 2.2 - */ -public interface Result { - Status getStatus(); -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java new file mode 100644 index 00000000..a805bdf2 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -0,0 +1,11 @@ +package com.jaspersoft.android.sdk.network.api; + +/** + * TODO implement tests + * + * @author Tom Koptel + * @since 2.2 + */ +public class InputControlRestApiTest { + +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index d075fc0c..c50f3767 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; +import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -88,7 +89,9 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.newInstance()); + Observable call = restApiUnderTest + .runExportExecution("any_id", ExecutionRequestOptions.newInstance()); + call.toBlocking().first(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index a2132c36..aeb4cdb0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -71,7 +71,8 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.searchResources(null); + Observable call = restApiUnderTest.searchResources(null); + call.toBlocking().first(); } @Test From 2104430550b570d320cef071d485238e31338f37 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 7 Sep 2015 16:32:24 +0300 Subject: [PATCH 093/457] Add explanation for custom Gson converter --- .../android/sdk/network/api/GsonConverterFactory.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java index 4be6f7fa..8a0e0ac9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import com.google.gson.Gson; +import com.google.gson.TypeAdapter; import com.squareup.okhttp.MediaType; import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.ResponseBody; @@ -40,6 +41,9 @@ import retrofit.Converter; /** + * Temporary workaround around {@link TypeAdapter} issue which causes null fields to be parsed. + * The issue submitted on following link + * * @author Tom Koptel * @since 2.0 */ From 8fcbc024be488ae7af06ff65f20f7798528da028 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 11:11:48 +0300 Subject: [PATCH 094/457] Add intial tests for InputControlRestApi --- .../network/api/InputControlRestApiImpl.java | 15 ++-- .../network/api/InputControlRestApiTest.java | 72 +++++++++++++++++++ .../android/sdk/test/MockResponseFactory.java | 51 +++++++++++++ 3 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 122e8c1c..fd297511 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.text.TextUtils; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; @@ -42,6 +43,8 @@ import retrofit.http.Query; import rx.Observable; +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; + /** * @author Tom Koptel * @since 2.2 @@ -55,14 +58,15 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override - public Observable requestInputControls(@NonNull String reportUri) { - return requestInputControls(reportUri, false) - .onErrorResumeNext(RestErrorAdapter.get()); + public Observable requestInputControls(@Nullable String reportUri) { + checkNotNull(reportUri, "Report URI should not be null"); + return requestInputControls(reportUri, false); } @NonNull @Override public Observable requestInputControls(@NonNull String reportUri, boolean excludeState) { + checkNotNull(reportUri, "Report URI should not be null"); return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null) .onErrorResumeNext(RestErrorAdapter.get()); } @@ -70,13 +74,14 @@ public Observable requestInputControls(@NonNull String rep @NonNull @Override public Observable requestInputControlsInitialStates(@NonNull String reportUri) { - return requestInputControlsInitialStates(reportUri, false) - .onErrorResumeNext(RestErrorAdapter.get()); + checkNotNull(reportUri, "Report URI should not be null"); + return requestInputControlsInitialStates(reportUri, false); } @NonNull @Override public Observable requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { + checkNotNull(reportUri, "Report URI should not be null"); return mRestApi.requestInputControlsInitialValues(reportUri, freshData) .onErrorResumeNext(RestErrorAdapter.get()); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index a805bdf2..c157fca9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -1,5 +1,17 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.exception.RestError; +import com.jaspersoft.android.sdk.test.MockResponseFactory; +import com.jaspersoft.android.sdk.test.WebMockRule; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import rx.Observable; + /** * TODO implement tests * @@ -8,4 +20,64 @@ */ public class InputControlRestApiTest { + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + + private InputControlRestApi restApiUnderTest; + + @Before + public void setup() { + restApiUnderTest = new InputControlRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { + mExpectedException.expect(IllegalArgumentException.class); + new InputControlRestApi.Builder(null, "cookie").build(); + } + + @Test + public void shouldThrowIllegalArgumentExceptionForNullCookie() { + mExpectedException.expect(IllegalArgumentException.class); + InputControlRestApi restApi = new InputControlRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); + } + + @Test + public void requestInputControlsShouldNotAllowNullReportUri1() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report URI should not be null"); + restApiUnderTest.requestInputControls(null); + } + + @Test + public void requestInputControlsShouldNotAllowNullReportUri2() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report URI should not be null"); + restApiUnderTest.requestInputControls(null, false); + } + + @Test + public void requestInputControlsInitialStatesShouldNotAllowNullReportUri1() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report URI should not be null"); + restApiUnderTest.requestInputControlsInitialStates(null); + } + + @Test + public void requestInputControlsInitialStatesShouldNotAllowNullReportUri2() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report URI should not be null"); + restApiUnderTest.requestInputControlsInitialStates(null, false); + } + + @Test + public void requestInputControlsShouldThrowRestError() { + mExpectedException.expect(RestError.class); + mWebMockRule.enqueue(MockResponseFactory.create500()); + Observable call = restApiUnderTest.requestInputControls("any_id"); + call.toBlocking().first(); + } + } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java new file mode 100644 index 00000000..2f512c37 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test; + +import com.squareup.okhttp.mockwebserver.MockResponse; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class MockResponseFactory { + + private MockResponseFactory() {} + + public static MockResponse create200() { + return new MockResponse() + .setStatus("HTTP/1.1 200 Ok"); + } + + public static MockResponse create204() { + return new MockResponse() + .setStatus("HTTP/1.1 204 No Content"); + } + + public static MockResponse create500() { + return new MockResponse() + .setStatus("HTTP/1.1 500 Internal Server Error"); + } +} From d58ef52d81c8c2ead56e4756f35d1b8ad916ea74 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 11:26:36 +0300 Subject: [PATCH 095/457] Simplifying API for requesting input control states --- client-network/build.gradle | 1 - .../sdk/network/api/InputControlRestApi.java | 5 +-- .../network/api/InputControlRestApiImpl.java | 25 ++++++----- .../network/api/InputControlRestApiTest.java | 18 +++++++- .../api/InputControlRestApiTest.java | 42 ++++++++++++++++--- 5 files changed, 68 insertions(+), 23 deletions(-) diff --git a/client-network/build.gradle b/client-network/build.gradle index e08bfcda..23ecb1e8 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -56,6 +56,5 @@ dependencies { testCompile 'org.robolectric:shadows-support-v4:3.0' testCompile 'org.robolectric:shadows-httpclient:3.0' testCompile 'com.squareup.okhttp:mockwebserver:2.4.0' - testCompile project(':js-android-sdk-client') compile 'com.squareup.okhttp:okhttp:2.4.0' } \ No newline at end of file diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index b4ebdcbe..b69377f7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -69,7 +69,6 @@ Observable requestInputControlsInitialStates(@NonNull */ @NonNull Observable requestInputControlsStates(@NonNull String reportUri, - @NonNull Set controlsId, @NonNull Map> controlsValues); /** @@ -77,14 +76,12 @@ Observable requestInputControlsStates(@NonNull String * delegate cascading resolving for the server, also should handle non-cascading cases * * @param reportUri uri of report - * @param controlsId collection of controls ids - * @param controlsValues collection of associated parameters client has provided + * @param controlsValues map of {control_id: [value, value]} associated input controls metadata * @param freshData whether data should be retrieved from cache or not * @return unmodifiable list of {@link InputControlState} */ @NonNull Observable requestInputControlsStates(@NonNull String reportUri, - @NonNull Set controlsId, @NonNull Map> controlsValues, boolean freshData); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index fd297511..c2339bda 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -65,7 +65,7 @@ public Observable requestInputControls(@Nullable String re @NonNull @Override - public Observable requestInputControls(@NonNull String reportUri, boolean excludeState) { + public Observable requestInputControls(@Nullable String reportUri, boolean excludeState) { checkNotNull(reportUri, "Report URI should not be null"); return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null) .onErrorResumeNext(RestErrorAdapter.get()); @@ -73,14 +73,14 @@ public Observable requestInputControls(@NonNull String rep @NonNull @Override - public Observable requestInputControlsInitialStates(@NonNull String reportUri) { + public Observable requestInputControlsInitialStates(@Nullable String reportUri) { checkNotNull(reportUri, "Report URI should not be null"); return requestInputControlsInitialStates(reportUri, false); } @NonNull @Override - public Observable requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData) { + public Observable requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); return mRestApi.requestInputControlsInitialValues(reportUri, freshData) .onErrorResumeNext(RestErrorAdapter.get()); @@ -88,20 +88,23 @@ public Observable requestInputControlsInitialStates(@ @NonNull @Override - public Observable requestInputControlsStates(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues) { - return requestInputControlsStates(reportUri, controlsId, controlsValues, false) + public Observable requestInputControlsStates(@Nullable String reportUri, + @Nullable Map> controlsValues) { + checkNotNull(reportUri, "Report URI should not be null"); + checkNotNull(controlsValues, "Controls values should not be null"); + return requestInputControlsStates(reportUri, controlsValues, false) .onErrorResumeNext(RestErrorAdapter.get()); } @NonNull @Override - public Observable requestInputControlsStates(@NonNull String reportUri, - @NonNull Set controlsId, - @NonNull Map> controlsValues, + public Observable requestInputControlsStates(@Nullable String reportUri, + @Nullable Map> controlsValues, boolean freshData) { - String ids = TextUtils.join(";", controlsId); + checkNotNull(reportUri, "Report URI should not be null"); + checkNotNull(controlsValues, "Controls values should not be null"); + + String ids = TextUtils.join(";", controlsValues.keySet()); return mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData) .onErrorResumeNext(RestErrorAdapter.get()); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index c157fca9..35f376d3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -10,11 +10,11 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import java.util.Collections; + import rx.Observable; /** - * TODO implement tests - * * @author Tom Koptel * @since 2.2 */ @@ -72,6 +72,20 @@ public void requestInputControlsInitialStatesShouldNotAllowNullReportUri2() { restApiUnderTest.requestInputControlsInitialStates(null, false); } + @Test + public void requestInputControlsStatesShouldNotAllowNullReportUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report URI should not be null"); + restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP); + } + + @Test + public void requestInputControlsStatesShouldNotAllowNullControlParams() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Controls values should not be null"); + restApiUnderTest.requestInputControlsStates("any_id", null); + } + @Test public void requestInputControlsShouldThrowRestError() { mExpectedException.expect(RestError.class); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 9ee90787..6459738f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -34,9 +34,16 @@ import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; +import org.robolectric.shadows.httpclient.FakeHttp; -import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; import rx.Observable; @@ -51,14 +58,25 @@ * @author Tom Koptel * @since 2.0 */ +@RunWith(RobolectricTestRunner.class) +@Config(manifest = Config.NONE) public class InputControlRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); private InputControlRestApi mRestApi; + public static final Map> CONTROL_PARAMETERS = new HashMap<>(); + + static { + Set values = new HashSet<>(); + values.add("19"); + CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); + } @Before public void setup() { + FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); + mAuthenticator.authorize(); String cookie = mAuthenticator.getCookie(); mRestApi = new InputControlRestApi.Builder(mMetadata.getServerUrl(), cookie) @@ -67,7 +85,7 @@ public void setup() { } @Test - public void shouldProvideInputControlsList() throws IOException { + public void shouldProvideInputControlsList() { Observable call = mRestApi.requestInputControls(REPORT_URI); List controls = call.toBlocking().first().getValues(); @@ -81,7 +99,7 @@ public void shouldProvideInputControlsList() throws IOException { * TODO: Implement annotation to mark specific API tests. */ @Test - public void shouldProvideInputControlsListIfStateExcluded() throws IOException { + public void shouldProvideInputControlsListIfStateExcluded() { Observable call = mRestApi.requestInputControls(REPORT_URI, true); List controls = call.toBlocking().first().getValues(); @@ -92,16 +110,30 @@ public void shouldProvideInputControlsListIfStateExcluded() throws IOException { } @Test - public void shouldProvideInitialInputControlsValues() throws IOException { + public void shouldProvideInitialInputControlsValues() { Observable call = mRestApi.requestInputControlsInitialStates(REPORT_URI); InputControlValueResponse response = call.toBlocking().first(); assertThat(response.getValues(), is(not(empty()))); } @Test - public void shouldProvideFreshInitialInputControlsValues() throws IOException { + public void shouldProvideFreshInitialInputControlsValues() { Observable call = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); InputControlValueResponse response = call.toBlocking().first(); assertThat(response.getValues(), is(not(empty()))); } + + @Test + public void shouldProvideStatesForInputControls() { + Observable call = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS); + InputControlValueResponse response = call.toBlocking().first(); + assertThat(response.getValues(), is(not(empty()))); + } + + @Test + public void shouldProvideFreshStatesForInputControls() { + Observable call = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); + InputControlValueResponse response = call.toBlocking().first(); + assertThat(response.getValues(), is(not(empty()))); + } } From fa1b103ee8e68d66c7bd10e23c4f7548da88321c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 11:40:09 +0300 Subject: [PATCH 096/457] Upgrading okhttp version 2.4.0 -> 2.5.0 --- client-network/build.gradle | 5 ++--- .../java/com/jaspersoft/android/sdk/test/WebMockRule.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/client-network/build.gradle b/client-network/build.gradle index 23ecb1e8..b2e4425e 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -39,7 +39,7 @@ dependencies { compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' - compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' + compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' @@ -55,6 +55,5 @@ dependencies { testCompile 'org.powermock:powermock-module-junit4:1.6.2' testCompile 'org.robolectric:shadows-support-v4:3.0' testCompile 'org.robolectric:shadows-httpclient:3.0' - testCompile 'com.squareup.okhttp:mockwebserver:2.4.0' - compile 'com.squareup.okhttp:okhttp:2.4.0' + testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java index 90d3e744..2654a04c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java @@ -76,7 +76,7 @@ public MockWebServer get() { } public String getRootUrl() { - return server.getUrl("/").toExternalForm(); + return server.url("/").url().toExternalForm(); } public void enqueue(MockResponse mockResponse) { From 3e73afdead46c18a25d78232d83e230f3026ae48 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 11:40:32 +0300 Subject: [PATCH 097/457] Fixing broken integration tests --- .../network/api/AuthenticationRestApi.java | 12 +++- .../api/AuthenticationRestApiImpl.java | 9 +-- .../api/AuthenticationRestApiTest.java | 6 +- .../api/ReportExecutionRestApiTest.java | 63 +++++++++---------- .../test/integration/api/ServerRestTest.java | 2 +- 5 files changed, 50 insertions(+), 42 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index 2b27898f..bf1cf6c7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -28,6 +28,7 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.squareup.okhttp.OkHttpClient; import java.util.Map; @@ -46,14 +47,23 @@ Observable authenticate(@NonNull String username, final class Builder { private final String mBaseUrl; + private RestApiLog mLog = RestApiLog.NONE; public Builder(String baseUrl) { Utils.checkNotNull(baseUrl, "Base url should not be null"); mBaseUrl = baseUrl; } + public Builder setLog(RestApiLog log) { + mLog = log; + return this; + } + public AuthenticationRestApi build() { - return new AuthenticationRestApiImpl(mBaseUrl); + OkHttpClient okHttpClient = new OkHttpClient(); + okHttpClient.setFollowRedirects(false); + okHttpClient.interceptors().add(new LoggingInterceptor(mLog)); + return new AuthenticationRestApiImpl(mBaseUrl, okHttpClient); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 2e8872ab..f80b6297 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -47,9 +47,11 @@ */ final class AuthenticationRestApiImpl implements AuthenticationRestApi { private final String mBaseUrl; + private final OkHttpClient mClient; - AuthenticationRestApiImpl(String baseUrl) { + AuthenticationRestApiImpl(String baseUrl, OkHttpClient okHttpClient) { mBaseUrl = baseUrl; + mClient = okHttpClient; } @NonNull @@ -61,10 +63,9 @@ public Observable authenticate(@NonNull final String username, return Observable.defer(new Func0>() { @Override public Observable call() { - OkHttpClient okHttpClient = new OkHttpClient(); - okHttpClient.setFollowRedirects(false); + Request request = createAuthRequest(username, password, organization, params); - Call call = okHttpClient.newCall(request); + Call call = mClient.newCall(request); try { com.squareup.okhttp.Response response = call.execute(); int statusCode = response.code(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 76530290..6338a9c5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; import org.junit.Test; @@ -44,7 +45,7 @@ * @since 2.0 */ public class AuthenticationRestApiTest { - String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; @Before public void setup() { @@ -54,8 +55,7 @@ public void setup() { @Test public void shouldReturnResponseForSpringRequest() throws IOException { AuthenticationRestApi authApi = new AuthenticationRestApi.Builder(mobileDemo2) -// .setLog(TestLogger.get(this)) -// .setLogLevel(RestApiLogLevel.FULL) + .setLog(TestLogger.get(this)) .build(); Observable response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); assertThat(response.toBlocking().first().getToken(), is(notNullValue())); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index e93554dc..71fdfba1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -26,15 +26,16 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -57,11 +58,25 @@ */ public class ReportExecutionRestApiTest { - private final String MOBILE_DEMO2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; private final String REPORT_URI1 = "/public/Samples/Reports/AllAccounts"; private final String REPORT_URI2 = "/public/Samples/Reports/ProfitDetailReport"; - AuthResponse mAuthResponse; - ReportExecutionRestApi mApi; + + ReportExecutionRestApi apiUnderTest; + + private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); + private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + + @Before + public void setup() { + mAuthenticator.authorize(); + String cookie = mAuthenticator.getCookie(); + + if (apiUnderTest == null) { + apiUnderTest = new ReportExecutionRestApi.Builder(mMetadata.getServerUrl(), cookie) + .setLog(TestLogger.get(this)) + .build(); + } + } @Test public void shouldStartReportExecution() { @@ -75,30 +90,27 @@ public void shouldStartReportExecution() { */ @Ignore public void shouldCancelReportExecution() throws InterruptedException { - ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse response = startExecution(); - Observable call = api.cancelReportExecution(response.getExecutionId()); + Observable call = apiUnderTest.cancelReportExecution(response.getExecutionId()); boolean cancelled = call.toBlocking().first(); assertThat(cancelled, is(true)); } @Test public void shouldReturnReportExecutionDetails() throws IOException { - ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - Observable call = api.requestReportExecutionDetails(executionResponse.getExecutionId()); + Observable call = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId()); ReportExecutionDetailsResponse response = call.toBlocking().first(); assertThat(response.getExecutionId(), is(executionId)); } @Test public void shouldCheckReportExecutionStatus() throws IOException { - ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); - Observable call = api.requestReportExecutionStatus(executionResponse.getExecutionId()); + Observable call = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId()); ExecutionStatusResponse response = call.toBlocking().first(); assertThat(response.getStatus(), is(notNullValue())); } @@ -108,27 +120,29 @@ public void shouldCheckReportExecutionStatus() throws IOException { */ @Ignore public void searchForExecutionShouldReturnResult() throws IOException { - ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); - Observable call = api.searchReportExecution(params); + Observable call = apiUnderTest.searchReportExecution(params); ReportExecutionSearchResponse response = call.toBlocking().first(); assertThat(response.getItems(), is(not(empty()))); } @Test public void updateOfParametersForExecutionShouldReturnResult() { - ReportExecutionRestApi api = getApi(); ReportExecutionDetailsResponse executionResponse = startExecution(); - Observable call = api.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); + Observable call = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); boolean success = call.toBlocking().first(); assertThat(success, is(true)); } + /** + * Helper methods + */ + @NonNull private ReportExecutionDetailsResponse startExecution() { return startExecution(REPORT_URI1); @@ -137,25 +151,8 @@ private ReportExecutionDetailsResponse startExecution() { @NonNull private ReportExecutionDetailsResponse startExecution(String uri) { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); - Observable call = getApi().runReportExecution(executionRequestOptions); + Observable call = apiUnderTest.runReportExecution(executionRequestOptions); return call.toBlocking().first(); } - private ReportExecutionRestApi getApi() { - if (mApi == null) { - mApi = new ReportExecutionRestApi.Builder(MOBILE_DEMO2, getAuthResponse().getToken()) - .setLog(TestLogger.get(this)) - .build(); - } - return mApi; - } - - private AuthResponse getAuthResponse() { - if (mAuthResponse == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(MOBILE_DEMO2).build(); - mAuthResponse = restApi.authenticate("joeuser", "joeuser", "organization_1", null) - .toBlocking().first(); - } - return mAuthResponse; - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index cb48ef15..1e0da74d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -45,7 +45,7 @@ */ public class ServerRestTest { - String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro"; + String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; @Test public void shouldRequestServerInfo() throws IOException { From 9dfd11b743224e948ed8a8efd18b6963edfa60fc Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 11:42:09 +0300 Subject: [PATCH 098/457] Add TODO for AuthenticationRestApi implementation --- .../android/sdk/network/api/AuthenticationRestApiImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index f80b6297..c2d55f6d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -42,6 +42,8 @@ import rx.functions.Func0; /** + * TODO refactor following module in easy testable units + * * @author Tom Koptel * @since 2.0 */ From 3bd50b68bcb537a05d73976d2da7cbb51dad3753 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 11:51:45 +0300 Subject: [PATCH 099/457] Add baseUrl normalize precondition --- .../android/sdk/network/api/BaseBuilder.java | 17 ++----- .../android/sdk/network/api/Utils.java | 9 +++- .../android/sdk/network/api/UtilsTest.java | 44 +++++++++++++++++++ 3 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index b59b9ada..77a112d5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -32,6 +32,8 @@ import retrofit.RxJavaCallAdapterFactory; /** + * TODO separate OkHttp client creation from Retrofit client + * * @author Tom Koptel * @since 2.0 */ @@ -49,22 +51,11 @@ public BaseBuilder(String baseUrl){ mRestAdapterBuilder = new Retrofit.Builder(); mRestAdapterBuilder.client(mOkHttpClient); - mRestAdapterBuilder.baseUrl(baseUrl); + mRestAdapterBuilder.baseUrl(Utils.normalizeBaseUrl(baseUrl)); Gson configuredGson = GsonFactory.create(); mRestAdapterBuilder.addConverterFactory(GsonConverterFactory.create(configuredGson)); mRestAdapterBuilder.addCallAdapterFactory(RxJavaCallAdapterFactory.create()); - - /* - TODO: Resolve error handling. It is still not clear what API will look like - */ -// mRestAdapterBuilder.setErrorHandler(new retrofit.ErrorHandler() { -// @Override -// @SuppressWarnings("unchecked") -// public Throwable handleError(RetrofitError cause) { -// return ErrorHandler.DEFAULT.handleError(cause); -// } -// }); } @SuppressWarnings("unchecked") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java index 8d95940b..674952af 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -52,4 +52,11 @@ static int headerToInt(com.squareup.okhttp.Headers headers, String key) { } private Utils() {} + + public static String normalizeBaseUrl(String baseUrl) { + if (baseUrl.endsWith("/")) { + return baseUrl; + } + return baseUrl + "/"; + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java new file mode 100644 index 00000000..2df2e6c2 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class UtilsTest { + + @Test + public void normalizeBaseUrlShouldAddTrailingSlashIfMissing() { + String url = "http://some.http"; + assertThat(Utils.normalizeBaseUrl(url), is(url + "/")); + } + +} From 0b5db25c1238b74886c4321fa4faa6539f6f539b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 12:21:35 +0300 Subject: [PATCH 100/457] Flatten InputControlsRestApi --- .../sdk/network/api/InputControlRestApi.java | 13 ---------- .../network/api/InputControlRestApiImpl.java | 24 ------------------- .../network/api/InputControlRestApiTest.java | 22 ++++------------- .../api/InputControlRestApiTest.java | 16 +------------ 4 files changed, 5 insertions(+), 70 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index b69377f7..df98cf5f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -42,9 +42,6 @@ */ public interface InputControlRestApi { - @NonNull - Observable requestInputControls(@NonNull String reportUri); - /** * Returns input controls for associated response. Options can be excluded by additional argument. * @@ -57,20 +54,10 @@ public interface InputControlRestApi { @NonNull Observable requestInputControls(@NonNull String reportUri, boolean excludeState); - @NonNull - Observable requestInputControlsInitialStates(@NonNull String reportUri); - @NonNull Observable requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData); - /** - * TODO: 1. consider to flatten controls id parameter. - */ - @NonNull - Observable requestInputControlsStates(@NonNull String reportUri, - @NonNull Map> controlsValues); - /** * Provides values for specified controls. This API helpful to * delegate cascading resolving for the server, also should handle non-cascading cases diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index c2339bda..e0b3f00d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -56,13 +56,6 @@ final class InputControlRestApiImpl implements InputControlRestApi { mRestApi = restAdapter.create(RestApi.class); } - @NonNull - @Override - public Observable requestInputControls(@Nullable String reportUri) { - checkNotNull(reportUri, "Report URI should not be null"); - return requestInputControls(reportUri, false); - } - @NonNull @Override public Observable requestInputControls(@Nullable String reportUri, boolean excludeState) { @@ -71,13 +64,6 @@ public Observable requestInputControls(@Nullable String re .onErrorResumeNext(RestErrorAdapter.get()); } - @NonNull - @Override - public Observable requestInputControlsInitialStates(@Nullable String reportUri) { - checkNotNull(reportUri, "Report URI should not be null"); - return requestInputControlsInitialStates(reportUri, false); - } - @NonNull @Override public Observable requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { @@ -86,16 +72,6 @@ public Observable requestInputControlsInitialStates(@ .onErrorResumeNext(RestErrorAdapter.get()); } - @NonNull - @Override - public Observable requestInputControlsStates(@Nullable String reportUri, - @Nullable Map> controlsValues) { - checkNotNull(reportUri, "Report URI should not be null"); - checkNotNull(controlsValues, "Controls values should not be null"); - return requestInputControlsStates(reportUri, controlsValues, false) - .onErrorResumeNext(RestErrorAdapter.get()); - } - @NonNull @Override public Observable requestInputControlsStates(@Nullable String reportUri, diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index 35f376d3..947cd024 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -45,26 +45,12 @@ public void shouldThrowIllegalArgumentExceptionForNullCookie() { } @Test - public void requestInputControlsShouldNotAllowNullReportUri1() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControls(null); - } - - @Test - public void requestInputControlsShouldNotAllowNullReportUri2() { + public void requestInputControlsShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); restApiUnderTest.requestInputControls(null, false); } - @Test - public void requestInputControlsInitialStatesShouldNotAllowNullReportUri1() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsInitialStates(null); - } - @Test public void requestInputControlsInitialStatesShouldNotAllowNullReportUri2() { mExpectedException.expect(NullPointerException.class); @@ -76,21 +62,21 @@ public void requestInputControlsInitialStatesShouldNotAllowNullReportUri2() { public void requestInputControlsStatesShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP); + restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP, true); } @Test public void requestInputControlsStatesShouldNotAllowNullControlParams() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.requestInputControlsStates("any_id", null); + restApiUnderTest.requestInputControlsStates("any_id", null, true); } @Test public void requestInputControlsShouldThrowRestError() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - Observable call = restApiUnderTest.requestInputControls("any_id"); + Observable call = restApiUnderTest.requestInputControls("any_id", true); call.toBlocking().first(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 6459738f..c392104f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -86,7 +86,7 @@ public void setup() { @Test public void shouldProvideInputControlsList() { - Observable call = mRestApi.requestInputControls(REPORT_URI); + Observable call = mRestApi.requestInputControls(REPORT_URI, false); List controls = call.toBlocking().first().getValues(); assertThat(controls, is(not(empty()))); @@ -109,13 +109,6 @@ public void shouldProvideInputControlsListIfStateExcluded() { assertThat(control.getState(), is(nullValue())); } - @Test - public void shouldProvideInitialInputControlsValues() { - Observable call = mRestApi.requestInputControlsInitialStates(REPORT_URI); - InputControlValueResponse response = call.toBlocking().first(); - assertThat(response.getValues(), is(not(empty()))); - } - @Test public void shouldProvideFreshInitialInputControlsValues() { Observable call = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); @@ -123,13 +116,6 @@ public void shouldProvideFreshInitialInputControlsValues() { assertThat(response.getValues(), is(not(empty()))); } - @Test - public void shouldProvideStatesForInputControls() { - Observable call = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS); - InputControlValueResponse response = call.toBlocking().first(); - assertThat(response.getValues(), is(not(empty()))); - } - @Test public void shouldProvideFreshStatesForInputControls() { Observable call = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); From 700fe4b209c76fee797ee03d87f359bd58802405 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 12:22:44 +0300 Subject: [PATCH 101/457] Update 'metadata' --- .../android/sdk/network/api/InputControlRestApiImpl.java | 2 +- .../jaspersoft/android/sdk/network/api/LoggingInterceptor.java | 2 +- .../main/java/com/jaspersoft/android/sdk/network/api/Utils.java | 2 +- .../android/sdk/network/api/InputControlRestApiTest.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index e0b3f00d..22038709 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -47,7 +47,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ final class InputControlRestApiImpl implements InputControlRestApi { private final RestApi mRestApi; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index b9796abe..16df2c3a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -34,7 +34,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ final class LoggingInterceptor implements Interceptor { private final RestApiLog logger; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java index 674952af..f80014e5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java @@ -26,7 +26,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ final class Utils { static T checkNotNull(T object, String message) { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index 947cd024..fd8d3c15 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -16,7 +16,7 @@ /** * @author Tom Koptel - * @since 2.2 + * @since 2.0 */ public class InputControlRestApiTest { From 8490669b1906054d2091aaafcca6efcf1b261e88 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 13:00:18 +0300 Subject: [PATCH 102/457] Add initial implementation for ReportOptions API --- .../sdk/network/api/ReportOptionRestApi.java | 70 +++++++++ .../network/api/ReportOptionRestApiImpl.java | 144 ++++++++++++++++++ .../entity/report/option/ReportOption.java | 89 +++++++++++ .../report/option/ReportOptionResponse.java | 49 ++++++ .../option/ReportOptionResponseTest.java | 29 ++++ .../report/option/ReportOptionTest.java | 34 +++++ 6 files changed, 415 insertions(+) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponseTest.java create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java new file mode 100644 index 00000000..465da0af --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -0,0 +1,70 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; + +import java.util.Map; +import java.util.Set; + +import rx.Observable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ReportOptionRestApi { + + @NonNull + Observable requestReportOptionsList(@NonNull String reportUnitUri); + + @NonNull + Observable createReportOption(@NonNull String optionLabel, + @NonNull Map> controlsValues, + boolean overwrite); + + @NonNull + Observable updateReportOption(@NonNull String reportUnitUri, + @NonNull String optionId, + @NonNull Map> controlsValues); + + @NonNull + Observable deleteReportOption(@NonNull String reportUnitUri, + @NonNull String optionId); + + final class Builder extends AuthBaseBuilder { + public Builder(String baseUrl, String cookie) { + super(baseUrl, cookie); + } + + @Override + ReportOptionRestApi createApi() { + return new ReportOptionRestApiImpl(getDefaultBuilder().build()); + } + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java new file mode 100644 index 00000000..1a1b7c5f --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -0,0 +1,144 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; +import com.squareup.okhttp.Response; + +import java.util.Map; +import java.util.Set; + +import retrofit.Retrofit; +import retrofit.http.Body; +import retrofit.http.DELETE; +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.POST; +import retrofit.http.Path; +import retrofit.http.Query; +import rx.Observable; +import rx.functions.Func1; + +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportOptionRestApiImpl implements ReportOptionRestApi { + private final RestApi mRestApi; + + private static final Func1> VOID_MAP_LAMBDA = new Func1>() { + @Override + public Observable call(Response response) { + return Observable.empty(); + } + }; + + ReportOptionRestApiImpl(Retrofit retrofit) { + mRestApi = retrofit.create(RestApi.class); + } + + @NonNull + @Override + public Observable requestReportOptionsList(@Nullable String reportUnitUri) { + checkNotNull(reportUnitUri, "Report uri should not be null"); + + return mRestApi.requestReportOptionsList(reportUnitUri) + .onErrorResumeNext(RestErrorAdapter.get()); + } + + @NonNull + @Override + public Observable createReportOption(@Nullable String optionLabel, + @Nullable Map> controlsValues, + boolean overwrite) { + checkNotNull(optionLabel, "Option label should not be null"); + checkNotNull(controlsValues, "Controls values should not be null"); + + return mRestApi.createReportOption(optionLabel, controlsValues, overwrite) + .onErrorResumeNext(RestErrorAdapter.get()); + } + + @NonNull + @Override + public Observable updateReportOption(@Nullable String reportUnitUri, + @Nullable String optionId, + @Nullable Map> controlsValues) { + checkNotNull(reportUnitUri, "Report uri should not be null"); + checkNotNull(optionId, "Option id should not be null"); + checkNotNull(controlsValues, "Controls values should not be null"); + + return mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues) + .flatMap(VOID_MAP_LAMBDA) + .onErrorResumeNext(RestErrorAdapter.get()); + } + + @NonNull + @Override + public Observable deleteReportOption(@Nullable String reportUnitUri, + @Nullable String optionId) { + checkNotNull(reportUnitUri, "Report uri should not be null"); + checkNotNull(optionId, "Option id should not be null"); + + return mRestApi.deleteReportOption(reportUnitUri, optionId) + .flatMap(VOID_MAP_LAMBDA) + .onErrorResumeNext(RestErrorAdapter.get()); + } + + private interface RestApi { + @NonNull + @Headers("Accept: application/json") + @GET("rest_v2/reports{reportUnitURI}/options") + Observable requestReportOptionsList( + @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); + + @NonNull + @Headers("Accept: application/json") + @POST("rest_v2/reports{reportUnitURI}/options") + Observable createReportOption(@NonNull @Query("label") String optionLabel, + @NonNull @Body Map> controlsValues, + @Query("overwrite") boolean overwrite); + + @NonNull + @Headers("Accept: application/json") + @POST("rest_v2/reports{reportUnitURI}/options/{optionId}") + Observable updateReportOption( + @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, + @NonNull @Path(value = "optionId", encoded = true) String optionId, + @NonNull @Body Map> controlsValues); + + @NonNull + @Headers("Accept: application/json") + @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") + Observable deleteReportOption( + @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, + @NonNull @Path(value = "optionId", encoded = true) String optionId); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java new file mode 100644 index 00000000..18d99619 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java @@ -0,0 +1,89 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.report.option; + +import android.support.annotation.NonNull; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportOption { + + @Expose + private String uri; + @Expose + private String id; + @Expose + private String label; + + @NonNull + public String getId() { + return id; + } + + @NonNull + public String getLabel() { + return label; + } + + @NonNull + public String getUri() { + return uri; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ReportOption that = (ReportOption) o; + + if (!uri.equals(that.uri)) return false; + if (!id.equals(that.id)) return false; + return label.equals(that.label); + + } + + @Override + public int hashCode() { + int result = uri.hashCode(); + result = 31 * result + id.hashCode(); + result = 31 * result + label.hashCode(); + return result; + } + + @Override + public String toString() { + return "ReportOption{" + + "id='" + id + '\'' + + ", uri='" + uri + '\'' + + ", label='" + label + '\'' + + '}'; + } +} + diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java new file mode 100644 index 00000000..2790f924 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java @@ -0,0 +1,49 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.report.option; + +import android.support.annotation.NonNull; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportOptionResponse { + + @Expose + @SerializedName("reportOptionsSummary") + private Set mOptions = Collections.emptySet(); + + @NonNull + public Set getOptions() { + return mOptions; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponseTest.java new file mode 100644 index 00000000..2561984c --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponseTest.java @@ -0,0 +1,29 @@ +package com.jaspersoft.android.sdk.network.entity.report.option; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportOptionResponseTest { + @Test + public void shouldHaveExposeAnnotationForFieldOptions() throws NoSuchFieldException { + Field field = ReportOptionResponse.class.getDeclaredField("mOptions"); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void optionsFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ReportOptionResponse.class.getDeclaredField("mOptions"); + assertThat(field, hasSerializedName("reportOptionsSummary")); + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java new file mode 100644 index 00000000..0dd338b5 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java @@ -0,0 +1,34 @@ +package com.jaspersoft.android.sdk.network.entity.report.option; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ReportOptionTest { + + @Test + @Parameters({ + "uri", + "id", + "label", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportOption.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + +} \ No newline at end of file From 1fd41994377793fe49d3552ed210409ee4d273ac Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 13:13:36 +0300 Subject: [PATCH 103/457] Implementing ReportOptionsRestApi unit test --- .../sdk/network/api/ReportOptionRestApi.java | 3 +- .../network/api/ReportOptionRestApiImpl.java | 20 ++- .../network/api/ReportOptionRestApiTest.java | 152 ++++++++++++++++++ 3 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 465da0af..3bf3db43 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -44,7 +44,8 @@ public interface ReportOptionRestApi { Observable requestReportOptionsList(@NonNull String reportUnitUri); @NonNull - Observable createReportOption(@NonNull String optionLabel, + Observable createReportOption(@NonNull String reportUnitUri, + @NonNull String optionLabel, @NonNull Map> controlsValues, boolean overwrite); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java index 1a1b7c5f..86cea586 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -76,13 +76,15 @@ public Observable requestReportOptionsList(@Nullable Strin @NonNull @Override - public Observable createReportOption(@Nullable String optionLabel, + public Observable createReportOption(@Nullable String reportUnitUri, + @Nullable String optionLabel, @Nullable Map> controlsValues, boolean overwrite) { + checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionLabel, "Option label should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); - return mRestApi.createReportOption(optionLabel, controlsValues, overwrite) + return mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite) .onErrorResumeNext(RestErrorAdapter.get()); } @@ -115,22 +117,24 @@ public Observable deleteReportOption(@Nullable String reportUnitUri, private interface RestApi { @NonNull @Headers("Accept: application/json") - @GET("rest_v2/reports{reportUnitURI}/options") + @GET("rest_v2/reports{reportUnitUri}/options") Observable requestReportOptionsList( @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); @NonNull @Headers("Accept: application/json") @POST("rest_v2/reports{reportUnitURI}/options") - Observable createReportOption(@NonNull @Query("label") String optionLabel, - @NonNull @Body Map> controlsValues, - @Query("overwrite") boolean overwrite); + Observable createReportOption( + @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, + @NonNull @Query("label") String optionLabel, + @NonNull @Body Map> controlsValues, + @Query("overwrite") boolean overwrite); @NonNull @Headers("Accept: application/json") @POST("rest_v2/reports{reportUnitURI}/options/{optionId}") Observable updateReportOption( - @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, + @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Path(value = "optionId", encoded = true) String optionId, @NonNull @Body Map> controlsValues); @@ -138,7 +142,7 @@ Observable updateReportOption( @Headers("Accept: application/json") @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") Observable deleteReportOption( - @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, + @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Path(value = "optionId", encoded = true) String optionId); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java new file mode 100644 index 00000000..1cf9908c --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -0,0 +1,152 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; +import com.jaspersoft.android.sdk.network.exception.RestError; +import com.jaspersoft.android.sdk.test.MockResponseFactory; +import com.jaspersoft.android.sdk.test.WebMockRule; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Collections; + +import rx.Observable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@SuppressWarnings("unchecked") +public class ReportOptionRestApiTest { + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + @Rule + public final ExpectedException mExpectedException = ExpectedException.none(); + + private ReportOptionRestApi restApiUnderTest; + + @Before + public void setup() { + restApiUnderTest = new ReportOptionRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + } + + @Test + public void requestReportOptionsListShouldNotAllowNullReportUnitUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report uri should not be null"); + restApiUnderTest.requestReportOptionsList(null); + } + + @Test + public void requestReportOptionsListShouldThrow500Error() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + Observable call = restApiUnderTest.requestReportOptionsList("any_id"); + call.toBlocking().first(); + } + + @Test + public void updateReportOptionShouldThrowRestErrorFor500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + Observable call = restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP); + call.toBlocking().first(); + } + + @Test + public void deleteReportOptionShouldThrowRestErrorFor500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + Observable call = restApiUnderTest.deleteReportOption("any_id", "option_id"); + call.toBlocking().first(); + } + + @Test + public void createReportOptionShouldNotAllowNullReportUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report uri should not be null"); + restApiUnderTest.createReportOption(null, "label", Collections.EMPTY_MAP, false); + } + + + @Test + public void createReportOptionShouldNotAllowNullOptionLabel() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Option label should not be null"); + restApiUnderTest.createReportOption("any_id", null, Collections.EMPTY_MAP, false); + } + + @Test + public void createReportOptionShouldNotAllowNullControlsValues() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Controls values should not be null"); + restApiUnderTest.createReportOption("any_id", "label", null, false); + } + + @Test + public void updateReportOptionShouldNotAllowNullReportUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report uri should not be null"); + restApiUnderTest.updateReportOption(null, "option_id", Collections.EMPTY_MAP); + } + + @Test + public void updateReportOptionShouldNotAllowNullOptionId() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Option id should not be null"); + restApiUnderTest.updateReportOption("any_id", null, Collections.EMPTY_MAP); + } + + @Test + public void updateReportOptionShouldNotAllowNullControlsValues() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Controls values should not be null"); + restApiUnderTest.updateReportOption("any_id", "option_id", null); + } + + @Test + public void deleteReportOptionShouldNotAllowNullReportUri() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report uri should not be null"); + restApiUnderTest.deleteReportOption(null, "option_id"); + } + + @Test + public void deleteReportOptionShouldNotAllowNullOptionId() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Option id should not be null"); + restApiUnderTest.deleteReportOption("any_id", null); + } +} From 728686e02f4c2c386cf9d74d2a933ff3e5b2f3c4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 8 Sep 2015 13:42:26 +0300 Subject: [PATCH 104/457] Add integration tests for ReportOptions API --- .../network/api/AuthenticationRestApi.java | 2 +- .../sdk/network/api/LoggingInterceptor.java | 10 +- .../network/api/ReportOptionRestApiImpl.java | 3 +- .../api/ReportOptionRestApiTest.java | 99 +++++++++++++++++++ .../integration/api/utils/JrsMetadata.java | 14 +-- 5 files changed, 111 insertions(+), 17 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index bf1cf6c7..50e4087a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -51,7 +51,7 @@ final class Builder { public Builder(String baseUrl) { Utils.checkNotNull(baseUrl, "Base url should not be null"); - mBaseUrl = baseUrl; + mBaseUrl = Utils.normalizeBaseUrl(baseUrl); } public Builder setLog(RestApiLog log) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index 16df2c3a..9c676061 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -48,19 +48,21 @@ public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); long t1 = System.nanoTime(); - logger.log(String.format("Sending request %s on %s%n%sWith body: \n%s", - request.url(), chain.connection(), request.headers(), bodyToString(request))); + logger.log(String.format("Sending request------------------------------------------------------>" + + "%nMethod: %s%nUrl: %s%nConnection: %s%n%sWith body: \n%s", + request.method(), request.url(), chain.connection(), request.headers(), bodyToString(request))); Response response = chain.proceed(request); long t2 = System.nanoTime(); - logger.log(String.format("Received response for %s in %.1fms%n%s", + logger.log(String.format("<-----------------------------------------------------Received response" + + "%nUrl: %s%nTime spent: %.1fms%n%s", response.request().url(), (t2 - t1) / 1e6d, response.headers())); return response; } - private static String bodyToString(final Request request){ + private static String bodyToString(final Request request) { try { final Request copy = request.newBuilder().build(); final Buffer buffer = new Buffer(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java index 86cea586..1d103369 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -40,6 +40,7 @@ import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.POST; +import retrofit.http.PUT; import retrofit.http.Path; import retrofit.http.Query; import rx.Observable; @@ -132,7 +133,7 @@ Observable createReportOption( @NonNull @Headers("Accept: application/json") - @POST("rest_v2/reports{reportUnitURI}/options/{optionId}") + @PUT("rest_v2/reports{reportUnitURI}/options/{optionId}") Observable updateReportOption( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Path(value = "optionId", encoded = true) String optionId, diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java new file mode 100644 index 00000000..0203a506 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -0,0 +1,99 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api; + +import com.jaspersoft.android.sdk.network.api.ReportOptionRestApi; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; +import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; + +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import rx.Observable; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportOptionRestApiTest { + + private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo(); + private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private ReportOptionRestApi apiUnderTest; + + + private static final String REPORT_URI = "/public/Samples/Reports/1._Geographic_Results_by_Segment_Report"; + public static final Map> CONTROL_PARAMETERS = new HashMap<>(); + static { + Set values = new HashSet<>(); + values.add("19"); + CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); + } + + @Before + public void setup() { + mAuthenticator.authorize(); + String cookie = mAuthenticator.getCookie(); + + if (apiUnderTest == null) { + apiUnderTest = new ReportOptionRestApi.Builder(mMetadata.getServerUrl(), cookie) + .setLog(TestLogger.get(this)) + .build(); + } + } + + @Test + public void shouldRequestReportOptionsList() { + Observable call = apiUnderTest.requestReportOptionsList(REPORT_URI); + ReportOptionResponse response = call.toBlocking().first(); + assertThat(response, is(not(nullValue()))); + } + + @Test + public void apiSupportsCrudForReportOption() { + Observable createCall = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true); + ReportOption response = createCall.toBlocking().first(); + assertThat(response.getLabel(), is("label")); + + Observable updateCall = apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS); + updateCall.toBlocking().firstOrDefault(null); + + Observable deleteCall = apiUnderTest.deleteReportOption(REPORT_URI, response.getId()); + deleteCall.toBlocking().firstOrDefault(null); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java index 7abcc6a5..6f8fbd53 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java @@ -47,10 +47,10 @@ private JrsMetadata(Builder builder) { public static JrsMetadata createMobileDemo() { return builder() - .setOrganization("organization_1") + .setOrganization("") .setServerUrl("http://mobiledemo.jaspersoft.com/jasperserver-pro") - .setUsername("joeuser") - .setPassword("joeuser") + .setUsername("superuser") + .setPassword("superuser") .build(); } @@ -130,7 +130,6 @@ private void checkValues() { assertPropertyNotEmpty(serverUrl, "serverUrl"); assertPropertyNotEmpty(username, "username"); assertPropertyNotEmpty(password, "password"); - serverUrl = resolveUrl(serverUrl); try { new URL(serverUrl); } catch (MalformedURLException e) { @@ -152,13 +151,6 @@ private void assertPropertyNotEmpty(String property, String propertyName) { } } - private static String resolveUrl(String url) { - if (!isEmpty(url) && !url.endsWith("/")) { - url = url + "/"; - } - return url; - } - private static boolean isEmpty(String str) { if (str == null || str.trim().length() == 0) return true; From 87907b8765c97ee5d9cdf4973d4b304325ff9c28 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 10:56:11 +0300 Subject: [PATCH 105/457] Converting Auth API to blocking one --- .../network/api/AuthenticationRestApi.java | 6 +- .../api/AuthenticationRestApiImpl.java | 84 ++++++++----------- .../api/AuthenticationRestApiTest.java | 13 ++- .../api/AuthenticationRestApiTest.java | 8 +- .../api/utils/TestAuthenticator.java | 3 +- 5 files changed, 46 insertions(+), 68 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index 50e4087a..85b2b50a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -26,21 +26,21 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.squareup.okhttp.OkHttpClient; import java.util.Map; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 */ public interface AuthenticationRestApi { @NonNull - Observable authenticate(@NonNull String username, + @WorkerThread + AuthResponse authenticate(@NonNull String username, @NonNull String password, @Nullable String organization, @Nullable Map params); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index c2d55f6d..18bf7e34 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -38,9 +38,6 @@ import java.util.Map; import java.util.Set; -import rx.Observable; -import rx.functions.Func0; - /** * TODO refactor following module in easy testable units * @@ -58,55 +55,42 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { @NonNull @Override - public Observable authenticate(@NonNull final String username, - @NonNull final String password, - final String organization, - final Map params) { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - - Request request = createAuthRequest(username, password, organization, params); - Call call = mClient.newCall(request); - try { - com.squareup.okhttp.Response response = call.execute(); - int statusCode = response.code(); - if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request - AuthResponse authResponse = AuthResponseFactory.create(response); - return Observable.just(authResponse); - } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request - String location = response.headers().get("Location"); - if (location == null) { - return Observable.error(new IllegalStateException("Location HEADER is missing please contact JRS admin")); - } - HttpUrl url = HttpUrl.parse(location); - String errorQueryParameter = url.queryParameter("error"); - if (errorQueryParameter == null) { - AuthResponse authResponse = AuthResponseFactory.create(response); - return Observable.just(authResponse); - } else { - com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() - .protocol(response.protocol()) - .request(response.request()) - .headers(response.headers()) - .body(response.body()) - .code(401) - .build(); - Throwable error = RestError.httpError(response401); - return Observable.error(error); - } - } else if (statusCode == 401) { - Throwable error = RestError.httpError(response); - return Observable.error(error); - } else { - Throwable error = RestError.httpError(response); - return Observable.error(error); - } - } catch (IOException e) { - return Observable.error(RestError.networkError(e)); + public AuthResponse authenticate(@NonNull final String username, + @NonNull final String password, + final String organization, + final Map params) { + Request request = createAuthRequest(username, password, organization, params); + Call call = mClient.newCall(request); + try { + com.squareup.okhttp.Response response = call.execute(); + int statusCode = response.code(); + if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request + return AuthResponseFactory.create(response); + } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request + String location = response.headers().get("Location"); + if (location == null) { + throw new IllegalStateException("Location HEADER is missing please contact JRS admin"); } + HttpUrl url = HttpUrl.parse(location); + String errorQueryParameter = url.queryParameter("error"); + if (errorQueryParameter == null) { + return AuthResponseFactory.create(response); + } else { + com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() + .protocol(response.protocol()) + .request(response.request()) + .headers(response.headers()) + .body(response.body()) + .code(401) + .build(); + throw RestError.httpError(response401); + } + } else { + throw RestError.httpError(response); } - }); + } catch (IOException ex) { + throw RestError.networkError(ex); + } } private Request createAuthRequest( diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index 44f7c0b4..88e7e176 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -34,8 +34,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import rx.Observable; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -72,8 +70,7 @@ public void shouldReturnResponseForSuccessRedirect() { mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - Observable obs = mRestApi.authenticate("joeuser", "joeuser", "null", null); - AuthResponse response = obs.toBlocking().first(); + AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", "null", null); assertThat(response.getToken(), is(notNullValue())); } @@ -85,7 +82,7 @@ public void shouldRiseErrorForErrorRedirect() { mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_ERROR); mWebMockRule.enqueue(mockResponse); - mRestApi.authenticate("joeuser", "joeuser", "null", null).toBlocking().first(); + mRestApi.authenticate("joeuser", "joeuser", "null", null); } @Test @@ -95,7 +92,7 @@ public void shouldRiseErrorForHttpException() { MockResponse mockResponse = create500Response(); mWebMockRule.enqueue(mockResponse); - mRestApi.authenticate("joeuser", "joeuser", "null", null).toBlocking().first(); + mRestApi.authenticate("joeuser", "joeuser", "null", null); } @Test @@ -106,7 +103,7 @@ public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() { MockResponse mockResponse = create302Response(); mWebMockRule.enqueue(mockResponse); - mRestApi.authenticate("joeuser", "joeuser", "null", null).toBlocking().first(); + mRestApi.authenticate("joeuser", "joeuser", "null", null); } private MockResponse create302Response() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 6338a9c5..4323db11 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -34,8 +34,6 @@ import java.io.IOException; -import rx.Observable; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -57,7 +55,7 @@ public void shouldReturnResponseForSpringRequest() throws IOException { AuthenticationRestApi authApi = new AuthenticationRestApi.Builder(mobileDemo2) .setLog(TestLogger.get(this)) .build(); - Observable response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); - assertThat(response.toBlocking().first().getToken(), is(notNullValue())); + AuthResponse response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); + assertThat(response.getToken(), is(notNullValue())); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java index 14249502..0db07ec6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java @@ -48,8 +48,7 @@ public void authorize() { if (mAuthResponse == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mJrsMetadata.getServerUrl()).build(); mAuthResponse = restApi - .authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null) - .toBlocking().first(); + .authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null); } } From a4451ad2cd4473f2cbc0bd84e18e0600fd6cabf8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 11:45:00 +0300 Subject: [PATCH 106/457] Converting Controls API to synchronous --- .../api/AuthenticationRestApiImpl.java | 1 - .../sdk/network/api/InputControlRestApi.java | 14 ++-- .../network/api/InputControlRestApiImpl.java | 63 +++++++++++++----- .../network/{exception => api}/RestError.java | 31 ++++++--- .../sdk/network/api/RestErrorAdapter.java | 2 - .../android/sdk/network/api/Utils.java | 66 +++++++++++++++++-- .../api/AuthenticationRestApiTest.java | 1 - .../network/api/InputControlRestApiTest.java | 22 +++++-- .../api/ReportExecutionRestApiTest.java | 1 - .../network/api/ReportExportRestApiTest.java | 1 - .../network/api/ReportOptionRestApiTest.java | 3 +- .../network/api/RepositoryRestApiTest.java | 1 - .../sdk/network/api/ServerRestApiTest.java | 1 - .../api/InputControlRestApiTest.java | 25 ++----- 14 files changed, 159 insertions(+), 73 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{exception => api}/RestError.java (75%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 18bf7e34..d821d48a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,7 +27,6 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.squareup.okhttp.Call; import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index df98cf5f..771850e2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; @@ -34,8 +35,6 @@ import java.util.Map; import java.util.Set; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 @@ -52,10 +51,12 @@ public interface InputControlRestApi { * @return unmodifiable list of {@link InputControl} */ @NonNull - Observable requestInputControls(@NonNull String reportUri, boolean excludeState); + @WorkerThread + InputControlResponse requestInputControls(@NonNull String reportUri, boolean excludeState); @NonNull - Observable requestInputControlsInitialStates(@NonNull String reportUri, + @WorkerThread + InputControlValueResponse requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData); /** @@ -68,7 +69,8 @@ Observable requestInputControlsInitialStates(@NonNull * @return unmodifiable list of {@link InputControlState} */ @NonNull - Observable requestInputControlsStates(@NonNull String reportUri, + @WorkerThread + InputControlValueResponse requestInputControlsStates(@NonNull String reportUri, @NonNull Map> controlsValues, boolean freshData); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 22038709..e6f8a9d5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -26,14 +26,16 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.text.TextUtils; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import java.io.IOException; import java.util.Map; import java.util.Set; +import retrofit.Call; +import retrofit.Response; import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; @@ -41,7 +43,6 @@ import retrofit.http.POST; import retrofit.http.Path; import retrofit.http.Query; -import rx.Observable; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; @@ -58,52 +59,80 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override - public Observable requestInputControls(@Nullable String reportUri, boolean excludeState) { + public InputControlResponse requestInputControls(@Nullable String reportUri, boolean excludeState) { checkNotNull(reportUri, "Report URI should not be null"); - return mRestApi.requestInputControls(reportUri, excludeState ? "state" : null) - .onErrorResumeNext(RestErrorAdapter.get()); + try { + Call call = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); + Response response = call.execute(); + if (response.isSuccess()) { + return response.body(); + } else { + throw RestError.httpError(response); + } + } catch (IOException ex) { + throw RestError.networkError(ex); + } } @NonNull @Override - public Observable requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { + public InputControlValueResponse requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); - return mRestApi.requestInputControlsInitialValues(reportUri, freshData) - .onErrorResumeNext(RestErrorAdapter.get()); + + try { + Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); + Response response = call.execute(); + if (response.isSuccess()) { + return response.body(); + } else { + throw RestError.httpError(response); + } + } catch (IOException ex) { + throw RestError.networkError(ex); + } } @NonNull @Override - public Observable requestInputControlsStates(@Nullable String reportUri, - @Nullable Map> controlsValues, - boolean freshData) { + public InputControlValueResponse requestInputControlsStates(@Nullable String reportUri, + @Nullable Map> controlsValues, + boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); - String ids = TextUtils.join(";", controlsValues.keySet()); - return mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData) - .onErrorResumeNext(RestErrorAdapter.get()); + try { + String ids = Utils.joinString(";", controlsValues.keySet()); + Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + Response response = call.execute(); + if (response.isSuccess()) { + return response.body(); + } else { + throw RestError.httpError(response); + } + } catch (IOException ex) { + throw RestError.networkError(ex); + } } private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls") - Observable requestInputControls( + Call requestInputControls( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("exclude") String state); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls/values") - Observable requestInputControlsInitialValues( + Call requestInputControlsInitialValues( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("freshData") boolean freshData); @NonNull @Headers("Accept: application/json") @POST("rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") - Observable requestInputControlsValues( + Call requestInputControlsValues( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @NonNull @Path(value = "controlsId", encoded = true) String ids, @NonNull @Body Map> controlsValues, diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java similarity index 75% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java index a8cf9083..2aa61b0b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/exception/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,13 +22,16 @@ * . */ -package com.jaspersoft.android.sdk.network.exception; +package com.jaspersoft.android.sdk.network.api; -//import retrofit.RetrofitError; +import android.support.annotation.Nullable; import java.io.IOException; +import retrofit.HttpException; +import retrofit.Response; + /** * Wrapper around exceptions which could pop up during request processing. * Motivation behind class was to incapsulate 3-d party errors in generic interface. @@ -37,17 +40,26 @@ * @since 2.0 */ public final class RestError extends RuntimeException { - public static RestError networkError(IOException exception) { + static RestError networkError(IOException exception) { return new RestError(exception.getMessage(), null, Kind.NETWORK, exception); } - public static RestError httpError(com.squareup.okhttp.Response response) { + static RestError httpError(HttpException httpException) { + Response response = httpException.response(); + return httpError(response.raw()); + } + + static RestError httpError(Response response) { + return httpError(response.raw()); + } + + static RestError httpError(com.squareup.okhttp.Response response) { String message = response.code() + " " + response.message(); return new RestError(message, response, Kind.HTTP, null); } - public static RestError unexpectedError(Throwable exception) { + static RestError unexpectedError(Throwable exception) { return new RestError(exception.getMessage(), null, Kind.UNEXPECTED, exception); } @@ -55,7 +67,7 @@ public static RestError unexpectedError(Throwable exception) { private final com.squareup.okhttp.Response response; private final Kind kind; - RestError(String message, com.squareup.okhttp.Response response,Kind kind, Throwable exception) { + RestError(String message,com.squareup.okhttp.Response response,Kind kind, Throwable exception) { super(message, exception); this.response = response; this.kind = kind; @@ -71,8 +83,9 @@ public String message() { return response.message(); } - public com.squareup.okhttp.Response response() { - return response; + @Nullable + public String errorBody() { + return Utils.bodyToString(response.body()); } public String urlString() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java index 873d9b84..906f6474 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.exception.RestError; - import retrofit.HttpException; import rx.Observable; import rx.functions.Func1; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java index f80014e5..41f8d876 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java @@ -24,25 +24,35 @@ package com.jaspersoft.android.sdk.network.api; +import com.squareup.okhttp.ResponseBody; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + /** * @author Tom Koptel * @since 2.0 */ final class Utils { - static T checkNotNull(T object, String message) { + private Utils() { + } + + public static T checkNotNull(T object, String message) { if (object == null) { throw new NullPointerException(message); } return object; } - static void checkArgument(boolean condition, String message) { + public static void checkArgument(boolean condition, String message) { if (condition) { throw new IllegalArgumentException(message); } } - static int headerToInt(com.squareup.okhttp.Headers headers, String key) { + public static int headerToInt(com.squareup.okhttp.Headers headers, String key) { String header = headers.get(key); if (header == null) { return 0; @@ -51,12 +61,58 @@ static int headerToInt(com.squareup.okhttp.Headers headers, String key) { } } - private Utils() {} - public static String normalizeBaseUrl(String baseUrl) { if (baseUrl.endsWith("/")) { return baseUrl; } return baseUrl + "/"; } + + public static String bodyToString(ResponseBody responseBody) { + try { + InputStream inputStream = responseBody.byteStream(); + return streamToString(inputStream); + } catch (IOException ex) { + return null; + } + } + + private static String streamToString(InputStream stream) throws IOException { + if (stream == null) { + return null; + } + + InputStreamReader is = new InputStreamReader(stream); + StringBuilder sb = new StringBuilder(); + BufferedReader br = new BufferedReader(is); + + try { + String read = br.readLine(); + while (read != null) { + sb.append(read); + read = br.readLine(); + } + return sb.toString(); + } finally { + try { + stream.close(); + } catch (IOException e) { + // close quietly + } + } + } + + public static String joinString(CharSequence delimiter, Iterable tokens) { + StringBuilder sb = new StringBuilder(); + boolean firstTime = true; + for (Object token: tokens) { + if (firstTime) { + firstTime = false; + } else { + sb.append(delimiter); + } + sb.append(token); + } + return sb.toString(); + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index 88e7e176..7e2d9427 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index fd8d3c15..daf07879 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -1,7 +1,5 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -12,12 +10,11 @@ import java.util.Collections; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 */ +@SuppressWarnings("unchecked") public class InputControlRestApiTest { @Rule @@ -73,11 +70,22 @@ public void requestInputControlsStatesShouldNotAllowNullControlParams() { } @Test - public void requestInputControlsShouldThrowRestError() { + public void requestInputControlsShouldThrowRestErrorFor500() { + mExpectedException.expect(RestError.class); + mWebMockRule.enqueue(MockResponseFactory.create500()); + restApiUnderTest.requestInputControls("any_id", true); + } + @Test + public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - Observable call = restApiUnderTest.requestInputControls("any_id", true); - call.toBlocking().first(); + restApiUnderTest.requestInputControlsInitialStates("any_id", true); } + @Test + public void requestInputControlsStatesShouldThrowRestErrorFor500() { + mExpectedException.expect(RestError.class); + mWebMockRule.enqueue(MockResponseFactory.create500()); + restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true); + } } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index 1b32df28..c279322c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index c50f3767..fe126f77 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index 1cf9908c..117cd4d0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index aeb4cdb0..ea1e06b1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java index 45a2b0a3..5237d7af 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.exception.RestError; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index c392104f..d990e009 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -34,10 +34,6 @@ import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.httpclient.FakeHttp; import java.util.HashMap; import java.util.HashSet; @@ -45,8 +41,6 @@ import java.util.Map; import java.util.Set; -import rx.Observable; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; @@ -58,8 +52,6 @@ * @author Tom Koptel * @since 2.0 */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) public class InputControlRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); @@ -75,8 +67,6 @@ public class InputControlRestApiTest { @Before public void setup() { - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - mAuthenticator.authorize(); String cookie = mAuthenticator.getCookie(); mRestApi = new InputControlRestApi.Builder(mMetadata.getServerUrl(), cookie) @@ -86,9 +76,8 @@ public void setup() { @Test public void shouldProvideInputControlsList() { - Observable call = mRestApi.requestInputControls(REPORT_URI, false); - - List controls = call.toBlocking().first().getValues(); + InputControlResponse response = mRestApi.requestInputControls(REPORT_URI, false); + List controls = response.getValues(); assertThat(controls, is(not(empty()))); InputControl control = controls.get(0); @@ -100,9 +89,9 @@ public void shouldProvideInputControlsList() { */ @Test public void shouldProvideInputControlsListIfStateExcluded() { - Observable call = mRestApi.requestInputControls(REPORT_URI, true); + InputControlResponse response = mRestApi.requestInputControls(REPORT_URI, true); - List controls = call.toBlocking().first().getValues(); + List controls = response.getValues(); assertThat(controls, is(not(empty()))); InputControl control = controls.get(0); @@ -111,15 +100,13 @@ public void shouldProvideInputControlsListIfStateExcluded() { @Test public void shouldProvideFreshInitialInputControlsValues() { - Observable call = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); - InputControlValueResponse response = call.toBlocking().first(); + InputControlValueResponse response = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); assertThat(response.getValues(), is(not(empty()))); } @Test public void shouldProvideFreshStatesForInputControls() { - Observable call = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); - InputControlValueResponse response = call.toBlocking().first(); + InputControlValueResponse response = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); assertThat(response.getValues(), is(not(empty()))); } } From 9dcbafb1996c913dc012586326922405696eb30b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 11:50:19 +0300 Subject: [PATCH 107/457] Implementing CallWrapper to reduce boilerplate --- .../android/sdk/network/api/CallWrapper.java | 59 +++++++++++++++++++ .../network/api/InputControlRestApiImpl.java | 44 +++----------- 2 files changed, 67 insertions(+), 36 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java new file mode 100644 index 00000000..e6f5d483 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java @@ -0,0 +1,59 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import java.io.IOException; + +import retrofit.Call; +import retrofit.Response; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class CallWrapper { + private final Call mDelegateCall; + + private CallWrapper(Call delegateCall) { + mDelegateCall = delegateCall; + } + + public static CallWrapper wrap(Call originalCall) { + return new CallWrapper<>(originalCall); + } + + public Body body() { + try { + Response response = mDelegateCall.execute(); + if (response.isSuccess()) { + return response.body(); + } else { + throw RestError.httpError(response); + } + } catch (IOException ex) { + throw RestError.networkError(ex); + } + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index e6f8a9d5..169951f3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -30,12 +30,10 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; -import java.io.IOException; import java.util.Map; import java.util.Set; import retrofit.Call; -import retrofit.Response; import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; @@ -61,17 +59,9 @@ final class InputControlRestApiImpl implements InputControlRestApi { @Override public InputControlResponse requestInputControls(@Nullable String reportUri, boolean excludeState) { checkNotNull(reportUri, "Report URI should not be null"); - try { - Call call = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); - Response response = call.execute(); - if (response.isSuccess()) { - return response.body(); - } else { - throw RestError.httpError(response); - } - } catch (IOException ex) { - throw RestError.networkError(ex); - } + + Call call = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); + return CallWrapper.wrap(call).body(); } @NonNull @@ -79,17 +69,8 @@ public InputControlResponse requestInputControls(@Nullable String reportUri, boo public InputControlValueResponse requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); - try { - Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); - Response response = call.execute(); - if (response.isSuccess()) { - return response.body(); - } else { - throw RestError.httpError(response); - } - } catch (IOException ex) { - throw RestError.networkError(ex); - } + Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); + return CallWrapper.wrap(call).body(); } @NonNull @@ -100,18 +81,9 @@ public InputControlValueResponse requestInputControlsStates(@Nullable String rep checkNotNull(reportUri, "Report URI should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); - try { - String ids = Utils.joinString(";", controlsValues.keySet()); - Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); - Response response = call.execute(); - if (response.isSuccess()) { - return response.body(); - } else { - throw RestError.httpError(response); - } - } catch (IOException ex) { - throw RestError.networkError(ex); - } + String ids = Utils.joinString(";", controlsValues.keySet()); + Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + return CallWrapper.wrap(call).body(); } private interface RestApi { From 2ffd35e082c9e484b56f15ed2daa57eb86649f73 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 12:04:01 +0300 Subject: [PATCH 108/457] Migrate Report Execution Api to synchronous paradigm --- .../android/sdk/network/api/CallWrapper.java | 13 +++ .../network/api/ReportExecutionRestApi.java | 23 ++--- .../api/ReportExecutionRestApiImpl.java | 87 ++++++++----------- .../api/ReportExecutionRestApiTest.java | 26 +++--- .../api/ReportExecutionRestApiTest.java | 20 ++--- .../api/ReportExportRestApiTest.java | 3 +- 6 files changed, 80 insertions(+), 92 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java index e6f5d483..e8fbb774 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java @@ -56,4 +56,17 @@ public Body body() { throw RestError.networkError(ex); } } + + public Response response() { + try { + Response response = mDelegateCall.execute(); + if (response.isSuccess()) { + return response; + } else { + throw RestError.httpError(response); + } + } catch (IOException ex) { + throw RestError.networkError(ex); + } + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 98c7c7d2..5518f3fb 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; @@ -35,8 +36,6 @@ import java.util.Collection; import java.util.Map; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 @@ -44,25 +43,29 @@ public interface ReportExecutionRestApi { @NonNull - Observable runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); + @WorkerThread + ReportExecutionDetailsResponse runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); @NonNull - Observable requestReportExecutionDetails(@NonNull String executionId); + @WorkerThread + ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId); @NonNull - Observable requestReportExecutionStatus(@NonNull String executionId); + @WorkerThread + ExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId); - @NonNull - Observable cancelReportExecution(@NonNull String executionId); + @WorkerThread + boolean cancelReportExecution(@NonNull String executionId); - @NonNull - Observable updateReportExecution(@NonNull String executionId, @NonNull Collection params); + @WorkerThread + boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params); /** * TODO: API is broken requires investigation before release */ @NonNull - Observable searchReportExecution(Map params); + @WorkerThread + ReportExecutionSearchResponse searchReportExecution(Map params); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 9c5e6fdc..71597fb4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -36,6 +36,7 @@ import java.util.Collection; import java.util.Map; +import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.Body; @@ -45,8 +46,6 @@ import retrofit.http.PUT; import retrofit.http.Path; import retrofit.http.QueryMap; -import rx.Observable; -import rx.functions.Func1; import static com.jaspersoft.android.sdk.network.api.Utils.checkArgument; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; @@ -65,110 +64,96 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NonNull @Override - public Observable runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) { + public ReportExecutionDetailsResponse runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) { checkNotNull(executionOptions, "Execution options should not be null"); - return mRestApi.runReportExecution(executionOptions) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.runReportExecution(executionOptions); + return CallWrapper.wrap(call).body(); } @NonNull @Override - public Observable requestReportExecutionDetails(@Nullable String executionId) { + public ReportExecutionDetailsResponse requestReportExecutionDetails(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - return mRestApi.requestReportExecutionDetails(executionId) - .onErrorResumeNext(RestErrorAdapter.get()); + + Call call = mRestApi.requestReportExecutionDetails(executionId); + return CallWrapper.wrap(call).body(); } @NonNull @Override - public Observable requestReportExecutionStatus(@Nullable String executionId) { + public ExecutionStatusResponse requestReportExecutionStatus(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - return mRestApi.requestReportExecutionStatus(executionId) - .onErrorResumeNext(RestErrorAdapter.get()); + + Call call = mRestApi.requestReportExecutionStatus(executionId); + return CallWrapper.wrap(call).body(); } - @NonNull @Override - public Observable cancelReportExecution(@Nullable String executionId) { + public boolean cancelReportExecution(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - return mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()) - .flatMap(new Func1, Observable>() { - @Override - public Observable call(Response response) { - int status = response.code(); - return Observable.just(status != 204); - } - }) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()); + Response response = CallWrapper.wrap(call).response(); + int status = response.code(); + return status != 204; } - @NonNull @Override - public Observable updateReportExecution(@Nullable String executionId, @Nullable Collection params) { + public boolean updateReportExecution(@Nullable String executionId, @Nullable Collection params) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(params, "Execution params id should not be null"); - return mRestApi.updateReportExecution(executionId, params) - .flatMap(new Func1, Observable>() { - @Override - public Observable call(Response response) { - int status = response.code(); - return Observable.just(status == 204); - } - }) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.updateReportExecution(executionId, params); + Response response = CallWrapper.wrap(call).response(); + int status = response.code(); + return status == 204; } @NonNull @Override - public Observable searchReportExecution(@Nullable Map params) { + public ReportExecutionSearchResponse searchReportExecution(@Nullable Map params) { checkNotNull(params, "Search params should not be null"); checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); - return mRestApi.searchReportExecution(params) - .flatMap(new Func1>() { - @Override - public Observable call(ReportExecutionSearchResponse response) { - if (response == null) { - return Observable.just(ReportExecutionSearchResponse.empty()); - } - return Observable.just(response); - } - }) - .onErrorResumeNext(RestErrorAdapter.get()); + + Call call = mRestApi.searchReportExecution(params); + ReportExecutionSearchResponse body = CallWrapper.wrap(call).body(); + if (body == null) { + return ReportExecutionSearchResponse.empty(); + } + return body; } interface RestApi { @NonNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions") - Observable runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); + Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}") - Observable requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId); + Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/status") - Observable requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId); + Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId); @NonNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/parameters") - Observable> updateReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, + Call updateReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, @NonNull @Body Collection params); @NonNull @Headers("Accept: application/json") @PUT("rest_v2/reportExecutions/{executionId}/status") - Observable> cancelReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, + Call cancelReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, @NonNull @Body ExecutionStatusResponse statusResponse); @Headers("Accept: application/json") @GET("rest_v2/reportExecutions") - Observable searchReportExecution(@Nullable @QueryMap(encoded = true) Map params); + Call searchReportExecution(@Nullable @QueryMap(encoded = true) Map params); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index c279322c..987fdbc1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -42,8 +42,6 @@ import java.util.HashMap; import java.util.Map; -import rx.Observable; - import static org.hamcrest.Matchers.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -95,7 +93,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(create500Response()); - restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri")).toBlocking().first(); + restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri")); } @Test @@ -103,7 +101,7 @@ public void bodyParameterShouldNotBeNullForRunReportExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runReportExecution(null).toBlocking().first(); + restApiUnderTest.runReportExecution(null); } @Test @@ -111,7 +109,7 @@ public void pathParameterShouldNotBeNullForRequestExecutionDetails() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionDetails(null).toBlocking().first(); + restApiUnderTest.requestReportExecutionDetails(null); } @Test @@ -119,7 +117,7 @@ public void pathParameterShouldNotBeNullForRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionStatus(null).toBlocking().first(); + restApiUnderTest.requestReportExecutionStatus(null); } @Test @@ -127,14 +125,14 @@ public void pathParameterShouldNotBeNullForCancelRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.cancelReportExecution(null).toBlocking().first(); + restApiUnderTest.cancelReportExecution(null); } @Test public void responseShouldNotBeCancelledIfResponseIs204() { mWebMockRule.enqueue(create204Response()); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id").toBlocking().first(); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); assertThat(cancelled, is(false)); } @@ -145,7 +143,7 @@ public void responseShouldBeCancelledIfResponseIs200() { response.setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id").toBlocking().first(); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); assertThat(cancelled, is(true)); } @@ -154,7 +152,7 @@ public void responseShouldBeCancelledIfResponseIs200() { public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws IOException { mWebMockRule.enqueue(create204Response()); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS).toBlocking().first(); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS); assertThat(response.getItems(), is(empty())); } @@ -164,7 +162,7 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOEx mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS).toBlocking().first(); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS); assertThat(response.getItems(), is(not(empty()))); } @@ -173,9 +171,7 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOEx public void executionUpdateRequestShouldBeSuccessIfResponseIs204() { mWebMockRule.enqueue(create204Response()); - Observable call = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_LIST); - boolean response = call.toBlocking().first(); - + boolean response = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_LIST); assertThat(response, is(true)); } @@ -184,7 +180,7 @@ public void bodyParameterShouldNotBeNullForExecutionUpdate() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution params id should not be null"); - restApiUnderTest.updateReportExecution("any_id", null).toBlocking().first(); + restApiUnderTest.updateReportExecution("any_id", null); } private MockResponse create200Response() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 71fdfba1..2dc88be1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -44,8 +44,6 @@ import java.util.HashMap; import java.util.Map; -import rx.Observable; - import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -91,8 +89,7 @@ public void shouldStartReportExecution() { @Ignore public void shouldCancelReportExecution() throws InterruptedException { ReportExecutionDetailsResponse response = startExecution(); - Observable call = apiUnderTest.cancelReportExecution(response.getExecutionId()); - boolean cancelled = call.toBlocking().first(); + boolean cancelled = apiUnderTest.cancelReportExecution(response.getExecutionId()); assertThat(cancelled, is(true)); } @@ -101,8 +98,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionDetailsResponse executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - Observable call = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId()); - ReportExecutionDetailsResponse response = call.toBlocking().first(); + ReportExecutionDetailsResponse response = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId()); assertThat(response.getExecutionId(), is(executionId)); } @@ -110,8 +106,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionDetailsResponse executionResponse = startExecution(); - Observable call = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId()); - ExecutionStatusResponse response = call.toBlocking().first(); + ExecutionStatusResponse response = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId()); assertThat(response.getStatus(), is(notNullValue())); } @@ -125,8 +120,7 @@ public void searchForExecutionShouldReturnResult() throws IOException { Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); - Observable call = apiUnderTest.searchReportExecution(params); - ReportExecutionSearchResponse response = call.toBlocking().first(); + ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(params); assertThat(response.getItems(), is(not(empty()))); } @@ -134,8 +128,7 @@ public void searchForExecutionShouldReturnResult() throws IOException { public void updateOfParametersForExecutionShouldReturnResult() { ReportExecutionDetailsResponse executionResponse = startExecution(); - Observable call = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); - boolean success = call.toBlocking().first(); + boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); assertThat(success, is(true)); } @@ -151,8 +144,7 @@ private ReportExecutionDetailsResponse startExecution() { @NonNull private ReportExecutionDetailsResponse startExecution(String uri) { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); - Observable call = apiUnderTest.runReportExecution(executionRequestOptions); - return call.toBlocking().first(); + return apiUnderTest.runReportExecution(executionRequestOptions); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index c62b012a..c4e0c4d3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -123,7 +123,6 @@ private ReportExportExecutionResponse startExportExecution(ReportExecutionDetail @NonNull private ReportExecutionDetailsResponse startExecution() { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); - Observable call = mExecApi.runReportExecution(executionRequestOptions); - return call.toBlocking().first(); + return mExecApi.runReportExecution(executionRequestOptions); } } From abb1abdc60000dc102ee23fd44e59b3cf3fdf05f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 12:13:12 +0300 Subject: [PATCH 109/457] Migrate Report Export Api to synchronous paradigm --- .../sdk/network/api/ReportExportRestApi.java | 15 ++-- .../network/api/ReportExportRestApiImpl.java | 77 ++++++++----------- .../network/api/ReportExportRestApiTest.java | 68 +++++++++------- .../api/ReportExportRestApiTest.java | 11 +-- 4 files changed, 83 insertions(+), 88 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 3b89c6d7..326017a6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; @@ -32,8 +33,6 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 @@ -41,16 +40,20 @@ public interface ReportExportRestApi { @NonNull - Observable runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + @WorkerThread + ReportExportExecutionResponse runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); @NonNull - Observable checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); + @WorkerThread + ExecutionStatusResponse checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); @NonNull - Observable requestExportOutput(@NonNull String executionId, @NonNull String exportId); + @WorkerThread + ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId); @NonNull - Observable requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); + @WorkerThread + ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index bb5968d4..ddf5768d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -34,6 +34,7 @@ import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; import com.squareup.okhttp.ResponseBody; +import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.Body; @@ -41,8 +42,6 @@ import retrofit.http.Headers; import retrofit.http.POST; import retrofit.http.Path; -import rx.Observable; -import rx.functions.Func1; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; @@ -59,92 +58,80 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @NonNull @Override - public Observable runExportExecution(@Nullable String executionId, - @Nullable ExecutionRequestOptions executionOptions) { + public ReportExportExecutionResponse runExportExecution(@Nullable String executionId, + @Nullable ExecutionRequestOptions executionOptions) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(executionOptions, "Execution options should not be null"); - return mRestApi.runReportExportExecution(executionId, executionOptions) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.runReportExportExecution(executionId, executionOptions); + return CallWrapper.wrap(call).body(); } @NonNull @Override - public Observable checkExportExecutionStatus(@Nullable String executionId, @Nullable String exportId) { + public ExecutionStatusResponse checkExportExecutionStatus(@Nullable String executionId, @Nullable String exportId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); - return mRestApi.checkReportExportStatus(executionId, exportId) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.checkReportExportStatus(executionId, exportId); + return CallWrapper.wrap(call).body(); } @NonNull @Override - public Observable requestExportOutput(@Nullable String executionId, @Nullable String exportId) { + public ExportResourceResponse requestExportOutput(@Nullable String executionId, @Nullable String exportId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); - return mRestApi.requestReportExportOutput(executionId, exportId) - .flatMap(new Func1, Observable>() { - @Override - public Observable call(Response rawResponse) { - com.squareup.okhttp.Headers headers = rawResponse.headers(); - - RetrofitExportInput exportInput = new RetrofitExportInput(rawResponse.body()); - String pages = headers.get("report-pages"); - boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); - - ExportResourceResponse response = ExportResourceResponse.create(exportInput, pages, isFinal); - return Observable.just(response); - } - }) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.requestReportExportOutput(executionId, exportId); + Response rawResponse = CallWrapper.wrap(call).response(); + com.squareup.okhttp.Headers headers = rawResponse.headers(); + + RetrofitExportInput exportInput = new RetrofitExportInput(rawResponse.body()); + String pages = headers.get("report-pages"); + boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); + + return ExportResourceResponse.create(exportInput, pages, isFinal); } @NonNull @Override - public Observable requestExportAttachment(@Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) { + public ExportInput requestExportAttachment(@Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); checkNotNull(attachmentId, "Attachment id should not be null"); - return mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId) - .flatMap(new Func1, Observable>() { - @Override - public Observable call(Response rawResponse) { - ResponseBody body = rawResponse.body(); - ExportInput response = new RetrofitExportInput(body); - return Observable.just(response); - } - }) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); + Response rawResponse = CallWrapper.wrap(call).response(); + ResponseBody body = rawResponse.body(); + return new RetrofitExportInput(body); } private interface RestApi { @NonNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/exports") - Observable runReportExportExecution(@NonNull @Path("executionId") String executionId, - @NonNull @Body ExecutionRequestOptions executionOptions); + Call runReportExportExecution(@NonNull @Path("executionId") String executionId, + @NonNull @Body ExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") - Observable checkReportExportStatus(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId); + Call checkReportExportStatus(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId); /** * 'suppressContentDisposition' used due to security implications this header has */ @NonNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") - Observable> requestReportExportOutput(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId); + Call requestReportExportOutput(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId); @NonNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") - Observable> requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId, - @NonNull @Path("attachmentId") String attachmentId); + Call requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, + @NonNull @Path("exportId") String exportId, + @NonNull @Path("attachmentId") String attachmentId); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index fe126f77..de57b430 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; @@ -42,8 +42,6 @@ import java.io.IOException; import java.io.InputStream; -import rx.Observable; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -82,17 +80,6 @@ public void shouldThrowIllegalArgumentExceptionForNullCookie() { new ReportExportRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); } - @Test - public void shouldThroughRestErrorOnSearchRequestIfHttpError() { - mExpectedException.expect(RestError.class); - - mWebMockRule.enqueue(create500Response()); - - Observable call = restApiUnderTest - .runExportExecution("any_id", ExecutionRequestOptions.newInstance()); - call.toBlocking().first(); - } - @Test public void pathParameterShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(NullPointerException.class); @@ -151,48 +138,71 @@ public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { @Test public void requestForOutputShouldParsePagesFromHeader() { - MockResponse mockResponse = create200Response() + MockResponse mockResponse = MockResponseFactory.create200() .setBody("") .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - Observable call = restApiUnderTest.requestExportOutput("any_id", "any_id"); - ExportResourceResponse resource = call.toBlocking().first(); + ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); assertThat(resource.getPages(), is("1-10")); } @Test public void requestForOutputShouldParseIsFinalHeader() { - MockResponse mockResponse = create200Response() + MockResponse mockResponse = MockResponseFactory.create200() .setBody("") .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - Observable call = restApiUnderTest.requestExportOutput("any_id", "any_id"); - ExportResourceResponse resource = call.toBlocking().first(); + ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); assertThat(resource.isFinal(), is(true)); } @Test public void requestForAttachmentShouldBeWrappedInsideInput() throws IOException { - MockResponse mockResponse = create200Response() + MockResponse mockResponse = MockResponseFactory.create200() .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - Observable call = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); - ExportInput resource = call.toBlocking().first(); + ExportInput resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); } - private MockResponse create200Response() { - return new MockResponse() - .setStatus("HTTP/1.1 200 Ok"); + @Test + public void runExportExecutionShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.newInstance()); } - private MockResponse create500Response() { - return new MockResponse() - .setStatus("HTTP/1.1 500 Internal Server Error"); + @Test + public void checkExportExecutionStatusShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.checkExportExecutionStatus("any_id", "any_id"); + } + + @Test + public void requestExportOutputShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.requestExportOutput("any_id", "any_id"); + } + + @Test + public void requestExportAttachmentShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index c4e0c4d3..3de42328 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -43,8 +43,6 @@ import java.io.IOException; -import rx.Observable; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -91,8 +89,7 @@ public void runExportRequestShouldReturnResult() { public void checkExportRequestStatusShouldReturnResult() throws IOException { ReportExecutionDetailsResponse exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - Observable call = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); - ExecutionStatusResponse response = call.toBlocking().first(); + ExecutionStatusResponse response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); assertThat(response, is(notNullValue())); } @@ -100,8 +97,7 @@ public void checkExportRequestStatusShouldReturnResult() throws IOException { public void requestExportOutputShouldReturnResult() { ReportExecutionDetailsResponse exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - Observable call = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); - ExportResourceResponse output = call.toBlocking().first(); + ExportResourceResponse output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); assertThat(output.getExportInput(), is(notNullValue())); assertThat(output.getPages(), is("1-2")); @@ -116,8 +112,7 @@ private ReportExportExecutionResponse startExportExecution(ReportExecutionDetail ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() .withPages("1-2") .withOutputFormat("PDF"); - Observable call = apiUnderTest.runExportExecution(exec.getExecutionId(), options); - return call.toBlocking().first(); + return apiUnderTest.runExportExecution(exec.getExecutionId(), options); } @NonNull From 4bd8d42362158a567481fc0fd771d94ca1eb4b0d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 12:34:30 +0300 Subject: [PATCH 110/457] Migrate Report Options Api to synchronous paradigm --- .../sdk/network/api/ReportOptionRestApi.java | 19 +++--- .../network/api/ReportOptionRestApiImpl.java | 58 +++++++++---------- .../report/option/ReportOptionResponse.java | 6 ++ .../network/api/ReportOptionRestApiTest.java | 12 +--- .../api/ReportOptionRestApiTest.java | 16 ++--- 5 files changed, 52 insertions(+), 59 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 3bf3db43..4f313fa0 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; @@ -32,8 +33,6 @@ import java.util.Map; import java.util.Set; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 @@ -41,21 +40,23 @@ public interface ReportOptionRestApi { @NonNull - Observable requestReportOptionsList(@NonNull String reportUnitUri); + @WorkerThread + ReportOptionResponse requestReportOptionsList(@NonNull String reportUnitUri); @NonNull - Observable createReportOption(@NonNull String reportUnitUri, + @WorkerThread + ReportOption createReportOption(@NonNull String reportUnitUri, @NonNull String optionLabel, @NonNull Map> controlsValues, boolean overwrite); - @NonNull - Observable updateReportOption(@NonNull String reportUnitUri, + @WorkerThread + void updateReportOption(@NonNull String reportUnitUri, @NonNull String optionId, @NonNull Map> controlsValues); - @NonNull - Observable deleteReportOption(@NonNull String reportUnitUri, + @WorkerThread + void deleteReportOption(@NonNull String reportUnitUri, @NonNull String optionId); final class Builder extends AuthBaseBuilder { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java index 1d103369..31a4b266 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; import com.squareup.okhttp.Response; @@ -34,6 +35,7 @@ import java.util.Map; import java.util.Set; +import retrofit.Call; import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.DELETE; @@ -43,8 +45,6 @@ import retrofit.http.PUT; import retrofit.http.Path; import retrofit.http.Query; -import rx.Observable; -import rx.functions.Func1; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; @@ -55,29 +55,31 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { private final RestApi mRestApi; - private static final Func1> VOID_MAP_LAMBDA = new Func1>() { - @Override - public Observable call(Response response) { - return Observable.empty(); - } - }; - ReportOptionRestApiImpl(Retrofit retrofit) { mRestApi = retrofit.create(RestApi.class); } @NonNull @Override - public Observable requestReportOptionsList(@Nullable String reportUnitUri) { + public ReportOptionResponse requestReportOptionsList(@Nullable String reportUnitUri) { checkNotNull(reportUnitUri, "Report uri should not be null"); - return mRestApi.requestReportOptionsList(reportUnitUri) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.requestReportOptionsList(reportUnitUri); + try { + return CallWrapper.wrap(call).body(); + } catch (JsonSyntaxException ex) { + /** + * This possible when there is no report options + * API responds with plain/text message: 'No options found for {URI}' + * As soon as there 2 options to reserve this we decide to swallow exception and return empty object + */ + return ReportOptionResponse.empty(); + } } @NonNull @Override - public Observable createReportOption(@Nullable String reportUnitUri, + public ReportOption createReportOption(@Nullable String reportUnitUri, @Nullable String optionLabel, @Nullable Map> controlsValues, boolean overwrite) { @@ -85,47 +87,43 @@ public Observable createReportOption(@Nullable String reportUnitUr checkNotNull(optionLabel, "Option label should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); - return mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite); + return CallWrapper.wrap(call).body(); } - @NonNull @Override - public Observable updateReportOption(@Nullable String reportUnitUri, + public void updateReportOption(@Nullable String reportUnitUri, @Nullable String optionId, @Nullable Map> controlsValues) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionId, "Option id should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); - return mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues) - .flatMap(VOID_MAP_LAMBDA) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues); + CallWrapper.wrap(call).body(); } - @NonNull @Override - public Observable deleteReportOption(@Nullable String reportUnitUri, + public void deleteReportOption(@Nullable String reportUnitUri, @Nullable String optionId) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionId, "Option id should not be null"); - return mRestApi.deleteReportOption(reportUnitUri, optionId) - .flatMap(VOID_MAP_LAMBDA) - .onErrorResumeNext(RestErrorAdapter.get()); + Call call = mRestApi.deleteReportOption(reportUnitUri, optionId); + CallWrapper.wrap(call).body(); } private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitUri}/options") - Observable requestReportOptionsList( + Call requestReportOptionsList( @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); @NonNull @Headers("Accept: application/json") @POST("rest_v2/reports{reportUnitURI}/options") - Observable createReportOption( + Call createReportOption( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Query("label") String optionLabel, @NonNull @Body Map> controlsValues, @@ -134,7 +132,7 @@ Observable createReportOption( @NonNull @Headers("Accept: application/json") @PUT("rest_v2/reports{reportUnitURI}/options/{optionId}") - Observable updateReportOption( + Call updateReportOption( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Path(value = "optionId", encoded = true) String optionId, @NonNull @Body Map> controlsValues); @@ -142,7 +140,7 @@ Observable updateReportOption( @NonNull @Headers("Accept: application/json") @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") - Observable deleteReportOption( + Call deleteReportOption( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Path(value = "optionId", encoded = true) String optionId); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java index 2790f924..0cca026e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java @@ -38,6 +38,12 @@ */ public final class ReportOptionResponse { + private ReportOptionResponse() {} + + public static ReportOptionResponse empty() { + return new ReportOptionResponse(); + } + @Expose @SerializedName("reportOptionsSummary") private Set mOptions = Collections.emptySet(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index 117cd4d0..7f321ee5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -35,8 +34,6 @@ import java.util.Collections; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 @@ -68,8 +65,7 @@ public void requestReportOptionsListShouldThrow500Error() { mWebMockRule.enqueue(MockResponseFactory.create500()); - Observable call = restApiUnderTest.requestReportOptionsList("any_id"); - call.toBlocking().first(); + restApiUnderTest.requestReportOptionsList("any_id"); } @Test @@ -78,8 +74,7 @@ public void updateReportOptionShouldThrowRestErrorFor500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - Observable call = restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP); - call.toBlocking().first(); + restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP); } @Test @@ -88,8 +83,7 @@ public void deleteReportOptionShouldThrowRestErrorFor500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - Observable call = restApiUnderTest.deleteReportOption("any_id", "option_id"); - call.toBlocking().first(); + restApiUnderTest.deleteReportOption("any_id", "option_id"); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 0203a506..97f4044c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -39,8 +39,6 @@ import java.util.Map; import java.util.Set; -import rx.Observable; - import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; @@ -79,21 +77,17 @@ public void setup() { @Test public void shouldRequestReportOptionsList() { - Observable call = apiUnderTest.requestReportOptionsList(REPORT_URI); - ReportOptionResponse response = call.toBlocking().first(); + ReportOptionResponse response = apiUnderTest.requestReportOptionsList(REPORT_URI); assertThat(response, is(not(nullValue()))); } @Test public void apiSupportsCrudForReportOption() { - Observable createCall = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true); - ReportOption response = createCall.toBlocking().first(); + ReportOption response = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true); assertThat(response.getLabel(), is("label")); - Observable updateCall = apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS); - updateCall.toBlocking().firstOrDefault(null); + apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS); - Observable deleteCall = apiUnderTest.deleteReportOption(REPORT_URI, response.getId()); - deleteCall.toBlocking().firstOrDefault(null); + apiUnderTest.deleteReportOption(REPORT_URI, response.getId()); } } From d3b6b9ddeac9b5b35de34f04288060982ab73048 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 12:49:13 +0300 Subject: [PATCH 111/457] Migrate Repository Api to synchronous paradigm --- .../sdk/network/api/RepositoryRestApi.java | 18 +-- .../network/api/RepositoryRestApiImpl.java | 107 ++++++++---------- .../network/api/RepositoryRestApiTest.java | 88 ++++++++------ .../api/RepositoryRestApiTest.java | 14 +-- 4 files changed, 116 insertions(+), 111 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index e4fe9a23..7f79a9a6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -26,6 +26,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; @@ -35,27 +36,30 @@ import java.util.Map; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 */ public interface RepositoryRestApi { @NonNull - Observable searchResources(@Nullable Map searchParams); + @WorkerThread + ResourceSearchResponse searchResources(@Nullable Map searchParams); @NonNull - Observable requestReportResource(@NonNull String resourceUri); + @WorkerThread + ReportLookupResponse requestReportResource(@NonNull String resourceUri); @NonNull - Observable requestDashboardResource(@NonNull String resourceUri); + @WorkerThread + DashboardLookupResponse requestDashboardResource(@NonNull String resourceUri); @NonNull - Observable requestLegacyDashboardResource(@NonNull String resourceUri); + @WorkerThread + LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull String resourceUri); @NonNull - Observable requestFolderResource(@NonNull String resourceUri); + @WorkerThread + FolderLookupResponse requestFolderResource(@NonNull String resourceUri); final class Builder extends AuthBaseBuilder { public Builder(String baseUrl, String cookie) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 2bc0b0ce..c010d366 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -35,15 +35,13 @@ import java.util.Map; -import retrofit.HttpException; +import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.Path; import retrofit.http.QueryMap; -import rx.Observable; -import rx.functions.Func1; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; import static com.jaspersoft.android.sdk.network.api.Utils.headerToInt; @@ -61,101 +59,96 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NonNull @Override - public Observable searchResources(@Nullable Map searchParams) { - return mRestApi.searchResources(searchParams) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - // If we user Response return type we need manually handle 500 errors - if (response.isSuccess()) { - return Observable.just(response); - } - return Observable.error(new HttpException(response)); - } - }) - .flatMap(new Func1, Observable>() { - @Override - public Observable call(Response rawResponse) { - int status = rawResponse.code(); - ResourceSearchResponse entity; - if (status == 204) { - entity = ResourceSearchResponse.empty(); - } else { - entity = rawResponse.body(); - com.squareup.okhttp.Headers headers = rawResponse.headers(); - - int resultCount = headerToInt(headers, "Result-Count"); - int totalCount = headerToInt(headers, "Total-Count"); - int startIndex = headerToInt(headers, "Start-Index"); - int nextOffset = headerToInt(headers, "Next-Offset"); - - entity.setResultCount(resultCount); - entity.setTotalCount(totalCount); - entity.setStartIndex(startIndex); - entity.setNextOffset(nextOffset); - } - return Observable.just(entity); - } - }) - .onErrorResumeNext(RestErrorAdapter.get()); + public ResourceSearchResponse searchResources(@Nullable Map searchParams) { + Call call = mRestApi.searchResources(searchParams); + Response rawResponse = CallWrapper.wrap(call).response(); + + int status = rawResponse.code(); + ResourceSearchResponse entity; + if (status == 204) { + entity = ResourceSearchResponse.empty(); + } else { + entity = rawResponse.body(); + com.squareup.okhttp.Headers headers = rawResponse.headers(); + + int resultCount = headerToInt(headers, "Result-Count"); + int totalCount = headerToInt(headers, "Total-Count"); + int startIndex = headerToInt(headers, "Start-Index"); + int nextOffset = headerToInt(headers, "Next-Offset"); + + entity.setResultCount(resultCount); + entity.setTotalCount(totalCount); + entity.setStartIndex(startIndex); + entity.setNextOffset(nextOffset); + } + return entity; } @NonNull @Override - public Observable requestReportResource(@Nullable String resourceUri) { + public ReportLookupResponse requestReportResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Report uri should not be null"); - return mRestApi.requestReportResource(resourceUri) - .onErrorResumeNext(RestErrorAdapter.get()); + + Call call = mRestApi.requestReportResource(resourceUri); + return CallWrapper.wrap(call).body(); } @NonNull @Override - public Observable requestDashboardResource(@Nullable String resourceUri) { + public DashboardLookupResponse requestDashboardResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Dashboard uri should not be null"); - return mRestApi.requestDashboardResource(resourceUri) - .onErrorResumeNext(RestErrorAdapter.get()); + + Call call = mRestApi.requestDashboardResource(resourceUri); + return CallWrapper.wrap(call).body(); } @NonNull @Override - public Observable requestLegacyDashboardResource(@Nullable String resourceUri) { + public LegacyDashboardLookupResponse requestLegacyDashboardResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Legacy dashboard uri should not be null"); - return mRestApi.requestLegacyDashboardResource(resourceUri) - .onErrorResumeNext(RestErrorAdapter.get()); + + Call call = mRestApi.requestLegacyDashboardResource(resourceUri); + return CallWrapper.wrap(call).body(); } @NonNull @Override - public Observable requestFolderResource(@Nullable String resourceUri) { + public FolderLookupResponse requestFolderResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Folder uri should not be null"); - return mRestApi.requestFolderResource(resourceUri) - .onErrorResumeNext(RestErrorAdapter.get()); + + Call call = mRestApi.requestFolderResource(resourceUri); + return CallWrapper.wrap(call).body(); } private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("rest_v2/resources") - Observable> searchResources(@Nullable @QueryMap Map searchParams); + Call searchResources( + @Nullable @QueryMap Map searchParams); @NonNull @Headers("Accept: application/repository.reportUnit+json") @GET("rest_v2/resources{resourceUri}") - Observable requestReportResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); + Call requestReportResource( + @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.dashboard+json") @GET("rest_v2/resources{resourceUri}") - Observable requestDashboardResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); + Call requestDashboardResource( + @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.legacyDashboard+json") @GET("rest_v2/resources{resourceUri}") - Observable requestLegacyDashboardResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); + Call requestLegacyDashboardResource( + @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.folder+json") @GET("rest_v2/resources{resourceUri}") - Observable requestFolderResource(@NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); + Call requestFolderResource( + @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index ea1e06b1..7a789119 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; @@ -36,8 +37,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import rx.Observable; - import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -64,23 +63,11 @@ public void setup() { restApiUnderTest = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); } - @Test - public void shouldThroughRestErrorOnSearchRequestIfHttpError() { - mExpectedException.expect(RestError.class); - - mWebMockRule.enqueue(create500Response()); - - Observable call = restApiUnderTest.searchResources(null); - call.toBlocking().first(); - } - @Test public void shouldReturnEmptyResponseForNoContentResponse() { - mWebMockRule.enqueue(create204Response()); - - Observable call = restApiUnderTest.searchResources(null); - ResourceSearchResponse response = call.toBlocking().first(); + mWebMockRule.enqueue(MockResponseFactory.create204()); + ResourceSearchResponse response = restApiUnderTest.searchResources(null); assertThat(response.getResources(), is(empty())); } @@ -98,48 +85,45 @@ public void shouldThrowIllegalArgumentExceptionForNullCookie() { @Test public void requestForSearchShouldParseHeaderResultCount() { - MockResponse mockResponse = create200Response() + MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Result-Count", "100"); mWebMockRule.enqueue(mockResponse); - Observable call = restApiUnderTest.searchResources(null); - ResourceSearchResponse response = call.toBlocking().first(); + ResourceSearchResponse response = restApiUnderTest.searchResources(null); assertThat(response.getResultCount(), is(100)); } @Test public void requestForSearchShouldParseHeaderTotalCount() { - MockResponse mockResponse = create200Response() + MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Total-Count", "1000"); mWebMockRule.enqueue(mockResponse); - Observable call = restApiUnderTest.searchResources(null); - ResourceSearchResponse response = call.toBlocking().first(); + ResourceSearchResponse response = restApiUnderTest.searchResources(null); assertThat(response.getTotalCount(), is(1000)); } + @Test public void requestForSearchShouldParseHeaderStartIndex() { - MockResponse mockResponse = create200Response() + MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Start-Index", "5"); mWebMockRule.enqueue(mockResponse); - Observable call = restApiUnderTest.searchResources(null); - ResourceSearchResponse response = call.toBlocking().first(); + ResourceSearchResponse response = restApiUnderTest.searchResources(null); assertThat(response.getStartIndex(), is(5)); } @Test public void requestForSearchShouldParseHeaderNextOffset() { - MockResponse mockResponse = create200Response() + MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Next-Offset", "10"); mWebMockRule.enqueue(mockResponse); - Observable call = restApiUnderTest.searchResources(null); - ResourceSearchResponse response = call.toBlocking().first(); + ResourceSearchResponse response = restApiUnderTest.searchResources(null); assertThat(response.getNextOffset(), is(10)); } @@ -175,18 +159,48 @@ public void requestForFolderResourceShouldNotAcceptNullUri() { restApiUnderTest.requestFolderResource(null); } - private MockResponse create200Response() { - return new MockResponse() - .setStatus("HTTP/1.1 200 Ok"); + @Test + public void searchResourcesShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.searchResources(null); } - private MockResponse create204Response() { - return new MockResponse() - .setStatus("HTTP/1.1 204 No Content"); + @Test + public void requestReportResourceShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.requestReportResource("any_id"); } - private MockResponse create500Response() { - return new MockResponse() - .setStatus("HTTP/1.1 500 Internal Server Error"); + @Test + public void requestDashboardResourceShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.requestDashboardResource("any_id"); + } + + @Test + public void requestLegacyDashboardResourceShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.requestLegacyDashboardResource("any_id"); + } + + @Test + public void requestFolderResourceShouldThrowRestErrorOn500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.requestFolderResource("any_id"); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 15dad566..c58f38fb 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -36,8 +36,6 @@ import org.junit.Before; import org.junit.Test; -import rx.Observable; - import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; @@ -68,32 +66,28 @@ public void setup() { @Test public void shouldRequestListOfResources() { - Observable call = api.searchResources(null); - ResourceSearchResponse resourceSearchResponse = call.toBlocking().first(); + ResourceSearchResponse resourceSearchResponse = api.searchResources(null); assertThat(resourceSearchResponse, is(notNullValue())); assertThat(resourceSearchResponse.getResources(), is(not(empty()))); } @Test public void shouldRequestReport() { - Observable call = api.requestReportResource("/public/Samples/Reports/AllAccounts"); - ReportLookupResponse report = call.toBlocking().first(); + ReportLookupResponse report = api.requestReportResource("/public/Samples/Reports/AllAccounts"); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @Test public void shouldRequestDashboard() { - Observable call = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); - DashboardLookupResponse dashboard = call.toBlocking().first(); + DashboardLookupResponse dashboard = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); assertThat(dashboard, is(notNullValue())); assertThat(dashboard.getFoundations(), is(not(empty()))); } @Test public void shouldRequestRootFolder() { - Observable call = api.requestFolderResource("/"); - FolderLookupResponse folder = call.toBlocking().first(); + FolderLookupResponse folder = api.requestFolderResource("/"); assertThat(folder, is(notNullValue())); } From d24061eadae906261ce872b0fe44c9478db22669 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 12:52:23 +0300 Subject: [PATCH 112/457] Migrate Server Info Api to synchronous paradigm --- .../android/sdk/network/api/ServerRestApi.java | 10 +++------- .../android/sdk/network/api/ServerRestApiImpl.java | 10 +++++----- .../android/sdk/network/api/ServerRestApiTest.java | 10 +++------- .../sdk/test/integration/api/ServerRestTest.java | 5 +---- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index ff3d1031..1fbf5b23 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -25,13 +25,10 @@ package com.jaspersoft.android.sdk.network.api; import android.support.annotation.NonNull; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; -import retrofit.http.GET; -import retrofit.http.Headers; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 @@ -39,9 +36,8 @@ public interface ServerRestApi { @NonNull - @Headers("Accept: application/json") - @GET(value = "rest_v2/serverInfo") - Observable requestServerInfo(); + @WorkerThread + ServerInfoResponse requestServerInfo(); final class Builder extends BaseBuilder { public Builder(String baseUrl) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java index 01f48372..b57ded66 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java @@ -28,10 +28,10 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import retrofit.Call; import retrofit.Retrofit; import retrofit.http.GET; import retrofit.http.Headers; -import rx.Observable; /** * @author Tom Koptel @@ -47,15 +47,15 @@ public ServerRestApiImpl(Retrofit retrofit) { @NonNull @Override - public Observable requestServerInfo() { - return mApi.requestServerInfo() - .onErrorResumeNext(RestErrorAdapter.get()); + public ServerInfoResponse requestServerInfo() { + Call call = mApi.requestServerInfo(); + return CallWrapper.wrap(call).body(); } private interface RestApi { @NonNull @Headers("Accept: application/json") @GET(value = "rest_v2/serverInfo") - Observable requestServerInfo(); + Call requestServerInfo(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java index 5237d7af..476485c0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java @@ -24,8 +24,8 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; -import com.squareup.okhttp.mockwebserver.MockResponse; import org.junit.Rule; import org.junit.Test; @@ -46,10 +46,10 @@ public class ServerRestApiTest { public void shouldThroughRestErrorForHttpError() { mExpectedException.expect(RestError.class); - mWebMockRule.enqueue(create500Response()); + mWebMockRule.enqueue(MockResponseFactory.create500()); ServerRestApi restApi = new ServerRestApi.Builder(mWebMockRule.getRootUrl()).build(); - restApi.requestServerInfo().toBlocking().first(); + restApi.requestServerInfo(); } @Test @@ -58,8 +58,4 @@ public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { new ServerRestApi.Builder(null).build(); } - private MockResponse create500Response() { - return new MockResponse() - .setStatus("HTTP/1.1 500 Internal Server Error"); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 1e0da74d..b953c93d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -33,8 +33,6 @@ import java.io.IOException; -import rx.Observable; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -52,8 +50,7 @@ public void shouldRequestServerInfo() throws IOException { ServerRestApi api = new ServerRestApi.Builder(mobileDemo2) .setLog(TestLogger.get(this)) .build(); - Observable call = api.requestServerInfo(); - ServerInfoResponse response = call.toBlocking().first(); + ServerInfoResponse response = api.requestServerInfo(); assertThat(response, is(notNullValue())); } } From 18c3a3ed92dff0496c0c51f5c357d632e64357ce Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 12:54:44 +0300 Subject: [PATCH 113/457] Removing RX dependency --- client-network/build.gradle | 1 - .../android/sdk/network/api/BaseBuilder.java | 2 - .../android/sdk/network/api/RestError.java | 6 --- .../sdk/network/api/RestErrorAdapter.java | 51 ------------------- 4 files changed, 60 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java diff --git a/client-network/build.gradle b/client-network/build.gradle index b2e4425e..1dc735cf 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -37,7 +37,6 @@ dependencies { compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' - compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index 77a112d5..f24428d1 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -29,7 +29,6 @@ import com.squareup.okhttp.OkHttpClient; import retrofit.Retrofit; -import retrofit.RxJavaCallAdapterFactory; /** * TODO separate OkHttp client creation from Retrofit client @@ -55,7 +54,6 @@ public BaseBuilder(String baseUrl){ Gson configuredGson = GsonFactory.create(); mRestAdapterBuilder.addConverterFactory(GsonConverterFactory.create(configuredGson)); - mRestAdapterBuilder.addCallAdapterFactory(RxJavaCallAdapterFactory.create()); } @SuppressWarnings("unchecked") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java index 2aa61b0b..3b44c6c7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java @@ -29,7 +29,6 @@ import java.io.IOException; -import retrofit.HttpException; import retrofit.Response; /** @@ -45,11 +44,6 @@ static RestError networkError(IOException exception) { exception); } - static RestError httpError(HttpException httpException) { - Response response = httpException.response(); - return httpError(response.raw()); - } - static RestError httpError(Response response) { return httpError(response.raw()); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java deleted file mode 100644 index 906f6474..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestErrorAdapter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import retrofit.HttpException; -import rx.Observable; -import rx.functions.Func1; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RestErrorAdapter { - private RestErrorAdapter() {} - - public static Func1> get() { - return new Func1>() { - @Override - public Observable call(Throwable throwable) { - Class exceptionClass = throwable.getClass(); - if (HttpException.class.isAssignableFrom(exceptionClass)) { - HttpException httpException = (HttpException) throwable; - return Observable.error(RestError.httpError(httpException.response().raw())); - } - return Observable.error(RestError.unexpectedError(throwable)); - } - }; - } -} From c11f5309281d436688c560b65372bc094dcd2f89 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 16:23:47 +0300 Subject: [PATCH 114/457] Add visitor pattern to abstract Token implementations --- .../sdk/network/api/AuthBaseBuilder.java | 35 ++++++++++--- ...ceptor.java => CookieAuthInterceptor.java} | 14 ++--- .../sdk/network/api/DefaultAuthPolicy.java | 47 +++++++++++++++++ .../sdk/network/api/ReportOptionRestApi.java | 4 +- .../sdk/network/api/auth/AuthPolicy.java | 33 ++++++++++++ .../sdk/network/api/auth/CookieToken.java | 51 +++++++++++++++++++ .../android/sdk/network/api/auth/Token.java | 34 +++++++++++++ .../network/api/ReportOptionRestApiTest.java | 2 +- .../api/ReportOptionRestApiTest.java | 4 +- 9 files changed, 206 insertions(+), 18 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{AuthInterceptor.java => CookieAuthInterceptor.java} (83%) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AuthPolicy.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java index 677c144c..95700e36 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java @@ -24,27 +24,48 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.AuthPolicy; +import com.jaspersoft.android.sdk.network.api.auth.Token; + /** * @author Tom Koptel * @since 2.0 */ abstract class AuthBaseBuilder extends BaseBuilder { + private Token mToken; private final String mCookie; + private final AuthPolicy mAuthPolicy; public AuthBaseBuilder(String baseUrl, String cookie) { super(baseUrl); - if (cookie == null || cookie.length() == 0) { - throw new IllegalArgumentException("Cookie should not be null or empty"); - } mCookie = cookie; + mAuthPolicy = new DefaultAuthPolicy(getClient()); + } + + @SuppressWarnings("unchecked") + public SubBuilder setToken(Token token) { + mToken = token; + return (SubBuilder) this; + } + + @Override + public API build() { +// ensureSaneDefaults(); setupAuthenticator(); + return super.build(); } - private void setupAuthenticator() { - getClient().interceptors().add(AuthInterceptor.newInstance(mCookie)); + private void ensureSaneDefaults() { + if (mToken == null) { + throw new IllegalStateException("This API requires authentication"); + } } - public String getCookie() { - return mCookie; + private void setupAuthenticator() { + if (mCookie == null) { + mToken.acceptPolicy(mAuthPolicy); + } else { + getClient().interceptors().add(CookieAuthInterceptor.newInstance(mCookie)); + } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java similarity index 83% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java index e97d91a3..f750b7ab 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java @@ -36,23 +36,23 @@ * @author Tom Koptel * @since 2.0 */ -final class AuthInterceptor implements Interceptor { - private final String mToken; +final class CookieAuthInterceptor implements Interceptor { + private final String mCookie; - AuthInterceptor(String token) { - mToken = token; + CookieAuthInterceptor(String cookie) { + mCookie = cookie; } - public static AuthInterceptor newInstance(String token) { + public static CookieAuthInterceptor newInstance(String token) { checkNotNull(token, "Token should not be null"); - return new AuthInterceptor(token); + return new CookieAuthInterceptor(token); } @Override public Response intercept(Chain chain) throws IOException { Request originalRequest = chain.request(); Request compressedRequest = originalRequest.newBuilder() - .header("Cookie", mToken) + .header("Cookie", mCookie) .build(); return chain.proceed(compressedRequest); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java new file mode 100644 index 00000000..dfd5f4a1 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java @@ -0,0 +1,47 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.auth.AuthPolicy; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; +import com.squareup.okhttp.OkHttpClient; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class DefaultAuthPolicy implements AuthPolicy { + + private final OkHttpClient mHttpClient; + + DefaultAuthPolicy(OkHttpClient httpClient) { + mHttpClient = httpClient; + } + + @Override + public void applyCookieToken(CookieToken token) { + mHttpClient.interceptors().add(CookieAuthInterceptor.newInstance(token.get())); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 4f313fa0..13d0ee7c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -60,8 +60,8 @@ void deleteReportOption(@NonNull String reportUnitUri, @NonNull String optionId); final class Builder extends AuthBaseBuilder { - public Builder(String baseUrl, String cookie) { - super(baseUrl, cookie); + public Builder(String baseUrl) { + super(baseUrl, null); } @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AuthPolicy.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AuthPolicy.java new file mode 100644 index 00000000..c1e7cca7 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AuthPolicy.java @@ -0,0 +1,33 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api.auth; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface AuthPolicy { + void applyCookieToken(CookieToken token); +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java new file mode 100644 index 00000000..86157f3a --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java @@ -0,0 +1,51 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api.auth; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class CookieToken implements Token { + private final String mCookie; + + private CookieToken(String cookie) { + mCookie = cookie; + } + + public static CookieToken newInstance(String cookie) { + return new CookieToken(cookie); + } + + @Override + public String get() { + return mCookie; + } + + @Override + public void acceptPolicy(AuthPolicy policy) { + policy.applyCookieToken(this); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java new file mode 100644 index 00000000..77c681d0 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java @@ -0,0 +1,34 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api.auth; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface Token { + RawToken get(); + void acceptPolicy(AuthPolicy policy); +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index 7f321ee5..2c6e6ba7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -49,7 +49,7 @@ public class ReportOptionRestApiTest { @Before public void setup() { - restApiUnderTest = new ReportOptionRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + restApiUnderTest = new ReportOptionRestApi.Builder(mWebMockRule.getRootUrl()).build(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 97f4044c..b6512441 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.ReportOptionRestApi; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; import com.jaspersoft.android.sdk.test.TestLogger; @@ -69,8 +70,9 @@ public void setup() { String cookie = mAuthenticator.getCookie(); if (apiUnderTest == null) { - apiUnderTest = new ReportOptionRestApi.Builder(mMetadata.getServerUrl(), cookie) + apiUnderTest = new ReportOptionRestApi.Builder(mMetadata.getServerUrl()) .setLog(TestLogger.get(this)) + .setToken(CookieToken.newInstance(cookie)) .build(); } } From 0eff567ebc0398f6d59d560c08b1e56c5fca9086 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Sep 2015 17:32:07 +0300 Subject: [PATCH 115/457] Easy Builder creation API --- .../sdk/network/api/AuthBaseBuilder.java | 19 ++-------- .../android/sdk/network/api/BaseBuilder.java | 38 +++++++++++++++---- .../sdk/network/api/InputControlRestApi.java | 4 -- .../network/api/ReportExecutionRestApi.java | 4 -- .../sdk/network/api/ReportExportRestApi.java | 4 -- .../sdk/network/api/ReportOptionRestApi.java | 4 -- .../sdk/network/api/RepositoryRestApi.java | 4 -- .../sdk/network/api/ServerRestApi.java | 4 -- .../android/sdk/network/api/Utils.java | 12 ++++-- .../network/api/InputControlRestApiTest.java | 24 ++++++------ .../api/ReportExecutionRestApiTest.java | 24 ++++++------ .../network/api/ReportExportRestApiTest.java | 24 ++++++------ .../network/api/ReportOptionRestApiTest.java | 12 +++++- .../network/api/RepositoryRestApiTest.java | 24 ++++++------ .../sdk/network/api/ServerRestApiTest.java | 12 +++--- .../android/sdk/network/api/UtilsTest.java | 14 ++++++- .../api/InputControlRestApiTest.java | 5 ++- .../api/ReportExecutionRestApiTest.java | 5 ++- .../api/ReportExportRestApiTest.java | 9 ++++- .../api/ReportOptionRestApiTest.java | 3 +- .../api/RepositoryRestApiTest.java | 5 ++- .../test/integration/api/ServerRestTest.java | 3 +- 22 files changed, 138 insertions(+), 119 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java index 95700e36..a4cd9a46 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java @@ -33,12 +33,9 @@ */ abstract class AuthBaseBuilder extends BaseBuilder { private Token mToken; - private final String mCookie; private final AuthPolicy mAuthPolicy; - public AuthBaseBuilder(String baseUrl, String cookie) { - super(baseUrl); - mCookie = cookie; + public AuthBaseBuilder() { mAuthPolicy = new DefaultAuthPolicy(getClient()); } @@ -50,22 +47,14 @@ public SubBuilder setToken(Token token) { @Override public API build() { -// ensureSaneDefaults(); - setupAuthenticator(); - return super.build(); - } - - private void ensureSaneDefaults() { if (mToken == null) { throw new IllegalStateException("This API requires authentication"); } + setupAuthenticator(); + return super.build(); } private void setupAuthenticator() { - if (mCookie == null) { - mToken.acceptPolicy(mAuthPolicy); - } else { - getClient().interceptors().add(CookieAuthInterceptor.newInstance(mCookie)); - } + mToken.acceptPolicy(mAuthPolicy); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java index f24428d1..b62e748b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java @@ -26,10 +26,15 @@ import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; +import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; +import retrofit.Converter; import retrofit.Retrofit; +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; + + /** * TODO separate OkHttp client creation from Retrofit client * @@ -39,21 +44,29 @@ abstract class BaseBuilder { private final Retrofit.Builder mRestAdapterBuilder; private final OkHttpClient mOkHttpClient; + private final Converter.Factory mConverterFactory; private RestApiLog mLog = RestApiLog.NONE; + private HttpUrl mBaseUrl; - public BaseBuilder(String baseUrl){ - if (baseUrl == null || baseUrl.length() == 0) { - throw new IllegalArgumentException("Base url should not be null or empty"); - } + public BaseBuilder() { mOkHttpClient = new OkHttpClient(); mRestAdapterBuilder = new Retrofit.Builder(); - mRestAdapterBuilder.client(mOkHttpClient); - mRestAdapterBuilder.baseUrl(Utils.normalizeBaseUrl(baseUrl)); - Gson configuredGson = GsonFactory.create(); - mRestAdapterBuilder.addConverterFactory(GsonConverterFactory.create(configuredGson)); + mConverterFactory = GsonConverterFactory.create(configuredGson); + } + + @SuppressWarnings("unchecked") + public SubBuilder baseUrl(String baseUrl) { + checkNotNull(baseUrl, "baseUrl == null"); + baseUrl = Utils.normalizeBaseUrl(baseUrl); + HttpUrl httpUrl = HttpUrl.parse(baseUrl); + if (httpUrl == null) { + throw new IllegalArgumentException("Illegal URL: " + baseUrl); + } + mBaseUrl = httpUrl; + return (SubBuilder) this; } @SuppressWarnings("unchecked") @@ -73,7 +86,16 @@ OkHttpClient getClient() { abstract API createApi(); public API build() { + if (mBaseUrl == null) { + throw new IllegalStateException("Base url should be supplied to work with JRS API"); + } + mOkHttpClient.interceptors().add(new LoggingInterceptor(mLog)); + + mRestAdapterBuilder.client(mOkHttpClient); + mRestAdapterBuilder.baseUrl(mBaseUrl); + mRestAdapterBuilder.addConverterFactory(mConverterFactory); + return createApi(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 771850e2..105af3b4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -75,10 +75,6 @@ InputControlValueResponse requestInputControlsStates(@NonNull String reportUri, boolean freshData); final class Builder extends AuthBaseBuilder { - public Builder(String baseUrl, String cookie) { - super(baseUrl, cookie); - } - @Override InputControlRestApi createApi() { return new InputControlRestApiImpl(getDefaultBuilder().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 5518f3fb..7be49241 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -68,10 +68,6 @@ public interface ReportExecutionRestApi { ReportExecutionSearchResponse searchReportExecution(Map params); final class Builder extends AuthBaseBuilder { - public Builder(String baseUrl, String cookie) { - super(baseUrl, cookie); - } - @Override ReportExecutionRestApi createApi() { return new ReportExecutionRestApiImpl(getDefaultBuilder().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 326017a6..78d46676 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -56,10 +56,6 @@ public interface ReportExportRestApi { ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); final class Builder extends AuthBaseBuilder { - public Builder(String baseUrl, String cookie) { - super(baseUrl, cookie); - } - @Override ReportExportRestApi createApi() { return new ReportExportRestApiImpl(getDefaultBuilder().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 13d0ee7c..1a972198 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -60,10 +60,6 @@ void deleteReportOption(@NonNull String reportUnitUri, @NonNull String optionId); final class Builder extends AuthBaseBuilder { - public Builder(String baseUrl) { - super(baseUrl, null); - } - @Override ReportOptionRestApi createApi() { return new ReportOptionRestApiImpl(getDefaultBuilder().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 7f79a9a6..444c9f4d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -62,10 +62,6 @@ public interface RepositoryRestApi { FolderLookupResponse requestFolderResource(@NonNull String resourceUri); final class Builder extends AuthBaseBuilder { - public Builder(String baseUrl, String cookie) { - super(baseUrl, cookie); - } - @Override RepositoryRestApi createApi() { return new RepositoryRestApiImpl(getDefaultBuilder().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 1fbf5b23..156731a2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -40,10 +40,6 @@ public interface ServerRestApi { ServerInfoResponse requestServerInfo(); final class Builder extends BaseBuilder { - public Builder(String baseUrl) { - super(baseUrl); - } - @Override ServerRestApi createApi() { return new ServerRestApiImpl(getDefaultBuilder().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java index 41f8d876..6643ef54 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java @@ -61,11 +61,15 @@ public static int headerToInt(com.squareup.okhttp.Headers headers, String key) { } } - public static String normalizeBaseUrl(String baseUrl) { - if (baseUrl.endsWith("/")) { - return baseUrl; + public static String normalizeBaseUrl(String url) { + // If url is empty skip appending slash + if (url == null || url.length() == 0) { + return url; } - return baseUrl + "/"; + if (url.endsWith("/")) { + return url; + } + return url + "/"; } public static String bodyToString(ResponseBody responseBody) { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index daf07879..41b54802 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -1,5 +1,6 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -7,6 +8,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import java.util.Collections; @@ -22,23 +25,18 @@ public class InputControlRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); + @Mock + Token mToken; + private InputControlRestApi restApiUnderTest; @Before public void setup() { - restApiUnderTest = new InputControlRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { - mExpectedException.expect(IllegalArgumentException.class); - new InputControlRestApi.Builder(null, "cookie").build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullCookie() { - mExpectedException.expect(IllegalArgumentException.class); - InputControlRestApi restApi = new InputControlRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); + MockitoAnnotations.initMocks(this); + restApiUnderTest = new InputControlRestApi.Builder() + .setToken(mToken) + .baseUrl(mWebMockRule.getRootUrl()) + .build(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index 987fdbc1..801ba7b4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -36,6 +37,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import java.io.IOException; import java.util.Collections; @@ -69,22 +72,17 @@ public class ReportExecutionRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private ReportExecutionRestApi restApiUnderTest; + @Mock + Token mToken; + @Before public void setup() { + MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); - restApiUnderTest = new ReportExecutionRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { - mExpectedException.expect(IllegalArgumentException.class); - new RepositoryRestApi.Builder(null, "cookie").build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullCookie() { - mExpectedException.expect(IllegalArgumentException.class); - RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); + restApiUnderTest = new ReportExecutionRestApi.Builder() + .setToken(mToken) + .baseUrl(mWebMockRule.getRootUrl()) + .build(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index de57b430..40443a7d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; @@ -38,6 +39,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import java.io.IOException; import java.io.InputStream; @@ -62,22 +65,17 @@ public class ReportExportRestApiTest { @ResourceFile("json/root_folder.json") TestResource mResource; + @Mock + Token mToken; + @Before public void setup() { + MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); - restApiUnderTest = new ReportExportRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { - mExpectedException.expect(IllegalArgumentException.class); - new ReportExportRestApi.Builder(null, "cookie").build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullCookie() { - mExpectedException.expect(IllegalArgumentException.class); - new ReportExportRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); + restApiUnderTest = new ReportExportRestApi.Builder() + .setToken(mToken) + .baseUrl(mWebMockRule.getRootUrl()) + .build(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index 2c6e6ba7..c527d202 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -31,6 +32,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import java.util.Collections; @@ -47,9 +50,16 @@ public class ReportOptionRestApiTest { private ReportOptionRestApi restApiUnderTest; + @Mock + Token mToken; + @Before public void setup() { - restApiUnderTest = new ReportOptionRestApi.Builder(mWebMockRule.getRootUrl()).build(); + MockitoAnnotations.initMocks(this); + restApiUnderTest = new ReportOptionRestApi.Builder() + .setToken(mToken) + .baseUrl(mWebMockRule.getRootUrl()) + .build(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index 7a789119..9de0f2e9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -36,6 +37,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; @@ -57,10 +60,17 @@ public class RepositoryRestApiTest { private RepositoryRestApi restApiUnderTest; + @Mock + Token mToken; + @Before public void setup() { + MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); - restApiUnderTest = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), "cookie").build(); + restApiUnderTest = new RepositoryRestApi.Builder() + .setToken(mToken) + .baseUrl(mWebMockRule.getRootUrl()) + .build(); } @Test @@ -71,18 +81,6 @@ public void shouldReturnEmptyResponseForNoContentResponse() { assertThat(response.getResources(), is(empty())); } - @Test - public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { - mExpectedException.expect(IllegalArgumentException.class); - new RepositoryRestApi.Builder(null, "cookie").build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullCookie() { - mExpectedException.expect(IllegalArgumentException.class); - RepositoryRestApi restApi = new RepositoryRestApi.Builder(mWebMockRule.getRootUrl(), null).build(); - } - @Test public void requestForSearchShouldParseHeaderResultCount() { MockResponse mockResponse = MockResponseFactory.create200() diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java index 476485c0..83b2cb30 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java @@ -27,9 +27,11 @@ import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.MockitoAnnotations; /** * @author Tom Koptel @@ -48,14 +50,10 @@ public void shouldThroughRestErrorForHttpError() { mWebMockRule.enqueue(MockResponseFactory.create500()); - ServerRestApi restApi = new ServerRestApi.Builder(mWebMockRule.getRootUrl()).build(); + ServerRestApi restApi = new ServerRestApi.Builder() + .baseUrl(mWebMockRule.getRootUrl()) + .build(); restApi.requestServerInfo(); } - @Test - public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { - mExpectedException.expect(IllegalArgumentException.class); - new ServerRestApi.Builder(null).build(); - } - } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java index 2df2e6c2..46d8583c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java @@ -28,6 +28,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; /** * @author Tom Koptel @@ -37,8 +38,19 @@ public class UtilsTest { @Test public void normalizeBaseUrlShouldAddTrailingSlashIfMissing() { - String url = "http://some.http"; + String url = "http://mobiledemo.jaspersoft.com/jasperserver-pro"; assertThat(Utils.normalizeBaseUrl(url), is(url + "/")); } + @Test + public void normalizeBaseUrlShouldNotNormalizeEmptyString() { + String url = ""; + assertThat(Utils.normalizeBaseUrl(url), is("")); + } + @Test + public void normalizeBaseUrlShouldNotNormalizeNullString() { + String url = null; + assertThat(Utils.normalizeBaseUrl(url), is(nullValue())); + } + } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index d990e009..7d1893cb 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.InputControlRestApi; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; @@ -69,7 +70,9 @@ public class InputControlRestApiTest { public void setup() { mAuthenticator.authorize(); String cookie = mAuthenticator.getCookie(); - mRestApi = new InputControlRestApi.Builder(mMetadata.getServerUrl(), cookie) + mRestApi = new InputControlRestApi.Builder() + .setToken(CookieToken.newInstance(cookie)) + .baseUrl(mMetadata.getServerUrl()) .setLog(TestLogger.get(this)) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 2dc88be1..254a28d2 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; @@ -70,7 +71,9 @@ public void setup() { String cookie = mAuthenticator.getCookie(); if (apiUnderTest == null) { - apiUnderTest = new ReportExecutionRestApi.Builder(mMetadata.getServerUrl(), cookie) + apiUnderTest = new ReportExecutionRestApi.Builder() + .setToken(CookieToken.newInstance(cookie)) + .baseUrl(mMetadata.getServerUrl()) .setLog(TestLogger.get(this)) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 3de42328..62b83132 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; @@ -66,13 +67,17 @@ public void setup() { String cookie = mAuthenticator.getCookie(); if (mExecApi == null) { - mExecApi = new ReportExecutionRestApi.Builder(mMetadata.getServerUrl(), cookie) + mExecApi = new ReportExecutionRestApi.Builder() + .setToken(CookieToken.newInstance(cookie)) + .baseUrl(mMetadata.getServerUrl()) .setLog(TestLogger.get(this)) .build(); } if (apiUnderTest == null) { - apiUnderTest = new ReportExportRestApi.Builder(mMetadata.getServerUrl(), cookie) + apiUnderTest = new ReportExportRestApi.Builder() + .setToken(CookieToken.newInstance(cookie)) + .baseUrl(mMetadata.getServerUrl()) .setLog(TestLogger.get(this)) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index b6512441..e98dc645 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -70,9 +70,10 @@ public void setup() { String cookie = mAuthenticator.getCookie(); if (apiUnderTest == null) { - apiUnderTest = new ReportOptionRestApi.Builder(mMetadata.getServerUrl()) + apiUnderTest = new ReportOptionRestApi.Builder() .setLog(TestLogger.get(this)) .setToken(CookieToken.newInstance(cookie)) + .baseUrl(mMetadata.getServerUrl()) .build(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index c58f38fb..1c3bc6d0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; @@ -58,7 +59,9 @@ public void setup() { String cookie = mAuthenticator.getCookie(); if (api == null) { - api = new RepositoryRestApi.Builder(mMetadata.getServerUrl(), cookie) + api = new RepositoryRestApi.Builder() + .setToken(CookieToken.newInstance(cookie)) + .baseUrl(mMetadata.getServerUrl()) .setLog(TestLogger.get(this)) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index b953c93d..35e933f0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -47,8 +47,9 @@ public class ServerRestTest { @Test public void shouldRequestServerInfo() throws IOException { - ServerRestApi api = new ServerRestApi.Builder(mobileDemo2) + ServerRestApi api = new ServerRestApi.Builder() .setLog(TestLogger.get(this)) + .baseUrl(mobileDemo2) .build(); ServerInfoResponse response = api.requestServerInfo(); assertThat(response, is(notNullValue())); From a7df75e0258b80f029f4bcd5e173932b61492cd7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:15:40 +0300 Subject: [PATCH 116/457] Generifying creation of API objects --- .../{BaseBuilder.java => AdapterBuilder.java} | 57 +++++-------- ...{AuthBaseBuilder.java => AuthBuilder.java} | 31 +++---- .../network/api/AuthenticationRestApi.java | 25 ++---- .../api/AuthenticationRestApiImpl.java | 4 +- .../sdk/network/api/ClientBuilder.java | 57 +++++++++++++ .../sdk/network/api/GenericAuthBuilder.java | 80 +++++++++++++++++++ .../sdk/network/api/GenericBuilder.java | 69 ++++++++++++++++ .../sdk/network/api/InputControlRestApi.java | 18 ++--- .../network/api/ReportExecutionRestApi.java | 4 +- .../sdk/network/api/ReportExportRestApi.java | 4 +- .../sdk/network/api/ReportOptionRestApi.java | 4 +- .../sdk/network/api/RepositoryRestApi.java | 4 +- .../sdk/network/api/ServerRestApi.java | 4 +- .../api/AuthenticationRestApiTest.java | 10 +-- .../network/api/InputControlRestApiTest.java | 2 +- .../api/ReportExecutionRestApiTest.java | 2 +- .../network/api/ReportExportRestApiTest.java | 2 +- .../network/api/ReportOptionRestApiTest.java | 2 +- .../network/api/RepositoryRestApiTest.java | 2 +- .../api/AuthenticationRestApiTest.java | 5 +- .../api/InputControlRestApiTest.java | 4 +- .../api/ReportExecutionRestApiTest.java | 4 +- .../api/ReportExportRestApiTest.java | 8 +- .../api/ReportOptionRestApiTest.java | 4 +- .../api/RepositoryRestApiTest.java | 4 +- .../test/integration/api/ServerRestTest.java | 2 +- .../api/utils/TestAuthenticator.java | 4 +- 27 files changed, 297 insertions(+), 119 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{BaseBuilder.java => AdapterBuilder.java} (64%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{AuthBaseBuilder.java => AuthBuilder.java} (69%) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java similarity index 64% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java index b62e748b..0ddf223f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/BaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -29,73 +29,54 @@ import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; -import retrofit.Converter; import retrofit.Retrofit; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - /** - * TODO separate OkHttp client creation from Retrofit client - * * @author Tom Koptel * @since 2.0 */ -abstract class BaseBuilder { +final class AdapterBuilder { private final Retrofit.Builder mRestAdapterBuilder; - private final OkHttpClient mOkHttpClient; - private final Converter.Factory mConverterFactory; + private final GsonConverterFactory mConverterFactory; - private RestApiLog mLog = RestApiLog.NONE; - private HttpUrl mBaseUrl; + final ClientBuilder clientBuilder; + HttpUrl baseUrl; - public BaseBuilder() { - mOkHttpClient = new OkHttpClient(); + public AdapterBuilder(ClientBuilder clientBuilder){ mRestAdapterBuilder = new Retrofit.Builder(); Gson configuredGson = GsonFactory.create(); mConverterFactory = GsonConverterFactory.create(configuredGson); + + this.clientBuilder = clientBuilder; } @SuppressWarnings("unchecked") - public SubBuilder baseUrl(String baseUrl) { + public AdapterBuilder baseUrl(String baseUrl) { checkNotNull(baseUrl, "baseUrl == null"); baseUrl = Utils.normalizeBaseUrl(baseUrl); HttpUrl httpUrl = HttpUrl.parse(baseUrl); if (httpUrl == null) { throw new IllegalArgumentException("Illegal URL: " + baseUrl); } - mBaseUrl = httpUrl; - return (SubBuilder) this; + this.baseUrl = httpUrl; + return this; } - @SuppressWarnings("unchecked") - public SubBuilder setLog(RestApiLog log) { - mLog = log; - return (SubBuilder) this; - } - - Retrofit.Builder getDefaultBuilder() { - return mRestAdapterBuilder; - } - - OkHttpClient getClient() { - return mOkHttpClient; - } - - abstract API createApi(); - - public API build() { - if (mBaseUrl == null) { + public void ensureDefaults() { + if (baseUrl == null) { throw new IllegalStateException("Base url should be supplied to work with JRS API"); } + } - mOkHttpClient.interceptors().add(new LoggingInterceptor(mLog)); - - mRestAdapterBuilder.client(mOkHttpClient); - mRestAdapterBuilder.baseUrl(mBaseUrl); + Retrofit createAdapter() { + OkHttpClient client = clientBuilder.build(); + mRestAdapterBuilder.client(client); + mRestAdapterBuilder.baseUrl(baseUrl); mRestAdapterBuilder.addConverterFactory(mConverterFactory); - return createApi(); + return mRestAdapterBuilder.build(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java similarity index 69% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java index a4cd9a46..43bad25a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBaseBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java @@ -24,37 +24,40 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.AuthPolicy; import com.jaspersoft.android.sdk.network.api.auth.Token; +import com.squareup.okhttp.OkHttpClient; + +import retrofit.Retrofit; /** * @author Tom Koptel * @since 2.0 */ -abstract class AuthBaseBuilder extends BaseBuilder { +final class AuthBuilder { + private final AdapterBuilder mAdapterBuilder; private Token mToken; - private final AuthPolicy mAuthPolicy; - public AuthBaseBuilder() { - mAuthPolicy = new DefaultAuthPolicy(getClient()); + public AuthBuilder(AdapterBuilder adapterBuilder) { + mAdapterBuilder = adapterBuilder; } - @SuppressWarnings("unchecked") - public SubBuilder setToken(Token token) { + public AuthBuilder setToken(Token token) { mToken = token; - return (SubBuilder) this; + return this; } - @Override - public API build() { + void ensureDefaults() { if (mToken == null) { throw new IllegalStateException("This API requires authentication"); } - setupAuthenticator(); - return super.build(); } - private void setupAuthenticator() { - mToken.acceptPolicy(mAuthPolicy); + Retrofit createAdapter() { + OkHttpClient client = mAdapterBuilder.clientBuilder.getClient(); + + DefaultAuthPolicy authPolicy = new DefaultAuthPolicy(client); + mToken.acceptPolicy(authPolicy); + + return mAdapterBuilder.createAdapter(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index 85b2b50a..c2fa3d70 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -29,6 +29,7 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; import java.util.Map; @@ -45,25 +46,13 @@ AuthResponse authenticate(@NonNull String username, @Nullable String organization, @Nullable Map params); - final class Builder { - private final String mBaseUrl; - private RestApiLog mLog = RestApiLog.NONE; - - public Builder(String baseUrl) { - Utils.checkNotNull(baseUrl, "Base url should not be null"); - mBaseUrl = Utils.normalizeBaseUrl(baseUrl); - } - - public Builder setLog(RestApiLog log) { - mLog = log; - return this; - } - - public AuthenticationRestApi build() { - OkHttpClient okHttpClient = new OkHttpClient(); + final class Builder extends GenericBuilder { + @Override + AuthenticationRestApi createApi() { + HttpUrl baseUrl = adapterBuilder.baseUrl; + OkHttpClient okHttpClient = clientBuilder.getClient(); okHttpClient.setFollowRedirects(false); - okHttpClient.interceptors().add(new LoggingInterceptor(mLog)); - return new AuthenticationRestApiImpl(mBaseUrl, okHttpClient); + return new AuthenticationRestApiImpl(baseUrl, okHttpClient); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index d821d48a..7ec89677 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -44,10 +44,10 @@ * @since 2.0 */ final class AuthenticationRestApiImpl implements AuthenticationRestApi { - private final String mBaseUrl; + private final HttpUrl mBaseUrl; private final OkHttpClient mClient; - AuthenticationRestApiImpl(String baseUrl, OkHttpClient okHttpClient) { + AuthenticationRestApiImpl(HttpUrl baseUrl, OkHttpClient okHttpClient) { mBaseUrl = baseUrl; mClient = okHttpClient; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java new file mode 100644 index 00000000..74927a6f --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.squareup.okhttp.OkHttpClient; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ClientBuilder { + private final OkHttpClient mOkHttpClient; + private RestApiLog mLog = RestApiLog.NONE; + + public ClientBuilder() { + mOkHttpClient = new OkHttpClient(); + } + + public ClientBuilder setLog(RestApiLog log) { + mLog = log; + return this; + } + + public OkHttpClient build() { + mOkHttpClient.interceptors().add(new LoggingInterceptor(mLog)); + return mOkHttpClient; + } + + OkHttpClient getClient() { + return mOkHttpClient; + } + + void ensureDefaults() { + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java new file mode 100644 index 00000000..f3e3a61c --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +import retrofit.Retrofit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class GenericAuthBuilder { + private final ClientBuilder mClientBuilder; + private final AdapterBuilder mAdapterBuilder; + private final AuthBuilder mAuthBuilder; + + public GenericAuthBuilder() { + mClientBuilder = new ClientBuilder(); + mAdapterBuilder = new AdapterBuilder(mClientBuilder); + mAuthBuilder = new AuthBuilder(mAdapterBuilder); + } + + @SuppressWarnings("unchecked") + public TargetBuilder baseUrl(String baseUrl) { + mAdapterBuilder.baseUrl(baseUrl); + return (TargetBuilder) this; + } + + @SuppressWarnings("unchecked") + public TargetBuilder log(RestApiLog log) { + mClientBuilder.setLog(log); + return (TargetBuilder) this; + } + + @SuppressWarnings("unchecked") + public TargetBuilder token(Token token) { + mAuthBuilder.setToken(token); + return (TargetBuilder) this; + } + + abstract Api createApi(); + + public Api build() { + ensureDefaults(); + return createApi(); + } + + void ensureDefaults() { + mClientBuilder.ensureDefaults(); + mAdapterBuilder.ensureDefaults(); + mAuthBuilder.ensureDefaults(); + } + + Retrofit createAdapter() { + return mAuthBuilder.createAdapter(); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java new file mode 100644 index 00000000..85da93de --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import retrofit.Retrofit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class GenericBuilder { + protected final ClientBuilder clientBuilder; + protected final AdapterBuilder adapterBuilder; + + public GenericBuilder() { + clientBuilder = new ClientBuilder(); + adapterBuilder = new AdapterBuilder(clientBuilder); + } + + @SuppressWarnings("unchecked") + public TargetBuilder baseUrl(String baseUrl) { + adapterBuilder.baseUrl(baseUrl); + return (TargetBuilder) this; + } + + @SuppressWarnings("unchecked") + public TargetBuilder log(RestApiLog log) { + clientBuilder.setLog(log); + return (TargetBuilder) this; + } + + void ensureDefaults() { + clientBuilder.ensureDefaults(); + adapterBuilder.ensureDefaults(); + } + + Retrofit createAdapter() { + return adapterBuilder.createAdapter(); + } + + abstract Api createApi(); + + public Api build() { + ensureDefaults(); + return createApi(); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 105af3b4..48d16b90 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -43,10 +43,10 @@ public interface InputControlRestApi { /** * Returns input controls for associated response. Options can be excluded by additional argument. - * + *

* ATTENTION: Exclude flag works only on JRS instances 6.0+ * - * @param reportUri uri of report + * @param reportUri uri of report * @param excludeState exclude field state which incorporates options values for control * @return unmodifiable list of {@link InputControl} */ @@ -57,27 +57,27 @@ public interface InputControlRestApi { @NonNull @WorkerThread InputControlValueResponse requestInputControlsInitialStates(@NonNull String reportUri, - boolean freshData); + boolean freshData); /** * Provides values for specified controls. This API helpful to * delegate cascading resolving for the server, also should handle non-cascading cases * - * @param reportUri uri of report + * @param reportUri uri of report * @param controlsValues map of {control_id: [value, value]} associated input controls metadata - * @param freshData whether data should be retrieved from cache or not + * @param freshData whether data should be retrieved from cache or not * @return unmodifiable list of {@link InputControlState} */ @NonNull @WorkerThread InputControlValueResponse requestInputControlsStates(@NonNull String reportUri, - @NonNull Map> controlsValues, - boolean freshData); + @NonNull Map> controlsValues, + boolean freshData); - final class Builder extends AuthBaseBuilder { + final class Builder extends GenericAuthBuilder { @Override InputControlRestApi createApi() { - return new InputControlRestApiImpl(getDefaultBuilder().build()); + return new InputControlRestApiImpl(createAdapter()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 7be49241..3a0913d0 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -67,10 +67,10 @@ public interface ReportExecutionRestApi { @WorkerThread ReportExecutionSearchResponse searchReportExecution(Map params); - final class Builder extends AuthBaseBuilder { + final class Builder extends GenericAuthBuilder { @Override ReportExecutionRestApi createApi() { - return new ReportExecutionRestApiImpl(getDefaultBuilder().build()); + return new ReportExecutionRestApiImpl(createAdapter()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 78d46676..7d0a3f66 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -55,10 +55,10 @@ public interface ReportExportRestApi { @WorkerThread ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); - final class Builder extends AuthBaseBuilder { + final class Builder extends GenericAuthBuilder { @Override ReportExportRestApi createApi() { - return new ReportExportRestApiImpl(getDefaultBuilder().build()); + return new ReportExportRestApiImpl(createAdapter()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 1a972198..8c2c7042 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -59,10 +59,10 @@ void updateReportOption(@NonNull String reportUnitUri, void deleteReportOption(@NonNull String reportUnitUri, @NonNull String optionId); - final class Builder extends AuthBaseBuilder { + final class Builder extends GenericAuthBuilder { @Override ReportOptionRestApi createApi() { - return new ReportOptionRestApiImpl(getDefaultBuilder().build()); + return new ReportOptionRestApiImpl(createAdapter()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 444c9f4d..5cae1b77 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -61,10 +61,10 @@ public interface RepositoryRestApi { @WorkerThread FolderLookupResponse requestFolderResource(@NonNull String resourceUri); - final class Builder extends AuthBaseBuilder { + final class Builder extends GenericAuthBuilder { @Override RepositoryRestApi createApi() { - return new RepositoryRestApiImpl(getDefaultBuilder().build()); + return new RepositoryRestApiImpl(createAdapter()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 156731a2..406608b4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -39,10 +39,10 @@ public interface ServerRestApi { @WorkerThread ServerInfoResponse requestServerInfo(); - final class Builder extends BaseBuilder { + final class Builder extends GenericBuilder { @Override ServerRestApi createApi() { - return new ServerRestApiImpl(getDefaultBuilder().build()); + return new ServerRestApiImpl(createAdapter()); } } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index 7e2d9427..0aa658c1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -54,13 +54,9 @@ public class AuthenticationRestApiTest { @Before public void setup() { - mRestApi = new AuthenticationRestApi.Builder(mWebMockRule.getRootUrl()).build(); - } - - @Test - public void shouldThrowIllegalArgumentExceptionForNullBaseUrl() { - mExpectedException.expect(NullPointerException.class); - new AuthenticationRestApi.Builder(null).build(); + mRestApi = new AuthenticationRestApi.Builder() + .baseUrl(mWebMockRule.getRootUrl()) + .build(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index 41b54802..0aa200d5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -34,7 +34,7 @@ public class InputControlRestApiTest { public void setup() { MockitoAnnotations.initMocks(this); restApiUnderTest = new InputControlRestApi.Builder() - .setToken(mToken) + .token(mToken) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index 801ba7b4..733f7385 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -80,7 +80,7 @@ public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); restApiUnderTest = new ReportExecutionRestApi.Builder() - .setToken(mToken) + .token(mToken) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index 40443a7d..c5c4f1d8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -73,7 +73,7 @@ public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); restApiUnderTest = new ReportExportRestApi.Builder() - .setToken(mToken) + .token(mToken) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index c527d202..c853ed80 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -57,7 +57,7 @@ public class ReportOptionRestApiTest { public void setup() { MockitoAnnotations.initMocks(this); restApiUnderTest = new ReportOptionRestApi.Builder() - .setToken(mToken) + .token(mToken) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index 9de0f2e9..28f7720b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -68,7 +68,7 @@ public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); restApiUnderTest = new RepositoryRestApi.Builder() - .setToken(mToken) + .token(mToken) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 4323db11..e3fc7677 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -52,8 +52,9 @@ public void setup() { @Test public void shouldReturnResponseForSpringRequest() throws IOException { - AuthenticationRestApi authApi = new AuthenticationRestApi.Builder(mobileDemo2) - .setLog(TestLogger.get(this)) + AuthenticationRestApi authApi = new AuthenticationRestApi.Builder() + .baseUrl(mobileDemo2) + .log(TestLogger.get(this)) .build(); AuthResponse response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); assertThat(response.getToken(), is(notNullValue())); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 7d1893cb..36b05c83 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -71,9 +71,9 @@ public void setup() { mAuthenticator.authorize(); String cookie = mAuthenticator.getCookie(); mRestApi = new InputControlRestApi.Builder() - .setToken(CookieToken.newInstance(cookie)) + .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .setLog(TestLogger.get(this)) + .log(TestLogger.get(this)) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 254a28d2..8b9b9985 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -72,9 +72,9 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportExecutionRestApi.Builder() - .setToken(CookieToken.newInstance(cookie)) + .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .setLog(TestLogger.get(this)) + .log(TestLogger.get(this)) .build(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 62b83132..783a94ac 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -68,17 +68,17 @@ public void setup() { if (mExecApi == null) { mExecApi = new ReportExecutionRestApi.Builder() - .setToken(CookieToken.newInstance(cookie)) + .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .setLog(TestLogger.get(this)) + .log(TestLogger.get(this)) .build(); } if (apiUnderTest == null) { apiUnderTest = new ReportExportRestApi.Builder() - .setToken(CookieToken.newInstance(cookie)) + .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .setLog(TestLogger.get(this)) + .log(TestLogger.get(this)) .build(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index e98dc645..d4d23041 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -71,8 +71,8 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportOptionRestApi.Builder() - .setLog(TestLogger.get(this)) - .setToken(CookieToken.newInstance(cookie)) + .log(TestLogger.get(this)) + .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 1c3bc6d0..b7b751d1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -60,9 +60,9 @@ public void setup() { if (api == null) { api = new RepositoryRestApi.Builder() - .setToken(CookieToken.newInstance(cookie)) + .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .setLog(TestLogger.get(this)) + .log(TestLogger.get(this)) .build(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 35e933f0..b83ac7a3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -48,7 +48,7 @@ public class ServerRestTest { @Test public void shouldRequestServerInfo() throws IOException { ServerRestApi api = new ServerRestApi.Builder() - .setLog(TestLogger.get(this)) + .log(TestLogger.get(this)) .baseUrl(mobileDemo2) .build(); ServerInfoResponse response = api.requestServerInfo(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java index 0db07ec6..4af36ad6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java @@ -46,7 +46,9 @@ public static TestAuthenticator newInstance(JrsMetadata metadata) { public void authorize() { if (mAuthResponse == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder(mJrsMetadata.getServerUrl()).build(); + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() + .baseUrl(mJrsMetadata.getServerUrl()) + .build(); mAuthResponse = restApi .authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null); } From 3ea260fd627810362c8d5439335fbe98667b718b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:25:34 +0300 Subject: [PATCH 117/457] Add AuthenticationRestApiBuilderTest --- .../sdk/network/api/AdapterBuilder.java | 3 - .../sdk/network/api/ClientBuilder.java | 7 +- .../sdk/network/api/GenericBuilder.java | 2 +- .../api/AuthenticationRestApiBuilderTest.java | 65 +++++++++++++++++++ .../api/AuthenticationRestApiTest.java | 2 +- .../test/integration/api/ServerRestTest.java | 2 +- 6 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java index 0ddf223f..7235ef10 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java @@ -66,9 +66,6 @@ public AdapterBuilder baseUrl(String baseUrl) { } public void ensureDefaults() { - if (baseUrl == null) { - throw new IllegalStateException("Base url should be supplied to work with JRS API"); - } } Retrofit createAdapter() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java index 74927a6f..d4793fde 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java @@ -38,8 +38,8 @@ public ClientBuilder() { mOkHttpClient = new OkHttpClient(); } - public ClientBuilder setLog(RestApiLog log) { - mLog = log; + public ClientBuilder setLog(RestApiLog logger) { + mLog = logger; return this; } @@ -53,5 +53,8 @@ OkHttpClient getClient() { } void ensureDefaults() { + if (mLog == null) { + mLog = RestApiLog.NONE; + } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java index 85da93de..650514f5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java @@ -46,7 +46,7 @@ public TargetBuilder baseUrl(String baseUrl) { } @SuppressWarnings("unchecked") - public TargetBuilder log(RestApiLog log) { + public TargetBuilder logger(RestApiLog log) { clientBuilder.setLog(log); return (TargetBuilder) this; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java new file mode 100644 index 00000000..88ec63ec --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class AuthenticationRestApiBuilderTest { + + private AuthenticationRestApi.Builder builderUnderTest; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() { + builderUnderTest = new AuthenticationRestApi.Builder(); + } + + @Test + public void builderShouldNotAllowNullBaseUrl() { + expectedException.expect(NullPointerException.class); + builderUnderTest.baseUrl(null); + } + + @Test + public void builderShouldNotAllowEmptyUrl() { + expectedException.expect(IllegalArgumentException.class); + builderUnderTest.baseUrl(""); + } + + @Test + public void builderShouldAllowNullLogLevel() { + builderUnderTest.logger(null); + builderUnderTest.build(); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index e3fc7677..ec661b5e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -54,7 +54,7 @@ public void setup() { public void shouldReturnResponseForSpringRequest() throws IOException { AuthenticationRestApi authApi = new AuthenticationRestApi.Builder() .baseUrl(mobileDemo2) - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .build(); AuthResponse response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); assertThat(response.getToken(), is(notNullValue())); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index b83ac7a3..cf2f6b40 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -48,7 +48,7 @@ public class ServerRestTest { @Test public void shouldRequestServerInfo() throws IOException { ServerRestApi api = new ServerRestApi.Builder() - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .baseUrl(mobileDemo2) .build(); ServerInfoResponse response = api.requestServerInfo(); From 249de1cbb7def7b344e84588851f200356a2d656 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:34:47 +0300 Subject: [PATCH 118/457] Implementing InputControlRestApiBuilderTest --- .../sdk/network/api/AdapterBuilder.java | 3 + .../android/sdk/network/api/AuthBuilder.java | 5 +- .../sdk/network/api/GenericAuthBuilder.java | 2 +- .../api/AuthenticationRestApiBuilderTest.java | 9 ++ .../api/InputControlRestApiBuilderTest.java | 99 +++++++++++++++++++ .../api/InputControlRestApiTest.java | 2 +- .../api/ReportExecutionRestApiTest.java | 2 +- .../api/ReportExportRestApiTest.java | 4 +- .../api/ReportOptionRestApiTest.java | 2 +- .../api/RepositoryRestApiTest.java | 2 +- 10 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java index 7235ef10..0ddf223f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java @@ -66,6 +66,9 @@ public AdapterBuilder baseUrl(String baseUrl) { } public void ensureDefaults() { + if (baseUrl == null) { + throw new IllegalStateException("Base url should be supplied to work with JRS API"); + } } Retrofit createAdapter() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java index 43bad25a..ff1b661f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java @@ -29,6 +29,8 @@ import retrofit.Retrofit; +import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; + /** * @author Tom Koptel * @since 2.0 @@ -42,13 +44,14 @@ public AuthBuilder(AdapterBuilder adapterBuilder) { } public AuthBuilder setToken(Token token) { + checkNotNull(token, "token == null"); mToken = token; return this; } void ensureDefaults() { if (mToken == null) { - throw new IllegalStateException("This API requires authentication"); + throw new IllegalStateException("This API requires authentication token"); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java index f3e3a61c..40c9db90 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java @@ -50,7 +50,7 @@ public TargetBuilder baseUrl(String baseUrl) { } @SuppressWarnings("unchecked") - public TargetBuilder log(RestApiLog log) { + public TargetBuilder logger(RestApiLog log) { mClientBuilder.setLog(log); return (TargetBuilder) this; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java index 88ec63ec..dd41b4b4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java @@ -48,6 +48,8 @@ public void setup() { @Test public void builderShouldNotAllowNullBaseUrl() { expectedException.expect(NullPointerException.class); + expectedException.expectMessage("baseUrl == null"); + builderUnderTest.baseUrl(null); } @@ -60,6 +62,13 @@ public void builderShouldNotAllowEmptyUrl() { @Test public void builderShouldAllowNullLogLevel() { builderUnderTest.logger(null); + } + + @Test + public void builderShouldEnsureBaseUrlNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Base url should be supplied to work with JRS API"); + builderUnderTest.build(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java new file mode 100644 index 00000000..8e55bfe4 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java @@ -0,0 +1,99 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class InputControlRestApiBuilderTest { + private InputControlRestApi.Builder builderUnderTest; + + @Mock + Token mToken; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + builderUnderTest = new InputControlRestApi.Builder(); + } + + @Test + public void builderShouldNotAllowNullBaseUrl() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("baseUrl == null"); + + builderUnderTest.baseUrl(null); + } + + @Test + public void builderShouldNotAllowEmptyUrl() { + expectedException.expect(IllegalArgumentException.class); + builderUnderTest.baseUrl(""); + } + + @Test + public void builderShouldAllowNullLogLevel() { + builderUnderTest.logger(null); + } + + @Test + public void builderShouldEnsureBaseUrlNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Base url should be supplied to work with JRS API"); + + builderUnderTest.token(mToken); + builderUnderTest.build(); + } + + @Test + public void builderShouldEnsureTokenNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("This API requires authentication token"); + + builderUnderTest.baseUrl("http://localhost"); + builderUnderTest.build(); + } + + @Test + public void builderShouldAllowNullToken() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("token == null"); + + builderUnderTest.token(null); + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 36b05c83..d26a9847 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -73,7 +73,7 @@ public void setup() { mRestApi = new InputControlRestApi.Builder() .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 8b9b9985..cd5236a1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -74,7 +74,7 @@ public void setup() { apiUnderTest = new ReportExecutionRestApi.Builder() .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .build(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 783a94ac..e0f800d4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -70,7 +70,7 @@ public void setup() { mExecApi = new ReportExecutionRestApi.Builder() .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .build(); } @@ -78,7 +78,7 @@ public void setup() { apiUnderTest = new ReportExportRestApi.Builder() .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .build(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index d4d23041..2d1e4f29 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -71,7 +71,7 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportOptionRestApi.Builder() - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index b7b751d1..af4bc522 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -62,7 +62,7 @@ public void setup() { api = new RepositoryRestApi.Builder() .token(CookieToken.newInstance(cookie)) .baseUrl(mMetadata.getServerUrl()) - .log(TestLogger.get(this)) + .logger(TestLogger.get(this)) .build(); } } From 664519bfa552470946e5e0f83748f1c447175ee8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:35:46 +0300 Subject: [PATCH 119/457] Implementing ReportExecutionRestApiBuilderTest --- .../ReportExecutionRestApiBuilderTest.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java new file mode 100644 index 00000000..64fb5bdb --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java @@ -0,0 +1,99 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportExecutionRestApiBuilderTest { + private ReportExecutionRestApi.Builder builderUnderTest; + + @Mock + Token mToken; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + builderUnderTest = new ReportExecutionRestApi.Builder(); + } + + @Test + public void builderShouldNotAllowNullBaseUrl() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("baseUrl == null"); + + builderUnderTest.baseUrl(null); + } + + @Test + public void builderShouldNotAllowEmptyUrl() { + expectedException.expect(IllegalArgumentException.class); + builderUnderTest.baseUrl(""); + } + + @Test + public void builderShouldAllowNullLogLevel() { + builderUnderTest.logger(null); + } + + @Test + public void builderShouldEnsureBaseUrlNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Base url should be supplied to work with JRS API"); + + builderUnderTest.token(mToken); + builderUnderTest.build(); + } + + @Test + public void builderShouldEnsureTokenNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("This API requires authentication token"); + + builderUnderTest.baseUrl("http://localhost"); + builderUnderTest.build(); + } + + @Test + public void builderShouldAllowNullToken() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("token == null"); + + builderUnderTest.token(null); + } +} From 3d4cbbdf565bc147420f6621281600f836745948 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:36:41 +0300 Subject: [PATCH 120/457] Implementing ReportExportRestApiBuilderTest --- .../api/ReportExportRestApiBuilderTest.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java new file mode 100644 index 00000000..ff75f470 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java @@ -0,0 +1,99 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportExportRestApiBuilderTest { + private ReportExportRestApi.Builder builderUnderTest; + + @Mock + Token mToken; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + builderUnderTest = new ReportExportRestApi.Builder(); + } + + @Test + public void builderShouldNotAllowNullBaseUrl() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("baseUrl == null"); + + builderUnderTest.baseUrl(null); + } + + @Test + public void builderShouldNotAllowEmptyUrl() { + expectedException.expect(IllegalArgumentException.class); + builderUnderTest.baseUrl(""); + } + + @Test + public void builderShouldAllowNullLogLevel() { + builderUnderTest.logger(null); + } + + @Test + public void builderShouldEnsureBaseUrlNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Base url should be supplied to work with JRS API"); + + builderUnderTest.token(mToken); + builderUnderTest.build(); + } + + @Test + public void builderShouldEnsureTokenNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("This API requires authentication token"); + + builderUnderTest.baseUrl("http://localhost"); + builderUnderTest.build(); + } + + @Test + public void builderShouldAllowNullToken() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("token == null"); + + builderUnderTest.token(null); + } +} From 90968a36e2c95197d43281688d54310cf785af26 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:37:22 +0300 Subject: [PATCH 121/457] Implementing ReportOptionRestApiBuilderTest --- .../api/ReportOptionRestApiBuilderTest.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java new file mode 100644 index 00000000..a8f4bfd9 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java @@ -0,0 +1,99 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportOptionRestApiBuilderTest { + private ReportOptionRestApi.Builder builderUnderTest; + + @Mock + Token mToken; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + builderUnderTest = new ReportOptionRestApi.Builder(); + } + + @Test + public void builderShouldNotAllowNullBaseUrl() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("baseUrl == null"); + + builderUnderTest.baseUrl(null); + } + + @Test + public void builderShouldNotAllowEmptyUrl() { + expectedException.expect(IllegalArgumentException.class); + builderUnderTest.baseUrl(""); + } + + @Test + public void builderShouldAllowNullLogLevel() { + builderUnderTest.logger(null); + } + + @Test + public void builderShouldEnsureBaseUrlNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Base url should be supplied to work with JRS API"); + + builderUnderTest.token(mToken); + builderUnderTest.build(); + } + + @Test + public void builderShouldEnsureTokenNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("This API requires authentication token"); + + builderUnderTest.baseUrl("http://localhost"); + builderUnderTest.build(); + } + + @Test + public void builderShouldAllowNullToken() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("token == null"); + + builderUnderTest.token(null); + } +} From 2e665321a5efe1d4c0df848cd5133f3d9174baee Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:38:33 +0300 Subject: [PATCH 122/457] Implementing RepositoryRestApiBuilderTest --- .../api/RepositoryRestApiBuilderTest.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java new file mode 100644 index 00000000..a7de7cc9 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java @@ -0,0 +1,99 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RepositoryRestApiBuilderTest { + private RepositoryRestApi.Builder builderUnderTest; + + @Mock + Token mToken; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + builderUnderTest = new RepositoryRestApi.Builder(); + } + + @Test + public void builderShouldNotAllowNullBaseUrl() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("baseUrl == null"); + + builderUnderTest.baseUrl(null); + } + + @Test + public void builderShouldNotAllowEmptyUrl() { + expectedException.expect(IllegalArgumentException.class); + builderUnderTest.baseUrl(""); + } + + @Test + public void builderShouldAllowNullLogLevel() { + builderUnderTest.logger(null); + } + + @Test + public void builderShouldEnsureBaseUrlNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Base url should be supplied to work with JRS API"); + + builderUnderTest.token(mToken); + builderUnderTest.build(); + } + + @Test + public void builderShouldEnsureTokenNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("This API requires authentication token"); + + builderUnderTest.baseUrl("http://localhost"); + builderUnderTest.build(); + } + + @Test + public void builderShouldAllowNullToken() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("token == null"); + + builderUnderTest.token(null); + } +} From 8e28ecc06e42f6dfd3a71f67e3b856c5f1c616f3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 13:39:25 +0300 Subject: [PATCH 123/457] Implementing ServerRestApiBuilderTest --- .../network/api/ServerRestApiBuilderTest.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiBuilderTest.java new file mode 100644 index 00000000..f70385ec --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiBuilderTest.java @@ -0,0 +1,73 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerRestApiBuilderTest { + private ServerRestApi.Builder builderUnderTest; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setup() { + builderUnderTest = new ServerRestApi.Builder(); + } + + @Test + public void builderShouldNotAllowNullBaseUrl() { + expectedException.expect(NullPointerException.class); + expectedException.expectMessage("baseUrl == null"); + + builderUnderTest.baseUrl(null); + } + + @Test + public void builderShouldNotAllowEmptyUrl() { + expectedException.expect(IllegalArgumentException.class); + builderUnderTest.baseUrl(""); + } + + @Test + public void builderShouldAllowNullLogLevel() { + builderUnderTest.logger(null); + } + + @Test + public void builderShouldEnsureBaseUrlNotNull() { + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Base url should be supplied to work with JRS API"); + + builderUnderTest.build(); + } +} From 324dc8399f1611a10c9690a623b45f265518de42 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Sep 2015 14:48:40 +0300 Subject: [PATCH 124/457] Add initial version of API for ServerService --- client-service/build.gradle | 21 ++-- .../sdk/service/data/server/FeatureSet.java | 4 +- .../sdk/service/data/server/ServerInfo.java | 71 ++++++++++- .../service/server/ServerInfoTransformer.java | 59 +++++++++ .../sdk/service/server/ServerService.java | 41 ++++++- .../server/ServerInfoTransformerTest.java | 113 ++++++++++++++++++ .../sdk/service/server/ServerServiceTest.java | 41 +++++++ 7 files changed, 333 insertions(+), 17 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java diff --git a/client-service/build.gradle b/client-service/build.gradle index 245aa2e3..0ad3e7d8 100644 --- a/client-service/build.gradle +++ b/client-service/build.gradle @@ -35,20 +35,19 @@ android { dependencies { compile project(':js-android-sdk-client-network') compile 'com.android.support:support-annotations:22.2.0' + compile 'io.reactivex:rxjava:1.0.14' - // Hamcrest Matchers for Junit - testCompile('org.hamcrest:hamcrest-integration:1.3') - - testCompile('junit:junit:4.12') { - transitive = false - } - // JunitParams testCompile('pl.pragmatists:JUnitParams:1.0.4') { - transitive = false + exclude group: 'org.hamcrest' } - - // Mockito - testCompile("org.mockito:mockito-core:1.10.19") { + testCompile 'org.hamcrest:hamcrest-integration:1.3' + testCompile('org.mockito:mockito-core:1.10.19') { exclude group: 'org.hamcrest' + exclude group: 'org.objenesis' + } + testCompile('org.powermock:powermock-api-mockito:1.6.2') { + exclude group: 'org.mockito' } + testCompile 'org.powermock:powermock-module-junit4:1.6.2' + testCompile 'org.robolectric:shadows-support-v4:3.0' } \ No newline at end of file diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java index 4606771e..3141fcfd 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -48,7 +48,7 @@ public String asString() { return mRawData; } - public static FeatureSet create(String rawString) { + public static FeatureSet parse(String rawString) { return new FeatureSet(rawString); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index 67a177ad..97ec261a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -24,17 +24,84 @@ package com.jaspersoft.android.sdk.service.data.server; +import java.text.SimpleDateFormat; + /** * @author Tom Koptel * @since 2.0 */ public final class ServerInfo { - private String dateFormatPattern; - private String datetimeFormatPattern; + private SimpleDateFormat dateFormatPattern; + private SimpleDateFormat datetimeFormatPattern; private ServerVersion version; private ServerEdition edition; private String licenseType; private String build; private String editionName; private FeatureSet features; + + public String getBuild() { + return build; + } + + public void setBuild(String build) { + this.build = build; + } + + public SimpleDateFormat getDateFormatPattern() { + return dateFormatPattern; + } + + public void setDateFormatPattern(String dateFormatPattern) { + this.dateFormatPattern = new SimpleDateFormat(dateFormatPattern); + } + + public SimpleDateFormat getDatetimeFormatPattern() { + return datetimeFormatPattern; + } + + public void setDatetimeFormatPattern(String datetimeFormatPattern) { + this.datetimeFormatPattern = new SimpleDateFormat(datetimeFormatPattern); + } + + public ServerEdition getEdition() { + return edition; + } + + public void setEdition(String edition) { + this.edition = ServerEdition.valueOf(edition); + } + + public String getEditionName() { + return editionName; + } + + public void setEditionName(String editionName) { + this.editionName = editionName; + } + + public FeatureSet getFeatures() { + return features; + } + + public void setFeatures(String features) { + this.features = FeatureSet.parse(features); + } + + public String getLicenseType() { + return licenseType; + } + + public void setLicenseType(String licenseType) { + this.licenseType = licenseType; + } + + public ServerVersion getVersion() { + return version; + } + + public void setVersion(String version) { + ServerVersion.Parser parser = ServerVersion.defaultParser(); + this.version = parser.parse(version); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java new file mode 100644 index 00000000..4a924f62 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -0,0 +1,59 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class ServerInfoTransformer { + + private static class InstanceHolder { + private static ServerInfoTransformer INSTANCE = new ServerInfoTransformer(); + } + + private ServerInfoTransformer() { + // single instance + } + + public static ServerInfoTransformer getInstance() { + return InstanceHolder.INSTANCE; + } + + public ServerInfo transform(ServerInfoResponse response) { + ServerInfo serverInfo = new ServerInfo(); + serverInfo.setBuild(response.getBuild()); + serverInfo.setDateFormatPattern(response.getDateFormatPattern()); + serverInfo.setDatetimeFormatPattern(response.getDatetimeFormatPattern()); + serverInfo.setVersion(response.getVersion()); + serverInfo.setEdition(response.getEdition()); + serverInfo.setEditionName(response.getEditionName()); + serverInfo.setFeatures(response.getFeatures()); + return serverInfo; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java index fc3c0ac0..9e55c2d9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java @@ -1,11 +1,48 @@ package com.jaspersoft.android.sdk.service.server; +import android.support.annotation.VisibleForTesting; + +import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import rx.Observable; +import rx.functions.Func0; +import rx.functions.Func1; + /** * @author Tom Koptel * @since 2.0 */ -public interface ServerService { - ServerInfo getServerInfo(); +public final class ServerService { + private final ServerRestApi mRestApi; + private final ServerInfoTransformer mTransformer; + + @VisibleForTesting + ServerService(ServerRestApi restApi, ServerInfoTransformer transformer) { + mRestApi = restApi; + mTransformer = transformer; + } + + public static ServerService newInstance(ServerRestApi restApi) { + return new ServerService(restApi, ServerInfoTransformer.getInstance()); + } + + public rx.Observable requestServerInfo() { + return requestApiCall().flatMap(new Func1>() { + @Override + public Observable call(ServerInfoResponse response) { + return Observable.just(mTransformer.transform(response)); + } + }); + } + + private rx.Observable requestApiCall() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + return Observable.just(mRestApi.requestServerInfo()); + } + }); + } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java new file mode 100644 index 00000000..6ece6b57 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -0,0 +1,113 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.service.data.server.ServerEdition; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.text.SimpleDateFormat; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ServerInfoResponse.class}) +public class ServerInfoTransformerTest { + + ServerInfoResponse mServerInfoResponse; + + private ServerInfoTransformer transformerUnderTest; + + @Before + public void setup() { + transformerUnderTest = ServerInfoTransformer.getInstance(); + mServerInfoResponse = PowerMockito.mock(ServerInfoResponse.class); + when(mServerInfoResponse.getBuild()).thenReturn("20150527_1447"); + when(mServerInfoResponse.getDateFormatPattern()).thenReturn("yyyy-MM-dd"); + when(mServerInfoResponse.getDatetimeFormatPattern()).thenReturn("yyyy-MM-dd'T'HH:mm:ss"); + when(mServerInfoResponse.getVersion()).thenReturn("6.1"); + when(mServerInfoResponse.getEdition()).thenReturn("PRO"); + when(mServerInfoResponse.getEditionName()).thenReturn("Enterprise for AWS"); + when(mServerInfoResponse.getFeatures()).thenReturn("Fusion"); + } + + @Test + public void shouldTransformBuildProperty() { + ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + assertThat(info.getBuild(), is("20150527_1447")); + } + + @Test + public void shouldTransformDateFormatProperty() { + ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + assertThat(info.getDateFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd"))); + } + + @Test + public void shouldTransformDateTimeFormatProperty() { + ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + assertThat(info.getDatetimeFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"))); + } + + @Test + public void shouldTransformServerVersionProperty() { + ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + assertThat(info.getVersion(), is(ServerVersion.AMBER_MR2)); + } + + @Test + public void shouldTransformServerEditionProperty() { + ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + assertThat(info.getEdition(), is(ServerEdition.PRO)); + } + + @Test + public void shouldTransformServerEditionNameProperty() { + ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + assertThat(info.getEditionName(), is("Enterprise for AWS")); + } + + @Test + public void shouldTransformFeaturesProperty() { + ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + assertThat(info.getFeatures().asSet(), contains("Fusion")); + } + +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java index 7d3c29d4..f63f0a94 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java @@ -1,9 +1,50 @@ package com.jaspersoft.android.sdk.service.server; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + /** * @author Tom Koptel * @since 2.0 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ServerInfoResponse.class}) public class ServerServiceTest { + @Mock + ServerRestApi mockApi; + @Mock + ServerInfoTransformer mockTransformer; + @Mock + ServerInfoResponse mockResponse; + + private ServerService serviceUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + serviceUnderTest = new ServerService(mockApi, mockTransformer); + } + + @Test + public void requestInfoShouldProvideServerInfoDataObject() { + when(mockApi.requestServerInfo()).thenReturn(mockResponse); + + serviceUnderTest.requestServerInfo().subscribe(); + + verify(mockTransformer, times(1)).transform(mockResponse); + verify(mockApi, times(1)).requestServerInfo(); + } } \ No newline at end of file From 4913619f99b5a6cf7061946ed7ff9b6015eb8399 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Sep 2015 15:12:55 +0300 Subject: [PATCH 125/457] Initial design of ServerSession --- .../sdk/service/server/InfoProvider.java | 35 ++++++++ .../sdk/service/server/ServerSession.java | 81 +++++++++++++++++++ .../sdk/service/server/TokenProvider.java | 35 ++++++++ 3 files changed, 151 insertions(+) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java new file mode 100644 index 00000000..fcf5093d --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface InfoProvider { + ServerInfo provideInfo(); +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java new file mode 100644 index 00000000..218b704e --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java @@ -0,0 +1,81 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import com.jaspersoft.android.sdk.network.api.auth.Token; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ServerSession { + private final TokenProvider mTokenProvider; + private final InfoProvider mInfoProvider; + private final String mBaseUrl; + + public ServerSession(Builder builder) { + mBaseUrl = builder.serverUrl; + mInfoProvider = builder.infoProvider; + mTokenProvider = builder.tokenProvider; + } + + public String getBaseUrl() { + return mBaseUrl; + } + + public ServerInfo getInfo() { + return mInfoProvider.provideInfo(); + } + + public Token getTokenProvider() { + return mTokenProvider.provideToken(); + } + + public static class Builder { + private String serverUrl; + private TokenProvider tokenProvider; + private InfoProvider infoProvider; + + public Builder serverUrl(String serverUrl) { + this.serverUrl = serverUrl; + return this; + } + + public Builder tokenProvider(TokenProvider tokenProvider) { + this.tokenProvider = tokenProvider; + return this; + } + + public Builder infoProvider(InfoProvider infoProvider) { + this.infoProvider = infoProvider; + return this; + } + + public ServerSession build() { + return new ServerSession(this); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java new file mode 100644 index 00000000..7aa2079b --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface TokenProvider { + Token provideToken(); +} From 6776fa21ca04c35efe8225965df87fd860754b41 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Sep 2015 15:15:46 +0300 Subject: [PATCH 126/457] Implementing GreedyInfoProvider --- .../service/server/GreedyInfoProvider.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java new file mode 100644 index 00000000..ea48a0c3 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java @@ -0,0 +1,52 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import android.support.annotation.VisibleForTesting; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class GreedyInfoProvider implements InfoProvider { + private final ServerService mServerService; + + @VisibleForTesting + GreedyInfoProvider(ServerService serverService) { + mServerService = serverService; + } + + public static GreedyInfoProvider newInstance(ServerService serverService) { + return new GreedyInfoProvider(serverService); + } + + @Override + public ServerInfo provideInfo() { + return mServerService.requestServerInfo() + .toBlocking().firstOrDefault(null); + } +} From 36844d5bde2218067171b40428511633b001b79b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Sep 2015 15:50:51 +0300 Subject: [PATCH 127/457] Enhancing ServerSession builder --- .../service/server/GreedyInfoProvider.java | 13 +++- .../sdk/service/server/InfoProvider.java | 3 + .../sdk/service/server/ServerService.java | 8 ++ .../sdk/service/server/ServerSession.java | 51 +++++++++---- .../sdk/service/server/TokenProvider.java | 3 + .../android/sdk/service/server/Utils.java | 41 ++++++++++ .../server/ServerSessionBuilderTest.java | 75 +++++++++++++++++++ .../sdk/service/server/ServerSessionTest.java | 68 +++++++++++++++++ 8 files changed, 243 insertions(+), 19 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/Utils.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java index ea48a0c3..28ef0087 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java @@ -24,7 +24,9 @@ package com.jaspersoft.android.sdk.service.server; +import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; +import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -32,7 +34,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class GreedyInfoProvider implements InfoProvider { +final class GreedyInfoProvider implements InfoProvider { private final ServerService mServerService; @VisibleForTesting @@ -40,13 +42,16 @@ public final class GreedyInfoProvider implements InfoProvider { mServerService = serverService; } - public static GreedyInfoProvider newInstance(ServerService serverService) { - return new GreedyInfoProvider(serverService); + public static InfoProvider newInstance(String serverUrl) { + ServerService service = ServerService.newInstance(serverUrl); + return new GreedyInfoProvider(service); } @Override + @NonNull + @WorkerThread public ServerInfo provideInfo() { return mServerService.requestServerInfo() - .toBlocking().firstOrDefault(null); + .toBlocking().first(); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java index fcf5093d..44cde2a4 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.service.server; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.service.data.server.ServerInfo; /** @@ -31,5 +33,6 @@ * @since 2.0 */ public interface InfoProvider { + @NonNull ServerInfo provideInfo(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java index 9e55c2d9..b129fecd 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java @@ -28,6 +28,14 @@ public static ServerService newInstance(ServerRestApi restApi) { return new ServerService(restApi, ServerInfoTransformer.getInstance()); } + public static ServerService newInstance(String baseUrl) { + ServerRestApi restApi = new ServerRestApi.Builder() + .baseUrl(baseUrl) + .build(); + + return new ServerService(restApi, ServerInfoTransformer.getInstance()); + } + public rx.Observable requestServerInfo() { return requestApiCall().flatMap(new Func1>() { @Override diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java index 218b704e..5df178d8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.service.server; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -34,23 +36,28 @@ public final class ServerSession { private final TokenProvider mTokenProvider; private final InfoProvider mInfoProvider; - private final String mBaseUrl; + private final String mServerUrl; - public ServerSession(Builder builder) { - mBaseUrl = builder.serverUrl; - mInfoProvider = builder.infoProvider; - mTokenProvider = builder.tokenProvider; + ServerSession(@NonNull String serverUrl, + @NonNull TokenProvider tokenProvider, + @NonNull InfoProvider infoProvider) { + mTokenProvider = tokenProvider; + mInfoProvider = infoProvider; + mServerUrl = serverUrl; } - public String getBaseUrl() { - return mBaseUrl; + @NonNull + public String getServerUrl() { + return mServerUrl; } + @NonNull public ServerInfo getInfo() { return mInfoProvider.provideInfo(); } - public Token getTokenProvider() { + @NonNull + public Token getToken() { return mTokenProvider.provideToken(); } @@ -59,23 +66,37 @@ public static class Builder { private TokenProvider tokenProvider; private InfoProvider infoProvider; - public Builder serverUrl(String serverUrl) { + public Builder serverUrl(@NonNull String serverUrl) { + Utils.checkNotNull(serverUrl, "serverUrl == null"); this.serverUrl = serverUrl; return this; } - public Builder tokenProvider(TokenProvider tokenProvider) { + public Builder tokenProvider(@NonNull TokenProvider tokenProvider) { + Utils.checkNotNull(serverUrl, "tokenProvider == null"); this.tokenProvider = tokenProvider; return this; } - public Builder infoProvider(InfoProvider infoProvider) { - this.infoProvider = infoProvider; - return this; + @NonNull + public ServerSession build() { + ensureState(); + ensureSaneDefaults(); + + return new ServerSession(serverUrl, tokenProvider, infoProvider); } - public ServerSession build() { - return new ServerSession(this); + private void ensureState() { + if (serverUrl == null) { + throw new IllegalStateException("Session requires server url"); + } + if (tokenProvider == null) { + throw new IllegalStateException("Session requires token provider"); + } + } + + private void ensureSaneDefaults() { + infoProvider = GreedyInfoProvider.newInstance(serverUrl); } } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java index 7aa2079b..ec85baa5 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.service.server; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.auth.Token; /** @@ -31,5 +33,6 @@ * @since 2.0 */ public interface TokenProvider { + @NonNull Token provideToken(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/Utils.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/Utils.java new file mode 100644 index 00000000..67b6a20d --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/Utils.java @@ -0,0 +1,41 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class Utils { + private Utils() { + } + + public static T checkNotNull(T object, String message) { + if (object == null) { + throw new NullPointerException(message); + } + return object; + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java new file mode 100644 index 00000000..10254fb7 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java @@ -0,0 +1,75 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerSessionBuilderTest { + + private ServerSession.Builder objectUnderTest; + + @Rule + public ExpectedException mException = ExpectedException.none(); + + @Before + public void setup() { + objectUnderTest = new ServerSession.Builder(); + } + + @Test + public void builderShouldNotAcceptNullServerUrl() { + mException.expect(NullPointerException.class); + mException.expectMessage("serverUrl == null"); + objectUnderTest.serverUrl(null); + } + + @Test + public void builderShouldNotAllowNullServerUrl() { + mException.expect(IllegalStateException.class); + mException.expectMessage("Session requires server url"); + objectUnderTest.build(); + } + + @Test + public void builderShouldNotAcceptNullTokenProvider() { + mException.expect(NullPointerException.class); + mException.expectMessage("tokenProvider == null"); + objectUnderTest.tokenProvider(null); + } + + @Test + public void builderShouldNotAllowNullTokenProvider() { + mException.expect(IllegalStateException.class); + mException.expectMessage("Session requires token provider"); + objectUnderTest.serverUrl("any url").build(); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java new file mode 100644 index 00000000..1b3a9aeb --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.server; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerSessionTest { + + @Mock + TokenProvider mTokenProvider; + @Mock + InfoProvider mInfoProvider; + + String serverUrl = "http://localhost"; + + private ServerSession objectUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new ServerSession(serverUrl, mTokenProvider, mInfoProvider); + } + + @Test + public void sessionShouldProvideInfo() { + objectUnderTest.getInfo(); + verify(mInfoProvider, times(1)).provideInfo(); + } + + @Test + public void sessionShouldProvideToken() { + objectUnderTest.getToken(); + verify(mTokenProvider, times(1)).provideToken(); + } + +} From 9bc8aa87d02a9bdfaaca337a9c69152c9e739b94 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Sep 2015 15:57:02 +0300 Subject: [PATCH 128/457] Renaming ServerService -> ServerInfoService --- .../sdk/service/server/GreedyInfoProvider.java | 10 +++++----- ...{ServerService.java => ServerInfoService.java} | 15 +++++++++------ ...erviceTest.java => ServerInfoServiceTest.java} | 6 +++--- 3 files changed, 17 insertions(+), 14 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/server/{ServerService.java => ServerInfoService.java} (74%) rename client-service/src/test/java/com/jaspersoft/android/sdk/service/server/{ServerServiceTest.java => ServerInfoServiceTest.java} (88%) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java index 28ef0087..c6988bbc 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java @@ -35,15 +35,15 @@ * @since 2.0 */ final class GreedyInfoProvider implements InfoProvider { - private final ServerService mServerService; + private final ServerInfoService mServerInfoService; @VisibleForTesting - GreedyInfoProvider(ServerService serverService) { - mServerService = serverService; + GreedyInfoProvider(ServerInfoService serverInfoService) { + mServerInfoService = serverInfoService; } public static InfoProvider newInstance(String serverUrl) { - ServerService service = ServerService.newInstance(serverUrl); + ServerInfoService service = ServerInfoService.newInstance(serverUrl); return new GreedyInfoProvider(service); } @@ -51,7 +51,7 @@ public static InfoProvider newInstance(String serverUrl) { @NonNull @WorkerThread public ServerInfo provideInfo() { - return mServerService.requestServerInfo() + return mServerInfoService.requestServerInfo() .toBlocking().first(); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java similarity index 74% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index b129fecd..2e669437 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -14,28 +14,31 @@ * @author Tom Koptel * @since 2.0 */ -public final class ServerService { +public final class ServerInfoService { private final ServerRestApi mRestApi; private final ServerInfoTransformer mTransformer; @VisibleForTesting - ServerService(ServerRestApi restApi, ServerInfoTransformer transformer) { + ServerInfoService(ServerRestApi restApi, ServerInfoTransformer transformer) { mRestApi = restApi; mTransformer = transformer; } - public static ServerService newInstance(ServerRestApi restApi) { - return new ServerService(restApi, ServerInfoTransformer.getInstance()); + public static ServerInfoService newInstance(ServerRestApi restApi) { + return new ServerInfoService(restApi, ServerInfoTransformer.getInstance()); } - public static ServerService newInstance(String baseUrl) { + public static ServerInfoService newInstance(String baseUrl) { ServerRestApi restApi = new ServerRestApi.Builder() .baseUrl(baseUrl) .build(); - return new ServerService(restApi, ServerInfoTransformer.getInstance()); + return new ServerInfoService(restApi, ServerInfoTransformer.getInstance()); } + /** + * TODO: Replace with abstract ASYNC policy + */ public rx.Observable requestServerInfo() { return requestApiCall().flatMap(new Func1>() { @Override diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java similarity index 88% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java index f63f0a94..7ad553d5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java @@ -21,7 +21,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({ServerInfoResponse.class}) -public class ServerServiceTest { +public class ServerInfoServiceTest { @Mock ServerRestApi mockApi; @@ -30,12 +30,12 @@ public class ServerServiceTest { @Mock ServerInfoResponse mockResponse; - private ServerService serviceUnderTest; + private ServerInfoService serviceUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - serviceUnderTest = new ServerService(mockApi, mockTransformer); + serviceUnderTest = new ServerInfoService(mockApi, mockTransformer); } @Test From bf3e998216709251fcb5183b44e3ca966fd00559 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Sep 2015 17:16:22 +0300 Subject: [PATCH 129/457] Remove ServerSession abstraction --- .../service/server/GreedyInfoProvider.java | 2 + .../sdk/service/server/InfoProvider.java | 4 +- .../sdk/service/server/ServerSession.java | 102 ------------------ .../server/ServerSessionBuilderTest.java | 75 ------------- .../sdk/service/server/ServerSessionTest.java | 68 ------------ 5 files changed, 5 insertions(+), 246 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java delete mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java delete mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java index c6988bbc..573814db 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java @@ -31,6 +31,8 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; /** + * Always make call on server + * * @author Tom Koptel * @since 2.0 */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java index 44cde2a4..18877807 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java @@ -29,10 +29,12 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; /** + * Internal interface to abstract out server info generation strategy + * * @author Tom Koptel * @since 2.0 */ -public interface InfoProvider { +interface InfoProvider { @NonNull ServerInfo provideInfo(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java deleted file mode 100644 index 5df178d8..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerSession.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.server; - -import android.support.annotation.NonNull; - -import com.jaspersoft.android.sdk.network.api.auth.Token; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ServerSession { - private final TokenProvider mTokenProvider; - private final InfoProvider mInfoProvider; - private final String mServerUrl; - - ServerSession(@NonNull String serverUrl, - @NonNull TokenProvider tokenProvider, - @NonNull InfoProvider infoProvider) { - mTokenProvider = tokenProvider; - mInfoProvider = infoProvider; - mServerUrl = serverUrl; - } - - @NonNull - public String getServerUrl() { - return mServerUrl; - } - - @NonNull - public ServerInfo getInfo() { - return mInfoProvider.provideInfo(); - } - - @NonNull - public Token getToken() { - return mTokenProvider.provideToken(); - } - - public static class Builder { - private String serverUrl; - private TokenProvider tokenProvider; - private InfoProvider infoProvider; - - public Builder serverUrl(@NonNull String serverUrl) { - Utils.checkNotNull(serverUrl, "serverUrl == null"); - this.serverUrl = serverUrl; - return this; - } - - public Builder tokenProvider(@NonNull TokenProvider tokenProvider) { - Utils.checkNotNull(serverUrl, "tokenProvider == null"); - this.tokenProvider = tokenProvider; - return this; - } - - @NonNull - public ServerSession build() { - ensureState(); - ensureSaneDefaults(); - - return new ServerSession(serverUrl, tokenProvider, infoProvider); - } - - private void ensureState() { - if (serverUrl == null) { - throw new IllegalStateException("Session requires server url"); - } - if (tokenProvider == null) { - throw new IllegalStateException("Session requires token provider"); - } - } - - private void ensureSaneDefaults() { - infoProvider = GreedyInfoProvider.newInstance(serverUrl); - } - } -} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java deleted file mode 100644 index 10254fb7..00000000 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionBuilderTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.server; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ServerSessionBuilderTest { - - private ServerSession.Builder objectUnderTest; - - @Rule - public ExpectedException mException = ExpectedException.none(); - - @Before - public void setup() { - objectUnderTest = new ServerSession.Builder(); - } - - @Test - public void builderShouldNotAcceptNullServerUrl() { - mException.expect(NullPointerException.class); - mException.expectMessage("serverUrl == null"); - objectUnderTest.serverUrl(null); - } - - @Test - public void builderShouldNotAllowNullServerUrl() { - mException.expect(IllegalStateException.class); - mException.expectMessage("Session requires server url"); - objectUnderTest.build(); - } - - @Test - public void builderShouldNotAcceptNullTokenProvider() { - mException.expect(NullPointerException.class); - mException.expectMessage("tokenProvider == null"); - objectUnderTest.tokenProvider(null); - } - - @Test - public void builderShouldNotAllowNullTokenProvider() { - mException.expect(IllegalStateException.class); - mException.expectMessage("Session requires token provider"); - objectUnderTest.serverUrl("any url").build(); - } -} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java deleted file mode 100644 index 1b3a9aeb..00000000 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerSessionTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.server; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ServerSessionTest { - - @Mock - TokenProvider mTokenProvider; - @Mock - InfoProvider mInfoProvider; - - String serverUrl = "http://localhost"; - - private ServerSession objectUnderTest; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - objectUnderTest = new ServerSession(serverUrl, mTokenProvider, mInfoProvider); - } - - @Test - public void sessionShouldProvideInfo() { - objectUnderTest.getInfo(); - verify(mInfoProvider, times(1)).provideInfo(); - } - - @Test - public void sessionShouldProvideToken() { - objectUnderTest.getToken(); - verify(mTokenProvider, times(1)).provideToken(); - } - -} From fe749dd341a206c0d1d1a85867b0c0a95eb0fb44 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Sep 2015 17:17:58 +0300 Subject: [PATCH 130/457] Remove server package --- .../android/sdk/service/{server => }/GreedyInfoProvider.java | 2 +- .../android/sdk/service/{server => }/InfoProvider.java | 2 +- .../android/sdk/service/{server => }/ServerInfoService.java | 2 +- .../sdk/service/{server => }/ServerInfoTransformer.java | 4 ++-- .../android/sdk/service/{server => }/TokenProvider.java | 2 +- .../jaspersoft/android/sdk/service/{server => }/Utils.java | 2 +- .../sdk/service/{server => }/ServerInfoServiceTest.java | 2 +- .../sdk/service/{server => }/ServerInfoTransformerTest.java | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/{server => }/GreedyInfoProvider.java (97%) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/{server => }/InfoProvider.java (96%) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/{server => }/ServerInfoService.java (97%) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/{server => }/ServerInfoTransformer.java (94%) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/{server => }/TokenProvider.java (96%) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/{server => }/Utils.java (96%) rename client-service/src/test/java/com/jaspersoft/android/sdk/service/{server => }/ServerInfoServiceTest.java (96%) rename client-service/src/test/java/com/jaspersoft/android/sdk/service/{server => }/ServerInfoTransformerTest.java (97%) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java similarity index 97% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java index 573814db..95714a60 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java similarity index 96% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java index 18877807..49cf6fe6 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; import android.support.annotation.NonNull; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java similarity index 97% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index 2e669437..e72f6378 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; import android.support.annotation.VisibleForTesting; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java similarity index 94% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java index 4a924f62..17a98691 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java similarity index 96% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java index ec85baa5..718c7de0 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/TokenProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; import android.support.annotation.NonNull; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/Utils.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Utils.java similarity index 96% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/server/Utils.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/Utils.java index 67b6a20d..ebb1494a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/Utils.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Utils.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; /** * @author Tom Koptel diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java similarity index 96% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java index 7ad553d5..a467514f 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java similarity index 97% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java index 6ece6b57..4d0d2855 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.service.data.server.ServerEdition; From cfbf85fd3024479bcfceadd04188cf720e5b14c4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 16 Sep 2015 11:11:42 +0300 Subject: [PATCH 131/457] Initial AuthService impl --- client-service/build.gradle | 23 +++---- .../android/sdk/service/AuthService.java | 67 +++++++++++++++++++ .../android/sdk/service/AuthServiceTest.java | 46 +++++++++++++ 3 files changed, 124 insertions(+), 12 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java diff --git a/client-service/build.gradle b/client-service/build.gradle index 245aa2e3..e7ff8b54 100644 --- a/client-service/build.gradle +++ b/client-service/build.gradle @@ -35,20 +35,19 @@ android { dependencies { compile project(':js-android-sdk-client-network') compile 'com.android.support:support-annotations:22.2.0' + compile 'io.reactivex:rxjava:1.0.14' - // Hamcrest Matchers for Junit - testCompile('org.hamcrest:hamcrest-integration:1.3') - - testCompile('junit:junit:4.12') { - transitive = false - } - // JunitParams testCompile('pl.pragmatists:JUnitParams:1.0.4') { - transitive = false + exclude group: 'org.hamcrest' } - - // Mockito - testCompile("org.mockito:mockito-core:1.10.19") { + testCompile 'org.hamcrest:hamcrest-integration:1.3' + testCompile('org.mockito:mockito-core:1.10.19') { exclude group: 'org.hamcrest' + exclude group: 'org.objenesis' + } + testCompile('org.powermock:powermock-api-mockito:1.6.2') { + exclude group: 'org.mockito' } -} \ No newline at end of file + testCompile 'org.powermock:powermock-module-junit4:1.6.2' + testCompile 'org.robolectric:shadows-support-v4:3.0' +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java new file mode 100644 index 00000000..9ea98bad --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java @@ -0,0 +1,67 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; +import com.jaspersoft.android.sdk.network.api.auth.Token; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; + +import rx.Observable; +import rx.functions.Func0; +import rx.functions.Func1; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class AuthService { + private final AuthenticationRestApi mRestApi; + + public AuthService(AuthenticationRestApi restApi) { + mRestApi = restApi; + } + + public Observable> authenticate(String username, String password, String organization) { + return makeApiCall(username, password, organization) + .flatMap(new Func1>>() { + @Override + public Observable> call(AuthResponse authResponse) { + Token cookieToken = CookieToken.newInstance(authResponse.getToken()); + return Observable.just(cookieToken); + } + }); + } + + private Observable makeApiCall(final String username, final String password, final String organization) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + AuthResponse response = mRestApi.authenticate(username, password, organization, null); + return Observable.just(response); + } + }); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java new file mode 100644 index 00000000..ced20f91 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java @@ -0,0 +1,46 @@ +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.mockito.Matchers.anyMap; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({AuthResponse.class}) +public class AuthServiceTest { + @Mock + AuthenticationRestApi mRestApi; + private AuthService objectUnderTest; + private AuthResponse authResponse; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + authResponse = PowerMockito.mock(AuthResponse.class); + objectUnderTest = new AuthService(mRestApi); + } + + @Test + public void testAuthenticate() { + when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(authResponse); + objectUnderTest.authenticate("user", "1234", "organization").subscribe(); + verify(mRestApi, times(1)).authenticate("user", "1234", "organization", null); + } +} \ No newline at end of file From ad5f5a421c88c120385eeed2b674dcb8aff94231 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Sep 2015 02:46:41 +0300 Subject: [PATCH 132/457] Implementing PublicKey encryption algorythm --- client-network/build.gradle | 1 + .../network/api/PublicKeyGeneratorTest.java | 18 ++++++++ .../sdk/network/api/PublicKeyGenerator.java | 45 +++++++++++++++++++ .../test/resources/json/encryption_key.json | 5 +++ client/build.gradle | 2 +- ui/build.gradle | 2 +- 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java create mode 100644 client-network/src/test/resources/json/encryption_key.json diff --git a/client-network/build.gradle b/client-network/build.gradle index 1dc735cf..8b4eca3b 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -39,6 +39,7 @@ dependencies { compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' + compile 'com.madgag.spongycastle:prov:1.52.0.0' testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' diff --git a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java new file mode 100644 index 00000000..7d528a6b --- /dev/null +++ b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java @@ -0,0 +1,18 @@ +package com.jaspersoft.android.sdk.network.api; + +import android.test.AndroidTestCase; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class PublicKeyGeneratorTest extends AndroidTestCase { + private final static String PUBLIC_EXPONENT = "10001"; + private final static String MODULUS = "95d334976c4cd8ee44dd9b1d756ea7eba34a8b6b9f5903d4480b6a38dcdaa9e602590bdd871fb618f9a88467c4da16085a8104e8488203459358a049ad435eeaa5a600447d3c55caa362c6e10eea0081f2c6a60e99e8ca02c98948d36dad2b00146ef5054f638f4143f2e4ccefb17630fe658e995406464d4f84af2269dcdb81"; + + public void testGenerateKey() throws Exception { + PublicKeyGenerator keyGenerator = new PublicKeyGenerator(MODULUS, PUBLIC_EXPONENT); + String encryptedPass = keyGenerator.generateKey("1234"); + assertTrue(encryptedPass != null); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java new file mode 100644 index 00000000..51928f70 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java @@ -0,0 +1,45 @@ +package com.jaspersoft.android.sdk.network.api; + +import java.math.BigInteger; +import java.security.KeyFactory; +import java.security.Security; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.RSAPublicKeySpec; + +import javax.crypto.Cipher; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class PublicKeyGenerator { + private static final String UTF8 = "utf-8"; + + private final BigInteger mModulus; + private final BigInteger mExponent; + + static { + Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); + } + + public PublicKeyGenerator(String modulus, String exponent) { + mModulus = new BigInteger(modulus, 16); + mExponent = new BigInteger(exponent, 16); + } + + public String generateKey(String text) { + try { + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(mModulus, mExponent); + RSAPublicKey key = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec); + + Cipher cipher = Cipher.getInstance("RSA/NONE/NoPadding", "SC"); + cipher.init(Cipher.ENCRYPT_MODE, key); + + byte[] cipherData = cipher.doFinal(text.getBytes(UTF8)); + return new String(cipherData, UTF8); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/client-network/src/test/resources/json/encryption_key.json b/client-network/src/test/resources/json/encryption_key.json new file mode 100644 index 00000000..7f42b295 --- /dev/null +++ b/client-network/src/test/resources/json/encryption_key.json @@ -0,0 +1,5 @@ +{ + "maxdigits": "131", + "e": "10001", + "n": "95d334976c4cd8ee44dd9b1d756ea7eba34a8b6b9f5903d4480b6a38dcdaa9e602590bdd871fb618f9a88467c4da16085a8104e8488203459358a049ad435eeaa5a600447d3c55caa362c6e10eea0081f2c6a60e99e8ca02c98948d36dad2b00146ef5054f638f4143f2e4ccefb17630fe658e995406464d4f84af2269dcdb81" +} \ No newline at end of file diff --git a/client/build.gradle b/client/build.gradle index e173501b..80b9042d 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' description = 'js-android-sdk-client' version = clientModuleVersion diff --git a/ui/build.gradle b/ui/build.gradle index 47e689e8..8fd181f2 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +//apply plugin: 'com.github.dcendents.android-maven' description = 'js-android-sdk-ui' version = '1.9' From da8e9c5e9a39870ee6665c688984c06726e8b13e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Sep 2015 17:16:41 +0300 Subject: [PATCH 133/457] Implementing encrypted passwords in authentication API --- .../src/androidTest/AndroidManifest.xml | 32 ++++++++ .../api/AuthenticationWithEncryption.java | 61 +++++++++++++++ .../network/api/PasswordEncryptionTest.java | 19 +++++ .../network/api/PublicKeyGeneratorTest.java | 18 ----- .../sdk/network/api/AdapterBuilder.java | 4 +- .../api/AnonymousSessionInterceptor.java | 52 +++++++++++++ .../android/sdk/network/api/AuthBuilder.java | 4 +- .../network/api/AuthenticationRestApi.java | 9 ++- .../api/AuthenticationRestApiImpl.java | 43 ++++++++++- .../sdk/network/api/GenericAuthBuilder.java | 4 +- .../sdk/network/api/GenericBuilder.java | 4 +- .../sdk/network/api/InputControlRestApi.java | 2 +- .../sdk/network/api/PasswordEncryption.java | 74 +++++++++++++++++++ .../sdk/network/api/PublicKeyGenerator.java | 45 ----------- .../network/api/ReportExecutionRestApi.java | 2 +- .../sdk/network/api/ReportExportRestApi.java | 2 +- .../sdk/network/api/ReportOptionRestApi.java | 2 +- .../sdk/network/api/RepositoryRestApi.java | 2 +- .../sdk/network/api/ServerRestApi.java | 2 +- .../entity/server/EncryptionMetadata.java | 60 +++++++++++++++ .../api/AuthenticationRestApiTest.java | 2 +- 21 files changed, 360 insertions(+), 83 deletions(-) create mode 100644 client-network/src/androidTest/AndroidManifest.xml create mode 100644 client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java create mode 100644 client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java delete mode 100644 client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java diff --git a/client-network/src/androidTest/AndroidManifest.xml b/client-network/src/androidTest/AndroidManifest.xml new file mode 100644 index 00000000..55fdae29 --- /dev/null +++ b/client-network/src/androidTest/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java new file mode 100644 index 00000000..87467b45 --- /dev/null +++ b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import android.test.AndroidTestCase; +import android.util.Log; + +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; + +import java.net.URLEncoder; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class AuthenticationWithEncryption extends AndroidTestCase { + + public void testEncryptionWithPassword() throws Exception { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() + .baseUrl("http://192.168.88.55:8085/jasperserver-pro-61/") + .logger(new RestApiLog() { + @Override + public void log(String message) { + Log.d(AuthenticationWithEncryption.class.getSimpleName(), message); + } + }) + .build(); + EncryptionMetadata metadata = restApi.requestEncryptionMetadata(); + + PasswordEncryption generator = new PasswordEncryption( + metadata.getModulus(), + metadata.getExponent()); + String cipher = generator.encrypt(URLEncoder.encode("superuser", "UTF-8")); + + AuthResponse authResponse = restApi.authenticate("superuser", cipher, null, null); + assertTrue(authResponse != null); + } +} diff --git a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java new file mode 100644 index 00000000..435756f7 --- /dev/null +++ b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java @@ -0,0 +1,19 @@ +package com.jaspersoft.android.sdk.network.api; + +import android.test.AndroidTestCase; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class PasswordEncryptionTest extends AndroidTestCase { + private final static String PUBLIC_EXPONENT = "010001"; + private final static String MODULUS = "8964f27abbbde8f903c1a63670d98533b307166aac1f4cbaae025337a31ca032b2675196e89d0da4115d56adfa6965a2e695f073a8b587f47b9e392a7514d6895b6347bd4c14a43f4127841fa93008ba780bafac49d03954dad954857c6de8af3278320cce1a4a43f5c411a911280a05b71c0ec11a66b2e942c152ccecb564cf"; + private final static String RESULT = "5f3138592ee53d7956e10b2a40ceae2849cb161e27b0b82590348490d13f20345771f4184209b98230ad8d3d7ea752d33ce8db5bf8359c76b67e51964a21fbbedc8ad6b21a3c0cf2c680ebf31ad44ad84802d8d5f56bcda21c5d2f8004f0354b21a07d6e5e33e5784fc8fe29a1552cbdd7e47d2b01e2e26939616b8d0927d492"; + + public void testGenerateKey() throws Exception { + PasswordEncryption keyGenerator = new PasswordEncryption(MODULUS, PUBLIC_EXPONENT); + String encryptedPass = keyGenerator.encrypt("superuser"); + assertTrue(RESULT.equals(encryptedPass)); + } +} diff --git a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java deleted file mode 100644 index 7d528a6b..00000000 --- a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PublicKeyGeneratorTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.jaspersoft.android.sdk.network.api; - -import android.test.AndroidTestCase; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class PublicKeyGeneratorTest extends AndroidTestCase { - private final static String PUBLIC_EXPONENT = "10001"; - private final static String MODULUS = "95d334976c4cd8ee44dd9b1d756ea7eba34a8b6b9f5903d4480b6a38dcdaa9e602590bdd871fb618f9a88467c4da16085a8104e8488203459358a049ad435eeaa5a600447d3c55caa362c6e10eea0081f2c6a60e99e8ca02c98948d36dad2b00146ef5054f638f4143f2e4ccefb17630fe658e995406464d4f84af2269dcdb81"; - - public void testGenerateKey() throws Exception { - PublicKeyGenerator keyGenerator = new PublicKeyGenerator(MODULUS, PUBLIC_EXPONENT); - String encryptedPass = keyGenerator.generateKey("1234"); - assertTrue(encryptedPass != null); - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java index 0ddf223f..8dc3c95c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java @@ -71,12 +71,12 @@ public void ensureDefaults() { } } - Retrofit createAdapter() { + Retrofit.Builder getAdapter() { OkHttpClient client = clientBuilder.build(); mRestAdapterBuilder.client(client); mRestAdapterBuilder.baseUrl(baseUrl); mRestAdapterBuilder.addConverterFactory(mConverterFactory); - return mRestAdapterBuilder.build(); + return mRestAdapterBuilder; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java new file mode 100644 index 00000000..078b5e21 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java @@ -0,0 +1,52 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.squareup.okhttp.Interceptor; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class AnonymousSessionInterceptor implements Interceptor { + private final AuthResponse mAuthResponse; + + AnonymousSessionInterceptor(AuthResponse authResponse) { + mAuthResponse = authResponse; + } + + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request().newBuilder() + .addHeader("Cookie", mAuthResponse.getToken()) + .build(); + return chain.proceed(request); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java index ff1b661f..118f136a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java @@ -55,12 +55,12 @@ void ensureDefaults() { } } - Retrofit createAdapter() { + Retrofit.Builder getAdapter() { OkHttpClient client = mAdapterBuilder.clientBuilder.getClient(); DefaultAuthPolicy authPolicy = new DefaultAuthPolicy(client); mToken.acceptPolicy(authPolicy); - return mAdapterBuilder.createAdapter(); + return mAdapterBuilder.getAdapter(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index c2fa3d70..7c069cf8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -29,6 +29,7 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; @@ -46,13 +47,17 @@ AuthResponse authenticate(@NonNull String username, @Nullable String organization, @Nullable Map params); + @NonNull + @WorkerThread + EncryptionMetadata requestEncryptionMetadata(); + final class Builder extends GenericBuilder { @Override AuthenticationRestApi createApi() { HttpUrl baseUrl = adapterBuilder.baseUrl; OkHttpClient okHttpClient = clientBuilder.getClient(); okHttpClient.setFollowRedirects(false); - return new AuthenticationRestApiImpl(baseUrl, okHttpClient); + return new AuthenticationRestApiImpl(baseUrl, okHttpClient, getAdapter()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 7ec89677..b7169158 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,6 +27,8 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.squareup.okhttp.Call; import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; @@ -37,6 +39,11 @@ import java.util.Map; import java.util.Set; +import retrofit.Response; +import retrofit.Retrofit; +import retrofit.http.GET; +import retrofit.http.Headers; + /** * TODO refactor following module in easy testable units * @@ -46,10 +53,12 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { private final HttpUrl mBaseUrl; private final OkHttpClient mClient; + private final Retrofit.Builder mRestAdapterBuilder; - AuthenticationRestApiImpl(HttpUrl baseUrl, OkHttpClient okHttpClient) { + AuthenticationRestApiImpl(HttpUrl baseUrl, OkHttpClient okHttpClient, Retrofit.Builder retrofit) { mBaseUrl = baseUrl; mClient = okHttpClient; + mRestAdapterBuilder = retrofit; } @NonNull @@ -92,6 +101,20 @@ public AuthResponse authenticate(@NonNull final String username, } } + @NonNull + @Override + public EncryptionMetadata requestEncryptionMetadata() { + RestApi api = mRestAdapterBuilder.build().create(RestApi.class); + Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); + AuthResponse anonymousResponse = AuthResponseFactory.create(response.raw()); + + mClient.interceptors().add(new AnonymousSessionInterceptor(anonymousResponse)); + mRestAdapterBuilder.client(mClient); + RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); + + return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata()).body(); + } + private Request createAuthRequest( @NonNull final String username, @NonNull final String password, @@ -102,9 +125,12 @@ private Request createAuthRequest( client.setFollowRedirects(false); FormEncodingBuilder formBody = new FormEncodingBuilder() - .add("j_username", username) .add("j_password", password) - .add("orgId", organization); + .add("j_username", username); + + if (organization != null) { + formBody.add("orgId", organization); + } if (params != null) { Set> entrySet = params.entrySet(); @@ -120,4 +146,15 @@ private Request createAuthRequest( .post(formBody.build()) .build(); } + + private interface RestApi { + @NonNull + @Headers("Accept: application/json") + @GET("rest_v2/serverInfo") + retrofit.Call requestAnonymousCookie(); + + @NonNull + @GET("GetEncryptionKey") + retrofit.Call requestEncryptionMetadata(); + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java index 40c9db90..0086ff67 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java @@ -74,7 +74,7 @@ void ensureDefaults() { mAuthBuilder.ensureDefaults(); } - Retrofit createAdapter() { - return mAuthBuilder.createAdapter(); + Retrofit.Builder getAdapter() { + return mAuthBuilder.getAdapter(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java index 650514f5..21143b6b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java @@ -56,8 +56,8 @@ void ensureDefaults() { adapterBuilder.ensureDefaults(); } - Retrofit createAdapter() { - return adapterBuilder.createAdapter(); + Retrofit.Builder getAdapter() { + return adapterBuilder.getAdapter(); } abstract Api createApi(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 48d16b90..d54afb10 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -77,7 +77,7 @@ InputControlValueResponse requestInputControlsStates(@NonNull String reportUri, final class Builder extends GenericAuthBuilder { @Override InputControlRestApi createApi() { - return new InputControlRestApiImpl(createAdapter()); + return new InputControlRestApiImpl(getAdapter().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java new file mode 100644 index 00000000..952f56de --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java @@ -0,0 +1,74 @@ +package com.jaspersoft.android.sdk.network.api; + +import java.math.BigInteger; +import java.net.URLEncoder; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.security.PublicKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.RSAPublicKeySpec; + +import javax.crypto.Cipher; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class PasswordEncryption { + private static final String UTF_8 = "UTF-8"; + public static final int RADIX_16 = 16; + + private final BigInteger mModulus; + private final BigInteger mExponent; + private final Provider mProvider; + + public PasswordEncryption(String modulus, String exponent) { + exponent = new StringBuilder(exponent).insert(0, "0").toString(); + mModulus = new BigInteger(modulus, RADIX_16); + mExponent = new BigInteger(exponent, RADIX_16); + mProvider = new org.spongycastle.jce.provider.BouncyCastleProvider(); + } + + public String encrypt(String text) { + try { + PublicKey publicKey = createPublicKey(); + + Cipher cipher = Cipher.getInstance("RSA/NONE/NoPadding", mProvider); + cipher.init(Cipher.ENCRYPT_MODE, publicKey); + + String utfPass = URLEncoder.encode(text, UTF_8); + byte[] encryptedUtfPass = cipher.doFinal(utfPass.getBytes()); + + String hashedInput = byteArrayToHexString(encryptedUtfPass); + return hashedInput; + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + private PublicKey createPublicKey() throws NoSuchAlgorithmException, InvalidKeySpecException { + KeyFactory keyFactory = KeyFactory.getInstance("RSA", mProvider); + RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(mModulus, mExponent); + return keyFactory.generatePublic(pubKeySpec); + } + + /** + * Convert byteArr to hex sting. + * + * @param byteArr + * @return + */ + private static String byteArrayToHexString(byte[] byteArr) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < byteArr.length; i++) { + byte b = byteArr[i]; + int high = (b & 0xF0) >> 4; + int low = b & 0x0F; + + sb.append(Character.forDigit(high, 16)); + sb.append(Character.forDigit(low, 16)); + } + return sb.toString(); + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java deleted file mode 100644 index 51928f70..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PublicKeyGenerator.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jaspersoft.android.sdk.network.api; - -import java.math.BigInteger; -import java.security.KeyFactory; -import java.security.Security; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.RSAPublicKeySpec; - -import javax.crypto.Cipher; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class PublicKeyGenerator { - private static final String UTF8 = "utf-8"; - - private final BigInteger mModulus; - private final BigInteger mExponent; - - static { - Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); - } - - public PublicKeyGenerator(String modulus, String exponent) { - mModulus = new BigInteger(modulus, 16); - mExponent = new BigInteger(exponent, 16); - } - - public String generateKey(String text) { - try { - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(mModulus, mExponent); - RSAPublicKey key = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec); - - Cipher cipher = Cipher.getInstance("RSA/NONE/NoPadding", "SC"); - cipher.init(Cipher.ENCRYPT_MODE, key); - - byte[] cipherData = cipher.doFinal(text.getBytes(UTF8)); - return new String(cipherData, UTF8); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 3a0913d0..daeb8804 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -70,7 +70,7 @@ public interface ReportExecutionRestApi { final class Builder extends GenericAuthBuilder { @Override ReportExecutionRestApi createApi() { - return new ReportExecutionRestApiImpl(createAdapter()); + return new ReportExecutionRestApiImpl(getAdapter().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 7d0a3f66..3b2fed32 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -58,7 +58,7 @@ public interface ReportExportRestApi { final class Builder extends GenericAuthBuilder { @Override ReportExportRestApi createApi() { - return new ReportExportRestApiImpl(createAdapter()); + return new ReportExportRestApiImpl(getAdapter().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 8c2c7042..96cf334a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -62,7 +62,7 @@ void deleteReportOption(@NonNull String reportUnitUri, final class Builder extends GenericAuthBuilder { @Override ReportOptionRestApi createApi() { - return new ReportOptionRestApiImpl(createAdapter()); + return new ReportOptionRestApiImpl(getAdapter().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 5cae1b77..8fcf58fc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -64,7 +64,7 @@ public interface RepositoryRestApi { final class Builder extends GenericAuthBuilder { @Override RepositoryRestApi createApi() { - return new RepositoryRestApiImpl(createAdapter()); + return new RepositoryRestApiImpl(getAdapter().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 406608b4..c6d82b3e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -42,7 +42,7 @@ public interface ServerRestApi { final class Builder extends GenericBuilder { @Override ServerRestApi createApi() { - return new ServerRestApiImpl(createAdapter()); + return new ServerRestApiImpl(getAdapter().build()); } } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java new file mode 100644 index 00000000..97a7b59a --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.server; + +import android.support.annotation.NonNull; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class EncryptionMetadata { + @Expose + private int maxdigits; + @Expose + @SerializedName("e") + private String exponent; + @Expose + @SerializedName("n") + private String modulus; + + @NonNull + public String getExponent() { + return exponent; + } + + @NonNull + public int getMaxdigits() { + return maxdigits; + } + + @NonNull + public String getModulus() { + return modulus; + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index 0aa658c1..ddd6b75c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -65,7 +65,7 @@ public void shouldReturnResponseForSuccessRedirect() { mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", "null", null); + AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", null, null); assertThat(response.getToken(), is(notNullValue())); } From 31f6c946cfe3f290d674e3f80ad76e8f9e1983fc Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 11:25:13 +0300 Subject: [PATCH 134/457] Add granular endpints for ServerInfoApi module --- .../sdk/network/api/AdapterBuilder.java | 10 ++- .../sdk/network/api/LoggingInterceptor.java | 10 ++- .../sdk/network/api/ServerRestApi.java | 27 +++++++ .../sdk/network/api/ServerRestApiImpl.java | 81 +++++++++++++++++++ .../network/api/StringConverterFactory.java | 78 ++++++++++++++++++ .../test/integration/api/ServerRestTest.java | 72 +++++++++++++++-- 6 files changed, 265 insertions(+), 13 deletions(-) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java index 8dc3c95c..1f2879eb 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java @@ -29,6 +29,7 @@ import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; +import retrofit.Converter; import retrofit.Retrofit; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; @@ -39,7 +40,8 @@ */ final class AdapterBuilder { private final Retrofit.Builder mRestAdapterBuilder; - private final GsonConverterFactory mConverterFactory; + private final Converter.Factory mGsonConverterFactory; + private final Converter.Factory mStringConverterFactory; final ClientBuilder clientBuilder; HttpUrl baseUrl; @@ -48,7 +50,8 @@ public AdapterBuilder(ClientBuilder clientBuilder){ mRestAdapterBuilder = new Retrofit.Builder(); Gson configuredGson = GsonFactory.create(); - mConverterFactory = GsonConverterFactory.create(configuredGson); + mGsonConverterFactory = GsonConverterFactory.create(configuredGson); + mStringConverterFactory = StringConverterFactory.create(); this.clientBuilder = clientBuilder; } @@ -75,7 +78,8 @@ Retrofit.Builder getAdapter() { OkHttpClient client = clientBuilder.build(); mRestAdapterBuilder.client(client); mRestAdapterBuilder.baseUrl(baseUrl); - mRestAdapterBuilder.addConverterFactory(mConverterFactory); + mRestAdapterBuilder.addConverterFactory(mStringConverterFactory); + mRestAdapterBuilder.addConverterFactory(mGsonConverterFactory); return mRestAdapterBuilder; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index 9c676061..69c6d8bf 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -27,6 +27,7 @@ import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; +import com.squareup.okhttp.ResponseBody; import java.io.IOException; @@ -55,11 +56,14 @@ public Response intercept(Interceptor.Chain chain) throws IOException { Response response = chain.proceed(request); long t2 = System.nanoTime(); + String bodyString = response.body().string(); logger.log(String.format("<-----------------------------------------------------Received response" + - "%nUrl: %s%nTime spent: %.1fms%n%s", - response.request().url(), (t2 - t1) / 1e6d, response.headers())); + "%nUrl: %s%nTime spent: %.1fms%n%s%nBody: %s", + response.request().url(), (t2 - t1) / 1e6d, response.headers(), bodyString)); - return response; + return response.newBuilder() + .body(ResponseBody.create(response.body().contentType(), bodyString)) + .build(); } private static String bodyToString(final Request request) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index c6d82b3e..52084f4f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -38,6 +38,33 @@ public interface ServerRestApi { @NonNull @WorkerThread ServerInfoResponse requestServerInfo(); + @NonNull + @WorkerThread + String requestBuild(); + @NonNull + @WorkerThread + String requestDateFormatPattern(); + @NonNull + @WorkerThread + String requestDateTimeFormatPattern(); + @NonNull + @WorkerThread + String requestEdition(); + @NonNull + @WorkerThread + String requestEditionName(); + @NonNull + @WorkerThread + String requestVersion(); + @NonNull + @WorkerThread + String requestFeatures(); + @NonNull + @WorkerThread + String requestLicenseType(); + @NonNull + @WorkerThread + String requestExpiration(); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java index b57ded66..30a75ea8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java @@ -52,10 +52,91 @@ public ServerInfoResponse requestServerInfo() { return CallWrapper.wrap(call).body(); } + @NonNull + @Override + public String requestEdition() { + return CallWrapper.wrap(mApi.requestEdition()).body(); + } + + @NonNull + @Override + public String requestVersion() { + return CallWrapper.wrap(mApi.requestVersion()).body(); + } + + @NonNull + @Override + public String requestBuild() { + return CallWrapper.wrap(mApi.requestBuild()).body(); + } + + @NonNull + @Override + public String requestFeatures() { + return CallWrapper.wrap(mApi.requestFeatures()).body(); + } + + @NonNull + @Override + public String requestEditionName() { + return CallWrapper.wrap(mApi.requestEditionName()).body(); + } + + @NonNull + @Override + public String requestLicenseType() { + return CallWrapper.wrap(mApi.requestLicenseType()).body(); + } + + @NonNull + @Override + public String requestExpiration() { + return CallWrapper.wrap(mApi.requestExpiration()).body(); + } + + @NonNull + @Override + public String requestDateFormatPattern() { + return CallWrapper.wrap(mApi.requestDateFormatPattern()).body(); + } + + @NonNull + @Override + public String requestDateTimeFormatPattern() { + return CallWrapper.wrap(mApi.requestDateTimeFormatPattern()).body(); + } + private interface RestApi { @NonNull @Headers("Accept: application/json") @GET(value = "rest_v2/serverInfo") Call requestServerInfo(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/edition") + Call requestEdition(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/version") + Call requestVersion(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/build") + Call requestBuild(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/features") + Call requestFeatures(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/editionName") + Call requestEditionName(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/licenseType") + Call requestLicenseType(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/expiration") + Call requestExpiration(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/dateFormatPattern") + Call requestDateFormatPattern(); + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/datetimeFormatPattern") + Call requestDateTimeFormatPattern(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java new file mode 100644 index 00000000..47afed62 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java @@ -0,0 +1,78 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.api; + +import com.squareup.okhttp.MediaType; +import com.squareup.okhttp.RequestBody; +import com.squareup.okhttp.ResponseBody; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; + +import retrofit.Converter; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class StringConverterFactory implements Converter.Factory { + private StringConverterFactory() {} + + public static StringConverterFactory create() { + return new StringConverterFactory(); + } + + @Override + public Converter get(Type type) { + Class cls = (Class) type; + if (String.class.isAssignableFrom(cls)) { + return new StringConverter(); + } + return null; + } + + private static class StringConverter implements Converter { + private static final MediaType PLAIN_TEXT = MediaType.parse("text/plain; charset=UTF-8"); + + @Override + public String fromBody(ResponseBody body) throws IOException { + return new String(body.bytes()); + } + + @Override + public RequestBody toBody(String value) { + return RequestBody.create(PLAIN_TEXT, convertToBytes(value)); + } + + private static byte[] convertToBytes(String string) { + try { + return string.getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + } +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index cf2f6b40..01cdc5b9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -29,10 +29,9 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.test.TestLogger; +import org.junit.Before; import org.junit.Test; -import java.io.IOException; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -43,15 +42,74 @@ */ public class ServerRestTest { - String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; + private String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; + private ServerRestApi apiUnderTest; - @Test - public void shouldRequestServerInfo() throws IOException { - ServerRestApi api = new ServerRestApi.Builder() + @Before + public void setup() { + apiUnderTest = new ServerRestApi.Builder() .logger(TestLogger.get(this)) .baseUrl(mobileDemo2) .build(); - ServerInfoResponse response = api.requestServerInfo(); + } + + @Test + public void shouldRequestServerInfo() throws Exception { + ServerInfoResponse response = apiUnderTest.requestServerInfo(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestBuild() throws Exception { + String response = apiUnderTest.requestBuild(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestDateFormatPattern() throws Exception { + String response = apiUnderTest.requestDateFormatPattern(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestDateTimeFormatPattern() throws Exception { + String response = apiUnderTest.requestDateTimeFormatPattern(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestEdition() throws Exception { + String response = apiUnderTest.requestEdition(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestEditionName() throws Exception { + String response = apiUnderTest.requestEditionName(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestVersion() throws Exception { + String response = apiUnderTest.requestVersion(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestFeatures() throws Exception { + String response = apiUnderTest.requestFeatures(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestLicenseType() throws Exception { + String response = apiUnderTest.requestLicenseType(); + assertThat(response, is(notNullValue())); + } + + @Test + public void shouldRequestExpiration() throws Exception { + String response = apiUnderTest.requestExpiration(); assertThat(response, is(notNullValue())); } } From e238dadcac563161384ef9cdca172f55645bc1b0 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 11:34:13 +0300 Subject: [PATCH 135/457] Update anonymous session request approach --- .../api/AnonymousSessionInterceptor.java | 52 ------------------- .../api/AuthenticationRestApiImpl.java | 10 ++-- 2 files changed, 5 insertions(+), 57 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java deleted file mode 100644 index 078b5e21..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AnonymousSessionInterceptor.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.squareup.okhttp.Interceptor; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class AnonymousSessionInterceptor implements Interceptor { - private final AuthResponse mAuthResponse; - - AnonymousSessionInterceptor(AuthResponse authResponse) { - mAuthResponse = authResponse; - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request request = chain.request().newBuilder() - .addHeader("Cookie", mAuthResponse.getToken()) - .build(); - return chain.proceed(request); - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index b7169158..1bf1dd88 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.squareup.okhttp.Call; import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; @@ -107,8 +106,9 @@ public EncryptionMetadata requestEncryptionMetadata() { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); AuthResponse anonymousResponse = AuthResponseFactory.create(response.raw()); + String anonymousCookie = anonymousResponse.getToken(); - mClient.interceptors().add(new AnonymousSessionInterceptor(anonymousResponse)); + mClient.interceptors().add(CookieAuthInterceptor.newInstance(anonymousCookie)); mRestAdapterBuilder.client(mClient); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); @@ -149,9 +149,9 @@ private Request createAuthRequest( private interface RestApi { @NonNull - @Headers("Accept: application/json") - @GET("rest_v2/serverInfo") - retrofit.Call requestAnonymousCookie(); + @Headers("Accept: text/plain") + @GET("rest_v2/serverInfo/edition") + retrofit.Call requestAnonymousCookie(); @NonNull @GET("GetEncryptionKey") From 592bfb10bbbfaf94e29210e68832d8302c13472c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 14:54:25 +0300 Subject: [PATCH 136/457] Remove android tests. Created alternative. --- client-network/build.gradle | 2 + .../src/androidTest/AndroidManifest.xml | 32 ---------- .../api/AuthenticationWithEncryption.java | 61 ------------------- .../sdk/network/api/PasswordEncryption.java | 16 ++++- .../entity/server/EncryptionMetadata.java | 7 +++ .../network/api/PasswordEncryptionTest.java | 11 +++- .../api/AuthenticationRestApiTest.java | 22 +++++++ 7 files changed, 52 insertions(+), 99 deletions(-) delete mode 100644 client-network/src/androidTest/AndroidManifest.xml delete mode 100644 client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java rename client-network/src/{androidTest => test}/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java (74%) diff --git a/client-network/build.gradle b/client-network/build.gradle index 8b4eca3b..091ab6bd 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -56,4 +56,6 @@ dependencies { testCompile 'org.robolectric:shadows-support-v4:3.0' testCompile 'org.robolectric:shadows-httpclient:3.0' testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' + // In order to test on JVM side we need stock BouncyCastle provider + testCompile 'org.bouncycastle:bcprov-jdk16:1.46' } \ No newline at end of file diff --git a/client-network/src/androidTest/AndroidManifest.xml b/client-network/src/androidTest/AndroidManifest.xml deleted file mode 100644 index 55fdae29..00000000 --- a/client-network/src/androidTest/AndroidManifest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - diff --git a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java b/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java deleted file mode 100644 index 87467b45..00000000 --- a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/AuthenticationWithEncryption.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import android.test.AndroidTestCase; -import android.util.Log; - -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; - -import java.net.URLEncoder; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class AuthenticationWithEncryption extends AndroidTestCase { - - public void testEncryptionWithPassword() throws Exception { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() - .baseUrl("http://192.168.88.55:8085/jasperserver-pro-61/") - .logger(new RestApiLog() { - @Override - public void log(String message) { - Log.d(AuthenticationWithEncryption.class.getSimpleName(), message); - } - }) - .build(); - EncryptionMetadata metadata = restApi.requestEncryptionMetadata(); - - PasswordEncryption generator = new PasswordEncryption( - metadata.getModulus(), - metadata.getExponent()); - String cipher = generator.encrypt(URLEncoder.encode("superuser", "UTF-8")); - - AuthResponse authResponse = restApi.authenticate("superuser", cipher, null, null); - assertTrue(authResponse != null); - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java index 952f56de..2242b4b5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java @@ -1,5 +1,7 @@ package com.jaspersoft.android.sdk.network.api; +import org.spongycastle.jce.provider.BouncyCastleProvider; + import java.math.BigInteger; import java.net.URLEncoder; import java.security.KeyFactory; @@ -23,11 +25,19 @@ public final class PasswordEncryption { private final BigInteger mExponent; private final Provider mProvider; - public PasswordEncryption(String modulus, String exponent) { - exponent = new StringBuilder(exponent).insert(0, "0").toString(); + private PasswordEncryption(Provider provider, String modulus, String exponent) { mModulus = new BigInteger(modulus, RADIX_16); mExponent = new BigInteger(exponent, RADIX_16); - mProvider = new org.spongycastle.jce.provider.BouncyCastleProvider(); + mProvider = provider; + } + + public static PasswordEncryption newInstance(String modulus, String exponent) { + BouncyCastleProvider provider = new BouncyCastleProvider(); + return newInstance(provider, modulus, exponent); + } + + public static PasswordEncryption newInstance(Provider provider, String modulus, String exponent) { + return new PasswordEncryption(provider, modulus, exponent); } public String encrypt(String text) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java index 97a7b59a..e1750233 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java @@ -37,6 +37,9 @@ public final class EncryptionMetadata { @Expose private int maxdigits; @Expose + @SerializedName("Error") + private String error; + @Expose @SerializedName("e") private String exponent; @Expose @@ -57,4 +60,8 @@ public int getMaxdigits() { public String getModulus() { return modulus; } + + public boolean isAvailable() { + return error == null; + } } diff --git a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java similarity index 74% rename from client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java index 435756f7..313e4d1d 100644 --- a/client-network/src/androidTest/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java @@ -1,18 +1,23 @@ package com.jaspersoft.android.sdk.network.api; -import android.test.AndroidTestCase; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.junit.Test; + +import static junit.framework.Assert.assertTrue; /** * @author Tom Koptel * @since 2.0 */ -public class PasswordEncryptionTest extends AndroidTestCase { +public class PasswordEncryptionTest { private final static String PUBLIC_EXPONENT = "010001"; private final static String MODULUS = "8964f27abbbde8f903c1a63670d98533b307166aac1f4cbaae025337a31ca032b2675196e89d0da4115d56adfa6965a2e695f073a8b587f47b9e392a7514d6895b6347bd4c14a43f4127841fa93008ba780bafac49d03954dad954857c6de8af3278320cce1a4a43f5c411a911280a05b71c0ec11a66b2e942c152ccecb564cf"; private final static String RESULT = "5f3138592ee53d7956e10b2a40ceae2849cb161e27b0b82590348490d13f20345771f4184209b98230ad8d3d7ea752d33ce8db5bf8359c76b67e51964a21fbbedc8ad6b21a3c0cf2c680ebf31ad44ad84802d8d5f56bcda21c5d2f8004f0354b21a07d6e5e33e5784fc8fe29a1552cbdd7e47d2b01e2e26939616b8d0927d492"; + @Test public void testGenerateKey() throws Exception { - PasswordEncryption keyGenerator = new PasswordEncryption(MODULUS, PUBLIC_EXPONENT); + PasswordEncryption keyGenerator = PasswordEncryption. + newInstance(new BouncyCastleProvider(), MODULUS, PUBLIC_EXPONENT); String encryptedPass = keyGenerator.encrypt("superuser"); assertTrue(RESULT.equals(encryptedPass)); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index ec661b5e..5646f8e8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -25,14 +25,18 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.PasswordEncryption; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; import com.jaspersoft.android.sdk.test.TestLogger; +import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Before; import org.junit.Test; import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; +import java.net.URLEncoder; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -50,6 +54,24 @@ public void setup() { FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); } + @Test + public void shouldEncryptWithPassword() throws Exception { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() + .baseUrl("http://192.168.88.55:8085/jasperserver-pro-61/") + .logger(TestLogger.get(this)) + .build(); + EncryptionMetadata metadata = restApi.requestEncryptionMetadata(); + + PasswordEncryption generator = PasswordEncryption.newInstance( + new BouncyCastleProvider(), + metadata.getModulus(), + metadata.getExponent()); + String cipher = generator.encrypt(URLEncoder.encode("superuser", "UTF-8")); + + AuthResponse authResponse = restApi.authenticate("superuser", cipher, null, null); + assertThat(authResponse, is(notNullValue())); + } + @Test public void shouldReturnResponseForSpringRequest() throws IOException { AuthenticationRestApi authApi = new AuthenticationRestApi.Builder() From 054b7f04c0bcb902dc4b13f6c81f1ff32e7a2633 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 15:11:39 +0300 Subject: [PATCH 137/457] Rename 'newInstance' -> 'create' factory method --- .../sdk/network/api/AuthenticationRestApiImpl.java | 2 +- .../android/sdk/network/api/CookieAuthInterceptor.java | 2 +- .../android/sdk/network/api/DefaultAuthPolicy.java | 2 +- .../android/sdk/network/api/PasswordEncryption.java | 6 +++--- .../android/sdk/network/api/auth/CookieToken.java | 2 +- .../network/entity/execution/ExecutionRequestOptions.java | 2 +- .../android/sdk/network/api/PasswordEncryptionTest.java | 2 +- .../android/sdk/network/api/ReportExportRestApiTest.java | 4 ++-- .../entity/execution/ExecutionRequestOptionsTest.java | 2 +- .../test/integration/api/AuthenticationRestApiTest.java | 2 +- .../sdk/test/integration/api/InputControlRestApiTest.java | 4 ++-- .../test/integration/api/ReportExecutionRestApiTest.java | 4 ++-- .../sdk/test/integration/api/ReportExportRestApiTest.java | 8 ++++---- .../sdk/test/integration/api/ReportOptionRestApiTest.java | 4 ++-- .../sdk/test/integration/api/RepositoryRestApiTest.java | 4 ++-- .../sdk/test/integration/api/utils/TestAuthenticator.java | 2 +- .../com/jaspersoft/android/sdk/service/AuthService.java | 2 +- 17 files changed, 27 insertions(+), 27 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 1bf1dd88..e2bbb419 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -108,7 +108,7 @@ public EncryptionMetadata requestEncryptionMetadata() { AuthResponse anonymousResponse = AuthResponseFactory.create(response.raw()); String anonymousCookie = anonymousResponse.getToken(); - mClient.interceptors().add(CookieAuthInterceptor.newInstance(anonymousCookie)); + mClient.interceptors().add(CookieAuthInterceptor.create(anonymousCookie)); mRestAdapterBuilder.client(mClient); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java index f750b7ab..58fe4d63 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java @@ -43,7 +43,7 @@ final class CookieAuthInterceptor implements Interceptor { mCookie = cookie; } - public static CookieAuthInterceptor newInstance(String token) { + public static CookieAuthInterceptor create(String token) { checkNotNull(token, "Token should not be null"); return new CookieAuthInterceptor(token); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java index dfd5f4a1..59e3fc9b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java @@ -42,6 +42,6 @@ final class DefaultAuthPolicy implements AuthPolicy { @Override public void applyCookieToken(CookieToken token) { - mHttpClient.interceptors().add(CookieAuthInterceptor.newInstance(token.get())); + mHttpClient.interceptors().add(CookieAuthInterceptor.create(token.get())); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java index 2242b4b5..464457f2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java @@ -31,12 +31,12 @@ private PasswordEncryption(Provider provider, String modulus, String exponent) { mProvider = provider; } - public static PasswordEncryption newInstance(String modulus, String exponent) { + public static PasswordEncryption create(String modulus, String exponent) { BouncyCastleProvider provider = new BouncyCastleProvider(); - return newInstance(provider, modulus, exponent); + return create(provider, modulus, exponent); } - public static PasswordEncryption newInstance(Provider provider, String modulus, String exponent) { + public static PasswordEncryption create(Provider provider, String modulus, String exponent) { return new PasswordEncryption(provider, modulus, exponent); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java index 86157f3a..939fcb4c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java @@ -35,7 +35,7 @@ private CookieToken(String cookie) { mCookie = cookie; } - public static CookieToken newInstance(String cookie) { + public static CookieToken create(String cookie) { return new CookieToken(cookie); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 678ab4e8..815ed4cc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -66,7 +66,7 @@ public class ExecutionRequestOptions { protected ExecutionRequestOptions() {} - public static ExecutionRequestOptions newInstance() { + public static ExecutionRequestOptions create() { return new ExecutionRequestOptions(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java index 313e4d1d..dc991161 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java @@ -17,7 +17,7 @@ public class PasswordEncryptionTest { @Test public void testGenerateKey() throws Exception { PasswordEncryption keyGenerator = PasswordEncryption. - newInstance(new BouncyCastleProvider(), MODULUS, PUBLIC_EXPONENT); + create(new BouncyCastleProvider(), MODULUS, PUBLIC_EXPONENT); String encryptedPass = keyGenerator.encrypt("superuser"); assertTrue(RESULT.equals(encryptedPass)); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index c5c4f1d8..dff0c5d3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -83,7 +83,7 @@ public void pathParameterShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.newInstance()); + restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.create()); } @Test @@ -174,7 +174,7 @@ public void runExportExecutionShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.newInstance()); + restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create()); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java index ed83f4ae..f4eef982 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java @@ -55,7 +55,7 @@ public class ExecutionRequestOptionsTest { @Before public void setup() { - requestUnderTest = ExecutionRequestOptions.newInstance(); + requestUnderTest = ExecutionRequestOptions.create(); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 5646f8e8..89b97af6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -62,7 +62,7 @@ public void shouldEncryptWithPassword() throws Exception { .build(); EncryptionMetadata metadata = restApi.requestEncryptionMetadata(); - PasswordEncryption generator = PasswordEncryption.newInstance( + PasswordEncryption generator = PasswordEncryption.create( new BouncyCastleProvider(), metadata.getModulus(), metadata.getExponent()); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index d26a9847..b540f3d9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -56,7 +56,7 @@ public class InputControlRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); private InputControlRestApi mRestApi; public static final Map> CONTROL_PARAMETERS = new HashMap<>(); @@ -71,7 +71,7 @@ public void setup() { mAuthenticator.authorize(); String cookie = mAuthenticator.getCookie(); mRestApi = new InputControlRestApi.Builder() - .token(CookieToken.newInstance(cookie)) + .token(CookieToken.create(cookie)) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index cd5236a1..5ba33ed5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -63,7 +63,7 @@ public class ReportExecutionRestApiTest { ReportExecutionRestApi apiUnderTest; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); @Before public void setup() { @@ -72,7 +72,7 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportExecutionRestApi.Builder() - .token(CookieToken.newInstance(cookie)) + .token(CookieToken.create(cookie)) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index e0f800d4..b97763e8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -59,7 +59,7 @@ public class ReportExportRestApiTest { ReportExportRestApi apiUnderTest; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); @Before public void setup() { @@ -68,7 +68,7 @@ public void setup() { if (mExecApi == null) { mExecApi = new ReportExecutionRestApi.Builder() - .token(CookieToken.newInstance(cookie)) + .token(CookieToken.create(cookie)) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -76,7 +76,7 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportExportRestApi.Builder() - .token(CookieToken.newInstance(cookie)) + .token(CookieToken.create(cookie)) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -114,7 +114,7 @@ public void requestExportOutputShouldReturnResult() { */ @NonNull private ReportExportExecutionResponse startExportExecution(ReportExecutionDetailsResponse exec) { - ExecutionRequestOptions options = ExecutionRequestOptions.newInstance() + ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") .withOutputFormat("PDF"); return apiUnderTest.runExportExecution(exec.getExecutionId(), options); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 2d1e4f29..a200e711 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -52,7 +52,7 @@ public class ReportOptionRestApiTest { private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); private ReportOptionRestApi apiUnderTest; @@ -72,7 +72,7 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportOptionRestApi.Builder() .logger(TestLogger.get(this)) - .token(CookieToken.newInstance(cookie)) + .token(CookieToken.create(cookie)) .baseUrl(mMetadata.getServerUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index af4bc522..d0b2b347 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -50,7 +50,7 @@ public class RepositoryRestApiTest { private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.newInstance(mMetadata); + private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); private RepositoryRestApi api; @Before @@ -60,7 +60,7 @@ public void setup() { if (api == null) { api = new RepositoryRestApi.Builder() - .token(CookieToken.newInstance(cookie)) + .token(CookieToken.create(cookie)) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java index 4af36ad6..2994cfc3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java @@ -40,7 +40,7 @@ public TestAuthenticator(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; } - public static TestAuthenticator newInstance(JrsMetadata metadata) { + public static TestAuthenticator create(JrsMetadata metadata) { return new TestAuthenticator(metadata); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java index 9ea98bad..7d521f2b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java @@ -49,7 +49,7 @@ public Observable> authenticate(String username, String password, Strin .flatMap(new Func1>>() { @Override public Observable> call(AuthResponse authResponse) { - Token cookieToken = CookieToken.newInstance(authResponse.getToken()); + Token cookieToken = CookieToken.create(authResponse.getToken()); return Observable.just(cookieToken); } }); From 7a755da18ef7497ad96f26d3aa84693fb4a5ab5d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 15:29:05 +0300 Subject: [PATCH 138/457] Refactor PasswordEncryption -> JSEncryptionManager --- ...asswordEncryption.java => JSEncryptionManager.java} | 10 +++++----- ...ncryptionTest.java => JSEncryptionManagerTest.java} | 4 ++-- .../integration/api/AuthenticationRestApiTest.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{PasswordEncryption.java => JSEncryptionManager.java} (86%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/api/{PasswordEncryptionTest.java => JSEncryptionManagerTest.java} (91%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManager.java similarity index 86% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManager.java index 464457f2..f2a41bc5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/PasswordEncryption.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManager.java @@ -17,7 +17,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class PasswordEncryption { +public final class JSEncryptionManager { private static final String UTF_8 = "UTF-8"; public static final int RADIX_16 = 16; @@ -25,19 +25,19 @@ public final class PasswordEncryption { private final BigInteger mExponent; private final Provider mProvider; - private PasswordEncryption(Provider provider, String modulus, String exponent) { + private JSEncryptionManager(Provider provider, String modulus, String exponent) { mModulus = new BigInteger(modulus, RADIX_16); mExponent = new BigInteger(exponent, RADIX_16); mProvider = provider; } - public static PasswordEncryption create(String modulus, String exponent) { + public static JSEncryptionManager create(String modulus, String exponent) { BouncyCastleProvider provider = new BouncyCastleProvider(); return create(provider, modulus, exponent); } - public static PasswordEncryption create(Provider provider, String modulus, String exponent) { - return new PasswordEncryption(provider, modulus, exponent); + public static JSEncryptionManager create(Provider provider, String modulus, String exponent) { + return new JSEncryptionManager(provider, modulus, exponent); } public String encrypt(String text) { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManagerTest.java similarity index 91% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManagerTest.java index dc991161..76e4f4af 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/PasswordEncryptionTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManagerTest.java @@ -9,14 +9,14 @@ * @author Tom Koptel * @since 2.0 */ -public class PasswordEncryptionTest { +public class JSEncryptionManagerTest { private final static String PUBLIC_EXPONENT = "010001"; private final static String MODULUS = "8964f27abbbde8f903c1a63670d98533b307166aac1f4cbaae025337a31ca032b2675196e89d0da4115d56adfa6965a2e695f073a8b587f47b9e392a7514d6895b6347bd4c14a43f4127841fa93008ba780bafac49d03954dad954857c6de8af3278320cce1a4a43f5c411a911280a05b71c0ec11a66b2e942c152ccecb564cf"; private final static String RESULT = "5f3138592ee53d7956e10b2a40ceae2849cb161e27b0b82590348490d13f20345771f4184209b98230ad8d3d7ea752d33ce8db5bf8359c76b67e51964a21fbbedc8ad6b21a3c0cf2c680ebf31ad44ad84802d8d5f56bcda21c5d2f8004f0354b21a07d6e5e33e5784fc8fe29a1552cbdd7e47d2b01e2e26939616b8d0927d492"; @Test public void testGenerateKey() throws Exception { - PasswordEncryption keyGenerator = PasswordEncryption. + JSEncryptionManager keyGenerator = JSEncryptionManager. create(new BouncyCastleProvider(), MODULUS, PUBLIC_EXPONENT); String encryptedPass = keyGenerator.encrypt("superuser"); assertTrue(RESULT.equals(encryptedPass)); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 89b97af6..ea4577e1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.api.PasswordEncryption; +import com.jaspersoft.android.sdk.network.api.JSEncryptionManager; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; import com.jaspersoft.android.sdk.test.TestLogger; @@ -62,7 +62,7 @@ public void shouldEncryptWithPassword() throws Exception { .build(); EncryptionMetadata metadata = restApi.requestEncryptionMetadata(); - PasswordEncryption generator = PasswordEncryption.create( + JSEncryptionManager generator = JSEncryptionManager.create( new BouncyCastleProvider(), metadata.getModulus(), metadata.getExponent()); From ceb3a73bcd4d4b9299c182411b2af211a048fb69 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 17:16:48 +0300 Subject: [PATCH 139/457] Implementing conditionable authentication --- .../network/api/AuthenticationRestApi.java | 4 +- .../api/AuthenticationRestApiImpl.java | 6 +- ...anager.java => JSEncryptionAlgorithm.java} | 28 ++-- ...yptionMetadata.java => EncryptionKey.java} | 2 +- ...st.java => JSEncryptionAlgorithmTest.java} | 10 +- .../api/AuthenticationRestApiTest.java | 13 +- .../android/sdk/service/AuthService.java | 67 -------- .../android/sdk/service/auth/AuthService.java | 41 +++++ .../sdk/service/auth/SpringAuthService.java | 147 ++++++++++++++++++ .../android/sdk/service/AuthServiceTest.java | 46 ------ .../service/auth/SpringAuthServiceTest.java | 81 ++++++++++ 11 files changed, 299 insertions(+), 146 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{JSEncryptionManager.java => JSEncryptionAlgorithm.java} (67%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/{EncryptionMetadata.java => EncryptionKey.java} (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/api/{JSEncryptionManagerTest.java => JSEncryptionAlgorithmTest.java} (75%) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java delete mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index 7c069cf8..cacf1e88 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -29,7 +29,7 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; @@ -49,7 +49,7 @@ AuthResponse authenticate(@NonNull String username, @NonNull @WorkerThread - EncryptionMetadata requestEncryptionMetadata(); + EncryptionKey requestEncryptionMetadata(); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index e2bbb419..b2a26761 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,7 +27,7 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.Call; import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; @@ -102,7 +102,7 @@ public AuthResponse authenticate(@NonNull final String username, @NonNull @Override - public EncryptionMetadata requestEncryptionMetadata() { + public EncryptionKey requestEncryptionMetadata() { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); AuthResponse anonymousResponse = AuthResponseFactory.create(response.raw()); @@ -155,6 +155,6 @@ private interface RestApi { @NonNull @GET("GetEncryptionKey") - retrofit.Call requestEncryptionMetadata(); + retrofit.Call requestEncryptionMetadata(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManager.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java similarity index 67% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManager.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java index f2a41bc5..82448b2b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManager.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java @@ -17,32 +17,28 @@ * @author Tom Koptel * @since 2.0 */ -public final class JSEncryptionManager { +public final class JSEncryptionAlgorithm { private static final String UTF_8 = "UTF-8"; public static final int RADIX_16 = 16; - private final BigInteger mModulus; - private final BigInteger mExponent; private final Provider mProvider; - private JSEncryptionManager(Provider provider, String modulus, String exponent) { - mModulus = new BigInteger(modulus, RADIX_16); - mExponent = new BigInteger(exponent, RADIX_16); + private JSEncryptionAlgorithm(Provider provider) { mProvider = provider; } - public static JSEncryptionManager create(String modulus, String exponent) { + public static JSEncryptionAlgorithm create() { BouncyCastleProvider provider = new BouncyCastleProvider(); - return create(provider, modulus, exponent); + return create(provider); } - public static JSEncryptionManager create(Provider provider, String modulus, String exponent) { - return new JSEncryptionManager(provider, modulus, exponent); + public static JSEncryptionAlgorithm create(Provider provider) { + return new JSEncryptionAlgorithm(provider); } - public String encrypt(String text) { + public String encrypt(String modulus, String exponent, String text) { try { - PublicKey publicKey = createPublicKey(); + PublicKey publicKey = createPublicKey(modulus, exponent); Cipher cipher = Cipher.getInstance("RSA/NONE/NoPadding", mProvider); cipher.init(Cipher.ENCRYPT_MODE, publicKey); @@ -57,9 +53,13 @@ public String encrypt(String text) { } } - private PublicKey createPublicKey() throws NoSuchAlgorithmException, InvalidKeySpecException { + private PublicKey createPublicKey(String modulus, String exponent) + throws NoSuchAlgorithmException, InvalidKeySpecException { + BigInteger m = new BigInteger(modulus, RADIX_16); + BigInteger e = new BigInteger(exponent, RADIX_16); + KeyFactory keyFactory = KeyFactory.getInstance("RSA", mProvider); - RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(mModulus, mExponent); + RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(m, e); return keyFactory.generatePublic(pubKeySpec); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java index e1750233..b81a1801 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionMetadata.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java @@ -33,7 +33,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class EncryptionMetadata { +public final class EncryptionKey { @Expose private int maxdigits; @Expose diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManagerTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithmTest.java similarity index 75% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManagerTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithmTest.java index 76e4f4af..7edda5dd 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionManagerTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithmTest.java @@ -9,16 +9,16 @@ * @author Tom Koptel * @since 2.0 */ -public class JSEncryptionManagerTest { - private final static String PUBLIC_EXPONENT = "010001"; +public class JSEncryptionAlgorithmTest { + private final static String PUBLIC_EXPONENT = "10001"; private final static String MODULUS = "8964f27abbbde8f903c1a63670d98533b307166aac1f4cbaae025337a31ca032b2675196e89d0da4115d56adfa6965a2e695f073a8b587f47b9e392a7514d6895b6347bd4c14a43f4127841fa93008ba780bafac49d03954dad954857c6de8af3278320cce1a4a43f5c411a911280a05b71c0ec11a66b2e942c152ccecb564cf"; private final static String RESULT = "5f3138592ee53d7956e10b2a40ceae2849cb161e27b0b82590348490d13f20345771f4184209b98230ad8d3d7ea752d33ce8db5bf8359c76b67e51964a21fbbedc8ad6b21a3c0cf2c680ebf31ad44ad84802d8d5f56bcda21c5d2f8004f0354b21a07d6e5e33e5784fc8fe29a1552cbdd7e47d2b01e2e26939616b8d0927d492"; @Test public void testGenerateKey() throws Exception { - JSEncryptionManager keyGenerator = JSEncryptionManager. - create(new BouncyCastleProvider(), MODULUS, PUBLIC_EXPONENT); - String encryptedPass = keyGenerator.encrypt("superuser"); + JSEncryptionAlgorithm keyGenerator = JSEncryptionAlgorithm. + create(new BouncyCastleProvider()); + String encryptedPass = keyGenerator.encrypt(MODULUS, PUBLIC_EXPONENT, "superuser"); assertTrue(RESULT.equals(encryptedPass)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index ea4577e1..453e27d9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -25,9 +25,9 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.api.JSEncryptionManager; +import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; -import com.jaspersoft.android.sdk.network.entity.server.EncryptionMetadata; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.TestLogger; import org.bouncycastle.jce.provider.BouncyCastleProvider; @@ -60,13 +60,10 @@ public void shouldEncryptWithPassword() throws Exception { .baseUrl("http://192.168.88.55:8085/jasperserver-pro-61/") .logger(TestLogger.get(this)) .build(); - EncryptionMetadata metadata = restApi.requestEncryptionMetadata(); + EncryptionKey key = restApi.requestEncryptionMetadata(); - JSEncryptionManager generator = JSEncryptionManager.create( - new BouncyCastleProvider(), - metadata.getModulus(), - metadata.getExponent()); - String cipher = generator.encrypt(URLEncoder.encode("superuser", "UTF-8")); + JSEncryptionAlgorithm generator = JSEncryptionAlgorithm.create(new BouncyCastleProvider()); + String cipher = generator.encrypt(key.getModulus(), key.getExponent(), "superuser"); AuthResponse authResponse = restApi.authenticate("superuser", cipher, null, null); assertThat(authResponse, is(notNullValue())); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java deleted file mode 100644 index 7d521f2b..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/AuthService.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.api.auth.CookieToken; -import com.jaspersoft.android.sdk.network.api.auth.Token; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; - -import rx.Observable; -import rx.functions.Func0; -import rx.functions.Func1; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class AuthService { - private final AuthenticationRestApi mRestApi; - - public AuthService(AuthenticationRestApi restApi) { - mRestApi = restApi; - } - - public Observable> authenticate(String username, String password, String organization) { - return makeApiCall(username, password, organization) - .flatMap(new Func1>>() { - @Override - public Observable> call(AuthResponse authResponse) { - Token cookieToken = CookieToken.create(authResponse.getToken()); - return Observable.just(cookieToken); - } - }); - } - - private Observable makeApiCall(final String username, final String password, final String organization) { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - AuthResponse response = mRestApi.authenticate(username, password, organization, null); - return Observable.just(response); - } - }); - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java new file mode 100644 index 00000000..782cddcc --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -0,0 +1,41 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.api.auth.Token; + +import rx.Observable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface AuthService { + @NonNull + Observable> authenticate(); + +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java new file mode 100644 index 00000000..c5eeaa4b --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -0,0 +1,147 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +import android.support.annotation.NonNull; +import android.support.annotation.VisibleForTesting; + +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; +import com.jaspersoft.android.sdk.network.api.auth.Token; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; + +import rx.Observable; +import rx.functions.Func0; +import rx.functions.Func1; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class SpringAuthService implements AuthService { + private final AuthenticationRestApi mRestApi; + private final String mUsername; + private final String mPassword; + private final String mOrganization; + private final JSEncryptionAlgorithm mEncryptionAlgorythm; + + @VisibleForTesting + SpringAuthService( + @NonNull JSEncryptionAlgorithm generator, + @NonNull AuthenticationRestApi restApi, + @NonNull String username, + @NonNull String password, + @NonNull String organization) { + mEncryptionAlgorythm = generator; + mRestApi = restApi; + mUsername = username; + mPassword = password; + mOrganization = organization; + } + + @Override + public Observable> authenticate() { + return authenticationCall(mUsername, mPassword, mOrganization) + .flatMap(new Func1>>() { + @Override + public Observable> call(AuthResponse authResponse) { + Token cookieToken = CookieToken.create(authResponse.getToken()); + return Observable.just(cookieToken); + } + }); + } + + private Observable authenticationCall(final String username, final String password, final String organization) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + AuthResponse response = invokeAuthentication(password, username, organization); + return Observable.just(response); + } + }); + } + + @NonNull + private AuthResponse invokeAuthentication(String password, String username, String organization) { + String targetPassword = password; + EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); + + if (encryptionKey.isAvailable()) { + targetPassword = encryptPassword(password, encryptionKey); + } + + return mRestApi.authenticate(username, targetPassword, organization, null); + } + + private String encryptPassword(String password, EncryptionKey key) { + return mEncryptionAlgorythm.encrypt(key.getModulus(), key.getExponent(), password); + } + + public static class Builder { + private AuthenticationRestApi mRestApi; + private String mUsername; + private String mPassword; + private String mOrganization; + + public Builder username(String username) { + // Assert value + mUsername = username; + return this; + } + + public Builder password(String password) { + // Assert value + mPassword = password; + return this; + } + + public Builder organization(String organization) { + // Assert value + mOrganization = organization; + return this; + } + + public Builder restApi(AuthenticationRestApi restApi) { + // Assert value + mRestApi = restApi; + return this; + } + + public Builder withDefaultApiProvider(String serverUrl) { + mRestApi = new AuthenticationRestApi.Builder() + .baseUrl(serverUrl) + .build(); + return this; + } + + public SpringAuthService build() { + // Assert values + JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); + return new SpringAuthService(algorithm, mRestApi, mUsername, mPassword, mOrganization); + } + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java deleted file mode 100644 index ced20f91..00000000 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/AuthServiceTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({AuthResponse.class}) -public class AuthServiceTest { - @Mock - AuthenticationRestApi mRestApi; - private AuthService objectUnderTest; - private AuthResponse authResponse; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - authResponse = PowerMockito.mock(AuthResponse.class); - objectUnderTest = new AuthService(mRestApi); - } - - @Test - public void testAuthenticate() { - when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(authResponse); - objectUnderTest.authenticate("user", "1234", "organization").subscribe(); - verify(mRestApi, times(1)).authenticate("user", "1234", "organization", null); - } -} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java new file mode 100644 index 00000000..d94f99f4 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -0,0 +1,81 @@ +package com.jaspersoft.android.sdk.service.auth; + +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; +import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.mockito.Matchers.anyMap; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({AuthResponse.class, EncryptionKey.class, JSEncryptionAlgorithm.class}) +public class SpringAuthServiceTest { + + @Mock + AuthenticationRestApi mRestApi; + @Mock + AuthResponse mAuthResponse; + @Mock + JSEncryptionAlgorithm mAlgorithm; + @Mock + EncryptionKey mKey; + + private SpringAuthService objectUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new SpringAuthService( + mAlgorithm, + mRestApi, + "user", + "1234", + "organization" + ); + + when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); + when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(mAuthResponse); + } + + @Test + public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { + when(mKey.isAvailable()).thenReturn(true); + when(mKey.getExponent()).thenReturn("e"); + when(mKey.getModulus()).thenReturn("m"); + when(mAlgorithm.encrypt(anyString(), anyString(), anyString())).thenReturn("hashed password"); + + objectUnderTest.authenticate().subscribe(); + + verify(mRestApi, times(1)).authenticate("user", "hashed password", "organization", null); + verify(mRestApi, times(1)).requestEncryptionMetadata(); + verify(mAlgorithm, times(1)).encrypt("m", "e", "1234"); + } + + @Test + public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() { + when(mKey.isAvailable()).thenReturn(false); + + objectUnderTest.authenticate().subscribe(); + + verify(mRestApi, times(1)).authenticate("user", "1234", "organization", null); + verify(mRestApi, times(1)).requestEncryptionMetadata(); + verifyZeroInteractions(mAlgorithm); + } +} \ No newline at end of file From da3af9453fe0eff1d2c76ca58d49ab0fd449b874 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 17:49:27 +0300 Subject: [PATCH 140/457] Implementing save builder for SpringAuthService --- .../android/sdk/service/Preconditions.java | 41 ++++++ .../android/sdk/service/auth/AuthService.java | 1 - .../sdk/service/auth/SpringAuthService.java | 63 +++++---- .../auth/SpringAuthServiceBuilderTest.java | 122 ++++++++++++++++++ 4 files changed, 202 insertions(+), 25 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java new file mode 100644 index 00000000..738b2e29 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java @@ -0,0 +1,41 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class Preconditions { + private Preconditions() { + } + + public static T checkNotNull(T object, String message) { + if (object == null) { + throw new NullPointerException(message); + } + return object; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 782cddcc..35c95573 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -37,5 +37,4 @@ public interface AuthService { @NonNull Observable> authenticate(); - } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index c5eeaa4b..c33210b7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.auth; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; @@ -38,6 +39,8 @@ import rx.functions.Func0; import rx.functions.Func1; +import static com.jaspersoft.android.sdk.service.Preconditions.checkNotNull; + /** * @author Tom Koptel * @since 2.0 @@ -47,7 +50,7 @@ public final class SpringAuthService implements AuthService { private final String mUsername; private final String mPassword; private final String mOrganization; - private final JSEncryptionAlgorithm mEncryptionAlgorythm; + private final JSEncryptionAlgorithm mEncryptionAlgorithm; @VisibleForTesting SpringAuthService( @@ -56,16 +59,17 @@ public final class SpringAuthService implements AuthService { @NonNull String username, @NonNull String password, @NonNull String organization) { - mEncryptionAlgorythm = generator; + mEncryptionAlgorithm = generator; mRestApi = restApi; mUsername = username; mPassword = password; mOrganization = organization; } + @NonNull @Override public Observable> authenticate() { - return authenticationCall(mUsername, mPassword, mOrganization) + return authenticationCall() .flatMap(new Func1>>() { @Override public Observable> call(AuthResponse authResponse) { @@ -75,30 +79,32 @@ public Observable> call(AuthResponse authResponse) { }); } - private Observable authenticationCall(final String username, final String password, final String organization) { + @NonNull + private Observable authenticationCall() { return Observable.defer(new Func0>() { @Override public Observable call() { - AuthResponse response = invokeAuthentication(password, username, organization); + AuthResponse response = invokeAuthentication(); return Observable.just(response); } }); } @NonNull - private AuthResponse invokeAuthentication(String password, String username, String organization) { - String targetPassword = password; + private AuthResponse invokeAuthentication() { + String password = mPassword; EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); if (encryptionKey.isAvailable()) { - targetPassword = encryptPassword(password, encryptionKey); + password = encryptPassword(mPassword, encryptionKey); } - return mRestApi.authenticate(username, targetPassword, organization, null); + return mRestApi.authenticate(mUsername, password, mOrganization, null); } + @NonNull private String encryptPassword(String password, EncryptionKey key) { - return mEncryptionAlgorythm.encrypt(key.getModulus(), key.getExponent(), password); + return mEncryptionAlgorithm.encrypt(key.getModulus(), key.getExponent(), password); } public static class Builder { @@ -107,41 +113,50 @@ public static class Builder { private String mPassword; private String mOrganization; - public Builder username(String username) { - // Assert value - mUsername = username; + public Builder username(@NonNull String username) { + mUsername = checkNotNull(username, "username == null"); return this; } - public Builder password(String password) { - // Assert value - mPassword = password; + public Builder password(@NonNull String password) { + mPassword = checkNotNull(password, "password == null"); return this; } - public Builder organization(String organization) { - // Assert value - mOrganization = organization; + public Builder restApi(@NonNull AuthenticationRestApi restApi) { + mRestApi = checkNotNull(restApi, "restApi == null"); return this; } - public Builder restApi(AuthenticationRestApi restApi) { - // Assert value - mRestApi = restApi; + public Builder organization(@Nullable String organization) { + mOrganization = organization; return this; } - public Builder withDefaultApiProvider(String serverUrl) { + public Builder withDefaultApiProvider(@NonNull String serverUrl) { mRestApi = new AuthenticationRestApi.Builder() .baseUrl(serverUrl) .build(); return this; } + @NonNull public SpringAuthService build() { - // Assert values + ensureValidState(); JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); return new SpringAuthService(algorithm, mRestApi, mUsername, mPassword, mOrganization); } + + private void ensureValidState() { + if (mUsername == null) { + throw new IllegalStateException("Username should not be null"); + } + if (mPassword == null) { + throw new IllegalStateException("Password should not be null"); + } + if (mRestApi == null) { + throw new IllegalStateException("Rest api should not be null. Either set it or call withDefaultApiProvider(url)"); + } + } } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java new file mode 100644 index 00000000..9c1137f1 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java @@ -0,0 +1,122 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class SpringAuthServiceBuilderTest { + + private SpringAuthService.Builder objectUnderTest; + + @Mock + AuthenticationRestApi mRestApi; + + @Rule + public ExpectedException mException = ExpectedException.none(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new SpringAuthService.Builder(); + } + + @Test + public void builderShouldNotAllowNullUsername() { + mException.expect(NullPointerException.class); + mException.expectMessage("username == null"); + + objectUnderTest.username(null); + } + + @Test + public void builderShouldNotAllowNullPassword() { + mException.expect(NullPointerException.class); + mException.expectMessage("password == null"); + + objectUnderTest.password(null); + } + + @Test + public void builderShouldNotAllowNullRestApi() { + mException.expect(NullPointerException.class); + mException.expectMessage("restApi == null"); + + objectUnderTest.restApi(null); + } + + @Test + public void serviceShouldThrowIfBuildWithNullUsername() { + mException.expect(IllegalStateException.class); + mException.expectMessage("Username should not be null"); + + objectUnderTest.restApi(mRestApi); + objectUnderTest.password(""); + objectUnderTest.build(); + } + + @Test + public void serviceShouldThrowIfBuildWithNullPassword() { + mException.expect(IllegalStateException.class); + mException.expectMessage("Password should not be null"); + + objectUnderTest.restApi(mRestApi); + objectUnderTest.username(""); + objectUnderTest.build(); + } + + @Test + public void serviceShouldThrowIfBuildWithNullRestApi() { + mException.expect(IllegalStateException.class); + mException.expectMessage("Rest api should not be null. Either set it or call withDefaultApiProvider(url)"); + + objectUnderTest.username(""); + objectUnderTest.password(""); + objectUnderTest.build(); + } + + @Test + public void builderShouldCreateServiceWithDefaultApi() { + objectUnderTest.username(""); + objectUnderTest.password(""); + + SpringAuthService service = objectUnderTest.withDefaultApiProvider("http://localhost/").build(); + assertThat(service, is(notNullValue())); + } +} From e6398f10053a025cc6146a7d5f49c22f25ca1dd5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Sep 2015 17:53:16 +0300 Subject: [PATCH 141/457] Hide magic number of JSEncryptionAlgorithm --- .../android/sdk/network/api/JSEncryptionAlgorithm.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java index 82448b2b..016eb1f7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java @@ -19,7 +19,7 @@ */ public final class JSEncryptionAlgorithm { private static final String UTF_8 = "UTF-8"; - public static final int RADIX_16 = 16; + private static final int RADIX_16 = 16; private final Provider mProvider; @@ -46,8 +46,7 @@ public String encrypt(String modulus, String exponent, String text) { String utfPass = URLEncoder.encode(text, UTF_8); byte[] encryptedUtfPass = cipher.doFinal(utfPass.getBytes()); - String hashedInput = byteArrayToHexString(encryptedUtfPass); - return hashedInput; + return byteArrayToHexString(encryptedUtfPass); } catch (Exception ex) { throw new RuntimeException(ex); } @@ -76,8 +75,8 @@ private static String byteArrayToHexString(byte[] byteArr) { int high = (b & 0xF0) >> 4; int low = b & 0x0F; - sb.append(Character.forDigit(high, 16)); - sb.append(Character.forDigit(low, 16)); + sb.append(Character.forDigit(high, RADIX_16)); + sb.append(Character.forDigit(low, RADIX_16)); } return sb.toString(); } From 63d413370118e60f9816a9b60c89cdfcdbc5384e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Sep 2015 12:39:17 +0300 Subject: [PATCH 142/457] Revert android-maven plugin for gradle files --- .../android/sdk/service/auth/SpringAuthService.java | 5 ++++- client/build.gradle | 2 +- ui/build.gradle | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index c33210b7..35f489e2 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -133,6 +133,9 @@ public Builder organization(@Nullable String organization) { return this; } + /** + * TODO experimental API consider before release + */ public Builder withDefaultApiProvider(@NonNull String serverUrl) { mRestApi = new AuthenticationRestApi.Builder() .baseUrl(serverUrl) @@ -155,7 +158,7 @@ private void ensureValidState() { throw new IllegalStateException("Password should not be null"); } if (mRestApi == null) { - throw new IllegalStateException("Rest api should not be null. Either set it or call withDefaultApiProvider(url)"); + throw new IllegalStateException("Rest api should not be null. Either set it or call useDefaultApi(url)"); } } } diff --git a/client/build.gradle b/client/build.gradle index 80b9042d..e173501b 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -//apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'com.github.dcendents.android-maven' description = 'js-android-sdk-client' version = clientModuleVersion diff --git a/ui/build.gradle b/ui/build.gradle index 8fd181f2..47e689e8 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.library' -//apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'com.github.dcendents.android-maven' description = 'js-android-sdk-ui' version = '1.9' From 2789598e642c7bd5a7e5c592b70241cfa3894d62 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Sep 2015 13:54:12 +0300 Subject: [PATCH 143/457] Introducing locale and timeZone optionals for SpringAuthService --- .../sdk/service/auth/SpringAuthService.java | 63 ++++++++++++++++++- .../auth/SpringAuthServiceBuilderTest.java | 16 +++++ .../service/auth/SpringAuthServiceTest.java | 35 ++++++++--- 3 files changed, 104 insertions(+), 10 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 35f489e2..fabcbe17 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -35,6 +35,11 @@ import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.TimeZone; + import rx.Observable; import rx.functions.Func0; import rx.functions.Func1; @@ -51,6 +56,8 @@ public final class SpringAuthService implements AuthService { private final String mPassword; private final String mOrganization; private final JSEncryptionAlgorithm mEncryptionAlgorithm; + private final Locale mLocale; + private final TimeZone mTimeZone; @VisibleForTesting SpringAuthService( @@ -58,12 +65,17 @@ public final class SpringAuthService implements AuthService { @NonNull AuthenticationRestApi restApi, @NonNull String username, @NonNull String password, - @NonNull String organization) { + @NonNull String organization, + @NonNull Locale locale, + @NonNull TimeZone timeZone + ) { mEncryptionAlgorithm = generator; mRestApi = restApi; mUsername = username; mPassword = password; mOrganization = organization; + mLocale = locale; + mTimeZone = timeZone; } @NonNull @@ -99,7 +111,22 @@ private AuthResponse invokeAuthentication() { password = encryptPassword(mPassword, encryptionKey); } - return mRestApi.authenticate(mUsername, password, mOrganization, null); + Map params = prepareOptionals(); + return mRestApi.authenticate(mUsername, password, mOrganization, params); + } + + private Map prepareOptionals() { + Map params = new HashMap<>(); + + // For Locale.US it will produce "en_US" result + String locale = mLocale.getLanguage() + "_" + mLocale.getCountry(); + // Result could be "Europe/Helsinki" + String timeZone = mTimeZone.getID(); + + params.put("userLocale", locale); + params.put("userTimezone", timeZone); + + return params; } @NonNull @@ -113,6 +140,10 @@ public static class Builder { private String mPassword; private String mOrganization; + // Optional + private Locale mLocale; + private TimeZone mTimeZone; + public Builder username(@NonNull String username) { mUsername = checkNotNull(username, "username == null"); return this; @@ -133,6 +164,16 @@ public Builder organization(@Nullable String organization) { return this; } + public Builder timeZone(@NonNull TimeZone timeZone) { + mTimeZone = checkNotNull(timeZone, "timeZone == null"); + return this; + } + + public Builder locale(@NonNull Locale locale) { + mLocale = checkNotNull(locale, "locale == null"); + return this; + } + /** * TODO experimental API consider before release */ @@ -146,8 +187,24 @@ public Builder withDefaultApiProvider(@NonNull String serverUrl) { @NonNull public SpringAuthService build() { ensureValidState(); + ensureDefaults(); JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); - return new SpringAuthService(algorithm, mRestApi, mUsername, mPassword, mOrganization); + return new SpringAuthService(algorithm, + mRestApi, + mUsername, + mPassword, + mOrganization, + mLocale, + mTimeZone); + } + + private void ensureDefaults() { + if (mTimeZone == null) { + mTimeZone = TimeZone.getDefault(); + } + if (mLocale == null) { + mLocale = Locale.getDefault(); + } } private void ensureValidState() { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java index 9c1137f1..0270d587 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java @@ -81,6 +81,22 @@ public void builderShouldNotAllowNullRestApi() { objectUnderTest.restApi(null); } + @Test + public void builderShouldNotAllowNullLocale() { + mException.expect(NullPointerException.class); + mException.expectMessage("locale == null"); + + objectUnderTest.locale(null); + } + + @Test + public void builderShouldNotAllowNullTimeZone() { + mException.expect(NullPointerException.class); + mException.expectMessage("timeZone == null"); + + objectUnderTest.timeZone(null); + } + @Test public void serviceShouldThrowIfBuildWithNullUsername() { mException.expect(IllegalStateException.class); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index d94f99f4..b24c6180 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -13,6 +13,11 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.TimeZone; + import static org.mockito.Matchers.anyMap; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.times; @@ -25,9 +30,13 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({AuthResponse.class, EncryptionKey.class, JSEncryptionAlgorithm.class}) +@PrepareForTest({ + Locale.class, + AuthResponse.class, + EncryptionKey.class, + JSEncryptionAlgorithm.class, +}) public class SpringAuthServiceTest { - @Mock AuthenticationRestApi mRestApi; @Mock @@ -36,9 +45,18 @@ public class SpringAuthServiceTest { JSEncryptionAlgorithm mAlgorithm; @Mock EncryptionKey mKey; + @Mock + TimeZone mTimeZone; private SpringAuthService objectUnderTest; + private static final Map sOptionals = new HashMap<>(); + + static { + sOptionals.put("userLocale", "en_US"); + sOptionals.put("userTimezone", "Europe/Helsinki"); + } + @Before public void setup() { MockitoAnnotations.initMocks(this); @@ -47,15 +65,18 @@ public void setup() { mRestApi, "user", "1234", - "organization" + "organization", + Locale.US, + mTimeZone ); when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); + when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(mAuthResponse); } @Test - public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { + public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { when(mKey.isAvailable()).thenReturn(true); when(mKey.getExponent()).thenReturn("e"); when(mKey.getModulus()).thenReturn("m"); @@ -63,18 +84,18 @@ public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { objectUnderTest.authenticate().subscribe(); - verify(mRestApi, times(1)).authenticate("user", "hashed password", "organization", null); + verify(mRestApi, times(1)).authenticate("user", "hashed password", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); verify(mAlgorithm, times(1)).encrypt("m", "e", "1234"); } @Test - public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() { + public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() { when(mKey.isAvailable()).thenReturn(false); objectUnderTest.authenticate().subscribe(); - verify(mRestApi, times(1)).authenticate("user", "1234", "organization", null); + verify(mRestApi, times(1)).authenticate("user", "1234", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); verifyZeroInteractions(mAlgorithm); } From 7e9fcc993fd9c9a6bf2ffd0e0c59ea0cc3068042 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Sep 2015 14:13:21 +0300 Subject: [PATCH 144/457] Add unit test for EncryptionKey --- .../entity/server/EncryptionKeyTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java new file mode 100644 index 00000000..a8cde428 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java @@ -0,0 +1,45 @@ +package com.jaspersoft.android.sdk.network.entity.server; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class EncryptionKeyTest { + @Test + @Parameters({ + "error", + "exponent", + "maxdigits", + "modulus", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = EncryptionKey.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + @Parameters({ + "error|Error", + "exponent|e", + "modulus|n", + }) + public void optionsFieldShouldHaveSerializedNameAnnotationForField(String fieldName, String serializeName) throws NoSuchFieldException { + Field field = EncryptionKey.class.getDeclaredField(fieldName); + assertThat(field, hasSerializedName(serializeName)); + } +} \ No newline at end of file From a146e9712a51c947959e7ee22d2d873705f4d47e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 22 Sep 2015 09:14:04 +0300 Subject: [PATCH 145/457] Initial design of API --- .../sdk/network/api/RepositoryRestApi.java | 4 ++ .../repository/RepositoryRestApiFactory.java | 53 +++++++++++++++ .../service/repository/RepositoryService.java | 16 +++-- .../service/repository/SearchCriteria.java | 65 +++++++++++++++++++ .../sdk/service/repository/SearchResult.java | 45 +++++++++++++ .../sdk/service/repository/SearchTask.java | 47 ++++++++++++++ .../repository/RepositoryServiceTest.java | 29 +++++++++ 7 files changed, 254 insertions(+), 5 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 8fcf58fc..c0097f6a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -61,6 +61,10 @@ public interface RepositoryRestApi { @WorkerThread FolderLookupResponse requestFolderResource(@NonNull String resourceUri); + interface Factory { + RepositoryRestApi get(); + } + final class Builder extends GenericAuthBuilder { @Override RepositoryRestApi createApi() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java new file mode 100644 index 00000000..a5e9f7f1 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java @@ -0,0 +1,53 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import android.support.annotation.WorkerThread; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.service.TokenProvider; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class RepositoryRestApiFactory implements RepositoryRestApi.Factory { + private final String mServerUrl; + private final TokenProvider mTokenProvider; + + public RepositoryRestApiFactory(String serverUrl, TokenProvider tokenProvider) { + mServerUrl = serverUrl; + mTokenProvider = tokenProvider; + } + + @Override + @WorkerThread + public RepositoryRestApi get() { + return new RepositoryRestApi.Builder() + .baseUrl(mServerUrl) + .token(mTokenProvider.provideToken()) + .build(); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index c01b7eb5..8e1e56ea 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -1,13 +1,19 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.data.resource.ResourceLookup; - -import java.util.Collection; +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; /** * @author Tom Koptel * @since 2.0 */ -public interface RepositoryService { - Collection searchResources(); +public class RepositoryService { + private final RepositoryRestApi.Factory mRestApiFactory; + + public RepositoryService(RepositoryRestApi.Factory apiFactory) { + mRestApiFactory = apiFactory; + } + + public SearchTask search(SearchCriteria criteria) { + return new SearchTask(criteria, mRestApiFactory); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java new file mode 100644 index 00000000..1b05f3d2 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -0,0 +1,65 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class SearchCriteria { + public static int ALL = 0; + public static int REPORT = 1; + public static int DASHBOARD = 2; + public static int LEGACY_DASHBOARD = 4; + + private final int mCount; + private final int mResourceMask; + + private SearchCriteria(int count, + int resourceMask) { + mCount = count; + mResourceMask = resourceMask; + } + + public static class Builder { + + private int mCount; + private int mResourceMask; + + public Builder limitCount(int count) { + mCount = count; + return this; + } + + public Builder resourceMask(int resourceMask) { + mResourceMask = resourceMask; + return this; + } + + public SearchCriteria build() { + return new SearchCriteria(mCount, mResourceMask); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java new file mode 100644 index 00000000..93df029b --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java @@ -0,0 +1,45 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.service.data.resource.ResourceLookup; + +import java.util.Collection; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class SearchResult { + private final Collection mResult; + + public SearchResult(Collection raw) { + mResult = raw; + } + + public Collection getResult() { + return mResult; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java new file mode 100644 index 00000000..89dc87cc --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -0,0 +1,47 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; + +import rx.Observable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class SearchTask { + private final SearchCriteria mCriteria; + private final RepositoryRestApi.Factory mRestFactory; + + public SearchTask( SearchCriteria criteria, RepositoryRestApi.Factory restFactory) { + mCriteria = criteria; + mRestFactory = restFactory; + } + + public Observable nextLookup() { + return Observable.empty(); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index f002becb..25c5624d 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -1,9 +1,38 @@ package com.jaspersoft.android.sdk.service.repository; +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.service.TokenProvider; + +import org.junit.Test; +import org.mockito.Mock; + /** * @author Tom Koptel * @since 2.0 */ public class RepositoryServiceTest { + @Mock + TokenProvider mTokenProvider; + + String mServerUrl = "http://localhost"; + + @Test + public void shouldProvideListOfResources() { + RepositoryRestApi.Factory apiFactory = new RepositoryRestApiFactory(mServerUrl, mTokenProvider); + RepositoryService service = new RepositoryService(apiFactory); + SearchCriteria criteria = new SearchCriteria.Builder() + .limitCount(10) + .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) + .build(); + SearchTask task = service.search(criteria); + // 10 + task.nextLookup().subscribe(); + // 20 + task.nextLookup().subscribe(); + // 5 + task.nextLookup().subscribe(); + // 0 + task.nextLookup().subscribe(); + } } \ No newline at end of file From 451587c476213482203473ac062af881f332e591 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Sep 2015 13:40:08 +0300 Subject: [PATCH 146/457] Implementing SearchCriteria --- .../service/repository/SearchCriteria.java | 126 ++++++++++++++--- .../repository/RepositoryServiceTest.java | 4 +- .../repository/SearchCriteriaTest.java | 133 ++++++++++++++++++ 3 files changed, 245 insertions(+), 18 deletions(-) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 1b05f3d2..56003559 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -24,42 +24,136 @@ package com.jaspersoft.android.sdk.service.repository; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.HashMap; +import java.util.Map; + /** * @author Tom Koptel * @since 2.0 */ public final class SearchCriteria { - public static int ALL = 0; - public static int REPORT = 1; - public static int DASHBOARD = 2; - public static int LEGACY_DASHBOARD = 4; - private final int mCount; + public static int ALL = 1; + public static int REPORT = (1 << 1); + public static int DASHBOARD = (1 << 2); + public static int LEGACY_DASHBOARD = (1 << 3); + + private final Integer mCount; private final int mResourceMask; + private final Boolean mRecursive; + private final Boolean mForceFullPage; + private final String mQuery; + private final String mSortBy; - private SearchCriteria(int count, - int resourceMask) { - mCount = count; - mResourceMask = resourceMask; + private SearchCriteria(Builder builder) { + mCount = builder.count; + mResourceMask = builder.resourceMask; + mRecursive = builder.recursive; + mForceFullPage = builder.forceFullPage; + mQuery = builder.query; + mSortBy = builder.sort; } - public static class Builder { + @NonNull + public static SearchCriteria.Builder builder() { + return new SearchCriteria.Builder(); + } + + @NonNull + public Map toMap() { + Map params = new HashMap<>(); + + if (mCount != null) { + params.put("limit", String.valueOf(mCount)); + } + if (mRecursive != null) { + params.put("recursive", String.valueOf(mRecursive)); + } + if (mForceFullPage != null) { + params.put("forceFullPage", String.valueOf(mForceFullPage)); + } + if (mQuery != null && mQuery.length() > 0) { + params.put("q", mQuery); + } + if (mSortBy != null) { + params.put("sortBy", mSortBy); + } + + populateTypes(params); + return params; + } - private int mCount; - private int mResourceMask; + private void populateTypes(Map params) { + boolean includeReport = + (mResourceMask & REPORT) == REPORT || (mResourceMask & ALL) == ALL; + if (includeReport) { + params.put("type", "reportUnit"); + } + boolean includeDashboard = + (mResourceMask & DASHBOARD) == DASHBOARD || (mResourceMask & ALL) == ALL; + if (includeDashboard) { + params.put("type", "dashboard"); + } + boolean includeLegacyDashboard = + (mResourceMask & LEGACY_DASHBOARD) == LEGACY_DASHBOARD || (mResourceMask & ALL) == ALL; + if (includeLegacyDashboard) { + params.put("type", "legacyDashboard"); + } + } + + public static class Builder { + @Nullable + private Integer count; + private int resourceMask; + @Nullable + private Boolean recursive; + @Nullable + private Boolean forceFullPage; + @Nullable + private String query; + @Nullable + private String sort; public Builder limitCount(int count) { - mCount = count; + this.count = count; return this; } public Builder resourceMask(int resourceMask) { - mResourceMask = resourceMask; + this.resourceMask = resourceMask; + return this; + } + + public Builder recursive(boolean recursive) { + this.recursive = recursive; + return this; + } + + public Builder forceFullPage(boolean forceFullPage) { + this.forceFullPage = forceFullPage; + return this; + } + + public Builder query(@Nullable String query) { + this.query = query; + return this; + } + + public Builder sortByLabel() { + this.sort = "label"; + return this; + } + + public Builder sortByCreationDate() { + this.sort = "creationDate"; return this; } - public SearchCriteria build() { - return new SearchCriteria(mCount, mResourceMask); + public SearchCriteria create() { + return new SearchCriteria(this); } } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 25c5624d..73324350 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -21,10 +21,10 @@ public void shouldProvideListOfResources() { RepositoryRestApi.Factory apiFactory = new RepositoryRestApiFactory(mServerUrl, mTokenProvider); RepositoryService service = new RepositoryService(apiFactory); - SearchCriteria criteria = new SearchCriteria.Builder() + SearchCriteria criteria = SearchCriteria.builder() .limitCount(10) .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) - .build(); + .create(); SearchTask task = service.search(criteria); // 10 task.nextLookup().subscribe(); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java new file mode 100644 index 00000000..df05c797 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -0,0 +1,133 @@ +package com.jaspersoft.android.sdk.service.repository; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.HashMap; +import java.util.Map; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +@RunWith(JUnitParamsRunner.class) +public class SearchCriteriaTest { + + @Test + public void shouldIncludeCountInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .limitCount(100) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("limit", "100"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeRecursiveInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .recursive(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("recursive", "true"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeForceFullPageInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .forceFullPage(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("forceFullPage", "true"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeQueryPageInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .query("any") + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("q", "any"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeSortByLabelInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .sortByLabel() + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("sortBy", "label"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeSortByCreationDateInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .sortByCreationDate() + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("sortBy", "creationDate"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIgnoreEmptyQuery() { + SearchCriteria criteria = SearchCriteria.builder() + .query("") + .create(); + + Map emptytMap = new HashMap<>(); + assertThat(criteria.toMap(), is(emptytMap)); + } + + @Test + @Parameters({ + "REPORT|reportUnit", + "DASHBOARD|dashboard", + "LEGACY_DASHBOARD|legacyDashboard", + "ALL|reportUnit:dashboard:legacyDashboard", + }) + public void criteriaShouldIncludeTypeInParams(String flag, String types) throws Exception { + Integer resource = (Integer) SearchCriteria.class.getField(flag).get(null); + + SearchCriteria criteria = SearchCriteria.builder() + .resourceMask(resource) + .create(); + + Map resultMap = new HashMap<>(); + if (types.contains(":")) { + for (String type : types.split(":")) { + resultMap.put("type", type); + } + } else { + resultMap.put("type", types); + } + + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldReturnEmptyParamsIfNoSupplied() { + SearchCriteria criteria = SearchCriteria.builder().create(); + Map resultMap = new HashMap<>(); + assertThat(criteria.toMap(), is(resultMap)); + } +} \ No newline at end of file From 3c25a7411d4337d4a8a35120400563b6f9d0b43d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Sep 2015 14:19:22 +0300 Subject: [PATCH 147/457] Implementing SearchStrategy Factory --- .../sdk/network/api/ServerRestApi.java | 4 ++ .../repository/EmeraldMR2SearchStrategy.java | 16 +++++++ .../repository/EmeraldMR3SearchStrategy.java | 16 +++++++ .../service/repository/RepositoryService.java | 12 +++-- .../service/repository/SearchStrategy.java | 25 ++++++++++ .../sdk/service/repository/SearchTask.java | 13 +++-- .../service/server/ServerRestApiFactory.java | 18 +++++++ .../repository/RepositoryServiceTest.java | 7 ++- .../repository/SearchStrategyTest.java | 48 +++++++++++++++++++ 9 files changed, 150 insertions(+), 9 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 52084f4f..52765a2e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -66,6 +66,10 @@ public interface ServerRestApi { @WorkerThread String requestExpiration(); + interface Factory { + ServerRestApi get(); + } + final class Builder extends GenericBuilder { @Override ServerRestApi createApi() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java new file mode 100644 index 00000000..0c84ddb2 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -0,0 +1,16 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; + +import rx.Observable; + +final class EmeraldMR2SearchStrategy implements SearchStrategy { + public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { + + } + + @Override + public Observable search() { + return null; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java new file mode 100644 index 00000000..14331143 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -0,0 +1,16 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; + +import rx.Observable; + +final class EmeraldMR3SearchStrategy implements SearchStrategy { + public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { + + } + + @Override + public Observable search() { + return null; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 8e1e56ea..31e86f33 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -1,19 +1,23 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; /** * @author Tom Koptel * @since 2.0 */ public class RepositoryService { - private final RepositoryRestApi.Factory mRestApiFactory; + private final RepositoryRestApi.Factory mRepositoryApiFactory; + private final ServerRestApi.Factory mInfoApiFactory; - public RepositoryService(RepositoryRestApi.Factory apiFactory) { - mRestApiFactory = apiFactory; + public RepositoryService(RepositoryRestApi.Factory repositoryApiFactory, + ServerRestApi.Factory infoApiFactory) { + mRepositoryApiFactory = repositoryApiFactory; + mInfoApiFactory = infoApiFactory; } public SearchTask search(SearchCriteria criteria) { - return new SearchTask(criteria, mRestApiFactory); + return new SearchTask(criteria, mRepositoryApiFactory, mInfoApiFactory); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java new file mode 100644 index 00000000..d7ab29ef --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -0,0 +1,25 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; + +import rx.Observable; + +public interface SearchStrategy { + Observable search(); + + class Factory { + public static SearchStrategy get(String serverVersion, + RepositoryRestApi.Factory repositoryApiFactory, + SearchCriteria criteria) { + ServerVersion version = ServerVersion.defaultParser().parse(serverVersion); + if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { + return new EmeraldMR2SearchStrategy(repositoryApiFactory, criteria); + } + if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { + return new EmeraldMR3SearchStrategy(repositoryApiFactory, criteria); + } + throw new UnsupportedOperationException("Could not resolve search strategy for serverVersion: " + serverVersion); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 89dc87cc..4d4fa86c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; import rx.Observable; @@ -34,11 +35,17 @@ */ public final class SearchTask { private final SearchCriteria mCriteria; - private final RepositoryRestApi.Factory mRestFactory; + private final RepositoryRestApi.Factory mRepositoryApiFactory; + private final ServerRestApi.Factory mInfoApiFactory; - public SearchTask( SearchCriteria criteria, RepositoryRestApi.Factory restFactory) { + private Observable searchStrategyObservable; + + SearchTask(SearchCriteria criteria, + RepositoryRestApi.Factory repositoryApiFactory, + ServerRestApi.Factory infoApiFactory) { mCriteria = criteria; - mRestFactory = restFactory; + mRepositoryApiFactory = repositoryApiFactory; + mInfoApiFactory = infoApiFactory; } public Observable nextLookup() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java new file mode 100644 index 00000000..75bc1fd7 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java @@ -0,0 +1,18 @@ +package com.jaspersoft.android.sdk.service.server; + +import com.jaspersoft.android.sdk.network.api.ServerRestApi; + +public final class ServerRestApiFactory implements ServerRestApi.Factory { + private final String mServerUrl; + + public ServerRestApiFactory(String serverUrl) { + mServerUrl = serverUrl; + } + + @Override + public ServerRestApi get() { + return new ServerRestApi.Builder() + .baseUrl(mServerUrl) + .build(); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 73324350..586b993f 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -1,7 +1,9 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.service.TokenProvider; +import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; import org.junit.Test; import org.mockito.Mock; @@ -18,8 +20,9 @@ public class RepositoryServiceTest { @Test public void shouldProvideListOfResources() { - RepositoryRestApi.Factory apiFactory = new RepositoryRestApiFactory(mServerUrl, mTokenProvider); - RepositoryService service = new RepositoryService(apiFactory); + RepositoryRestApi.Factory repoApi = new RepositoryRestApiFactory(mServerUrl, mTokenProvider); + ServerRestApi.Factory infoApi = new ServerRestApiFactory(mServerUrl); + RepositoryService service = new RepositoryService(repoApi, infoApi); SearchCriteria criteria = SearchCriteria.builder() .limitCount(10) diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java new file mode 100644 index 00000000..fb5e7d8f --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -0,0 +1,48 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.Matchers.instanceOf; +import static org.junit.Assert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public final class SearchStrategyTest { + + @Mock + RepositoryRestApi.Factory mFactory; + SearchCriteria mSearchCriteria = SearchCriteria.builder().create(); + + @Before + public void before() { + MockitoAnnotations.initMocks(this); + } + + @Test + @Parameters({ + "5.0", + "5.5", + }) + public void factoryCreatesEmeraldMR2Strategy(String version) { + SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, mSearchCriteria); + assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); + } + + @Test + @Parameters({ + "6.0", + "6.0.1", + }) + public void factoryCreatesEmeraldMR3Strategy(String version) { + SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, mSearchCriteria); + assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); + } +} From bf1009648a2e3ef009cee56e7b8a16571830d82b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Sep 2015 15:02:32 +0300 Subject: [PATCH 148/457] Implementing SearchTask --- .../service/repository/SearchCriteria.java | 5 ++ .../sdk/service/repository/SearchTask.java | 32 ++++++- .../service/repository/SearchTaskTest.java | 84 +++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 56003559..05b64931 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -62,6 +62,11 @@ public static SearchCriteria.Builder builder() { return new SearchCriteria.Builder(); } + @NonNull + public static SearchCriteria none() { + return builder().create(); + } + @NonNull public Map toMap() { Map params = new HashMap<>(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 4d4fa86c..5b5b36e7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -28,6 +28,8 @@ import com.jaspersoft.android.sdk.network.api.ServerRestApi; import rx.Observable; +import rx.functions.Func0; +import rx.functions.Func1; /** * @author Tom Koptel @@ -49,6 +51,34 @@ public final class SearchTask { } public Observable nextLookup() { - return Observable.empty(); + return defineSearchStrategy().flatMap(new Func1>() { + @Override + public Observable call(SearchStrategy searchStrategy) { + return searchStrategy.search(); + } + }); + } + + private Observable defineSearchStrategy() { + if (searchStrategyObservable == null) { + searchStrategyObservable = requestServerVersion().flatMap(new Func1>() { + @Override + public Observable call(String version) { + SearchStrategy strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); + return Observable.just(strategy); + } + }).cache(); + } + return searchStrategyObservable; + } + + private Observable requestServerVersion() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + String version = mInfoApiFactory.get().requestVersion(); + return Observable.just(version); + } + }); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java new file mode 100644 index 00000000..d437c387 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java @@ -0,0 +1,84 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import rx.Observable; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(SearchStrategy.Factory.class) +public class SearchTaskTest { + + SearchCriteria mSearchCriteria = SearchCriteria.none(); + + @Mock + RepositoryRestApi.Factory mRepoApiFactory; + @Mock + ServerRestApi.Factory mInfoApiFactory; + @Mock + RepositoryRestApi mRepoApi; + @Mock + ServerRestApi mInfoApi; + @Mock + SearchStrategy mSearchStrategy; + + private SearchTask objectUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new SearchTask(mSearchCriteria, mRepoApiFactory, mInfoApiFactory); + when(mRepoApiFactory.get()).thenReturn(mRepoApi); + when(mInfoApiFactory.get()).thenReturn(mInfoApi); + + Observable resultObservable = Observable.just(null); + when(mSearchStrategy.search()).thenReturn(resultObservable); + + PowerMockito.mockStatic(SearchStrategy.Factory.class); + PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.Factory.class), any(SearchCriteria.class))).thenReturn(mSearchStrategy); + } + + @Test + public void nextLookupShouldDefineSearchStrategy() { + when(mInfoApi.requestVersion()).thenReturn("5.5"); + objectUnderTest.nextLookup().toBlocking().first(); + + PowerMockito.verifyStatic(times(1)); + SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(mSearchCriteria)); + + verify(mInfoApi, times(1)).requestVersion(); + verify(mInfoApiFactory, times(1)).get(); + verify(mSearchStrategy, times(1)).search(); + } + + @Test + public void secondLookupShouldUseCachedStrategy() { + when(mInfoApi.requestVersion()).thenReturn("5.5"); + + objectUnderTest.nextLookup().toBlocking().first(); + objectUnderTest.nextLookup().toBlocking().first(); + + PowerMockito.verifyStatic(times(1)); + SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(mSearchCriteria)); + + verify(mInfoApi, times(1)).requestVersion(); + verify(mInfoApiFactory, times(1)).get(); + verify(mSearchStrategy, times(2)).search(); + } +} \ No newline at end of file From 18363bf169fd35623c3a0835c38c1863b9911ce1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Sep 2015 15:37:20 +0300 Subject: [PATCH 149/457] Add missing headers and copyright --- .../repository/EmeraldMR2SearchStrategy.java | 28 +++++++++++++++++++ .../repository/EmeraldMR3SearchStrategy.java | 28 +++++++++++++++++++ .../service/repository/RepositoryService.java | 24 ++++++++++++++++ .../service/repository/SearchStrategy.java | 28 +++++++++++++++++++ .../service/server/ServerRestApiFactory.java | 28 +++++++++++++++++++ .../repository/RepositoryServiceTest.java | 24 ++++++++++++++++ .../repository/SearchCriteriaTest.java | 28 +++++++++++++++++++ .../repository/SearchStrategyTest.java | 28 +++++++++++++++++++ .../service/repository/SearchTaskTest.java | 28 +++++++++++++++++++ 9 files changed, 244 insertions(+) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 0c84ddb2..9d0f4dd2 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -1,9 +1,37 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import rx.Observable; +/** + * @author Tom Koptel + * @since 2.0 + */ final class EmeraldMR2SearchStrategy implements SearchStrategy { public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 14331143..d25f39d7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -1,9 +1,37 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import rx.Observable; +/** + * @author Tom Koptel + * @since 2.0 + */ final class EmeraldMR3SearchStrategy implements SearchStrategy { public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 31e86f33..58de003f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -1,3 +1,27 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index d7ab29ef..fc761431 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -1,3 +1,27 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; @@ -5,6 +29,10 @@ import rx.Observable; +/** + * @author Tom Koptel + * @since 2.0 + */ public interface SearchStrategy { Observable search(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java index 75bc1fd7..6358e356 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java @@ -1,7 +1,35 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +/** + * @author Tom Koptel + * @since 2.0 + */ public final class ServerRestApiFactory implements ServerRestApi.Factory { private final String mServerUrl; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 586b993f..d1c0d581 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -1,3 +1,27 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index df05c797..855276e8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -1,3 +1,27 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import org.junit.Test; @@ -12,6 +36,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +/** + * @author Tom Koptel + * @since 2.0 + */ @RunWith(JUnitParamsRunner.class) public class SearchCriteriaTest { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index fb5e7d8f..43996b10 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -1,3 +1,27 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; @@ -14,6 +38,10 @@ import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertThat; +/** + * @author Tom Koptel + * @since 2.0 + */ @RunWith(JUnitParamsRunner.class) public final class SearchStrategyTest { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java index d437c387..f678018d 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java @@ -1,3 +1,27 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; @@ -21,6 +45,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +/** + * @author Tom Koptel + * @since 2.0 + */ @RunWith(PowerMockRunner.class) @PrepareForTest(SearchStrategy.Factory.class) public class SearchTaskTest { From 43715184e4c5f071384e36a077e36805ed00ef17 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Sep 2015 15:38:02 +0300 Subject: [PATCH 150/457] Implementing 'newBuilder' api for SearchCriteria --- .../service/repository/SearchCriteria.java | 76 +++++++++++++++++++ .../repository/SearchCriteriaTest.java | 74 ++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 05b64931..a02dd809 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -42,6 +42,7 @@ public final class SearchCriteria { public static int LEGACY_DASHBOARD = (1 << 3); private final Integer mCount; + private final Integer mOffset; private final int mResourceMask; private final Boolean mRecursive; private final Boolean mForceFullPage; @@ -50,6 +51,7 @@ public final class SearchCriteria { private SearchCriteria(Builder builder) { mCount = builder.count; + mOffset = builder.offset; mResourceMask = builder.resourceMask; mRecursive = builder.recursive; mForceFullPage = builder.forceFullPage; @@ -67,6 +69,65 @@ public static SearchCriteria none() { return builder().create(); } + @Nullable + public Integer getCount() { + return mCount; + } + + @Nullable + public Integer getOffset() { + return mOffset; + } + + @Nullable + public Boolean getForceFullPage() { + return mForceFullPage; + } + + @Nullable + public String getQuery() { + return mQuery; + } + + @Nullable + public Boolean getRecursive() { + return mRecursive; + } + + @Nullable + public String getSortBy() { + return mSortBy; + } + + public int getResourceMask() { + return mResourceMask; + } + + @NonNull + public SearchCriteria.Builder newBuilder() { + SearchCriteria.Builder builder = builder(); + if (mCount != null) { + builder.limitCount(mCount); + } + if (mOffset != null) { + builder.offset(mOffset); + } + if (mRecursive != null) { + builder.recursive(mRecursive); + } + if (mForceFullPage != null) { + builder.forceFullPage(mForceFullPage); + } + if (mQuery != null) { + builder.query(mQuery); + } + if (mSortBy != null) { + builder.sortBy(mSortBy); + } + builder.resourceMask(mResourceMask); + return builder; + } + @NonNull public Map toMap() { Map params = new HashMap<>(); @@ -74,6 +135,9 @@ public Map toMap() { if (mCount != null) { params.put("limit", String.valueOf(mCount)); } + if (mOffset != null) { + params.put("offset", String.valueOf(mOffset)); + } if (mRecursive != null) { params.put("recursive", String.valueOf(mRecursive)); } @@ -112,6 +176,8 @@ private void populateTypes(Map params) { public static class Builder { @Nullable private Integer count; + @Nullable + private Integer offset; private int resourceMask; @Nullable private Boolean recursive; @@ -127,6 +193,11 @@ public Builder limitCount(int count) { return this; } + public Builder offset(@Nullable Integer offset) { + this.offset = offset; + return this; + } + public Builder resourceMask(int resourceMask) { this.resourceMask = resourceMask; return this; @@ -147,6 +218,11 @@ public Builder query(@Nullable String query) { return this; } + Builder sortBy(String sort) { + this.sort = sort; + return this; + } + public Builder sortByLabel() { this.sort = "label"; return this; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index 855276e8..052b56cb 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -55,6 +55,18 @@ public void shouldIncludeCountInParams() { assertThat(criteria.toMap(), is(resultMap)); } + @Test + public void shouldIncludeOffsetInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .offset(100) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("offset", "100"); + + assertThat(criteria.toMap(), is(resultMap)); + } + @Test public void shouldIncludeRecursiveInParams() { SearchCriteria criteria = SearchCriteria.builder() @@ -158,4 +170,66 @@ public void shouldReturnEmptyParamsIfNoSupplied() { Map resultMap = new HashMap<>(); assertThat(criteria.toMap(), is(resultMap)); } + + @Test + public void newBuilderShouldCopyCount() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .limitCount(100) + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getCount(), is(100)); + } + + @Test + public void newBuilderShouldCopyOffset() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .offset(100) + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getOffset(), is(100)); + } + + @Test + public void newBuilderShouldCopyForceFullPageFlag() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .forceFullPage(true) + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getForceFullPage(), is(true)); + } + + @Test + public void newBuilderShouldCopyQuery() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .query("q") + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getQuery(), is("q")); + } + + @Test + public void newBuilderShouldCopyRecursiveFlag() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .recursive(true) + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getRecursive(), is(true)); + } + + @Test + public void newBuilderShouldCopySortBy() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .sortByCreationDate() + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getSortBy(), is("creationDate")); + } + @Test + public void newBuilderShouldCopyResourceMask() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getResourceMask(), is(SearchCriteria.REPORT | SearchCriteria.DASHBOARD)); + } } \ No newline at end of file From 90b772ce55a7142f0faeaa7b34b47b8d58e9e336 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 24 Sep 2015 12:21:30 +0300 Subject: [PATCH 151/457] Properly handling encryption key request if one is missing --- .../api/AuthenticationRestApiImpl.java | 12 +++- .../network/entity/server/EncryptionKey.java | 9 ++- .../api/AuthenticationRestApiTest.java | 59 ++++++++++++++----- .../android/sdk/test/MockResponseFactory.java | 5 ++ 4 files changed, 68 insertions(+), 17 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index b2a26761..26a56dbd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -26,6 +26,7 @@ import android.support.annotation.NonNull; +import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.Call; @@ -112,7 +113,16 @@ public EncryptionKey requestEncryptionMetadata() { mRestAdapterBuilder.client(mClient); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); - return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata()).body(); + try { + return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata()).body(); + } catch (JsonSyntaxException ex) { + /** + * This possible when security option is disabled on JRS side. + * API responds with malformed json. E.g. {Error: Key generation is off}. As you can see no quotes + * As soon as there 2 options to resolve this we decide to swallow exception and return empty object + */ + return EncryptionKey.empty(); + } } private Request createAuthRequest( diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java index b81a1801..bdb86613 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java @@ -46,6 +46,9 @@ public final class EncryptionKey { @SerializedName("n") private String modulus; + private EncryptionKey() { + } + @NonNull public String getExponent() { return exponent; @@ -62,6 +65,10 @@ public String getModulus() { } public boolean isAvailable() { - return error == null; + return exponent != null && modulus != null; + } + + public static EncryptionKey empty() { + return new EncryptionKey(); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index ddd6b75c..f21ef1bc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -25,7 +25,12 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; +import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; import org.junit.Before; @@ -52,8 +57,12 @@ public class AuthenticationRestApiTest { private AuthenticationRestApi mRestApi; + @ResourceFile("json/encryption_key.json") + TestResource mKey; + @Before public void setup() { + TestResourceInjector.inject(this); mRestApi = new AuthenticationRestApi.Builder() .baseUrl(mWebMockRule.getRootUrl()) .build(); @@ -61,8 +70,9 @@ public void setup() { @Test public void shouldReturnResponseForSuccessRedirect() { - MockResponse mockResponse = create302Response(); - mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); + MockResponse mockResponse = MockResponseFactory.create302() + .addHeader("Set-Cookie", "cookie1") + .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", null, null); @@ -73,8 +83,9 @@ public void shouldReturnResponseForSuccessRedirect() { public void shouldRiseErrorForErrorRedirect() { mExpectedException.expect(RestError.class); - MockResponse mockResponse = create302Response(); - mockResponse.addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_ERROR); + MockResponse mockResponse = MockResponseFactory.create302() + .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_ERROR) + .addHeader("Set-Cookie", "cookie1"); mWebMockRule.enqueue(mockResponse); mRestApi.authenticate("joeuser", "joeuser", "null", null); @@ -84,8 +95,7 @@ public void shouldRiseErrorForErrorRedirect() { public void shouldRiseErrorForHttpException() { mExpectedException.expect(RestError.class); - MockResponse mockResponse = create500Response(); - mWebMockRule.enqueue(mockResponse); + mWebMockRule.enqueue(MockResponseFactory.create500()); mRestApi.authenticate("joeuser", "joeuser", "null", null); } @@ -95,20 +105,39 @@ public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() { mExpectedException.expect(IllegalStateException.class); mExpectedException.expectMessage("Location HEADER is missing please contact JRS admin"); - MockResponse mockResponse = create302Response(); - mWebMockRule.enqueue(mockResponse); + mWebMockRule.enqueue(MockResponseFactory.create302().addHeader("Set-Cookie", "cookie1")); mRestApi.authenticate("joeuser", "joeuser", "null", null); } - private MockResponse create302Response() { - return new MockResponse() - .addHeader("Set-Cookie", "cookie1") - .setStatus("HTTP/1.1 302 Found"); + @Test + public void shouldReturnEncryptionKeyIfApiAvailable() { + MockResponse anonymousCookie = MockResponseFactory.create200() + .setBody("6.1") + .addHeader("Set-Cookie", "cookie1"); + MockResponse encryptionKey = MockResponseFactory.create200() + .setBody(mKey.asString()); + mWebMockRule.enqueue(anonymousCookie); + mWebMockRule.enqueue(encryptionKey); + + EncryptionKey keyResponse = mRestApi.requestEncryptionMetadata(); + assertThat(keyResponse, is(notNullValue())); } - private MockResponse create500Response() { - return new MockResponse() - .setStatus("HTTP/1.1 500 Internal Server Error"); + @Test + public void shouldReturnEmptyEncryptionKeyIfApiNotAvailable() { + MockResponse anonymousCookie = MockResponseFactory.create200() + .setBody("6.1") + .addHeader("Set-Cookie", "cookie1"); + + String malformedJson = "{Error: Key generation is off}"; + MockResponse encryptionKey = MockResponseFactory.create200() + .setBody(malformedJson); + + mWebMockRule.enqueue(anonymousCookie); + mWebMockRule.enqueue(encryptionKey); + + EncryptionKey keyResponse = mRestApi.requestEncryptionMetadata(); + assertThat(keyResponse.isAvailable(), is(false)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java index 2f512c37..93b72f64 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java @@ -48,4 +48,9 @@ public static MockResponse create500() { return new MockResponse() .setStatus("HTTP/1.1 500 Internal Server Error"); } + + public static MockResponse create302() { + return new MockResponse() + .setStatus("HTTP/1.1 302 Found"); + } } From fd9813a70b25be55b5d9274c99ad2044a02abb00 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 24 Sep 2015 14:48:59 +0300 Subject: [PATCH 152/457] Add initial implementation of Emerald MR3 search strategy --- .../repository/EmeraldMR2SearchStrategy.java | 5 +- .../repository/EmeraldMR3SearchStrategy.java | 49 ++++++++++++++++++- .../service/repository/SearchCriteria.java | 30 ++++++++---- .../sdk/service/repository/SearchResult.java | 28 +++++++++-- .../service/repository/SearchStrategy.java | 7 ++- .../sdk/service/repository/SearchTask.java | 9 ++-- .../service/repository/SearchTaskTest.java | 5 +- 7 files changed, 109 insertions(+), 24 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 9d0f4dd2..f632fe32 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -25,6 +25,9 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; + +import java.util.Collection; import rx.Observable; @@ -38,7 +41,7 @@ public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, } @Override - public Observable search() { + public Observable> search() { return null; } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index d25f39d7..950dea74 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -25,20 +25,65 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; + +import java.util.Collection; import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel * @since 2.0 */ final class EmeraldMR3SearchStrategy implements SearchStrategy { + private final RepositoryRestApi.Factory mRepoFactory; + private final SearchCriteria mInitialCriteria; + + private int mNextOffset; + public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { + mRepoFactory = repositoryApiFactory; + // Internally enabling 'forceFullPageFlag' + mInitialCriteria = criteria.newBuilder() + .forceFullPage(true) + .create(); + int initialOffset = (criteria.getOffset() == null) ? 0 : criteria.getOffset(); + mNextOffset = initialOffset; } @Override - public Observable search() { - return null; + public Observable> search() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + return Observable.just(makeApiCall()); + } + }); + } + + private Collection makeApiCall() { + SearchCriteria newSearchCriteria = resolveNextCriteria(); + RepositoryRestApi api = mRepoFactory.get(); + ResourceSearchResponse result = api.searchResources(newSearchCriteria.toMap()); + updateNextOffset(result); + return result.getResources(); + } + + private void updateNextOffset(ResourceSearchResponse result) { + int nextOffset = result.getNextOffset(); + + boolean endReached = (nextOffset == 0); + if (!endReached) { + mNextOffset = nextOffset; + } + } + + private SearchCriteria resolveNextCriteria() { + SearchCriteria.Builder newCriteriaBuilder = mInitialCriteria.newBuilder(); + newCriteriaBuilder.offset(mNextOffset); + return newCriteriaBuilder.create(); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index a02dd809..bb507c5f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -208,21 +208,11 @@ public Builder recursive(boolean recursive) { return this; } - public Builder forceFullPage(boolean forceFullPage) { - this.forceFullPage = forceFullPage; - return this; - } - public Builder query(@Nullable String query) { this.query = query; return this; } - Builder sortBy(String sort) { - this.sort = sort; - return this; - } - public Builder sortByLabel() { this.sort = "label"; return this; @@ -233,6 +223,26 @@ public Builder sortByCreationDate() { return this; } + /** + * Internal use. Mutating sortBy value. + * @param sort either 'label' or 'creationDate' + * @return chain builder instance + */ + Builder sortBy(String sort) { + this.sort = sort; + return this; + } + + /** + * Internal use. Mutating forceFullPage value. + * @param forceFullPage either true or false + * @return chain builder instance + */ + Builder forceFullPage(boolean forceFullPage) { + this.forceFullPage = forceFullPage; + return this; + } + public SearchCriteria create() { return new SearchCriteria(this); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java index 93df029b..66f1e43c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java @@ -24,22 +24,40 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.data.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; -import java.util.Collection; +import java.util.Collections; +import java.util.List; /** * @author Tom Koptel * @since 2.0 */ public final class SearchResult { - private final Collection mResult; + private static final SearchResult EMPTY = new SearchResult(Collections.emptyList(), false); - public SearchResult(Collection raw) { + private final List mResult; + private final boolean mReachedEnd; + + private SearchResult(List raw, boolean endResult) { mResult = raw; + mReachedEnd = endResult; } - public Collection getResult() { + public List getResult() { return mResult; } + + public boolean hasReachedEnd() { + return mReachedEnd; + } + + public static SearchResult reachedEnd(ResourceSearchResponse response) { + return new SearchResult(response.getResources(), true); + } + + public static SearchResult create(ResourceSearchResponse response) { + return new SearchResult(response.getResources(), false); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index fc761431..2c7c9082 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -25,16 +25,19 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import java.util.Collection; + import rx.Observable; /** * @author Tom Koptel * @since 2.0 */ -public interface SearchStrategy { - Observable search(); +interface SearchStrategy { + Observable> search(); class Factory { public static SearchStrategy get(String serverVersion, diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 5b5b36e7..423dfaad 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -26,6 +26,9 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; + +import java.util.Collection; import rx.Observable; import rx.functions.Func0; @@ -50,10 +53,10 @@ public final class SearchTask { mInfoApiFactory = infoApiFactory; } - public Observable nextLookup() { - return defineSearchStrategy().flatMap(new Func1>() { + public Observable> nextLookup() { + return defineSearchStrategy().flatMap(new Func1>>() { @Override - public Observable call(SearchStrategy searchStrategy) { + public Observable> call(SearchStrategy searchStrategy) { return searchStrategy.search(); } }); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java index f678018d..9ba730c6 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import org.junit.Before; import org.junit.Test; @@ -36,6 +37,8 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.Collection; + import rx.Observable; import static org.mockito.Matchers.any; @@ -75,7 +78,7 @@ public void setup() { when(mRepoApiFactory.get()).thenReturn(mRepoApi); when(mInfoApiFactory.get()).thenReturn(mInfoApi); - Observable resultObservable = Observable.just(null); + Observable> resultObservable = Observable.just(null); when(mSearchStrategy.search()).thenReturn(resultObservable); PowerMockito.mockStatic(SearchStrategy.Factory.class); From 9b7edad56ec582eac6eed415a960cd770ea43d58 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 10:10:16 +0300 Subject: [PATCH 153/457] Alterin SearchCriteria - Add support for 'forceTotalCount' internally - Add support for 'folderUri' - Refactor 'limitCount' -> 'limit' - Use primitives for 'limit' and 'offset' --- .../repository/EmeraldMR3SearchStrategy.java | 4 +- .../service/repository/SearchCriteria.java | 95 ++++++++++++++----- .../repository/RepositoryServiceTest.java | 2 +- .../repository/SearchCriteriaTest.java | 51 +++++++++- 4 files changed, 118 insertions(+), 34 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 950dea74..38ef8618 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -49,9 +49,7 @@ public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, mInitialCriteria = criteria.newBuilder() .forceFullPage(true) .create(); - - int initialOffset = (criteria.getOffset() == null) ? 0 : criteria.getOffset(); - mNextOffset = initialOffset; + mNextOffset = criteria.getOffset(); } @Override diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index bb507c5f..356bfdd9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -35,28 +35,34 @@ * @since 2.0 */ public final class SearchCriteria { + private static final int DEFAULT_OFFSET = 0; + private static final int DEFAULT_LIMIT = 100; - public static int ALL = 1; public static int REPORT = (1 << 1); public static int DASHBOARD = (1 << 2); public static int LEGACY_DASHBOARD = (1 << 3); + public static int ALL = REPORT | DASHBOARD | LEGACY_DASHBOARD; - private final Integer mCount; - private final Integer mOffset; + private final int mLimit; + private final int mOffset; private final int mResourceMask; private final Boolean mRecursive; private final Boolean mForceFullPage; + private final Boolean mForceTotalCount; private final String mQuery; private final String mSortBy; + private final String mFolderUri; private SearchCriteria(Builder builder) { - mCount = builder.count; + mLimit = builder.limit; mOffset = builder.offset; mResourceMask = builder.resourceMask; mRecursive = builder.recursive; mForceFullPage = builder.forceFullPage; + mForceTotalCount = builder.forceTotalCount; mQuery = builder.query; mSortBy = builder.sort; + mFolderUri = builder.folderUri; } @NonNull @@ -69,13 +75,11 @@ public static SearchCriteria none() { return builder().create(); } - @Nullable - public Integer getCount() { - return mCount; + public int getLimit() { + return mLimit; } - @Nullable - public Integer getOffset() { + public int getOffset() { return mOffset; } @@ -84,6 +88,11 @@ public Boolean getForceFullPage() { return mForceFullPage; } + @Nullable + public Boolean getForceTotalCount() { + return mForceTotalCount; + } + @Nullable public String getQuery() { return mQuery; @@ -103,28 +112,38 @@ public int getResourceMask() { return mResourceMask; } + @Nullable + public String getFolderUri() { + return mFolderUri; + } + @NonNull public SearchCriteria.Builder newBuilder() { SearchCriteria.Builder builder = builder(); - if (mCount != null) { - builder.limitCount(mCount); - } - if (mOffset != null) { - builder.offset(mOffset); - } + if (mRecursive != null) { builder.recursive(mRecursive); } if (mForceFullPage != null) { builder.forceFullPage(mForceFullPage); } + if (mForceTotalCount != null) { + builder.forceTotalCount(mForceTotalCount); + } if (mQuery != null) { builder.query(mQuery); } if (mSortBy != null) { builder.sortBy(mSortBy); } + if (mFolderUri != null) { + builder.folderUri(mFolderUri); + } + builder.resourceMask(mResourceMask); + builder.limit(mLimit); + builder.offset(mOffset); + return builder; } @@ -132,10 +151,10 @@ public SearchCriteria.Builder newBuilder() { public Map toMap() { Map params = new HashMap<>(); - if (mCount != null) { - params.put("limit", String.valueOf(mCount)); + if (mLimit != DEFAULT_LIMIT) { + params.put("limit", String.valueOf(mLimit)); } - if (mOffset != null) { + if (mOffset != DEFAULT_OFFSET) { params.put("offset", String.valueOf(mOffset)); } if (mRecursive != null) { @@ -144,12 +163,18 @@ public Map toMap() { if (mForceFullPage != null) { params.put("forceFullPage", String.valueOf(mForceFullPage)); } + if (mForceTotalCount != null) { + params.put("forceTotalCount", String.valueOf(mForceTotalCount)); + } if (mQuery != null && mQuery.length() > 0) { params.put("q", mQuery); } if (mSortBy != null) { params.put("sortBy", mSortBy); } + if (mFolderUri != null) { + params.put("folderUri", mFolderUri); + } populateTypes(params); return params; @@ -174,26 +199,29 @@ private void populateTypes(Map params) { } public static class Builder { - @Nullable - private Integer count; - @Nullable - private Integer offset; - private int resourceMask; + private int limit = DEFAULT_LIMIT; + private int offset = DEFAULT_OFFSET; + private int resourceMask = Integer.MIN_VALUE; + @Nullable private Boolean recursive; @Nullable private Boolean forceFullPage; @Nullable + public Boolean forceTotalCount; + @Nullable private String query; @Nullable private String sort; + @Nullable + private String folderUri; - public Builder limitCount(int count) { - this.count = count; + public Builder limit(int limit) { + this.limit = limit; return this; } - public Builder offset(@Nullable Integer offset) { + public Builder offset(int offset) { this.offset = offset; return this; } @@ -223,6 +251,11 @@ public Builder sortByCreationDate() { return this; } + public Builder folderUri(@Nullable String folderUri) { + this.folderUri = folderUri; + return this; + } + /** * Internal use. Mutating sortBy value. * @param sort either 'label' or 'creationDate' @@ -243,6 +276,16 @@ Builder forceFullPage(boolean forceFullPage) { return this; } + /** + * Internal use. Mutating forceTotalCount value. + * @param forceTotalCount either true or false + * @return chain builder instance + */ + Builder forceTotalCount(@Nullable Boolean forceTotalCount) { + this.forceTotalCount = forceTotalCount; + return this; + } + public SearchCriteria create() { return new SearchCriteria(this); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index d1c0d581..a11faf28 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -49,7 +49,7 @@ public void shouldProvideListOfResources() { RepositoryService service = new RepositoryService(repoApi, infoApi); SearchCriteria criteria = SearchCriteria.builder() - .limitCount(10) + .limit(10) .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) .create(); SearchTask task = service.search(criteria); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index 052b56cb..06178fc9 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -46,11 +46,11 @@ public class SearchCriteriaTest { @Test public void shouldIncludeCountInParams() { SearchCriteria criteria = SearchCriteria.builder() - .limitCount(100) + .limit(101) .create(); Map resultMap = new HashMap<>(); - resultMap.put("limit", "100"); + resultMap.put("limit", "101"); assertThat(criteria.toMap(), is(resultMap)); } @@ -91,6 +91,18 @@ public void shouldIncludeForceFullPageInParams() { assertThat(criteria.toMap(), is(resultMap)); } + @Test + public void shouldIncludeForceTotalCountPageInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .forceTotalCount(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("forceTotalCount", "true"); + + assertThat(criteria.toMap(), is(resultMap)); + } + @Test public void shouldIncludeQueryPageInParams() { SearchCriteria criteria = SearchCriteria.builder() @@ -127,6 +139,18 @@ public void shouldIncludeSortByCreationDateInParams() { assertThat(criteria.toMap(), is(resultMap)); } + @Test + public void shouldIncludeFolderUriInParams() { + SearchCriteria criteria = SearchCriteria.builder() + .folderUri("/") + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("folderUri", "/"); + + assertThat(criteria.toMap(), is(resultMap)); + } + @Test public void shouldIgnoreEmptyQuery() { SearchCriteria criteria = SearchCriteria.builder() @@ -174,10 +198,10 @@ public void shouldReturnEmptyParamsIfNoSupplied() { @Test public void newBuilderShouldCopyCount() { SearchCriteria searchCriteria = SearchCriteria.builder() - .limitCount(100) + .limit(100) .create(); SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getCount(), is(100)); + assertThat(newCriteria.getLimit(), is(100)); } @Test @@ -224,6 +248,7 @@ public void newBuilderShouldCopySortBy() { SearchCriteria newCriteria = searchCriteria.newBuilder().create(); assertThat(newCriteria.getSortBy(), is("creationDate")); } + @Test public void newBuilderShouldCopyResourceMask() { SearchCriteria searchCriteria = SearchCriteria.builder() @@ -232,4 +257,22 @@ public void newBuilderShouldCopyResourceMask() { SearchCriteria newCriteria = searchCriteria.newBuilder().create(); assertThat(newCriteria.getResourceMask(), is(SearchCriteria.REPORT | SearchCriteria.DASHBOARD)); } + + @Test + public void newBuilderShouldCopyForceTotalPageFlag() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .forceTotalCount(true) + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getForceTotalCount(), is(true)); + } + + @Test + public void newBuilderShouldCopyFolderUri() { + SearchCriteria searchCriteria = SearchCriteria.builder() + .folderUri("/") + .create(); + SearchCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getFolderUri(), is("/")); + } } \ No newline at end of file From a8e11960df77e9a7d5c911bd58644633cab7f64b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 10:37:47 +0300 Subject: [PATCH 154/457] Fix multimap issue for 'type' search parameter --- .../sdk/network/api/RepositoryRestApi.java | 2 +- .../network/api/RepositoryRestApiImpl.java | 28 +- .../network/api/RepositoryRestApiTest.java | 37 + .../test/resources/json/all_resources.json | 7908 +---------------- .../service/repository/SearchCriteria.java | 22 +- .../repository/SearchCriteriaTest.java | 50 +- 6 files changed, 180 insertions(+), 7867 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index c0097f6a..82a96aff 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -43,7 +43,7 @@ public interface RepositoryRestApi { @NonNull @WorkerThread - ResourceSearchResponse searchResources(@Nullable Map searchParams); + ResourceSearchResponse searchResources(@Nullable Map searchParams); @NonNull @WorkerThread diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index c010d366..0e2a63d9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -33,6 +33,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import java.util.HashMap; import java.util.Map; import retrofit.Call; @@ -41,6 +42,7 @@ import retrofit.http.GET; import retrofit.http.Headers; import retrofit.http.Path; +import retrofit.http.Query; import retrofit.http.QueryMap; import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; @@ -59,8 +61,27 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NonNull @Override - public ResourceSearchResponse searchResources(@Nullable Map searchParams) { - Call call = mRestApi.searchResources(searchParams); + public ResourceSearchResponse searchResources(@Nullable Map searchParams) { + Iterable types = null; + Call call; + + if (searchParams == null) { + call = mRestApi.searchResources(null, null); + } else { + Map copy = new HashMap<>(searchParams); + Object typeValues = copy.get("type"); + copy.remove("type"); + + if (typeValues == null) { + throw new IllegalStateException("Found null for key 'type'. Ensure this to be not a null"); + } + if (typeValues instanceof Iterable) { + types = (Iterable) typeValues; + } + + call = mRestApi.searchResources(copy, types); + } + Response rawResponse = CallWrapper.wrap(call).response(); int status = rawResponse.code(); @@ -125,7 +146,8 @@ private interface RestApi { @Headers("Accept: application/json") @GET("rest_v2/resources") Call searchResources( - @Nullable @QueryMap Map searchParams); + @Nullable @QueryMap Map searchParams, + @Nullable @Query("type") Iterable types); @NonNull @Headers("Accept: application/repository.reportUnit+json") diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index 28f7720b..d1aa175e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -32,6 +32,7 @@ import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.RecordedRequest; import org.junit.Before; import org.junit.Rule; @@ -40,6 +41,11 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -201,4 +207,35 @@ public void requestFolderResourceShouldThrowRestErrorOn500() { restApiUnderTest.requestFolderResource("any_id"); } + + @Test + public void searchEndpointShouldHandleMultipleResourceTypes() throws Exception { + MockResponse response = MockResponseFactory.create200() + .setBody("{\"resourceLookup\": []}"); + mWebMockRule.enqueue(response); + + Map params = new HashMap<>(); + params.put("folderUri", "/"); + + Set types = new HashSet<>(); + types.add("reportUnit"); + types.add("dashboard"); + params.put("type", types); + + restApiUnderTest.searchResources(params); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/resources?folderUri=/&type=reportUnit&type=dashboard")); + } + + @Test + public void searchEndpointShouldNotAcceptNullVorTypeKey() throws Exception { + mExpectedException.expect(IllegalStateException.class); + mExpectedException.expectMessage("Found null for key 'type'. Ensure this to be not a null"); + + Map params = new HashMap<>(); + params.put("type", null); + + restApiUnderTest.searchResources(params); + } } diff --git a/client-network/src/test/resources/json/all_resources.json b/client-network/src/test/resources/json/all_resources.json index 96ff0fa0..7cc3df21 100644 --- a/client-network/src/test/resources/json/all_resources.json +++ b/client-network/src/test/resources/json/all_resources.json @@ -1,7847 +1,83 @@ { - "inputControlState": [ + "resourceLookup": [ { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", - "id": "sales__product__product_name_1", - "options": [ - { - "selected": false, - "label": "ADJ Rosy Sunglasses", - "value": "ADJ Rosy Sunglasses" - }, - { - "selected": false, - "label": "Akron City Map", - "value": "Akron City Map" - }, - { - "selected": false, - "label": "Akron Eyeglass Screwdriver", - "value": "Akron Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "American Beef Bologna", - "value": "American Beef Bologna" - }, - { - "selected": false, - "label": "American Chicken Hot Dogs", - "value": "American Chicken Hot Dogs" - }, - { - "selected": false, - "label": "American Cole Slaw", - "value": "American Cole Slaw" - }, - { - "selected": false, - "label": "American Corned Beef", - "value": "American Corned Beef" - }, - { - "selected": false, - "label": "American Foot-Long Hot Dogs", - "value": "American Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "American Low Fat Bologna", - "value": "American Low Fat Bologna" - }, - { - "selected": false, - "label": "American Low Fat Cole Slaw", - "value": "American Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "American Pimento Loaf", - "value": "American Pimento Loaf" - }, - { - "selected": false, - "label": "American Potato Salad", - "value": "American Potato Salad" - }, - { - "selected": false, - "label": "American Roasted Chicken", - "value": "American Roasted Chicken" - }, - { - "selected": false, - "label": "American Sliced Chicken", - "value": "American Sliced Chicken" - }, - { - "selected": false, - "label": "American Sliced Ham", - "value": "American Sliced Ham" - }, - { - "selected": false, - "label": "American Sliced Turkey", - "value": "American Sliced Turkey" - }, - { - "selected": false, - "label": "American Turkey Hot Dogs", - "value": "American Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Amigo Lox", - "value": "Amigo Lox" - }, - { - "selected": false, - "label": "Amigo Scallops", - "value": "Amigo Scallops" - }, - { - "selected": false, - "label": "Applause Canned Mixed Fruit", - "value": "Applause Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Applause Canned Peaches", - "value": "Applause Canned Peaches" - }, - { - "selected": false, - "label": "Atomic Bubble Gum", - "value": "Atomic Bubble Gum" - }, - { - "selected": false, - "label": "Atomic Malted Milk Balls", - "value": "Atomic Malted Milk Balls" - }, - { - "selected": false, - "label": "Atomic Mint Chocolate Bar", - "value": "Atomic Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Atomic Mints", - "value": "Atomic Mints" - }, - { - "selected": false, - "label": "Atomic Semi-Sweet Chocolate Bar", - "value": "Atomic Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Atomic Spicy Mints", - "value": "Atomic Spicy Mints" - }, - { - "selected": false, - "label": "Atomic Tasty Candy Bar", - "value": "Atomic Tasty Candy Bar" - }, - { - "selected": false, - "label": "Atomic White Chocolate Bar", - "value": "Atomic White Chocolate Bar" - }, - { - "selected": false, - "label": "BBB Best Apple Butter", - "value": "BBB Best Apple Butter" - }, - { - "selected": false, - "label": "BBB Best Apple Jam", - "value": "BBB Best Apple Jam" - }, - { - "selected": false, - "label": "BBB Best Apple Jelly", - "value": "BBB Best Apple Jelly" - }, - { - "selected": false, - "label": "BBB Best Apple Preserves", - "value": "BBB Best Apple Preserves" - }, - { - "selected": false, - "label": "BBB Best Brown Sugar", - "value": "BBB Best Brown Sugar" - }, - { - "selected": false, - "label": "BBB Best Canola Oil", - "value": "BBB Best Canola Oil" - }, - { - "selected": false, - "label": "BBB Best Chunky Peanut Butter", - "value": "BBB Best Chunky Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best Columbian Coffee", - "value": "BBB Best Columbian Coffee" - }, - { - "selected": false, - "label": "BBB Best Corn Oil", - "value": "BBB Best Corn Oil" - }, - { - "selected": false, - "label": "BBB Best Creamy Peanut Butter", - "value": "BBB Best Creamy Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best Decaf Coffee", - "value": "BBB Best Decaf Coffee" - }, - { - "selected": false, - "label": "BBB Best Extra Chunky Peanut Butter", - "value": "BBB Best Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best French Roast Coffee", - "value": "BBB Best French Roast Coffee" - }, - { - "selected": false, - "label": "BBB Best Grape Jam", - "value": "BBB Best Grape Jam" - }, - { - "selected": false, - "label": "BBB Best Grape Jelly", - "value": "BBB Best Grape Jelly" - }, - { - "selected": false, - "label": "BBB Best Grape Preserves", - "value": "BBB Best Grape Preserves" - }, - { - "selected": false, - "label": "BBB Best Hot Chocolate", - "value": "BBB Best Hot Chocolate" - }, - { - "selected": false, - "label": "BBB Best Low Fat Apple Butter", - "value": "BBB Best Low Fat Apple Butter" - }, - { - "selected": false, - "label": "BBB Best Oregano", - "value": "BBB Best Oregano" - }, - { - "selected": false, - "label": "BBB Best Pepper", - "value": "BBB Best Pepper" - }, - { - "selected": false, - "label": "BBB Best Regular Coffee", - "value": "BBB Best Regular Coffee" - }, - { - "selected": false, - "label": "BBB Best Salt", - "value": "BBB Best Salt" - }, - { - "selected": false, - "label": "BBB Best Sesame Oil", - "value": "BBB Best Sesame Oil" - }, - { - "selected": false, - "label": "BBB Best Strawberry Jam", - "value": "BBB Best Strawberry Jam" - }, - { - "selected": false, - "label": "BBB Best Strawberry Jelly", - "value": "BBB Best Strawberry Jelly" - }, - { - "selected": false, - "label": "BBB Best Strawberry Preserves", - "value": "BBB Best Strawberry Preserves" - }, - { - "selected": false, - "label": "BBB Best Tomato Sauce", - "value": "BBB Best Tomato Sauce" - }, - { - "selected": false, - "label": "BBB Best Vegetable Oil", - "value": "BBB Best Vegetable Oil" - }, - { - "selected": false, - "label": "BBB Best White Sugar", - "value": "BBB Best White Sugar" - }, - { - "selected": false, - "label": "Best Choice Apple Fruit Roll", - "value": "Best Choice Apple Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Avocado Dip", - "value": "Best Choice Avocado Dip" - }, - { - "selected": false, - "label": "Best Choice BBQ Potato Chips", - "value": "Best Choice BBQ Potato Chips" - }, - { - "selected": false, - "label": "Best Choice Beef Jerky", - "value": "Best Choice Beef Jerky" - }, - { - "selected": false, - "label": "Best Choice Buttered Popcorn", - "value": "Best Choice Buttered Popcorn" - }, - { - "selected": false, - "label": "Best Choice Cheese Crackers", - "value": "Best Choice Cheese Crackers" - }, - { - "selected": false, - "label": "Best Choice Cheese Dip", - "value": "Best Choice Cheese Dip" - }, - { - "selected": false, - "label": "Best Choice Chocolate Chip Cookies", - "value": "Best Choice Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Best Choice Chocolate Donuts", - "value": "Best Choice Chocolate Donuts" - }, - { - "selected": false, - "label": "Best Choice Corn Chips", - "value": "Best Choice Corn Chips" - }, - { - "selected": false, - "label": "Best Choice Dried Apples", - "value": "Best Choice Dried Apples" - }, - { - "selected": false, - "label": "Best Choice Dried Apricots", - "value": "Best Choice Dried Apricots" - }, - { - "selected": false, - "label": "Best Choice Dried Dates", - "value": "Best Choice Dried Dates" - }, - { - "selected": false, - "label": "Best Choice Fondue Mix", - "value": "Best Choice Fondue Mix" - }, - { - "selected": false, - "label": "Best Choice Frosted Cookies", - "value": "Best Choice Frosted Cookies" - }, - { - "selected": false, - "label": "Best Choice Frosted Donuts", - "value": "Best Choice Frosted Donuts" - }, - { - "selected": false, - "label": "Best Choice Fudge Brownies", - "value": "Best Choice Fudge Brownies" - }, - { - "selected": false, - "label": "Best Choice Fudge Cookies", - "value": "Best Choice Fudge Cookies" - }, - { - "selected": false, - "label": "Best Choice Golden Raisins", - "value": "Best Choice Golden Raisins" - }, - { - "selected": false, - "label": "Best Choice Graham Crackers", - "value": "Best Choice Graham Crackers" - }, - { - "selected": false, - "label": "Best Choice Grape Fruit Roll", - "value": "Best Choice Grape Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Lemon Cookies", - "value": "Best Choice Lemon Cookies" - }, - { - "selected": false, - "label": "Best Choice Low Fat BBQ Chips", - "value": "Best Choice Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Best Choice Low Fat Chips", - "value": "Best Choice Low Fat Chips" - }, - { - "selected": false, - "label": "Best Choice Low Fat Cookies", - "value": "Best Choice Low Fat Cookies" - }, - { - "selected": false, - "label": "Best Choice Low Fat Popcorn", - "value": "Best Choice Low Fat Popcorn" - }, - { - "selected": false, - "label": "Best Choice Mini Donuts", - "value": "Best Choice Mini Donuts" - }, - { - "selected": false, - "label": "Best Choice No Salt Popcorn", - "value": "Best Choice No Salt Popcorn" - }, - { - "selected": false, - "label": "Best Choice Potato Chips", - "value": "Best Choice Potato Chips" - }, - { - "selected": false, - "label": "Best Choice Raisins", - "value": "Best Choice Raisins" - }, - { - "selected": false, - "label": "Best Choice Raspberry Fruit Roll", - "value": "Best Choice Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Salsa Dip", - "value": "Best Choice Salsa Dip" - }, - { - "selected": false, - "label": "Best Choice Salted Pretzels", - "value": "Best Choice Salted Pretzels" - }, - { - "selected": false, - "label": "Best Choice Sesame Crackers", - "value": "Best Choice Sesame Crackers" - }, - { - "selected": false, - "label": "Best Choice Strawberry Fruit Roll", - "value": "Best Choice Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Sugar Cookies", - "value": "Best Choice Sugar Cookies" - }, - { - "selected": false, - "label": "Best Corn Puffs", - "value": "Best Corn Puffs" - }, - { - "selected": false, - "label": "Best Grits", - "value": "Best Grits" - }, - { - "selected": false, - "label": "Best Oatmeal", - "value": "Best Oatmeal" - }, - { - "selected": false, - "label": "Best Wheat Puffs", - "value": "Best Wheat Puffs" - }, - { - "selected": false, - "label": "Better Beef Soup", - "value": "Better Beef Soup" - }, - { - "selected": false, - "label": "Better Canned Beets", - "value": "Better Canned Beets" - }, - { - "selected": false, - "label": "Better Canned Peas", - "value": "Better Canned Peas" - }, - { - "selected": false, - "label": "Better Canned String Beans", - "value": "Better Canned String Beans" - }, - { - "selected": false, - "label": "Better Canned Tomatos", - "value": "Better Canned Tomatos" - }, - { - "selected": false, - "label": "Better Canned Tuna in Oil", - "value": "Better Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Better Canned Tuna in Water", - "value": "Better Canned Tuna in Water" - }, - { - "selected": false, - "label": "Better Canned Yams", - "value": "Better Canned Yams" - }, - { - "selected": false, - "label": "Better Chicken Noodle Soup", - "value": "Better Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Better Chicken Ramen Soup", - "value": "Better Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Better Chicken Soup", - "value": "Better Chicken Soup" - }, - { - "selected": false, - "label": "Better Creamed Corn", - "value": "Better Creamed Corn" - }, - { - "selected": false, - "label": "Better Fancy Canned Anchovies", - "value": "Better Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Better Fancy Canned Clams", - "value": "Better Fancy Canned Clams" - }, - { - "selected": false, - "label": "Better Fancy Canned Oysters", - "value": "Better Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Better Fancy Canned Sardines", - "value": "Better Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Better Large Canned Shrimp", - "value": "Better Large Canned Shrimp" - }, - { - "selected": false, - "label": "Better Noodle Soup", - "value": "Better Noodle Soup" - }, - { - "selected": false, - "label": "Better Regular Ramen Soup", - "value": "Better Regular Ramen Soup" - }, - { - "selected": false, - "label": "Better Rice Soup", - "value": "Better Rice Soup" - }, - { - "selected": false, - "label": "Better Turkey Noodle Soup", - "value": "Better Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Better Vegetable Soup", - "value": "Better Vegetable Soup" - }, - { - "selected": false, - "label": "Big City Canned Mixed Fruit", - "value": "Big City Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Big City Canned Peaches", - "value": "Big City Canned Peaches" - }, - { - "selected": false, - "label": "Big Time Apple Cinnamon Waffles", - "value": "Big Time Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Big Time Beef TV Dinner", - "value": "Big Time Beef TV Dinner" - }, - { - "selected": false, - "label": "Big Time Blueberry Waffles", - "value": "Big Time Blueberry Waffles" - }, - { - "selected": false, - "label": "Big Time Chicken TV Dinner", - "value": "Big Time Chicken TV Dinner" - }, - { - "selected": false, - "label": "Big Time Fajita French Fries", - "value": "Big Time Fajita French Fries" - }, - { - "selected": false, - "label": "Big Time Frozen Broccoli", - "value": "Big Time Frozen Broccoli" - }, - { - "selected": false, - "label": "Big Time Frozen Carrots", - "value": "Big Time Frozen Carrots" - }, - { - "selected": false, - "label": "Big Time Frozen Cauliflower", - "value": "Big Time Frozen Cauliflower" - }, - { - "selected": false, - "label": "Big Time Frozen Cheese Pizza", - "value": "Big Time Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Breast", - "value": "Big Time Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Thighs", - "value": "Big Time Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Wings", - "value": "Big Time Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Big Time Frozen Corn", - "value": "Big Time Frozen Corn" - }, - { - "selected": false, - "label": "Big Time Frozen Mushroom Pizza", - "value": "Big Time Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Pancakes", - "value": "Big Time Frozen Pancakes" - }, - { - "selected": false, - "label": "Big Time Frozen Peas", - "value": "Big Time Frozen Peas" - }, - { - "selected": false, - "label": "Big Time Frozen Pepperoni Pizza", - "value": "Big Time Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Sausage Pizza", - "value": "Big Time Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Big Time Grape Popsicles", - "value": "Big Time Grape Popsicles" - }, - { - "selected": false, - "label": "Big Time Home Style French Fries", - "value": "Big Time Home Style French Fries" - }, - { - "selected": false, - "label": "Big Time Ice Cream", - "value": "Big Time Ice Cream" - }, - { - "selected": false, - "label": "Big Time Ice Cream Sandwich", - "value": "Big Time Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Big Time Lemon Popsicles", - "value": "Big Time Lemon Popsicles" - }, - { - "selected": false, - "label": "Big Time Lime Popsicles", - "value": "Big Time Lime Popsicles" - }, - { - "selected": false, - "label": "Big Time Low Fat French Fries", - "value": "Big Time Low Fat French Fries" - }, - { - "selected": false, - "label": "Big Time Low Fat Waffles", - "value": "Big Time Low Fat Waffles" - }, - { - "selected": false, - "label": "Big Time Orange Popsicles", - "value": "Big Time Orange Popsicles" - }, - { - "selected": false, - "label": "Big Time Pancake Mix", - "value": "Big Time Pancake Mix" - }, - { - "selected": false, - "label": "Big Time Popsicles", - "value": "Big Time Popsicles" - }, - { - "selected": false, - "label": "Big Time Turkey TV Dinner", - "value": "Big Time Turkey TV Dinner" - }, - { - "selected": false, - "label": "Big Time Waffles", - "value": "Big Time Waffles" - }, - { - "selected": false, - "label": "Bird Call 200 MG Acetominifen", - "value": "Bird Call 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Bird Call 200 MG Ibuprofen", - "value": "Bird Call 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Bird Call Angled Toothbrush", - "value": "Bird Call Angled Toothbrush" - }, - { - "selected": false, - "label": "Bird Call Apricot Shampoo", - "value": "Bird Call Apricot Shampoo" - }, - { - "selected": false, - "label": "Bird Call Buffered Aspirin", - "value": "Bird Call Buffered Aspirin" - }, - { - "selected": false, - "label": "Bird Call Childrens Aspirin", - "value": "Bird Call Childrens Aspirin" - }, - { - "selected": false, - "label": "Bird Call Childrens Cold Remedy", - "value": "Bird Call Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Bird Call Conditioning Shampoo", - "value": "Bird Call Conditioning Shampoo" - }, - { - "selected": false, - "label": "Bird Call Deodorant", - "value": "Bird Call Deodorant" - }, - { - "selected": false, - "label": "Bird Call Dishwasher Detergent", - "value": "Bird Call Dishwasher Detergent" - }, - { - "selected": false, - "label": "Bird Call Extra Moisture Shampoo", - "value": "Bird Call Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Bird Call HCL Nasal Spray", - "value": "Bird Call HCL Nasal Spray" - }, - { - "selected": false, - "label": "Bird Call Laundry Detergent", - "value": "Bird Call Laundry Detergent" - }, - { - "selected": false, - "label": "Bird Call Mint Mouthwash", - "value": "Bird Call Mint Mouthwash" - }, - { - "selected": false, - "label": "Bird Call Multi-Symptom Cold Remedy", - "value": "Bird Call Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Bird Call Silky Smooth Hair Conditioner", - "value": "Bird Call Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Bird Call Tartar Control Toothpaste", - "value": "Bird Call Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Bird Call Toothpaste", - "value": "Bird Call Toothpaste" - }, - { - "selected": false, - "label": "Bird Call Whitening Toothpast", - "value": "Bird Call Whitening Toothpast" - }, - { - "selected": false, - "label": "Black Tie City Map", - "value": "Black Tie City Map" - }, - { - "selected": false, - "label": "Black Tie Eyeglass Screwdriver", - "value": "Black Tie Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Blue Label Beef Soup", - "value": "Blue Label Beef Soup" - }, - { - "selected": false, - "label": "Blue Label Canned Beets", - "value": "Blue Label Canned Beets" - }, - { - "selected": false, - "label": "Blue Label Canned Peas", - "value": "Blue Label Canned Peas" - }, - { - "selected": false, - "label": "Blue Label Canned String Beans", - "value": "Blue Label Canned String Beans" - }, - { - "selected": false, - "label": "Blue Label Canned Tomatos", - "value": "Blue Label Canned Tomatos" - }, - { - "selected": false, - "label": "Blue Label Canned Tuna in Oil", - "value": "Blue Label Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Blue Label Canned Tuna in Water", - "value": "Blue Label Canned Tuna in Water" - }, - { - "selected": false, - "label": "Blue Label Canned Yams", - "value": "Blue Label Canned Yams" - }, - { - "selected": false, - "label": "Blue Label Chicken Noodle Soup", - "value": "Blue Label Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Chicken Ramen Soup", - "value": "Blue Label Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Blue Label Chicken Soup", - "value": "Blue Label Chicken Soup" - }, - { - "selected": false, - "label": "Blue Label Creamed Corn", - "value": "Blue Label Creamed Corn" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Anchovies", - "value": "Blue Label Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Clams", - "value": "Blue Label Fancy Canned Clams" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Oysters", - "value": "Blue Label Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Sardines", - "value": "Blue Label Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Blue Label Large Canned Shrimp", - "value": "Blue Label Large Canned Shrimp" - }, - { - "selected": false, - "label": "Blue Label Noodle Soup", - "value": "Blue Label Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Regular Ramen Soup", - "value": "Blue Label Regular Ramen Soup" - }, - { - "selected": false, - "label": "Blue Label Rice Soup", - "value": "Blue Label Rice Soup" - }, - { - "selected": false, - "label": "Blue Label Turkey Noodle Soup", - "value": "Blue Label Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Vegetable Soup", - "value": "Blue Label Vegetable Soup" - }, - { - "selected": false, - "label": "Blue Medal Egg Substitute", - "value": "Blue Medal Egg Substitute" - }, - { - "selected": false, - "label": "Blue Medal Large Brown Eggs", - "value": "Blue Medal Large Brown Eggs" - }, - { - "selected": false, - "label": "Blue Medal Large Eggs", - "value": "Blue Medal Large Eggs" - }, - { - "selected": false, - "label": "Blue Medal Small Brown Eggs", - "value": "Blue Medal Small Brown Eggs" - }, - { - "selected": false, - "label": "Blue Medal Small Eggs", - "value": "Blue Medal Small Eggs" - }, - { - "selected": false, - "label": "Booker 1% Milk", - "value": "Booker 1% Milk" - }, - { - "selected": false, - "label": "Booker 2% Milk", - "value": "Booker 2% Milk" - }, - { - "selected": false, - "label": "Booker Blueberry Yogurt", - "value": "Booker Blueberry Yogurt" - }, - { - "selected": false, - "label": "Booker Buttermilk", - "value": "Booker Buttermilk" - }, - { - "selected": false, - "label": "Booker Cheese Spread", - "value": "Booker Cheese Spread" - }, - { - "selected": false, - "label": "Booker Chocolate Milk", - "value": "Booker Chocolate Milk" - }, - { - "selected": false, - "label": "Booker Havarti Cheese", - "value": "Booker Havarti Cheese" - }, - { - "selected": false, - "label": "Booker Head Cheese", - "value": "Booker Head Cheese" - }, - { - "selected": false, - "label": "Booker Jack Cheese", - "value": "Booker Jack Cheese" - }, - { - "selected": false, - "label": "Booker Large Curd Cottage Cheese", - "value": "Booker Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Booker Low Fat Cottage Cheese", - "value": "Booker Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Booker Low Fat Sour Cream", - "value": "Booker Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Booker Low Fat String Cheese", - "value": "Booker Low Fat String Cheese" - }, - { - "selected": false, - "label": "Booker Mild Cheddar Cheese", - "value": "Booker Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Booker Muenster Cheese", - "value": "Booker Muenster Cheese" - }, - { - "selected": false, - "label": "Booker Sharp Cheddar Cheese", - "value": "Booker Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Booker Sour Cream", - "value": "Booker Sour Cream" - }, - { - "selected": false, - "label": "Booker Strawberry Yogurt", - "value": "Booker Strawberry Yogurt" - }, - { - "selected": false, - "label": "Booker String Cheese", - "value": "Booker String Cheese" - }, - { - "selected": false, - "label": "Booker Whole Milk", - "value": "Booker Whole Milk" - }, - { - "selected": false, - "label": "Bravo Beef Soup", - "value": "Bravo Beef Soup" - }, - { - "selected": false, - "label": "Bravo Canned Beets", - "value": "Bravo Canned Beets" - }, - { - "selected": false, - "label": "Bravo Canned Peas", - "value": "Bravo Canned Peas" - }, - { - "selected": false, - "label": "Bravo Canned String Beans", - "value": "Bravo Canned String Beans" - }, - { - "selected": false, - "label": "Bravo Canned Tomatos", - "value": "Bravo Canned Tomatos" - }, - { - "selected": false, - "label": "Bravo Canned Tuna in Oil", - "value": "Bravo Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Bravo Canned Tuna in Water", - "value": "Bravo Canned Tuna in Water" - }, - { - "selected": false, - "label": "Bravo Canned Yams", - "value": "Bravo Canned Yams" - }, - { - "selected": false, - "label": "Bravo Chicken Noodle Soup", - "value": "Bravo Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Chicken Ramen Soup", - "value": "Bravo Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Bravo Chicken Soup", - "value": "Bravo Chicken Soup" - }, - { - "selected": false, - "label": "Bravo Creamed Corn", - "value": "Bravo Creamed Corn" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Anchovies", - "value": "Bravo Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Clams", - "value": "Bravo Fancy Canned Clams" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Oysters", - "value": "Bravo Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Sardines", - "value": "Bravo Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Bravo Large Canned Shrimp", - "value": "Bravo Large Canned Shrimp" - }, - { - "selected": false, - "label": "Bravo Noodle Soup", - "value": "Bravo Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Regular Ramen Soup", - "value": "Bravo Regular Ramen Soup" - }, - { - "selected": false, - "label": "Bravo Rice Soup", - "value": "Bravo Rice Soup" - }, - { - "selected": false, - "label": "Bravo Turkey Noodle Soup", - "value": "Bravo Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Vegetable Soup", - "value": "Bravo Vegetable Soup" - }, - { - "selected": false, - "label": "Carlson 1% Milk", - "value": "Carlson 1% Milk" - }, - { - "selected": false, - "label": "Carlson 2% Milk", - "value": "Carlson 2% Milk" - }, - { - "selected": false, - "label": "Carlson Blueberry Yogurt", - "value": "Carlson Blueberry Yogurt" - }, - { - "selected": false, - "label": "Carlson Buttermilk", - "value": "Carlson Buttermilk" - }, - { - "selected": false, - "label": "Carlson Cheese Spread", - "value": "Carlson Cheese Spread" - }, - { - "selected": false, - "label": "Carlson Chocolate Milk", - "value": "Carlson Chocolate Milk" - }, - { - "selected": false, - "label": "Carlson Havarti Cheese", - "value": "Carlson Havarti Cheese" - }, - { - "selected": false, - "label": "Carlson Head Cheese", - "value": "Carlson Head Cheese" - }, - { - "selected": false, - "label": "Carlson Jack Cheese", - "value": "Carlson Jack Cheese" - }, - { - "selected": false, - "label": "Carlson Large Curd Cottage Cheese", - "value": "Carlson Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Carlson Low Fat Cottage Cheese", - "value": "Carlson Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Carlson Low Fat Sour Cream", - "value": "Carlson Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Carlson Low Fat String Cheese", - "value": "Carlson Low Fat String Cheese" - }, - { - "selected": false, - "label": "Carlson Mild Cheddar Cheese", - "value": "Carlson Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Carlson Muenster Cheese", - "value": "Carlson Muenster Cheese" - }, - { - "selected": false, - "label": "Carlson Sharp Cheddar Cheese", - "value": "Carlson Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Carlson Sour Cream", - "value": "Carlson Sour Cream" - }, - { - "selected": false, - "label": "Carlson Strawberry Yogurt", - "value": "Carlson Strawberry Yogurt" - }, - { - "selected": false, - "label": "Carlson String Cheese", - "value": "Carlson String Cheese" - }, - { - "selected": false, - "label": "Carlson Whole Milk", - "value": "Carlson Whole Milk" - }, - { - "selected": false, - "label": "Carrington Apple Cinnamon Waffles", - "value": "Carrington Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Carrington Beef TV Dinner", - "value": "Carrington Beef TV Dinner" - }, - { - "selected": false, - "label": "Carrington Blueberry Waffles", - "value": "Carrington Blueberry Waffles" - }, - { - "selected": false, - "label": "Carrington Chicken TV Dinner", - "value": "Carrington Chicken TV Dinner" - }, - { - "selected": false, - "label": "Carrington Fajita French Fries", - "value": "Carrington Fajita French Fries" - }, - { - "selected": false, - "label": "Carrington Frozen Broccoli", - "value": "Carrington Frozen Broccoli" - }, - { - "selected": false, - "label": "Carrington Frozen Carrots", - "value": "Carrington Frozen Carrots" - }, - { - "selected": false, - "label": "Carrington Frozen Cauliflower", - "value": "Carrington Frozen Cauliflower" - }, - { - "selected": false, - "label": "Carrington Frozen Cheese Pizza", - "value": "Carrington Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Breast", - "value": "Carrington Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Thighs", - "value": "Carrington Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Wings", - "value": "Carrington Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Carrington Frozen Corn", - "value": "Carrington Frozen Corn" - }, - { - "selected": false, - "label": "Carrington Frozen Mushroom Pizza", - "value": "Carrington Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Pancakes", - "value": "Carrington Frozen Pancakes" - }, - { - "selected": false, - "label": "Carrington Frozen Peas", - "value": "Carrington Frozen Peas" - }, - { - "selected": false, - "label": "Carrington Frozen Pepperoni Pizza", - "value": "Carrington Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Sausage Pizza", - "value": "Carrington Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Carrington Grape Popsicles", - "value": "Carrington Grape Popsicles" - }, - { - "selected": false, - "label": "Carrington Home Style French Fries", - "value": "Carrington Home Style French Fries" - }, - { - "selected": false, - "label": "Carrington Ice Cream", - "value": "Carrington Ice Cream" - }, - { - "selected": false, - "label": "Carrington Ice Cream Sandwich", - "value": "Carrington Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Carrington Lemon Popsicles", - "value": "Carrington Lemon Popsicles" - }, - { - "selected": false, - "label": "Carrington Lime Popsicles", - "value": "Carrington Lime Popsicles" - }, - { - "selected": false, - "label": "Carrington Low Fat French Fries", - "value": "Carrington Low Fat French Fries" - }, - { - "selected": false, - "label": "Carrington Low Fat Waffles", - "value": "Carrington Low Fat Waffles" - }, - { - "selected": false, - "label": "Carrington Orange Popsicles", - "value": "Carrington Orange Popsicles" - }, - { - "selected": false, - "label": "Carrington Pancake Mix", - "value": "Carrington Pancake Mix" - }, - { - "selected": false, - "label": "Carrington Popsicles", - "value": "Carrington Popsicles" - }, - { - "selected": false, - "label": "Carrington Turkey TV Dinner", - "value": "Carrington Turkey TV Dinner" - }, - { - "selected": false, - "label": "Carrington Waffles", - "value": "Carrington Waffles" - }, - { - "selected": false, - "label": "CDR Apple Butter", - "value": "CDR Apple Butter" - }, - { - "selected": false, - "label": "CDR Apple Jam", - "value": "CDR Apple Jam" - }, - { - "selected": false, - "label": "CDR Apple Jelly", - "value": "CDR Apple Jelly" - }, - { - "selected": false, - "label": "CDR Apple Preserves", - "value": "CDR Apple Preserves" - }, - { - "selected": false, - "label": "CDR Brown Sugar", - "value": "CDR Brown Sugar" - }, - { - "selected": false, - "label": "CDR Canola Oil", - "value": "CDR Canola Oil" - }, - { - "selected": false, - "label": "CDR Chunky Peanut Butter", - "value": "CDR Chunky Peanut Butter" - }, - { - "selected": false, - "label": "CDR Columbian Coffee", - "value": "CDR Columbian Coffee" - }, - { - "selected": false, - "label": "CDR Corn Oil", - "value": "CDR Corn Oil" - }, - { - "selected": false, - "label": "CDR Creamy Peanut Butter", - "value": "CDR Creamy Peanut Butter" - }, - { - "selected": false, - "label": "CDR Decaf Coffee", - "value": "CDR Decaf Coffee" - }, - { - "selected": false, - "label": "CDR Extra Chunky Peanut Butter", - "value": "CDR Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "CDR French Roast Coffee", - "value": "CDR French Roast Coffee" - }, - { - "selected": false, - "label": "CDR Grape Jam", - "value": "CDR Grape Jam" - }, - { - "selected": false, - "label": "CDR Grape Jelly", - "value": "CDR Grape Jelly" - }, - { - "selected": false, - "label": "CDR Grape Preserves", - "value": "CDR Grape Preserves" - }, - { - "selected": false, - "label": "CDR Hot Chocolate", - "value": "CDR Hot Chocolate" - }, - { - "selected": false, - "label": "CDR Low Fat Apple Butter", - "value": "CDR Low Fat Apple Butter" - }, - { - "selected": false, - "label": "CDR Oregano", - "value": "CDR Oregano" - }, - { - "selected": false, - "label": "CDR Pepper", - "value": "CDR Pepper" - }, - { - "selected": false, - "label": "CDR Regular Coffee", - "value": "CDR Regular Coffee" - }, - { - "selected": false, - "label": "CDR Salt", - "value": "CDR Salt" - }, - { - "selected": false, - "label": "CDR Sesame Oil", - "value": "CDR Sesame Oil" - }, - { - "selected": false, - "label": "CDR Strawberry Jam", - "value": "CDR Strawberry Jam" - }, - { - "selected": false, - "label": "CDR Strawberry Jelly", - "value": "CDR Strawberry Jelly" - }, - { - "selected": false, - "label": "CDR Strawberry Preserves", - "value": "CDR Strawberry Preserves" - }, - { - "selected": false, - "label": "CDR Tomato Sauce", - "value": "CDR Tomato Sauce" - }, - { - "selected": false, - "label": "CDR Vegetable Oil", - "value": "CDR Vegetable Oil" - }, - { - "selected": false, - "label": "CDR White Sugar", - "value": "CDR White Sugar" - }, - { - "selected": false, - "label": "Choice Bubble Gum", - "value": "Choice Bubble Gum" - }, - { - "selected": false, - "label": "Choice Malted Milk Balls", - "value": "Choice Malted Milk Balls" - }, - { - "selected": false, - "label": "Choice Mint Chocolate Bar", - "value": "Choice Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Choice Mints", - "value": "Choice Mints" - }, - { - "selected": false, - "label": "Choice Semi-Sweet Chocolate Bar", - "value": "Choice Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Choice Spicy Mints", - "value": "Choice Spicy Mints" - }, - { - "selected": false, - "label": "Choice Tasty Candy Bar", - "value": "Choice Tasty Candy Bar" - }, - { - "selected": false, - "label": "Choice White Chocolate Bar", - "value": "Choice White Chocolate Bar" - }, - { - "selected": false, - "label": "Club 1% Milk", - "value": "Club 1% Milk" - }, - { - "selected": false, - "label": "Club 2% Milk", - "value": "Club 2% Milk" - }, - { - "selected": false, - "label": "Club Blueberry Yogurt", - "value": "Club Blueberry Yogurt" - }, - { - "selected": false, - "label": "Club Buttermilk", - "value": "Club Buttermilk" - }, - { - "selected": false, - "label": "Club Cheese Spread", - "value": "Club Cheese Spread" - }, - { - "selected": false, - "label": "Club Chocolate Milk", - "value": "Club Chocolate Milk" - }, - { - "selected": false, - "label": "Club Havarti Cheese", - "value": "Club Havarti Cheese" - }, - { - "selected": false, - "label": "Club Head Cheese", - "value": "Club Head Cheese" - }, - { - "selected": false, - "label": "Club Jack Cheese", - "value": "Club Jack Cheese" - }, - { - "selected": false, - "label": "Club Large Curd Cottage Cheese", - "value": "Club Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Club Low Fat Cottage Cheese", - "value": "Club Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Club Low Fat Sour Cream", - "value": "Club Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Club Low Fat String Cheese", - "value": "Club Low Fat String Cheese" - }, - { - "selected": false, - "label": "Club Mild Cheddar Cheese", - "value": "Club Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Club Muenster Cheese", - "value": "Club Muenster Cheese" - }, - { - "selected": false, - "label": "Club Sharp Cheddar Cheese", - "value": "Club Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Club Sour Cream", - "value": "Club Sour Cream" - }, - { - "selected": false, - "label": "Club Strawberry Yogurt", - "value": "Club Strawberry Yogurt" - }, - { - "selected": false, - "label": "Club String Cheese", - "value": "Club String Cheese" - }, - { - "selected": false, - "label": "Club Whole Milk", - "value": "Club Whole Milk" - }, - { - "selected": false, - "label": "Colony Bagels", - "value": "Colony Bagels" - }, - { - "selected": false, - "label": "Colony Blueberry Muffins", - "value": "Colony Blueberry Muffins" - }, - { - "selected": false, - "label": "Colony Cranberry Muffins", - "value": "Colony Cranberry Muffins" - }, - { - "selected": false, - "label": "Colony English Muffins", - "value": "Colony English Muffins" - }, - { - "selected": false, - "label": "Colony Muffins", - "value": "Colony Muffins" - }, - { - "selected": false, - "label": "Colony Pumpernickel Bread", - "value": "Colony Pumpernickel Bread" - }, - { - "selected": false, - "label": "Colony Rye Bread", - "value": "Colony Rye Bread" - }, - { - "selected": false, - "label": "Colony Wheat Bread", - "value": "Colony Wheat Bread" - }, - { - "selected": false, - "label": "Colony White Bread", - "value": "Colony White Bread" - }, - { - "selected": false, - "label": "Colossal Manicotti", - "value": "Colossal Manicotti" - }, - { - "selected": false, - "label": "Colossal Ravioli", - "value": "Colossal Ravioli" - }, - { - "selected": false, - "label": "Colossal Rice Medly", - "value": "Colossal Rice Medly" - }, - { - "selected": false, - "label": "Colossal Spaghetti", - "value": "Colossal Spaghetti" - }, - { - "selected": false, - "label": "Colossal Thai Rice", - "value": "Colossal Thai Rice" - }, - { - "selected": false, - "label": "Consolidated 200 MG Acetominifen", - "value": "Consolidated 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Consolidated 200 MG Ibuprofen", - "value": "Consolidated 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Consolidated Angled Toothbrush", - "value": "Consolidated Angled Toothbrush" - }, - { - "selected": false, - "label": "Consolidated Apricot Shampoo", - "value": "Consolidated Apricot Shampoo" - }, - { - "selected": false, - "label": "Consolidated Buffered Aspirin", - "value": "Consolidated Buffered Aspirin" - }, - { - "selected": false, - "label": "Consolidated Childrens Aspirin", - "value": "Consolidated Childrens Aspirin" - }, - { - "selected": false, - "label": "Consolidated Childrens Cold Remedy", - "value": "Consolidated Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Consolidated Conditioning Shampoo", - "value": "Consolidated Conditioning Shampoo" - }, - { - "selected": false, - "label": "Consolidated Deodorant", - "value": "Consolidated Deodorant" - }, - { - "selected": false, - "label": "Consolidated Dishwasher Detergent", - "value": "Consolidated Dishwasher Detergent" - }, - { - "selected": false, - "label": "Consolidated Extra Moisture Shampoo", - "value": "Consolidated Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Consolidated HCL Nasal Spray", - "value": "Consolidated HCL Nasal Spray" - }, - { - "selected": false, - "label": "Consolidated Laundry Detergent", - "value": "Consolidated Laundry Detergent" - }, - { - "selected": false, - "label": "Consolidated Mint Mouthwash", - "value": "Consolidated Mint Mouthwash" - }, - { - "selected": false, - "label": "Consolidated Multi-Symptom Cold Remedy", - "value": "Consolidated Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Consolidated Silky Smooth Hair Conditioner", - "value": "Consolidated Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Consolidated Tartar Control Toothpaste", - "value": "Consolidated Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Consolidated Toothpaste", - "value": "Consolidated Toothpaste" - }, - { - "selected": false, - "label": "Consolidated Whitening Toothpast", - "value": "Consolidated Whitening Toothpast" - }, - { - "selected": false, - "label": "Cormorant 100 Watt Lightbulb", - "value": "Cormorant 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 25 Watt Lightbulb", - "value": "Cormorant 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 60 Watt Lightbulb", - "value": "Cormorant 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 75 Watt Lightbulb", - "value": "Cormorant 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant AAA-Size Batteries", - "value": "Cormorant AAA-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant AA-Size Batteries", - "value": "Cormorant AA-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant Bees Wax Candles", - "value": "Cormorant Bees Wax Candles" - }, - { - "selected": false, - "label": "Cormorant Copper Cleaner", - "value": "Cormorant Copper Cleaner" - }, - { - "selected": false, - "label": "Cormorant Copper Pot Scrubber", - "value": "Cormorant Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Cormorant Counter Cleaner", - "value": "Cormorant Counter Cleaner" - }, - { - "selected": false, - "label": "Cormorant C-Size Batteries", - "value": "Cormorant C-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant D-Size Batteries", - "value": "Cormorant D-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant Economy Toilet Brush", - "value": "Cormorant Economy Toilet Brush" - }, - { - "selected": false, - "label": "Cormorant Frying Pan", - "value": "Cormorant Frying Pan" - }, - { - "selected": false, - "label": "Cormorant Glass Cleaner", - "value": "Cormorant Glass Cleaner" - }, - { - "selected": false, - "label": "Cormorant Large Sponge", - "value": "Cormorant Large Sponge" - }, - { - "selected": false, - "label": "Cormorant Paper Cups", - "value": "Cormorant Paper Cups" - }, - { - "selected": false, - "label": "Cormorant Paper Plates", - "value": "Cormorant Paper Plates" - }, - { - "selected": false, - "label": "Cormorant Paper Towels", - "value": "Cormorant Paper Towels" - }, - { - "selected": false, - "label": "Cormorant Plastic Forks", - "value": "Cormorant Plastic Forks" - }, - { - "selected": false, - "label": "Cormorant Plastic Knives", - "value": "Cormorant Plastic Knives" - }, - { - "selected": false, - "label": "Cormorant Plastic Spoons", - "value": "Cormorant Plastic Spoons" - }, - { - "selected": false, - "label": "Cormorant Room Freshener", - "value": "Cormorant Room Freshener" - }, - { - "selected": false, - "label": "Cormorant Scented Tissue", - "value": "Cormorant Scented Tissue" - }, - { - "selected": false, - "label": "Cormorant Scented Toilet Tissue", - "value": "Cormorant Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Cormorant Scissors", - "value": "Cormorant Scissors" - }, - { - "selected": false, - "label": "Cormorant Screw Driver", - "value": "Cormorant Screw Driver" - }, - { - "selected": false, - "label": "Cormorant Silver Cleaner", - "value": "Cormorant Silver Cleaner" - }, - { - "selected": false, - "label": "Cormorant Soft Napkins", - "value": "Cormorant Soft Napkins" - }, - { - "selected": false, - "label": "Cormorant Tissues", - "value": "Cormorant Tissues" - }, - { - "selected": false, - "label": "Cormorant Toilet Bowl Cleaner", - "value": "Cormorant Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Cormorant Toilet Paper", - "value": "Cormorant Toilet Paper" - }, - { - "selected": false, - "label": "Curlew Lox", - "value": "Curlew Lox" - }, - { - "selected": false, - "label": "Curlew Scallops", - "value": "Curlew Scallops" - }, - { - "selected": false, - "label": "Cutting Edge Beef Bologna", - "value": "Cutting Edge Beef Bologna" - }, - { - "selected": false, - "label": "Cutting Edge Chicken Hot Dogs", - "value": "Cutting Edge Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Cutting Edge Cole Slaw", - "value": "Cutting Edge Cole Slaw" - }, - { - "selected": false, - "label": "Cutting Edge Corned Beef", - "value": "Cutting Edge Corned Beef" - }, - { - "selected": false, - "label": "Cutting Edge Foot-Long Hot Dogs", - "value": "Cutting Edge Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Cutting Edge Low Fat Bologna", - "value": "Cutting Edge Low Fat Bologna" - }, - { - "selected": false, - "label": "Cutting Edge Low Fat Cole Slaw", - "value": "Cutting Edge Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Cutting Edge Pimento Loaf", - "value": "Cutting Edge Pimento Loaf" - }, - { - "selected": false, - "label": "Cutting Edge Potato Salad", - "value": "Cutting Edge Potato Salad" - }, - { - "selected": false, - "label": "Cutting Edge Roasted Chicken", - "value": "Cutting Edge Roasted Chicken" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Chicken", - "value": "Cutting Edge Sliced Chicken" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Ham", - "value": "Cutting Edge Sliced Ham" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Turkey", - "value": "Cutting Edge Sliced Turkey" - }, - { - "selected": false, - "label": "Cutting Edge Turkey Hot Dogs", - "value": "Cutting Edge Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Denny 100 Watt Lightbulb", - "value": "Denny 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 25 Watt Lightbulb", - "value": "Denny 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 60 Watt Lightbulb", - "value": "Denny 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 75 Watt Lightbulb", - "value": "Denny 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny AAA-Size Batteries", - "value": "Denny AAA-Size Batteries" - }, - { - "selected": false, - "label": "Denny AA-Size Batteries", - "value": "Denny AA-Size Batteries" - }, - { - "selected": false, - "label": "Denny Bees Wax Candles", - "value": "Denny Bees Wax Candles" - }, - { - "selected": false, - "label": "Denny Copper Cleaner", - "value": "Denny Copper Cleaner" - }, - { - "selected": false, - "label": "Denny Copper Pot Scrubber", - "value": "Denny Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Denny Counter Cleaner", - "value": "Denny Counter Cleaner" - }, - { - "selected": false, - "label": "Denny C-Size Batteries", - "value": "Denny C-Size Batteries" - }, - { - "selected": false, - "label": "Denny D-Size Batteries", - "value": "Denny D-Size Batteries" - }, - { - "selected": false, - "label": "Denny Economy Toilet Brush", - "value": "Denny Economy Toilet Brush" - }, - { - "selected": false, - "label": "Denny Frying Pan", - "value": "Denny Frying Pan" - }, - { - "selected": false, - "label": "Denny Glass Cleaner", - "value": "Denny Glass Cleaner" - }, - { - "selected": false, - "label": "Denny Large Sponge", - "value": "Denny Large Sponge" - }, - { - "selected": false, - "label": "Denny Paper Cups", - "value": "Denny Paper Cups" - }, - { - "selected": false, - "label": "Denny Paper Plates", - "value": "Denny Paper Plates" - }, - { - "selected": false, - "label": "Denny Paper Towels", - "value": "Denny Paper Towels" - }, - { - "selected": false, - "label": "Denny Plastic Forks", - "value": "Denny Plastic Forks" - }, - { - "selected": false, - "label": "Denny Plastic Knives", - "value": "Denny Plastic Knives" - }, - { - "selected": false, - "label": "Denny Plastic Spoons", - "value": "Denny Plastic Spoons" - }, - { - "selected": false, - "label": "Denny Room Freshener", - "value": "Denny Room Freshener" - }, - { - "selected": false, - "label": "Denny Scented Tissue", - "value": "Denny Scented Tissue" - }, - { - "selected": false, - "label": "Denny Scented Toilet Tissue", - "value": "Denny Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Denny Scissors", - "value": "Denny Scissors" - }, - { - "selected": false, - "label": "Denny Screw Driver", - "value": "Denny Screw Driver" - }, - { - "selected": false, - "label": "Denny Silver Cleaner", - "value": "Denny Silver Cleaner" - }, - { - "selected": false, - "label": "Denny Soft Napkins", - "value": "Denny Soft Napkins" - }, - { - "selected": false, - "label": "Denny Tissues", - "value": "Denny Tissues" - }, - { - "selected": false, - "label": "Denny Toilet Bowl Cleaner", - "value": "Denny Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Denny Toilet Paper", - "value": "Denny Toilet Paper" - }, - { - "selected": false, - "label": "Discover Manicotti", - "value": "Discover Manicotti" - }, - { - "selected": false, - "label": "Discover Ravioli", - "value": "Discover Ravioli" - }, - { - "selected": false, - "label": "Discover Rice Medly", - "value": "Discover Rice Medly" - }, - { - "selected": false, - "label": "Discover Spaghetti", - "value": "Discover Spaghetti" - }, - { - "selected": false, - "label": "Discover Thai Rice", - "value": "Discover Thai Rice" - }, - { - "selected": false, - "label": "Dollar Monthly Auto Magazine", - "value": "Dollar Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Computer Magazine", - "value": "Dollar Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Fashion Magazine", - "value": "Dollar Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Home Magazine", - "value": "Dollar Monthly Home Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Sports Magazine", - "value": "Dollar Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Dual City Lox", - "value": "Dual City Lox" - }, - { - "selected": false, - "label": "Dual City Scallops", - "value": "Dual City Scallops" - }, - { - "selected": false, - "label": "Ebony Almonds", - "value": "Ebony Almonds" - }, - { - "selected": false, - "label": "Ebony Asparagus", - "value": "Ebony Asparagus" - }, - { - "selected": false, - "label": "Ebony Baby Onion", - "value": "Ebony Baby Onion" - }, - { - "selected": false, - "label": "Ebony Beets", - "value": "Ebony Beets" - }, - { - "selected": false, - "label": "Ebony Broccoli", - "value": "Ebony Broccoli" - }, - { - "selected": false, - "label": "Ebony Canned Peanuts", - "value": "Ebony Canned Peanuts" - }, - { - "selected": false, - "label": "Ebony Cantelope", - "value": "Ebony Cantelope" - }, - { - "selected": false, - "label": "Ebony Cauliflower", - "value": "Ebony Cauliflower" - }, - { - "selected": false, - "label": "Ebony Corn on the Cob", - "value": "Ebony Corn on the Cob" - }, - { - "selected": false, - "label": "Ebony Dried Mushrooms", - "value": "Ebony Dried Mushrooms" - }, - { - "selected": false, - "label": "Ebony Elephant Garlic", - "value": "Ebony Elephant Garlic" - }, - { - "selected": false, - "label": "Ebony Fancy Plums", - "value": "Ebony Fancy Plums" - }, - { - "selected": false, - "label": "Ebony Firm Tofu", - "value": "Ebony Firm Tofu" - }, - { - "selected": false, - "label": "Ebony Fresh Lima Beans", - "value": "Ebony Fresh Lima Beans" - }, - { - "selected": false, - "label": "Ebony Fuji Apples", - "value": "Ebony Fuji Apples" - }, - { - "selected": false, - "label": "Ebony Garlic", - "value": "Ebony Garlic" - }, - { - "selected": false, - "label": "Ebony Golden Delcious Apples", - "value": "Ebony Golden Delcious Apples" - }, - { - "selected": false, - "label": "Ebony Green Pepper", - "value": "Ebony Green Pepper" - }, - { - "selected": false, - "label": "Ebony Honey Dew", - "value": "Ebony Honey Dew" - }, - { - "selected": false, - "label": "Ebony Lemons", - "value": "Ebony Lemons" - }, - { - "selected": false, - "label": "Ebony Lettuce", - "value": "Ebony Lettuce" - }, - { - "selected": false, - "label": "Ebony Limes", - "value": "Ebony Limes" - }, - { - "selected": false, - "label": "Ebony Macintosh Apples", - "value": "Ebony Macintosh Apples" - }, - { - "selected": false, - "label": "Ebony Mandarin Oranges", - "value": "Ebony Mandarin Oranges" - }, - { - "selected": false, - "label": "Ebony Mixed Nuts", - "value": "Ebony Mixed Nuts" - }, - { - "selected": false, - "label": "Ebony Mushrooms", - "value": "Ebony Mushrooms" - }, - { - "selected": false, - "label": "Ebony New Potatos", - "value": "Ebony New Potatos" - }, - { - "selected": false, - "label": "Ebony Onions", - "value": "Ebony Onions" - }, - { - "selected": false, - "label": "Ebony Oranges", - "value": "Ebony Oranges" - }, - { - "selected": false, - "label": "Ebony Party Nuts", - "value": "Ebony Party Nuts" - }, - { - "selected": false, - "label": "Ebony Peaches", - "value": "Ebony Peaches" - }, - { - "selected": false, - "label": "Ebony Plums", - "value": "Ebony Plums" - }, - { - "selected": false, - "label": "Ebony Potatos", - "value": "Ebony Potatos" - }, - { - "selected": false, - "label": "Ebony Prepared Salad", - "value": "Ebony Prepared Salad" - }, - { - "selected": false, - "label": "Ebony Red Delcious Apples", - "value": "Ebony Red Delcious Apples" - }, - { - "selected": false, - "label": "Ebony Red Pepper", - "value": "Ebony Red Pepper" - }, - { - "selected": false, - "label": "Ebony Shitake Mushrooms", - "value": "Ebony Shitake Mushrooms" - }, - { - "selected": false, - "label": "Ebony Squash", - "value": "Ebony Squash" - }, - { - "selected": false, - "label": "Ebony Summer Squash", - "value": "Ebony Summer Squash" - }, - { - "selected": false, - "label": "Ebony Sweet Onion", - "value": "Ebony Sweet Onion" - }, - { - "selected": false, - "label": "Ebony Sweet Peas", - "value": "Ebony Sweet Peas" - }, - { - "selected": false, - "label": "Ebony Tangerines", - "value": "Ebony Tangerines" - }, - { - "selected": false, - "label": "Ebony Tomatos", - "value": "Ebony Tomatos" - }, - { - "selected": false, - "label": "Ebony Walnuts", - "value": "Ebony Walnuts" - }, - { - "selected": false, - "label": "Even Better 1% Milk", - "value": "Even Better 1% Milk" - }, - { - "selected": false, - "label": "Even Better 2% Milk", - "value": "Even Better 2% Milk" - }, - { - "selected": false, - "label": "Even Better Blueberry Yogurt", - "value": "Even Better Blueberry Yogurt" - }, - { - "selected": false, - "label": "Even Better Buttermilk", - "value": "Even Better Buttermilk" - }, - { - "selected": false, - "label": "Even Better Cheese Spread", - "value": "Even Better Cheese Spread" - }, - { - "selected": false, - "label": "Even Better Chocolate Milk", - "value": "Even Better Chocolate Milk" - }, - { - "selected": false, - "label": "Even Better Havarti Cheese", - "value": "Even Better Havarti Cheese" - }, - { - "selected": false, - "label": "Even Better Head Cheese", - "value": "Even Better Head Cheese" - }, - { - "selected": false, - "label": "Even Better Jack Cheese", - "value": "Even Better Jack Cheese" - }, - { - "selected": false, - "label": "Even Better Large Curd Cottage Cheese", - "value": "Even Better Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Even Better Low Fat Cottage Cheese", - "value": "Even Better Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Even Better Low Fat Sour Cream", - "value": "Even Better Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Even Better Low Fat String Cheese", - "value": "Even Better Low Fat String Cheese" - }, - { - "selected": false, - "label": "Even Better Mild Cheddar Cheese", - "value": "Even Better Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Even Better Muenster Cheese", - "value": "Even Better Muenster Cheese" - }, - { - "selected": false, - "label": "Even Better Sharp Cheddar Cheese", - "value": "Even Better Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Even Better Sour Cream", - "value": "Even Better Sour Cream" - }, - { - "selected": false, - "label": "Even Better Strawberry Yogurt", - "value": "Even Better Strawberry Yogurt" - }, - { - "selected": false, - "label": "Even Better String Cheese", - "value": "Even Better String Cheese" - }, - { - "selected": false, - "label": "Even Better Whole Milk", - "value": "Even Better Whole Milk" - }, - { - "selected": false, - "label": "Excellent Apple Drink", - "value": "Excellent Apple Drink" - }, - { - "selected": false, - "label": "Excellent Apple Juice", - "value": "Excellent Apple Juice" - }, - { - "selected": false, - "label": "Excellent Berry Juice", - "value": "Excellent Berry Juice" - }, - { - "selected": false, - "label": "Excellent Cola", - "value": "Excellent Cola" - }, - { - "selected": false, - "label": "Excellent Cranberry Juice", - "value": "Excellent Cranberry Juice" - }, - { - "selected": false, - "label": "Excellent Cream Soda", - "value": "Excellent Cream Soda" - }, - { - "selected": false, - "label": "Excellent Diet Cola", - "value": "Excellent Diet Cola" - }, - { - "selected": false, - "label": "Excellent Diet Soda", - "value": "Excellent Diet Soda" - }, - { - "selected": false, - "label": "Excellent Mango Drink", - "value": "Excellent Mango Drink" - }, - { - "selected": false, - "label": "Excellent Orange Juice", - "value": "Excellent Orange Juice" - }, - { - "selected": false, - "label": "Excellent Strawberry Drink", - "value": "Excellent Strawberry Drink" - }, - { - "selected": false, - "label": "Excel Monthly Auto Magazine", - "value": "Excel Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Computer Magazine", - "value": "Excel Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Fashion Magazine", - "value": "Excel Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Home Magazine", - "value": "Excel Monthly Home Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Sports Magazine", - "value": "Excel Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Fabulous Apple Drink", - "value": "Fabulous Apple Drink" - }, - { - "selected": false, - "label": "Fabulous Apple Juice", - "value": "Fabulous Apple Juice" - }, - { - "selected": false, - "label": "Fabulous Berry Juice", - "value": "Fabulous Berry Juice" - }, - { - "selected": false, - "label": "Fabulous Cola", - "value": "Fabulous Cola" - }, - { - "selected": false, - "label": "Fabulous Cranberry Juice", - "value": "Fabulous Cranberry Juice" - }, - { - "selected": false, - "label": "Fabulous Cream Soda", - "value": "Fabulous Cream Soda" - }, - { - "selected": false, - "label": "Fabulous Diet Cola", - "value": "Fabulous Diet Cola" - }, - { - "selected": false, - "label": "Fabulous Diet Soda", - "value": "Fabulous Diet Soda" - }, - { - "selected": false, - "label": "Fabulous Mango Drink", - "value": "Fabulous Mango Drink" - }, - { - "selected": false, - "label": "Fabulous Orange Juice", - "value": "Fabulous Orange Juice" - }, - { - "selected": false, - "label": "Fabulous Strawberry Drink", - "value": "Fabulous Strawberry Drink" - }, - { - "selected": false, - "label": "Fantastic Bagels", - "value": "Fantastic Bagels" - }, - { - "selected": false, - "label": "Fantastic Blueberry Muffins", - "value": "Fantastic Blueberry Muffins" - }, - { - "selected": false, - "label": "Fantastic Cranberry Muffins", - "value": "Fantastic Cranberry Muffins" - }, - { - "selected": false, - "label": "Fantastic English Muffins", - "value": "Fantastic English Muffins" - }, - { - "selected": false, - "label": "Fantastic Muffins", - "value": "Fantastic Muffins" - }, - { - "selected": false, - "label": "Fantastic Pumpernickel Bread", - "value": "Fantastic Pumpernickel Bread" - }, - { - "selected": false, - "label": "Fantastic Rye Bread", - "value": "Fantastic Rye Bread" - }, - { - "selected": false, - "label": "Fantastic Wheat Bread", - "value": "Fantastic Wheat Bread" - }, - { - "selected": false, - "label": "Fantastic White Bread", - "value": "Fantastic White Bread" - }, - { - "selected": false, - "label": "Fast Apple Fruit Roll", - "value": "Fast Apple Fruit Roll" - }, - { - "selected": false, - "label": "Fast Avocado Dip", - "value": "Fast Avocado Dip" - }, - { - "selected": false, - "label": "Fast BBQ Potato Chips", - "value": "Fast BBQ Potato Chips" - }, - { - "selected": false, - "label": "Fast Beef Jerky", - "value": "Fast Beef Jerky" - }, - { - "selected": false, - "label": "Fast Buttered Popcorn", - "value": "Fast Buttered Popcorn" - }, - { - "selected": false, - "label": "Fast Cheese Crackers", - "value": "Fast Cheese Crackers" - }, - { - "selected": false, - "label": "Fast Cheese Dip", - "value": "Fast Cheese Dip" - }, - { - "selected": false, - "label": "Fast Chocolate Chip Cookies", - "value": "Fast Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Fast Chocolate Donuts", - "value": "Fast Chocolate Donuts" - }, - { - "selected": false, - "label": "Fast Corn Chips", - "value": "Fast Corn Chips" - }, - { - "selected": false, - "label": "Fast Dried Apples", - "value": "Fast Dried Apples" - }, - { - "selected": false, - "label": "Fast Dried Apricots", - "value": "Fast Dried Apricots" - }, - { - "selected": false, - "label": "Fast Dried Dates", - "value": "Fast Dried Dates" - }, - { - "selected": false, - "label": "Fast Fondue Mix", - "value": "Fast Fondue Mix" - }, - { - "selected": false, - "label": "Fast Frosted Cookies", - "value": "Fast Frosted Cookies" - }, - { - "selected": false, - "label": "Fast Frosted Donuts", - "value": "Fast Frosted Donuts" - }, - { - "selected": false, - "label": "Fast Fudge Brownies", - "value": "Fast Fudge Brownies" - }, - { - "selected": false, - "label": "Fast Fudge Cookies", - "value": "Fast Fudge Cookies" - }, - { - "selected": false, - "label": "Fast Golden Raisins", - "value": "Fast Golden Raisins" - }, - { - "selected": false, - "label": "Fast Graham Crackers", - "value": "Fast Graham Crackers" - }, - { - "selected": false, - "label": "Fast Grape Fruit Roll", - "value": "Fast Grape Fruit Roll" - }, - { - "selected": false, - "label": "Fast Lemon Cookies", - "value": "Fast Lemon Cookies" - }, - { - "selected": false, - "label": "Fast Low Fat BBQ Chips", - "value": "Fast Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Fast Low Fat Chips", - "value": "Fast Low Fat Chips" - }, - { - "selected": false, - "label": "Fast Low Fat Cookies", - "value": "Fast Low Fat Cookies" - }, - { - "selected": false, - "label": "Fast Low Fat Popcorn", - "value": "Fast Low Fat Popcorn" - }, - { - "selected": false, - "label": "Fast Mini Donuts", - "value": "Fast Mini Donuts" - }, - { - "selected": false, - "label": "Fast No Salt Popcorn", - "value": "Fast No Salt Popcorn" - }, - { - "selected": false, - "label": "Fast Potato Chips", - "value": "Fast Potato Chips" - }, - { - "selected": false, - "label": "Fast Raisins", - "value": "Fast Raisins" - }, - { - "selected": false, - "label": "Fast Raspberry Fruit Roll", - "value": "Fast Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Fast Salsa Dip", - "value": "Fast Salsa Dip" - }, - { - "selected": false, - "label": "Fast Salted Pretzels", - "value": "Fast Salted Pretzels" - }, - { - "selected": false, - "label": "Fast Sesame Crackers", - "value": "Fast Sesame Crackers" - }, - { - "selected": false, - "label": "Fast Strawberry Fruit Roll", - "value": "Fast Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Fast Sugar Cookies", - "value": "Fast Sugar Cookies" - }, - { - "selected": false, - "label": "Faux Products 200 MG Acetominifen", - "value": "Faux Products 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Faux Products 200 MG Ibuprofen", - "value": "Faux Products 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Faux Products Angled Toothbrush", - "value": "Faux Products Angled Toothbrush" - }, - { - "selected": false, - "label": "Faux Products Apricot Shampoo", - "value": "Faux Products Apricot Shampoo" - }, - { - "selected": false, - "label": "Faux Products Buffered Aspirin", - "value": "Faux Products Buffered Aspirin" - }, - { - "selected": false, - "label": "Faux Products Childrens Aspirin", - "value": "Faux Products Childrens Aspirin" - }, - { - "selected": false, - "label": "Faux Products Childrens Cold Remedy", - "value": "Faux Products Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Faux Products Conditioning Shampoo", - "value": "Faux Products Conditioning Shampoo" - }, - { - "selected": false, - "label": "Faux Products Deodorant", - "value": "Faux Products Deodorant" - }, - { - "selected": false, - "label": "Faux Products Dishwasher Detergent", - "value": "Faux Products Dishwasher Detergent" - }, - { - "selected": false, - "label": "Faux Products Extra Moisture Shampoo", - "value": "Faux Products Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Faux Products HCL Nasal Spray", - "value": "Faux Products HCL Nasal Spray" - }, - { - "selected": false, - "label": "Faux Products Laundry Detergent", - "value": "Faux Products Laundry Detergent" - }, - { - "selected": false, - "label": "Faux Products Mint Mouthwash", - "value": "Faux Products Mint Mouthwash" - }, - { - "selected": false, - "label": "Faux Products Multi-Symptom Cold Remedy", - "value": "Faux Products Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Faux Products Silky Smooth Hair Conditioner", - "value": "Faux Products Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Faux Products Tartar Control Toothpaste", - "value": "Faux Products Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Faux Products Toothpaste", - "value": "Faux Products Toothpaste" - }, - { - "selected": false, - "label": "Faux Products Whitening Toothpast", - "value": "Faux Products Whitening Toothpast" - }, - { - "selected": false, - "label": "Footnote Extra Lean Hamburger", - "value": "Footnote Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Footnote Seasoned Hamburger", - "value": "Footnote Seasoned Hamburger" - }, - { - "selected": false, - "label": "Fort West Apple Fruit Roll", - "value": "Fort West Apple Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Avocado Dip", - "value": "Fort West Avocado Dip" - }, - { - "selected": false, - "label": "Fort West BBQ Potato Chips", - "value": "Fort West BBQ Potato Chips" - }, - { - "selected": false, - "label": "Fort West Beef Jerky", - "value": "Fort West Beef Jerky" - }, - { - "selected": false, - "label": "Fort West Buttered Popcorn", - "value": "Fort West Buttered Popcorn" - }, - { - "selected": false, - "label": "Fort West Cheese Crackers", - "value": "Fort West Cheese Crackers" - }, - { - "selected": false, - "label": "Fort West Cheese Dip", - "value": "Fort West Cheese Dip" - }, - { - "selected": false, - "label": "Fort West Chocolate Chip Cookies", - "value": "Fort West Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Fort West Chocolate Donuts", - "value": "Fort West Chocolate Donuts" - }, - { - "selected": false, - "label": "Fort West Corn Chips", - "value": "Fort West Corn Chips" - }, - { - "selected": false, - "label": "Fort West Dried Apples", - "value": "Fort West Dried Apples" - }, - { - "selected": false, - "label": "Fort West Dried Apricots", - "value": "Fort West Dried Apricots" - }, - { - "selected": false, - "label": "Fort West Dried Dates", - "value": "Fort West Dried Dates" - }, - { - "selected": false, - "label": "Fort West Fondue Mix", - "value": "Fort West Fondue Mix" - }, - { - "selected": false, - "label": "Fort West Frosted Cookies", - "value": "Fort West Frosted Cookies" - }, - { - "selected": false, - "label": "Fort West Frosted Donuts", - "value": "Fort West Frosted Donuts" - }, - { - "selected": false, - "label": "Fort West Fudge Brownies", - "value": "Fort West Fudge Brownies" - }, - { - "selected": false, - "label": "Fort West Fudge Cookies", - "value": "Fort West Fudge Cookies" - }, - { - "selected": false, - "label": "Fort West Golden Raisins", - "value": "Fort West Golden Raisins" - }, - { - "selected": false, - "label": "Fort West Graham Crackers", - "value": "Fort West Graham Crackers" - }, - { - "selected": false, - "label": "Fort West Grape Fruit Roll", - "value": "Fort West Grape Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Lemon Cookies", - "value": "Fort West Lemon Cookies" - }, - { - "selected": false, - "label": "Fort West Low Fat BBQ Chips", - "value": "Fort West Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Fort West Low Fat Chips", - "value": "Fort West Low Fat Chips" - }, - { - "selected": false, - "label": "Fort West Low Fat Cookies", - "value": "Fort West Low Fat Cookies" - }, - { - "selected": false, - "label": "Fort West Low Fat Popcorn", - "value": "Fort West Low Fat Popcorn" - }, - { - "selected": false, - "label": "Fort West Mini Donuts", - "value": "Fort West Mini Donuts" - }, - { - "selected": false, - "label": "Fort West No Salt Popcorn", - "value": "Fort West No Salt Popcorn" - }, - { - "selected": false, - "label": "Fort West Potato Chips", - "value": "Fort West Potato Chips" - }, - { - "selected": false, - "label": "Fort West Raisins", - "value": "Fort West Raisins" - }, - { - "selected": false, - "label": "Fort West Raspberry Fruit Roll", - "value": "Fort West Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Salsa Dip", - "value": "Fort West Salsa Dip" - }, - { - "selected": false, - "label": "Fort West Salted Pretzels", - "value": "Fort West Salted Pretzels" - }, - { - "selected": false, - "label": "Fort West Sesame Crackers", - "value": "Fort West Sesame Crackers" - }, - { - "selected": false, - "label": "Fort West Strawberry Fruit Roll", - "value": "Fort West Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Sugar Cookies", - "value": "Fort West Sugar Cookies" - }, - { - "selected": false, - "label": "Framton City Map", - "value": "Framton City Map" - }, - { - "selected": false, - "label": "Framton Eyeglass Screwdriver", - "value": "Framton Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Gauss Monthly Auto Magazine", - "value": "Gauss Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Computer Magazine", - "value": "Gauss Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Fashion Magazine", - "value": "Gauss Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Home Magazine", - "value": "Gauss Monthly Home Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Sports Magazine", - "value": "Gauss Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Genteel Extra Lean Hamburger", - "value": "Genteel Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Genteel Seasoned Hamburger", - "value": "Genteel Seasoned Hamburger" - }, - { - "selected": false, - "label": "Gerolli Extra Lean Hamburger", - "value": "Gerolli Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Gerolli Seasoned Hamburger", - "value": "Gerolli Seasoned Hamburger" - }, - { - "selected": false, - "label": "Giant Egg Substitute", - "value": "Giant Egg Substitute" - }, - { - "selected": false, - "label": "Giant Large Brown Eggs", - "value": "Giant Large Brown Eggs" - }, - { - "selected": false, - "label": "Giant Large Eggs", - "value": "Giant Large Eggs" - }, - { - "selected": false, - "label": "Giant Small Brown Eggs", - "value": "Giant Small Brown Eggs" - }, - { - "selected": false, - "label": "Giant Small Eggs", - "value": "Giant Small Eggs" - }, - { - "selected": false, - "label": "Golden Apple Cinnamon Waffles", - "value": "Golden Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Golden Beef TV Dinner", - "value": "Golden Beef TV Dinner" - }, - { - "selected": false, - "label": "Golden Blueberry Waffles", - "value": "Golden Blueberry Waffles" - }, - { - "selected": false, - "label": "Golden Chicken TV Dinner", - "value": "Golden Chicken TV Dinner" - }, - { - "selected": false, - "label": "Golden Fajita French Fries", - "value": "Golden Fajita French Fries" - }, - { - "selected": false, - "label": "Golden Frozen Broccoli", - "value": "Golden Frozen Broccoli" - }, - { - "selected": false, - "label": "Golden Frozen Carrots", - "value": "Golden Frozen Carrots" - }, - { - "selected": false, - "label": "Golden Frozen Cauliflower", - "value": "Golden Frozen Cauliflower" - }, - { - "selected": false, - "label": "Golden Frozen Cheese Pizza", - "value": "Golden Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Breast", - "value": "Golden Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Thighs", - "value": "Golden Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Wings", - "value": "Golden Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Golden Frozen Corn", - "value": "Golden Frozen Corn" - }, - { - "selected": false, - "label": "Golden Frozen Mushroom Pizza", - "value": "Golden Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Pancakes", - "value": "Golden Frozen Pancakes" - }, - { - "selected": false, - "label": "Golden Frozen Peas", - "value": "Golden Frozen Peas" - }, - { - "selected": false, - "label": "Golden Frozen Pepperoni Pizza", - "value": "Golden Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Sausage Pizza", - "value": "Golden Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Golden Grape Popsicles", - "value": "Golden Grape Popsicles" - }, - { - "selected": false, - "label": "Golden Home Style French Fries", - "value": "Golden Home Style French Fries" - }, - { - "selected": false, - "label": "Golden Ice Cream", - "value": "Golden Ice Cream" - }, - { - "selected": false, - "label": "Golden Ice Cream Sandwich", - "value": "Golden Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Golden Lemon Popsicles", - "value": "Golden Lemon Popsicles" - }, - { - "selected": false, - "label": "Golden Lime Popsicles", - "value": "Golden Lime Popsicles" - }, - { - "selected": false, - "label": "Golden Low Fat French Fries", - "value": "Golden Low Fat French Fries" - }, - { - "selected": false, - "label": "Golden Low Fat Waffles", - "value": "Golden Low Fat Waffles" - }, - { - "selected": false, - "label": "Golden Orange Popsicles", - "value": "Golden Orange Popsicles" - }, - { - "selected": false, - "label": "Golden Pancake Mix", - "value": "Golden Pancake Mix" - }, - { - "selected": false, - "label": "Golden Popsicles", - "value": "Golden Popsicles" - }, - { - "selected": false, - "label": "Golden Turkey TV Dinner", - "value": "Golden Turkey TV Dinner" - }, - { - "selected": false, - "label": "Golden Waffles", - "value": "Golden Waffles" - }, - { - "selected": false, - "label": "Good Chablis Wine", - "value": "Good Chablis Wine" - }, - { - "selected": false, - "label": "Good Chardonnay", - "value": "Good Chardonnay" - }, - { - "selected": false, - "label": "Good Chardonnay Wine", - "value": "Good Chardonnay Wine" - }, - { - "selected": false, - "label": "Good Imported Beer", - "value": "Good Imported Beer" - }, - { - "selected": false, - "label": "Good Light Beer", - "value": "Good Light Beer" - }, - { - "selected": false, - "label": "Good Light Wine", - "value": "Good Light Wine" - }, - { - "selected": false, - "label": "Good Merlot Wine", - "value": "Good Merlot Wine" - }, - { - "selected": false, - "label": "Good White Zinfandel Wine", - "value": "Good White Zinfandel Wine" - }, - { - "selected": false, - "label": "Gorilla 1% Milk", - "value": "Gorilla 1% Milk" - }, - { - "selected": false, - "label": "Gorilla 2% Milk", - "value": "Gorilla 2% Milk" - }, - { - "selected": false, - "label": "Gorilla Blueberry Yogurt", - "value": "Gorilla Blueberry Yogurt" - }, - { - "selected": false, - "label": "Gorilla Buttermilk", - "value": "Gorilla Buttermilk" - }, - { - "selected": false, - "label": "Gorilla Cheese Spread", - "value": "Gorilla Cheese Spread" - }, - { - "selected": false, - "label": "Gorilla Chocolate Milk", - "value": "Gorilla Chocolate Milk" - }, - { - "selected": false, - "label": "Gorilla Havarti Cheese", - "value": "Gorilla Havarti Cheese" - }, - { - "selected": false, - "label": "Gorilla Head Cheese", - "value": "Gorilla Head Cheese" - }, - { - "selected": false, - "label": "Gorilla Jack Cheese", - "value": "Gorilla Jack Cheese" - }, - { - "selected": false, - "label": "Gorilla Large Curd Cottage Cheese", - "value": "Gorilla Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Gorilla Low Fat Cottage Cheese", - "value": "Gorilla Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Gorilla Low Fat Sour Cream", - "value": "Gorilla Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Gorilla Low Fat String Cheese", - "value": "Gorilla Low Fat String Cheese" - }, - { - "selected": false, - "label": "Gorilla Mild Cheddar Cheese", - "value": "Gorilla Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Gorilla Muenster Cheese", - "value": "Gorilla Muenster Cheese" - }, - { - "selected": false, - "label": "Gorilla Sharp Cheddar Cheese", - "value": "Gorilla Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Gorilla Sour Cream", - "value": "Gorilla Sour Cream" - }, - { - "selected": false, - "label": "Gorilla Strawberry Yogurt", - "value": "Gorilla Strawberry Yogurt" - }, - { - "selected": false, - "label": "Gorilla String Cheese", - "value": "Gorilla String Cheese" - }, - { - "selected": false, - "label": "Gorilla Whole Milk", - "value": "Gorilla Whole Milk" - }, - { - "selected": false, - "label": "Great Bagels", - "value": "Great Bagels" - }, - { - "selected": false, - "label": "Great Blueberry Muffins", - "value": "Great Blueberry Muffins" - }, - { - "selected": false, - "label": "Great Cranberry Muffins", - "value": "Great Cranberry Muffins" - }, - { - "selected": false, - "label": "Great English Muffins", - "value": "Great English Muffins" - }, - { - "selected": false, - "label": "Great Muffins", - "value": "Great Muffins" - }, - { - "selected": false, - "label": "Great Pumpernickel Bread", - "value": "Great Pumpernickel Bread" - }, - { - "selected": false, - "label": "Great Rye Bread", - "value": "Great Rye Bread" - }, - { - "selected": false, - "label": "Great Wheat Bread", - "value": "Great Wheat Bread" - }, - { - "selected": false, - "label": "Great White Bread", - "value": "Great White Bread" - }, - { - "selected": false, - "label": "Green Ribbon Canned Mixed Fruit", - "value": "Green Ribbon Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Green Ribbon Canned Peaches", - "value": "Green Ribbon Canned Peaches" - }, - { - "selected": false, - "label": "Gulf Coast Bubble Gum", - "value": "Gulf Coast Bubble Gum" - }, - { - "selected": false, - "label": "Gulf Coast Malted Milk Balls", - "value": "Gulf Coast Malted Milk Balls" - }, - { - "selected": false, - "label": "Gulf Coast Mint Chocolate Bar", - "value": "Gulf Coast Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Gulf Coast Mints", - "value": "Gulf Coast Mints" - }, - { - "selected": false, - "label": "Gulf Coast Semi-Sweet Chocolate Bar", - "value": "Gulf Coast Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Gulf Coast Spicy Mints", - "value": "Gulf Coast Spicy Mints" - }, - { - "selected": false, - "label": "Gulf Coast Tasty Candy Bar", - "value": "Gulf Coast Tasty Candy Bar" - }, - { - "selected": false, - "label": "Gulf Coast White Chocolate Bar", - "value": "Gulf Coast White Chocolate Bar" - }, - { - "selected": false, - "label": "Hermanos Almonds", - "value": "Hermanos Almonds" - }, - { - "selected": false, - "label": "Hermanos Asparagus", - "value": "Hermanos Asparagus" - }, - { - "selected": false, - "label": "Hermanos Baby Onion", - "value": "Hermanos Baby Onion" - }, - { - "selected": false, - "label": "Hermanos Beets", - "value": "Hermanos Beets" - }, - { - "selected": false, - "label": "Hermanos Broccoli", - "value": "Hermanos Broccoli" - }, - { - "selected": false, - "label": "Hermanos Canned Peanuts", - "value": "Hermanos Canned Peanuts" - }, - { - "selected": false, - "label": "Hermanos Cantelope", - "value": "Hermanos Cantelope" - }, - { - "selected": false, - "label": "Hermanos Cauliflower", - "value": "Hermanos Cauliflower" - }, - { - "selected": false, - "label": "Hermanos Corn on the Cob", - "value": "Hermanos Corn on the Cob" - }, - { - "selected": false, - "label": "Hermanos Dried Mushrooms", - "value": "Hermanos Dried Mushrooms" - }, - { - "selected": false, - "label": "Hermanos Elephant Garlic", - "value": "Hermanos Elephant Garlic" - }, - { - "selected": false, - "label": "Hermanos Fancy Plums", - "value": "Hermanos Fancy Plums" - }, - { - "selected": false, - "label": "Hermanos Firm Tofu", - "value": "Hermanos Firm Tofu" - }, - { - "selected": false, - "label": "Hermanos Fresh Lima Beans", - "value": "Hermanos Fresh Lima Beans" - }, - { - "selected": false, - "label": "Hermanos Fuji Apples", - "value": "Hermanos Fuji Apples" - }, - { - "selected": false, - "label": "Hermanos Garlic", - "value": "Hermanos Garlic" - }, - { - "selected": false, - "label": "Hermanos Golden Delcious Apples", - "value": "Hermanos Golden Delcious Apples" - }, - { - "selected": false, - "label": "Hermanos Green Pepper", - "value": "Hermanos Green Pepper" - }, - { - "selected": false, - "label": "Hermanos Honey Dew", - "value": "Hermanos Honey Dew" - }, - { - "selected": false, - "label": "Hermanos Lemons", - "value": "Hermanos Lemons" - }, - { - "selected": false, - "label": "Hermanos Lettuce", - "value": "Hermanos Lettuce" - }, - { - "selected": false, - "label": "Hermanos Limes", - "value": "Hermanos Limes" - }, - { - "selected": false, - "label": "Hermanos Macintosh Apples", - "value": "Hermanos Macintosh Apples" - }, - { - "selected": false, - "label": "Hermanos Mandarin Oranges", - "value": "Hermanos Mandarin Oranges" - }, - { - "selected": false, - "label": "Hermanos Mixed Nuts", - "value": "Hermanos Mixed Nuts" - }, - { - "selected": false, - "label": "Hermanos Mushrooms", - "value": "Hermanos Mushrooms" - }, - { - "selected": false, - "label": "Hermanos New Potatos", - "value": "Hermanos New Potatos" - }, - { - "selected": false, - "label": "Hermanos Onions", - "value": "Hermanos Onions" - }, - { - "selected": false, - "label": "Hermanos Oranges", - "value": "Hermanos Oranges" - }, - { - "selected": false, - "label": "Hermanos Party Nuts", - "value": "Hermanos Party Nuts" - }, - { - "selected": false, - "label": "Hermanos Peaches", - "value": "Hermanos Peaches" - }, - { - "selected": false, - "label": "Hermanos Plums", - "value": "Hermanos Plums" - }, - { - "selected": false, - "label": "Hermanos Potatos", - "value": "Hermanos Potatos" - }, - { - "selected": false, - "label": "Hermanos Prepared Salad", - "value": "Hermanos Prepared Salad" - }, - { - "selected": false, - "label": "Hermanos Red Delcious Apples", - "value": "Hermanos Red Delcious Apples" - }, - { - "selected": false, - "label": "Hermanos Red Pepper", - "value": "Hermanos Red Pepper" - }, - { - "selected": false, - "label": "Hermanos Shitake Mushrooms", - "value": "Hermanos Shitake Mushrooms" - }, - { - "selected": false, - "label": "Hermanos Squash", - "value": "Hermanos Squash" - }, - { - "selected": false, - "label": "Hermanos Summer Squash", - "value": "Hermanos Summer Squash" - }, - { - "selected": false, - "label": "Hermanos Sweet Onion", - "value": "Hermanos Sweet Onion" - }, - { - "selected": false, - "label": "Hermanos Sweet Peas", - "value": "Hermanos Sweet Peas" - }, - { - "selected": false, - "label": "Hermanos Tangerines", - "value": "Hermanos Tangerines" - }, - { - "selected": false, - "label": "Hermanos Tomatos", - "value": "Hermanos Tomatos" - }, - { - "selected": false, - "label": "Hermanos Walnuts", - "value": "Hermanos Walnuts" - }, - { - "selected": false, - "label": "High Quality 100 Watt Lightbulb", - "value": "High Quality 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 25 Watt Lightbulb", - "value": "High Quality 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 60 Watt Lightbulb", - "value": "High Quality 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 75 Watt Lightbulb", - "value": "High Quality 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality AAA-Size Batteries", - "value": "High Quality AAA-Size Batteries" - }, - { - "selected": false, - "label": "High Quality AA-Size Batteries", - "value": "High Quality AA-Size Batteries" - }, - { - "selected": false, - "label": "High Quality Bees Wax Candles", - "value": "High Quality Bees Wax Candles" - }, - { - "selected": false, - "label": "High Quality Copper Cleaner", - "value": "High Quality Copper Cleaner" - }, - { - "selected": false, - "label": "High Quality Copper Pot Scrubber", - "value": "High Quality Copper Pot Scrubber" - }, - { - "selected": false, - "label": "High Quality Counter Cleaner", - "value": "High Quality Counter Cleaner" - }, - { - "selected": false, - "label": "High Quality C-Size Batteries", - "value": "High Quality C-Size Batteries" - }, - { - "selected": false, - "label": "High Quality D-Size Batteries", - "value": "High Quality D-Size Batteries" - }, - { - "selected": false, - "label": "High Quality Economy Toilet Brush", - "value": "High Quality Economy Toilet Brush" - }, - { - "selected": false, - "label": "High Quality Frying Pan", - "value": "High Quality Frying Pan" - }, - { - "selected": false, - "label": "High Quality Glass Cleaner", - "value": "High Quality Glass Cleaner" - }, - { - "selected": false, - "label": "High Quality Large Sponge", - "value": "High Quality Large Sponge" - }, - { - "selected": false, - "label": "High Quality Paper Cups", - "value": "High Quality Paper Cups" - }, - { - "selected": false, - "label": "High Quality Paper Plates", - "value": "High Quality Paper Plates" - }, - { - "selected": false, - "label": "High Quality Paper Towels", - "value": "High Quality Paper Towels" - }, - { - "selected": false, - "label": "High Quality Plastic Forks", - "value": "High Quality Plastic Forks" - }, - { - "selected": false, - "label": "High Quality Plastic Knives", - "value": "High Quality Plastic Knives" - }, - { - "selected": false, - "label": "High Quality Plastic Spoons", - "value": "High Quality Plastic Spoons" - }, - { - "selected": false, - "label": "High Quality Room Freshener", - "value": "High Quality Room Freshener" - }, - { - "selected": false, - "label": "High Quality Scented Tissue", - "value": "High Quality Scented Tissue" - }, - { - "selected": false, - "label": "High Quality Scented Toilet Tissue", - "value": "High Quality Scented Toilet Tissue" - }, - { - "selected": false, - "label": "High Quality Scissors", - "value": "High Quality Scissors" - }, - { - "selected": false, - "label": "High Quality Screw Driver", - "value": "High Quality Screw Driver" - }, - { - "selected": false, - "label": "High Quality Silver Cleaner", - "value": "High Quality Silver Cleaner" - }, - { - "selected": false, - "label": "High Quality Soft Napkins", - "value": "High Quality Soft Napkins" - }, - { - "selected": false, - "label": "High Quality Tissues", - "value": "High Quality Tissues" - }, - { - "selected": false, - "label": "High Quality Toilet Bowl Cleaner", - "value": "High Quality Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "High Quality Toilet Paper", - "value": "High Quality Toilet Paper" - }, - { - "selected": false, - "label": "High Top Almonds", - "value": "High Top Almonds" - }, - { - "selected": false, - "label": "High Top Asparagus", - "value": "High Top Asparagus" - }, - { - "selected": false, - "label": "High Top Baby Onion", - "value": "High Top Baby Onion" - }, - { - "selected": false, - "label": "High Top Beets", - "value": "High Top Beets" - }, - { - "selected": false, - "label": "High Top Broccoli", - "value": "High Top Broccoli" - }, - { - "selected": false, - "label": "High Top Canned Peanuts", - "value": "High Top Canned Peanuts" - }, - { - "selected": false, - "label": "High Top Cantelope", - "value": "High Top Cantelope" - }, - { - "selected": false, - "label": "High Top Cauliflower", - "value": "High Top Cauliflower" - }, - { - "selected": false, - "label": "High Top Corn on the Cob", - "value": "High Top Corn on the Cob" - }, - { - "selected": false, - "label": "High Top Dried Mushrooms", - "value": "High Top Dried Mushrooms" - }, - { - "selected": false, - "label": "High Top Elephant Garlic", - "value": "High Top Elephant Garlic" - }, - { - "selected": false, - "label": "High Top Fancy Plums", - "value": "High Top Fancy Plums" - }, - { - "selected": false, - "label": "High Top Firm Tofu", - "value": "High Top Firm Tofu" - }, - { - "selected": false, - "label": "High Top Fresh Lima Beans", - "value": "High Top Fresh Lima Beans" - }, - { - "selected": false, - "label": "High Top Fuji Apples", - "value": "High Top Fuji Apples" - }, - { - "selected": false, - "label": "High Top Garlic", - "value": "High Top Garlic" - }, - { - "selected": false, - "label": "High Top Golden Delcious Apples", - "value": "High Top Golden Delcious Apples" - }, - { - "selected": false, - "label": "High Top Green Pepper", - "value": "High Top Green Pepper" - }, - { - "selected": false, - "label": "High Top Honey Dew", - "value": "High Top Honey Dew" - }, - { - "selected": false, - "label": "High Top Lemons", - "value": "High Top Lemons" - }, - { - "selected": false, - "label": "High Top Lettuce", - "value": "High Top Lettuce" - }, - { - "selected": false, - "label": "High Top Limes", - "value": "High Top Limes" - }, - { - "selected": false, - "label": "High Top Macintosh Apples", - "value": "High Top Macintosh Apples" - }, - { - "selected": false, - "label": "High Top Mandarin Oranges", - "value": "High Top Mandarin Oranges" - }, - { - "selected": false, - "label": "High Top Mixed Nuts", - "value": "High Top Mixed Nuts" - }, - { - "selected": false, - "label": "High Top Mushrooms", - "value": "High Top Mushrooms" - }, - { - "selected": false, - "label": "High Top New Potatos", - "value": "High Top New Potatos" - }, - { - "selected": false, - "label": "High Top Onions", - "value": "High Top Onions" - }, - { - "selected": false, - "label": "High Top Oranges", - "value": "High Top Oranges" - }, - { - "selected": false, - "label": "High Top Party Nuts", - "value": "High Top Party Nuts" - }, - { - "selected": false, - "label": "High Top Peaches", - "value": "High Top Peaches" - }, - { - "selected": false, - "label": "High Top Plums", - "value": "High Top Plums" - }, - { - "selected": false, - "label": "High Top Potatos", - "value": "High Top Potatos" - }, - { - "selected": false, - "label": "High Top Prepared Salad", - "value": "High Top Prepared Salad" - }, - { - "selected": false, - "label": "High Top Red Delcious Apples", - "value": "High Top Red Delcious Apples" - }, - { - "selected": false, - "label": "High Top Red Pepper", - "value": "High Top Red Pepper" - }, - { - "selected": false, - "label": "High Top Shitake Mushrooms", - "value": "High Top Shitake Mushrooms" - }, - { - "selected": false, - "label": "High Top Squash", - "value": "High Top Squash" - }, - { - "selected": false, - "label": "High Top Summer Squash", - "value": "High Top Summer Squash" - }, - { - "selected": false, - "label": "High Top Sweet Onion", - "value": "High Top Sweet Onion" - }, - { - "selected": false, - "label": "High Top Sweet Peas", - "value": "High Top Sweet Peas" - }, - { - "selected": false, - "label": "High Top Tangerines", - "value": "High Top Tangerines" - }, - { - "selected": false, - "label": "High Top Tomatos", - "value": "High Top Tomatos" - }, - { - "selected": false, - "label": "High Top Walnuts", - "value": "High Top Walnuts" - }, - { - "selected": false, - "label": "Hilltop 200 MG Acetominifen", - "value": "Hilltop 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Hilltop 200 MG Ibuprofen", - "value": "Hilltop 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Hilltop Angled Toothbrush", - "value": "Hilltop Angled Toothbrush" - }, - { - "selected": false, - "label": "Hilltop Apricot Shampoo", - "value": "Hilltop Apricot Shampoo" - }, - { - "selected": false, - "label": "Hilltop Buffered Aspirin", - "value": "Hilltop Buffered Aspirin" - }, - { - "selected": false, - "label": "Hilltop Childrens Aspirin", - "value": "Hilltop Childrens Aspirin" - }, - { - "selected": false, - "label": "Hilltop Childrens Cold Remedy", - "value": "Hilltop Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Hilltop Conditioning Shampoo", - "value": "Hilltop Conditioning Shampoo" - }, - { - "selected": false, - "label": "Hilltop Deodorant", - "value": "Hilltop Deodorant" - }, - { - "selected": false, - "label": "Hilltop Dishwasher Detergent", - "value": "Hilltop Dishwasher Detergent" - }, - { - "selected": false, - "label": "Hilltop Extra Moisture Shampoo", - "value": "Hilltop Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Hilltop HCL Nasal Spray", - "value": "Hilltop HCL Nasal Spray" - }, - { - "selected": false, - "label": "Hilltop Laundry Detergent", - "value": "Hilltop Laundry Detergent" - }, - { - "selected": false, - "label": "Hilltop Mint Mouthwash", - "value": "Hilltop Mint Mouthwash" - }, - { - "selected": false, - "label": "Hilltop Multi-Symptom Cold Remedy", - "value": "Hilltop Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Hilltop Silky Smooth Hair Conditioner", - "value": "Hilltop Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Hilltop Tartar Control Toothpaste", - "value": "Hilltop Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Hilltop Toothpaste", - "value": "Hilltop Toothpaste" - }, - { - "selected": false, - "label": "Hilltop Whitening Toothpast", - "value": "Hilltop Whitening Toothpast" - }, - { - "selected": false, - "label": "Horatio Apple Fruit Roll", - "value": "Horatio Apple Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Avocado Dip", - "value": "Horatio Avocado Dip" - }, - { - "selected": false, - "label": "Horatio BBQ Potato Chips", - "value": "Horatio BBQ Potato Chips" - }, - { - "selected": false, - "label": "Horatio Beef Jerky", - "value": "Horatio Beef Jerky" - }, - { - "selected": false, - "label": "Horatio Buttered Popcorn", - "value": "Horatio Buttered Popcorn" - }, - { - "selected": false, - "label": "Horatio Cheese Crackers", - "value": "Horatio Cheese Crackers" - }, - { - "selected": false, - "label": "Horatio Cheese Dip", - "value": "Horatio Cheese Dip" - }, - { - "selected": false, - "label": "Horatio Chocolate Chip Cookies", - "value": "Horatio Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Horatio Chocolate Donuts", - "value": "Horatio Chocolate Donuts" - }, - { - "selected": false, - "label": "Horatio Corn Chips", - "value": "Horatio Corn Chips" - }, - { - "selected": false, - "label": "Horatio Dried Apples", - "value": "Horatio Dried Apples" - }, - { - "selected": false, - "label": "Horatio Dried Apricots", - "value": "Horatio Dried Apricots" - }, - { - "selected": false, - "label": "Horatio Dried Dates", - "value": "Horatio Dried Dates" - }, - { - "selected": false, - "label": "Horatio Fondue Mix", - "value": "Horatio Fondue Mix" - }, - { - "selected": false, - "label": "Horatio Frosted Cookies", - "value": "Horatio Frosted Cookies" - }, - { - "selected": false, - "label": "Horatio Frosted Donuts", - "value": "Horatio Frosted Donuts" - }, - { - "selected": false, - "label": "Horatio Fudge Brownies", - "value": "Horatio Fudge Brownies" - }, - { - "selected": false, - "label": "Horatio Fudge Cookies", - "value": "Horatio Fudge Cookies" - }, - { - "selected": false, - "label": "Horatio Golden Raisins", - "value": "Horatio Golden Raisins" - }, - { - "selected": false, - "label": "Horatio Graham Crackers", - "value": "Horatio Graham Crackers" - }, - { - "selected": false, - "label": "Horatio Grape Fruit Roll", - "value": "Horatio Grape Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Lemon Cookies", - "value": "Horatio Lemon Cookies" - }, - { - "selected": false, - "label": "Horatio Low Fat BBQ Chips", - "value": "Horatio Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Horatio Low Fat Chips", - "value": "Horatio Low Fat Chips" - }, - { - "selected": false, - "label": "Horatio Low Fat Cookies", - "value": "Horatio Low Fat Cookies" - }, - { - "selected": false, - "label": "Horatio Low Fat Popcorn", - "value": "Horatio Low Fat Popcorn" - }, - { - "selected": false, - "label": "Horatio Mini Donuts", - "value": "Horatio Mini Donuts" - }, - { - "selected": false, - "label": "Horatio No Salt Popcorn", - "value": "Horatio No Salt Popcorn" - }, - { - "selected": false, - "label": "Horatio Potato Chips", - "value": "Horatio Potato Chips" - }, - { - "selected": false, - "label": "Horatio Raisins", - "value": "Horatio Raisins" - }, - { - "selected": false, - "label": "Horatio Raspberry Fruit Roll", - "value": "Horatio Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Salsa Dip", - "value": "Horatio Salsa Dip" - }, - { - "selected": false, - "label": "Horatio Salted Pretzels", - "value": "Horatio Salted Pretzels" - }, - { - "selected": false, - "label": "Horatio Sesame Crackers", - "value": "Horatio Sesame Crackers" - }, - { - "selected": false, - "label": "Horatio Strawberry Fruit Roll", - "value": "Horatio Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Sugar Cookies", - "value": "Horatio Sugar Cookies" - }, - { - "selected": false, - "label": "Imagine Apple Cinnamon Waffles", - "value": "Imagine Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Imagine Beef TV Dinner", - "value": "Imagine Beef TV Dinner" - }, - { - "selected": false, - "label": "Imagine Blueberry Waffles", - "value": "Imagine Blueberry Waffles" - }, - { - "selected": false, - "label": "Imagine Chicken TV Dinner", - "value": "Imagine Chicken TV Dinner" - }, - { - "selected": false, - "label": "Imagine Fajita French Fries", - "value": "Imagine Fajita French Fries" - }, - { - "selected": false, - "label": "Imagine Frozen Broccoli", - "value": "Imagine Frozen Broccoli" - }, - { - "selected": false, - "label": "Imagine Frozen Carrots", - "value": "Imagine Frozen Carrots" - }, - { - "selected": false, - "label": "Imagine Frozen Cauliflower", - "value": "Imagine Frozen Cauliflower" - }, - { - "selected": false, - "label": "Imagine Frozen Cheese Pizza", - "value": "Imagine Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Breast", - "value": "Imagine Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Thighs", - "value": "Imagine Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Wings", - "value": "Imagine Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Imagine Frozen Corn", - "value": "Imagine Frozen Corn" - }, - { - "selected": false, - "label": "Imagine Frozen Mushroom Pizza", - "value": "Imagine Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Pancakes", - "value": "Imagine Frozen Pancakes" - }, - { - "selected": false, - "label": "Imagine Frozen Peas", - "value": "Imagine Frozen Peas" - }, - { - "selected": false, - "label": "Imagine Frozen Pepperoni Pizza", - "value": "Imagine Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Sausage Pizza", - "value": "Imagine Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Imagine Grape Popsicles", - "value": "Imagine Grape Popsicles" - }, - { - "selected": false, - "label": "Imagine Home Style French Fries", - "value": "Imagine Home Style French Fries" - }, - { - "selected": false, - "label": "Imagine Ice Cream", - "value": "Imagine Ice Cream" - }, - { - "selected": false, - "label": "Imagine Ice Cream Sandwich", - "value": "Imagine Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Imagine Lemon Popsicles", - "value": "Imagine Lemon Popsicles" - }, - { - "selected": false, - "label": "Imagine Lime Popsicles", - "value": "Imagine Lime Popsicles" - }, - { - "selected": false, - "label": "Imagine Low Fat French Fries", - "value": "Imagine Low Fat French Fries" - }, - { - "selected": false, - "label": "Imagine Low Fat Waffles", - "value": "Imagine Low Fat Waffles" - }, - { - "selected": false, - "label": "Imagine Orange Popsicles", - "value": "Imagine Orange Popsicles" - }, - { - "selected": false, - "label": "Imagine Pancake Mix", - "value": "Imagine Pancake Mix" - }, - { - "selected": false, - "label": "Imagine Popsicles", - "value": "Imagine Popsicles" - }, - { - "selected": false, - "label": "Imagine Turkey TV Dinner", - "value": "Imagine Turkey TV Dinner" - }, - { - "selected": false, - "label": "Imagine Waffles", - "value": "Imagine Waffles" - }, - { - "selected": false, - "label": "James Bay City Map", - "value": "James Bay City Map" - }, - { - "selected": false, - "label": "James Bay Eyeglass Screwdriver", - "value": "James Bay Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Jardon Manicotti", - "value": "Jardon Manicotti" - }, - { - "selected": false, - "label": "Jardon Ravioli", - "value": "Jardon Ravioli" - }, - { - "selected": false, - "label": "Jardon Rice Medly", - "value": "Jardon Rice Medly" - }, - { - "selected": false, - "label": "Jardon Spaghetti", - "value": "Jardon Spaghetti" - }, - { - "selected": false, - "label": "Jardon Thai Rice", - "value": "Jardon Thai Rice" - }, - { - "selected": false, - "label": "Jeffers Corn Puffs", - "value": "Jeffers Corn Puffs" - }, - { - "selected": false, - "label": "Jeffers Grits", - "value": "Jeffers Grits" - }, - { - "selected": false, - "label": "Jeffers Oatmeal", - "value": "Jeffers Oatmeal" - }, - { - "selected": false, - "label": "Jeffers Wheat Puffs", - "value": "Jeffers Wheat Puffs" - }, - { - "selected": false, - "label": "Johnson Corn Puffs", - "value": "Johnson Corn Puffs" - }, - { - "selected": false, - "label": "Johnson Grits", - "value": "Johnson Grits" - }, - { - "selected": false, - "label": "Johnson Oatmeal", - "value": "Johnson Oatmeal" - }, - { - "selected": false, - "label": "Johnson Wheat Puffs", - "value": "Johnson Wheat Puffs" - }, - { - "selected": false, - "label": "Jumbo Egg Substitute", - "value": "Jumbo Egg Substitute" - }, - { - "selected": false, - "label": "Jumbo Large Brown Eggs", - "value": "Jumbo Large Brown Eggs" - }, - { - "selected": false, - "label": "Jumbo Large Eggs", - "value": "Jumbo Large Eggs" - }, - { - "selected": false, - "label": "Jumbo Small Brown Eggs", - "value": "Jumbo Small Brown Eggs" - }, - { - "selected": false, - "label": "Jumbo Small Eggs", - "value": "Jumbo Small Eggs" - }, - { - "selected": false, - "label": "Just Right Beef Soup", - "value": "Just Right Beef Soup" - }, - { - "selected": false, - "label": "Just Right Canned Beets", - "value": "Just Right Canned Beets" - }, - { - "selected": false, - "label": "Just Right Canned Peas", - "value": "Just Right Canned Peas" - }, - { - "selected": false, - "label": "Just Right Canned String Beans", - "value": "Just Right Canned String Beans" - }, - { - "selected": false, - "label": "Just Right Canned Tomatos", - "value": "Just Right Canned Tomatos" - }, - { - "selected": false, - "label": "Just Right Canned Tuna in Oil", - "value": "Just Right Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Just Right Canned Tuna in Water", - "value": "Just Right Canned Tuna in Water" - }, - { - "selected": false, - "label": "Just Right Canned Yams", - "value": "Just Right Canned Yams" - }, - { - "selected": false, - "label": "Just Right Chicken Noodle Soup", - "value": "Just Right Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Chicken Ramen Soup", - "value": "Just Right Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Just Right Chicken Soup", - "value": "Just Right Chicken Soup" - }, - { - "selected": false, - "label": "Just Right Creamed Corn", - "value": "Just Right Creamed Corn" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Anchovies", - "value": "Just Right Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Clams", - "value": "Just Right Fancy Canned Clams" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Oysters", - "value": "Just Right Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Sardines", - "value": "Just Right Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Just Right Large Canned Shrimp", - "value": "Just Right Large Canned Shrimp" - }, - { - "selected": false, - "label": "Just Right Noodle Soup", - "value": "Just Right Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Regular Ramen Soup", - "value": "Just Right Regular Ramen Soup" - }, - { - "selected": false, - "label": "Just Right Rice Soup", - "value": "Just Right Rice Soup" - }, - { - "selected": false, - "label": "Just Right Turkey Noodle Soup", - "value": "Just Right Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Vegetable Soup", - "value": "Just Right Vegetable Soup" - }, - { - "selected": false, - "label": "King Rosy Sunglasses", - "value": "King Rosy Sunglasses" - }, - { - "selected": false, - "label": "Kiwi Lox", - "value": "Kiwi Lox" - }, - { - "selected": false, - "label": "Kiwi Scallops", - "value": "Kiwi Scallops" - }, - { - "selected": false, - "label": "Lake Beef Bologna", - "value": "Lake Beef Bologna" - }, - { - "selected": false, - "label": "Lake Chicken Hot Dogs", - "value": "Lake Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Lake Cole Slaw", - "value": "Lake Cole Slaw" - }, - { - "selected": false, - "label": "Lake Corned Beef", - "value": "Lake Corned Beef" - }, - { - "selected": false, - "label": "Lake Foot-Long Hot Dogs", - "value": "Lake Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Lake Low Fat Bologna", - "value": "Lake Low Fat Bologna" - }, - { - "selected": false, - "label": "Lake Low Fat Cole Slaw", - "value": "Lake Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Lake Pimento Loaf", - "value": "Lake Pimento Loaf" - }, - { - "selected": false, - "label": "Lake Potato Salad", - "value": "Lake Potato Salad" - }, - { - "selected": false, - "label": "Lake Roasted Chicken", - "value": "Lake Roasted Chicken" - }, - { - "selected": false, - "label": "Lake Sliced Chicken", - "value": "Lake Sliced Chicken" - }, - { - "selected": false, - "label": "Lake Sliced Ham", - "value": "Lake Sliced Ham" - }, - { - "selected": false, - "label": "Lake Sliced Turkey", - "value": "Lake Sliced Turkey" - }, - { - "selected": false, - "label": "Lake Turkey Hot Dogs", - "value": "Lake Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Landslide Apple Butter", - "value": "Landslide Apple Butter" - }, - { - "selected": false, - "label": "Landslide Apple Jam", - "value": "Landslide Apple Jam" - }, - { - "selected": false, - "label": "Landslide Apple Jelly", - "value": "Landslide Apple Jelly" - }, - { - "selected": false, - "label": "Landslide Apple Preserves", - "value": "Landslide Apple Preserves" - }, - { - "selected": false, - "label": "Landslide Brown Sugar", - "value": "Landslide Brown Sugar" - }, - { - "selected": false, - "label": "Landslide Canola Oil", - "value": "Landslide Canola Oil" - }, - { - "selected": false, - "label": "Landslide Chunky Peanut Butter", - "value": "Landslide Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Landslide Columbian Coffee", - "value": "Landslide Columbian Coffee" - }, - { - "selected": false, - "label": "Landslide Corn Oil", - "value": "Landslide Corn Oil" - }, - { - "selected": false, - "label": "Landslide Creamy Peanut Butter", - "value": "Landslide Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Landslide Decaf Coffee", - "value": "Landslide Decaf Coffee" - }, - { - "selected": false, - "label": "Landslide Extra Chunky Peanut Butter", - "value": "Landslide Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Landslide French Roast Coffee", - "value": "Landslide French Roast Coffee" - }, - { - "selected": false, - "label": "Landslide Grape Jam", - "value": "Landslide Grape Jam" - }, - { - "selected": false, - "label": "Landslide Grape Jelly", - "value": "Landslide Grape Jelly" - }, - { - "selected": false, - "label": "Landslide Grape Preserves", - "value": "Landslide Grape Preserves" - }, - { - "selected": false, - "label": "Landslide Hot Chocolate", - "value": "Landslide Hot Chocolate" - }, - { - "selected": false, - "label": "Landslide Low Fat Apple Butter", - "value": "Landslide Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Landslide Oregano", - "value": "Landslide Oregano" - }, - { - "selected": false, - "label": "Landslide Pepper", - "value": "Landslide Pepper" - }, - { - "selected": false, - "label": "Landslide Regular Coffee", - "value": "Landslide Regular Coffee" - }, - { - "selected": false, - "label": "Landslide Salt", - "value": "Landslide Salt" - }, - { - "selected": false, - "label": "Landslide Sesame Oil", - "value": "Landslide Sesame Oil" - }, - { - "selected": false, - "label": "Landslide Strawberry Jam", - "value": "Landslide Strawberry Jam" - }, - { - "selected": false, - "label": "Landslide Strawberry Jelly", - "value": "Landslide Strawberry Jelly" - }, - { - "selected": false, - "label": "Landslide Strawberry Preserves", - "value": "Landslide Strawberry Preserves" - }, - { - "selected": false, - "label": "Landslide Tomato Sauce", - "value": "Landslide Tomato Sauce" - }, - { - "selected": false, - "label": "Landslide Vegetable Oil", - "value": "Landslide Vegetable Oil" - }, - { - "selected": false, - "label": "Landslide White Sugar", - "value": "Landslide White Sugar" - }, - { - "selected": false, - "label": "Medalist Manicotti", - "value": "Medalist Manicotti" - }, - { - "selected": false, - "label": "Medalist Ravioli", - "value": "Medalist Ravioli" - }, - { - "selected": false, - "label": "Medalist Rice Medly", - "value": "Medalist Rice Medly" - }, - { - "selected": false, - "label": "Medalist Spaghetti", - "value": "Medalist Spaghetti" - }, - { - "selected": false, - "label": "Medalist Thai Rice", - "value": "Medalist Thai Rice" - }, - { - "selected": false, - "label": "Mighty Good Monthly Auto Magazine", - "value": "Mighty Good Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Computer Magazine", - "value": "Mighty Good Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Fashion Magazine", - "value": "Mighty Good Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Home Magazine", - "value": "Mighty Good Monthly Home Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Sports Magazine", - "value": "Mighty Good Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Modell Bagels", - "value": "Modell Bagels" - }, - { - "selected": false, - "label": "Modell Blueberry Muffins", - "value": "Modell Blueberry Muffins" - }, - { - "selected": false, - "label": "Modell Cranberry Muffins", - "value": "Modell Cranberry Muffins" - }, - { - "selected": false, - "label": "Modell English Muffins", - "value": "Modell English Muffins" - }, - { - "selected": false, - "label": "Modell Muffins", - "value": "Modell Muffins" - }, - { - "selected": false, - "label": "Modell Pumpernickel Bread", - "value": "Modell Pumpernickel Bread" - }, - { - "selected": false, - "label": "Modell Rye Bread", - "value": "Modell Rye Bread" - }, - { - "selected": false, - "label": "Modell Wheat Bread", - "value": "Modell Wheat Bread" - }, - { - "selected": false, - "label": "Modell White Bread", - "value": "Modell White Bread" - }, - { - "selected": false, - "label": "Moms Beef Bologna", - "value": "Moms Beef Bologna" - }, - { - "selected": false, - "label": "Moms Chicken Hot Dogs", - "value": "Moms Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Moms Cole Slaw", - "value": "Moms Cole Slaw" - }, - { - "selected": false, - "label": "Moms Corned Beef", - "value": "Moms Corned Beef" - }, - { - "selected": false, - "label": "Moms Foot-Long Hot Dogs", - "value": "Moms Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Moms Low Fat Bologna", - "value": "Moms Low Fat Bologna" - }, - { - "selected": false, - "label": "Moms Low Fat Cole Slaw", - "value": "Moms Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Moms Pimento Loaf", - "value": "Moms Pimento Loaf" - }, - { - "selected": false, - "label": "Moms Potato Salad", - "value": "Moms Potato Salad" - }, - { - "selected": false, - "label": "Moms Roasted Chicken", - "value": "Moms Roasted Chicken" - }, - { - "selected": false, - "label": "Moms Sliced Chicken", - "value": "Moms Sliced Chicken" - }, - { - "selected": false, - "label": "Moms Sliced Ham", - "value": "Moms Sliced Ham" - }, - { - "selected": false, - "label": "Moms Sliced Turkey", - "value": "Moms Sliced Turkey" - }, - { - "selected": false, - "label": "Moms Turkey Hot Dogs", - "value": "Moms Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Monarch Manicotti", - "value": "Monarch Manicotti" - }, - { - "selected": false, - "label": "Monarch Ravioli", - "value": "Monarch Ravioli" - }, - { - "selected": false, - "label": "Monarch Rice Medly", - "value": "Monarch Rice Medly" - }, - { - "selected": false, - "label": "Monarch Spaghetti", - "value": "Monarch Spaghetti" - }, - { - "selected": false, - "label": "Monarch Thai Rice", - "value": "Monarch Thai Rice" - }, - { - "selected": false, - "label": "Musial Bubble Gum", - "value": "Musial Bubble Gum" - }, - { - "selected": false, - "label": "Musial Malted Milk Balls", - "value": "Musial Malted Milk Balls" - }, - { - "selected": false, - "label": "Musial Mint Chocolate Bar", - "value": "Musial Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Musial Mints", - "value": "Musial Mints" - }, - { - "selected": false, - "label": "Musial Semi-Sweet Chocolate Bar", - "value": "Musial Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Musial Spicy Mints", - "value": "Musial Spicy Mints" - }, - { - "selected": false, - "label": "Musial Tasty Candy Bar", - "value": "Musial Tasty Candy Bar" - }, - { - "selected": false, - "label": "Musial White Chocolate Bar", - "value": "Musial White Chocolate Bar" - }, - { - "selected": false, - "label": "National Egg Substitute", - "value": "National Egg Substitute" - }, - { - "selected": false, - "label": "National Large Brown Eggs", - "value": "National Large Brown Eggs" - }, - { - "selected": false, - "label": "National Large Eggs", - "value": "National Large Eggs" - }, - { - "selected": false, - "label": "National Small Brown Eggs", - "value": "National Small Brown Eggs" - }, - { - "selected": false, - "label": "National Small Eggs", - "value": "National Small Eggs" - }, - { - "selected": false, - "label": "Nationeel Apple Fruit Roll", - "value": "Nationeel Apple Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Avocado Dip", - "value": "Nationeel Avocado Dip" - }, - { - "selected": false, - "label": "Nationeel BBQ Potato Chips", - "value": "Nationeel BBQ Potato Chips" - }, - { - "selected": false, - "label": "Nationeel Beef Jerky", - "value": "Nationeel Beef Jerky" - }, - { - "selected": false, - "label": "Nationeel Buttered Popcorn", - "value": "Nationeel Buttered Popcorn" - }, - { - "selected": false, - "label": "Nationeel Cheese Crackers", - "value": "Nationeel Cheese Crackers" - }, - { - "selected": false, - "label": "Nationeel Cheese Dip", - "value": "Nationeel Cheese Dip" - }, - { - "selected": false, - "label": "Nationeel Chocolate Chip Cookies", - "value": "Nationeel Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Nationeel Chocolate Donuts", - "value": "Nationeel Chocolate Donuts" - }, - { - "selected": false, - "label": "Nationeel Corn Chips", - "value": "Nationeel Corn Chips" - }, - { - "selected": false, - "label": "Nationeel Dried Apples", - "value": "Nationeel Dried Apples" - }, - { - "selected": false, - "label": "Nationeel Dried Apricots", - "value": "Nationeel Dried Apricots" - }, - { - "selected": false, - "label": "Nationeel Dried Dates", - "value": "Nationeel Dried Dates" - }, - { - "selected": false, - "label": "Nationeel Fondue Mix", - "value": "Nationeel Fondue Mix" - }, - { - "selected": false, - "label": "Nationeel Frosted Cookies", - "value": "Nationeel Frosted Cookies" - }, - { - "selected": false, - "label": "Nationeel Frosted Donuts", - "value": "Nationeel Frosted Donuts" - }, - { - "selected": false, - "label": "Nationeel Fudge Brownies", - "value": "Nationeel Fudge Brownies" - }, - { - "selected": false, - "label": "Nationeel Fudge Cookies", - "value": "Nationeel Fudge Cookies" - }, - { - "selected": false, - "label": "Nationeel Golden Raisins", - "value": "Nationeel Golden Raisins" - }, - { - "selected": false, - "label": "Nationeel Graham Crackers", - "value": "Nationeel Graham Crackers" - }, - { - "selected": false, - "label": "Nationeel Grape Fruit Roll", - "value": "Nationeel Grape Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Lemon Cookies", - "value": "Nationeel Lemon Cookies" - }, - { - "selected": false, - "label": "Nationeel Low Fat BBQ Chips", - "value": "Nationeel Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Nationeel Low Fat Chips", - "value": "Nationeel Low Fat Chips" - }, - { - "selected": false, - "label": "Nationeel Low Fat Cookies", - "value": "Nationeel Low Fat Cookies" - }, - { - "selected": false, - "label": "Nationeel Low Fat Popcorn", - "value": "Nationeel Low Fat Popcorn" - }, - { - "selected": false, - "label": "Nationeel Mini Donuts", - "value": "Nationeel Mini Donuts" - }, - { - "selected": false, - "label": "Nationeel No Salt Popcorn", - "value": "Nationeel No Salt Popcorn" - }, - { - "selected": false, - "label": "Nationeel Potato Chips", - "value": "Nationeel Potato Chips" - }, - { - "selected": false, - "label": "Nationeel Raisins", - "value": "Nationeel Raisins" - }, - { - "selected": false, - "label": "Nationeel Raspberry Fruit Roll", - "value": "Nationeel Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Salsa Dip", - "value": "Nationeel Salsa Dip" - }, - { - "selected": false, - "label": "Nationeel Salted Pretzels", - "value": "Nationeel Salted Pretzels" - }, - { - "selected": false, - "label": "Nationeel Sesame Crackers", - "value": "Nationeel Sesame Crackers" - }, - { - "selected": false, - "label": "Nationeel Strawberry Fruit Roll", - "value": "Nationeel Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Sugar Cookies", - "value": "Nationeel Sugar Cookies" - }, - { - "selected": false, - "label": "Pearl Chablis Wine", - "value": "Pearl Chablis Wine" - }, - { - "selected": false, - "label": "Pearl Chardonnay", - "value": "Pearl Chardonnay" - }, - { - "selected": false, - "label": "Pearl Chardonnay Wine", - "value": "Pearl Chardonnay Wine" - }, - { - "selected": false, - "label": "Pearl Imported Beer", - "value": "Pearl Imported Beer" - }, - { - "selected": false, - "label": "Pearl Light Beer", - "value": "Pearl Light Beer" - }, - { - "selected": false, - "label": "Pearl Light Wine", - "value": "Pearl Light Wine" - }, - { - "selected": false, - "label": "Pearl Merlot Wine", - "value": "Pearl Merlot Wine" - }, - { - "selected": false, - "label": "Pearl White Zinfandel Wine", - "value": "Pearl White Zinfandel Wine" - }, - { - "selected": false, - "label": "PigTail Apple Cinnamon Waffles", - "value": "PigTail Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "PigTail Beef TV Dinner", - "value": "PigTail Beef TV Dinner" - }, - { - "selected": false, - "label": "PigTail Blueberry Waffles", - "value": "PigTail Blueberry Waffles" - }, - { - "selected": false, - "label": "PigTail Chicken TV Dinner", - "value": "PigTail Chicken TV Dinner" - }, - { - "selected": false, - "label": "PigTail Fajita French Fries", - "value": "PigTail Fajita French Fries" - }, - { - "selected": false, - "label": "PigTail Frozen Broccoli", - "value": "PigTail Frozen Broccoli" - }, - { - "selected": false, - "label": "PigTail Frozen Carrots", - "value": "PigTail Frozen Carrots" - }, - { - "selected": false, - "label": "PigTail Frozen Cauliflower", - "value": "PigTail Frozen Cauliflower" - }, - { - "selected": false, - "label": "PigTail Frozen Cheese Pizza", - "value": "PigTail Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Breast", - "value": "PigTail Frozen Chicken Breast" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Thighs", - "value": "PigTail Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Wings", - "value": "PigTail Frozen Chicken Wings" - }, - { - "selected": false, - "label": "PigTail Frozen Corn", - "value": "PigTail Frozen Corn" - }, - { - "selected": false, - "label": "PigTail Frozen Mushroom Pizza", - "value": "PigTail Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Pancakes", - "value": "PigTail Frozen Pancakes" - }, - { - "selected": false, - "label": "PigTail Frozen Peas", - "value": "PigTail Frozen Peas" - }, - { - "selected": false, - "label": "PigTail Frozen Pepperoni Pizza", - "value": "PigTail Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Sausage Pizza", - "value": "PigTail Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "PigTail Grape Popsicles", - "value": "PigTail Grape Popsicles" - }, - { - "selected": false, - "label": "PigTail Home Style French Fries", - "value": "PigTail Home Style French Fries" - }, - { - "selected": false, - "label": "PigTail Ice Cream", - "value": "PigTail Ice Cream" - }, - { - "selected": false, - "label": "PigTail Ice Cream Sandwich", - "value": "PigTail Ice Cream Sandwich" - }, - { - "selected": false, - "label": "PigTail Lemon Popsicles", - "value": "PigTail Lemon Popsicles" - }, - { - "selected": false, - "label": "PigTail Lime Popsicles", - "value": "PigTail Lime Popsicles" - }, - { - "selected": false, - "label": "PigTail Low Fat French Fries", - "value": "PigTail Low Fat French Fries" - }, - { - "selected": false, - "label": "PigTail Low Fat Waffles", - "value": "PigTail Low Fat Waffles" - }, - { - "selected": false, - "label": "PigTail Orange Popsicles", - "value": "PigTail Orange Popsicles" - }, - { - "selected": false, - "label": "PigTail Pancake Mix", - "value": "PigTail Pancake Mix" - }, - { - "selected": false, - "label": "PigTail Popsicles", - "value": "PigTail Popsicles" - }, - { - "selected": false, - "label": "PigTail Turkey TV Dinner", - "value": "PigTail Turkey TV Dinner" - }, - { - "selected": false, - "label": "PigTail Waffles", - "value": "PigTail Waffles" - }, - { - "selected": false, - "label": "Plato Apple Butter", - "value": "Plato Apple Butter" - }, - { - "selected": false, - "label": "Plato Apple Jam", - "value": "Plato Apple Jam" - }, - { - "selected": false, - "label": "Plato Apple Jelly", - "value": "Plato Apple Jelly" - }, - { - "selected": false, - "label": "Plato Apple Preserves", - "value": "Plato Apple Preserves" - }, - { - "selected": false, - "label": "Plato Brown Sugar", - "value": "Plato Brown Sugar" - }, - { - "selected": false, - "label": "Plato Canola Oil", - "value": "Plato Canola Oil" - }, - { - "selected": false, - "label": "Plato Chunky Peanut Butter", - "value": "Plato Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Plato Columbian Coffee", - "value": "Plato Columbian Coffee" - }, - { - "selected": false, - "label": "Plato Corn Oil", - "value": "Plato Corn Oil" - }, - { - "selected": false, - "label": "Plato Creamy Peanut Butter", - "value": "Plato Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Plato Decaf Coffee", - "value": "Plato Decaf Coffee" - }, - { - "selected": false, - "label": "Plato Extra Chunky Peanut Butter", - "value": "Plato Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Plato French Roast Coffee", - "value": "Plato French Roast Coffee" - }, - { - "selected": false, - "label": "Plato Grape Jam", - "value": "Plato Grape Jam" - }, - { - "selected": false, - "label": "Plato Grape Jelly", - "value": "Plato Grape Jelly" - }, - { - "selected": false, - "label": "Plato Grape Preserves", - "value": "Plato Grape Preserves" - }, - { - "selected": false, - "label": "Plato Hot Chocolate", - "value": "Plato Hot Chocolate" - }, - { - "selected": false, - "label": "Plato Low Fat Apple Butter", - "value": "Plato Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Plato Oregano", - "value": "Plato Oregano" - }, - { - "selected": false, - "label": "Plato Pepper", - "value": "Plato Pepper" - }, - { - "selected": false, - "label": "Plato Regular Coffee", - "value": "Plato Regular Coffee" - }, - { - "selected": false, - "label": "Plato Salt", - "value": "Plato Salt" - }, - { - "selected": false, - "label": "Plato Sesame Oil", - "value": "Plato Sesame Oil" - }, - { - "selected": false, - "label": "Plato Strawberry Jam", - "value": "Plato Strawberry Jam" - }, - { - "selected": false, - "label": "Plato Strawberry Jelly", - "value": "Plato Strawberry Jelly" - }, - { - "selected": false, - "label": "Plato Strawberry Preserves", - "value": "Plato Strawberry Preserves" - }, - { - "selected": false, - "label": "Plato Tomato Sauce", - "value": "Plato Tomato Sauce" - }, - { - "selected": false, - "label": "Plato Vegetable Oil", - "value": "Plato Vegetable Oil" - }, - { - "selected": false, - "label": "Plato White Sugar", - "value": "Plato White Sugar" - }, - { - "selected": false, - "label": "Pleasant Beef Soup", - "value": "Pleasant Beef Soup" - }, - { - "selected": false, - "label": "Pleasant Canned Beets", - "value": "Pleasant Canned Beets" - }, - { - "selected": false, - "label": "Pleasant Canned Peas", - "value": "Pleasant Canned Peas" - }, - { - "selected": false, - "label": "Pleasant Canned String Beans", - "value": "Pleasant Canned String Beans" - }, - { - "selected": false, - "label": "Pleasant Canned Tomatos", - "value": "Pleasant Canned Tomatos" - }, - { - "selected": false, - "label": "Pleasant Canned Tuna in Oil", - "value": "Pleasant Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Pleasant Canned Tuna in Water", - "value": "Pleasant Canned Tuna in Water" - }, - { - "selected": false, - "label": "Pleasant Canned Yams", - "value": "Pleasant Canned Yams" - }, - { - "selected": false, - "label": "Pleasant Chicken Noodle Soup", - "value": "Pleasant Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Chicken Ramen Soup", - "value": "Pleasant Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Pleasant Chicken Soup", - "value": "Pleasant Chicken Soup" - }, - { - "selected": false, - "label": "Pleasant Creamed Corn", - "value": "Pleasant Creamed Corn" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Anchovies", - "value": "Pleasant Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Clams", - "value": "Pleasant Fancy Canned Clams" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Oysters", - "value": "Pleasant Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Sardines", - "value": "Pleasant Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Pleasant Large Canned Shrimp", - "value": "Pleasant Large Canned Shrimp" - }, - { - "selected": false, - "label": "Pleasant Noodle Soup", - "value": "Pleasant Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Regular Ramen Soup", - "value": "Pleasant Regular Ramen Soup" - }, - { - "selected": false, - "label": "Pleasant Rice Soup", - "value": "Pleasant Rice Soup" - }, - { - "selected": false, - "label": "Pleasant Turkey Noodle Soup", - "value": "Pleasant Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Vegetable Soup", - "value": "Pleasant Vegetable Soup" - }, - { - "selected": false, - "label": "Portsmouth Chablis Wine", - "value": "Portsmouth Chablis Wine" - }, - { - "selected": false, - "label": "Portsmouth Chardonnay", - "value": "Portsmouth Chardonnay" - }, - { - "selected": false, - "label": "Portsmouth Chardonnay Wine", - "value": "Portsmouth Chardonnay Wine" - }, - { - "selected": false, - "label": "Portsmouth Imported Beer", - "value": "Portsmouth Imported Beer" - }, - { - "selected": false, - "label": "Portsmouth Light Beer", - "value": "Portsmouth Light Beer" - }, - { - "selected": false, - "label": "Portsmouth Light Wine", - "value": "Portsmouth Light Wine" - }, - { - "selected": false, - "label": "Portsmouth Merlot Wine", - "value": "Portsmouth Merlot Wine" - }, - { - "selected": false, - "label": "Portsmouth White Zinfandel Wine", - "value": "Portsmouth White Zinfandel Wine" - }, - { - "selected": false, - "label": "Prelude Rosy Sunglasses", - "value": "Prelude Rosy Sunglasses" - }, - { - "selected": false, - "label": "Queen City Map", - "value": "Queen City Map" - }, - { - "selected": false, - "label": "Queen Eyeglass Screwdriver", - "value": "Queen Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Quick Extra Lean Hamburger", - "value": "Quick Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Quick Seasoned Hamburger", - "value": "Quick Seasoned Hamburger" - }, - { - "selected": false, - "label": "Radius Corn Puffs", - "value": "Radius Corn Puffs" - }, - { - "selected": false, - "label": "Radius Grits", - "value": "Radius Grits" - }, - { - "selected": false, - "label": "Radius Oatmeal", - "value": "Radius Oatmeal" - }, - { - "selected": false, - "label": "Radius Wheat Puffs", - "value": "Radius Wheat Puffs" - }, - { - "selected": false, - "label": "Red Spade Beef Bologna", - "value": "Red Spade Beef Bologna" - }, - { - "selected": false, - "label": "Red Spade Chicken Hot Dogs", - "value": "Red Spade Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Red Spade Cole Slaw", - "value": "Red Spade Cole Slaw" - }, - { - "selected": false, - "label": "Red Spade Corned Beef", - "value": "Red Spade Corned Beef" - }, - { - "selected": false, - "label": "Red Spade Foot-Long Hot Dogs", - "value": "Red Spade Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Red Spade Low Fat Bologna", - "value": "Red Spade Low Fat Bologna" - }, - { - "selected": false, - "label": "Red Spade Low Fat Cole Slaw", - "value": "Red Spade Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Red Spade Pimento Loaf", - "value": "Red Spade Pimento Loaf" - }, - { - "selected": false, - "label": "Red Spade Potato Salad", - "value": "Red Spade Potato Salad" - }, - { - "selected": false, - "label": "Red Spade Roasted Chicken", - "value": "Red Spade Roasted Chicken" - }, - { - "selected": false, - "label": "Red Spade Sliced Chicken", - "value": "Red Spade Sliced Chicken" - }, - { - "selected": false, - "label": "Red Spade Sliced Ham", - "value": "Red Spade Sliced Ham" - }, - { - "selected": false, - "label": "Red Spade Sliced Turkey", - "value": "Red Spade Sliced Turkey" - }, - { - "selected": false, - "label": "Red Spade Turkey Hot Dogs", - "value": "Red Spade Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Red Wing 100 Watt Lightbulb", - "value": "Red Wing 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 25 Watt Lightbulb", - "value": "Red Wing 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 60 Watt Lightbulb", - "value": "Red Wing 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 75 Watt Lightbulb", - "value": "Red Wing 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing AAA-Size Batteries", - "value": "Red Wing AAA-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing AA-Size Batteries", - "value": "Red Wing AA-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing Bees Wax Candles", - "value": "Red Wing Bees Wax Candles" - }, - { - "selected": false, - "label": "Red Wing Copper Cleaner", - "value": "Red Wing Copper Cleaner" - }, - { - "selected": false, - "label": "Red Wing Copper Pot Scrubber", - "value": "Red Wing Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Red Wing Counter Cleaner", - "value": "Red Wing Counter Cleaner" - }, - { - "selected": false, - "label": "Red Wing C-Size Batteries", - "value": "Red Wing C-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing D-Size Batteries", - "value": "Red Wing D-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing Economy Toilet Brush", - "value": "Red Wing Economy Toilet Brush" - }, - { - "selected": false, - "label": "Red Wing Frying Pan", - "value": "Red Wing Frying Pan" - }, - { - "selected": false, - "label": "Red Wing Glass Cleaner", - "value": "Red Wing Glass Cleaner" - }, - { - "selected": false, - "label": "Red Wing Large Sponge", - "value": "Red Wing Large Sponge" - }, - { - "selected": false, - "label": "Red Wing Paper Cups", - "value": "Red Wing Paper Cups" - }, - { - "selected": false, - "label": "Red Wing Paper Plates", - "value": "Red Wing Paper Plates" - }, - { - "selected": false, - "label": "Red Wing Paper Towels", - "value": "Red Wing Paper Towels" - }, - { - "selected": false, - "label": "Red Wing Plastic Forks", - "value": "Red Wing Plastic Forks" - }, - { - "selected": false, - "label": "Red Wing Plastic Knives", - "value": "Red Wing Plastic Knives" - }, - { - "selected": false, - "label": "Red Wing Plastic Spoons", - "value": "Red Wing Plastic Spoons" - }, - { - "selected": false, - "label": "Red Wing Room Freshener", - "value": "Red Wing Room Freshener" - }, - { - "selected": false, - "label": "Red Wing Scented Tissue", - "value": "Red Wing Scented Tissue" - }, - { - "selected": false, - "label": "Red Wing Scented Toilet Tissue", - "value": "Red Wing Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Red Wing Scissors", - "value": "Red Wing Scissors" - }, - { - "selected": false, - "label": "Red Wing Screw Driver", - "value": "Red Wing Screw Driver" - }, - { - "selected": false, - "label": "Red Wing Silver Cleaner", - "value": "Red Wing Silver Cleaner" - }, - { - "selected": false, - "label": "Red Wing Soft Napkins", - "value": "Red Wing Soft Napkins" - }, - { - "selected": false, - "label": "Red Wing Tissues", - "value": "Red Wing Tissues" - }, - { - "selected": false, - "label": "Red Wing Toilet Bowl Cleaner", - "value": "Red Wing Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Red Wing Toilet Paper", - "value": "Red Wing Toilet Paper" - }, - { - "selected": false, - "label": "Robust Monthly Auto Magazine", - "value": "Robust Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Computer Magazine", - "value": "Robust Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Fashion Magazine", - "value": "Robust Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Home Magazine", - "value": "Robust Monthly Home Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Sports Magazine", - "value": "Robust Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Shady Lake Manicotti", - "value": "Shady Lake Manicotti" - }, - { - "selected": false, - "label": "Shady Lake Ravioli", - "value": "Shady Lake Ravioli" - }, - { - "selected": false, - "label": "Shady Lake Rice Medly", - "value": "Shady Lake Rice Medly" - }, - { - "selected": false, - "label": "Shady Lake Spaghetti", - "value": "Shady Lake Spaghetti" - }, - { - "selected": false, - "label": "Shady Lake Thai Rice", - "value": "Shady Lake Thai Rice" - }, - { - "selected": false, - "label": "Ship Shape Extra Lean Hamburger", - "value": "Ship Shape Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Ship Shape Seasoned Hamburger", - "value": "Ship Shape Seasoned Hamburger" - }, - { - "selected": false, - "label": "Skinner Apple Drink", - "value": "Skinner Apple Drink" - }, - { - "selected": false, - "label": "Skinner Apple Juice", - "value": "Skinner Apple Juice" - }, - { - "selected": false, - "label": "Skinner Berry Juice", - "value": "Skinner Berry Juice" - }, - { - "selected": false, - "label": "Skinner Cola", - "value": "Skinner Cola" - }, - { - "selected": false, - "label": "Skinner Cranberry Juice", - "value": "Skinner Cranberry Juice" - }, - { - "selected": false, - "label": "Skinner Cream Soda", - "value": "Skinner Cream Soda" - }, - { - "selected": false, - "label": "Skinner Diet Cola", - "value": "Skinner Diet Cola" - }, - { - "selected": false, - "label": "Skinner Diet Soda", - "value": "Skinner Diet Soda" - }, - { - "selected": false, - "label": "Skinner Mango Drink", - "value": "Skinner Mango Drink" - }, - { - "selected": false, - "label": "Skinner Orange Juice", - "value": "Skinner Orange Juice" - }, - { - "selected": false, - "label": "Skinner Strawberry Drink", - "value": "Skinner Strawberry Drink" - }, - { - "selected": false, - "label": "Special Corn Puffs", - "value": "Special Corn Puffs" - }, - { - "selected": false, - "label": "Special Grits", - "value": "Special Grits" - }, - { - "selected": false, - "label": "Special Oatmeal", - "value": "Special Oatmeal" - }, - { - "selected": false, - "label": "Special Wheat Puffs", - "value": "Special Wheat Puffs" - }, - { - "selected": false, - "label": "Sphinx Bagels", - "value": "Sphinx Bagels" - }, - { - "selected": false, - "label": "Sphinx Blueberry Muffins", - "value": "Sphinx Blueberry Muffins" - }, - { - "selected": false, - "label": "Sphinx Cranberry Muffins", - "value": "Sphinx Cranberry Muffins" - }, - { - "selected": false, - "label": "Sphinx English Muffins", - "value": "Sphinx English Muffins" - }, - { - "selected": false, - "label": "Sphinx Muffins", - "value": "Sphinx Muffins" - }, - { - "selected": false, - "label": "Sphinx Pumpernickel Bread", - "value": "Sphinx Pumpernickel Bread" - }, - { - "selected": false, - "label": "Sphinx Rye Bread", - "value": "Sphinx Rye Bread" - }, - { - "selected": false, - "label": "Sphinx Wheat Bread", - "value": "Sphinx Wheat Bread" - }, - { - "selected": false, - "label": "Sphinx White Bread", - "value": "Sphinx White Bread" - }, - { - "selected": false, - "label": "Steady 200 MG Acetominifen", - "value": "Steady 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Steady 200 MG Ibuprofen", - "value": "Steady 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Steady Angled Toothbrush", - "value": "Steady Angled Toothbrush" - }, - { - "selected": false, - "label": "Steady Apricot Shampoo", - "value": "Steady Apricot Shampoo" - }, - { - "selected": false, - "label": "Steady Buffered Aspirin", - "value": "Steady Buffered Aspirin" - }, - { - "selected": false, - "label": "Steady Childrens Aspirin", - "value": "Steady Childrens Aspirin" - }, - { - "selected": false, - "label": "Steady Childrens Cold Remedy", - "value": "Steady Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Steady Conditioning Shampoo", - "value": "Steady Conditioning Shampoo" - }, - { - "selected": false, - "label": "Steady Deodorant", - "value": "Steady Deodorant" - }, - { - "selected": false, - "label": "Steady Dishwasher Detergent", - "value": "Steady Dishwasher Detergent" - }, - { - "selected": false, - "label": "Steady Extra Moisture Shampoo", - "value": "Steady Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Steady HCL Nasal Spray", - "value": "Steady HCL Nasal Spray" - }, - { - "selected": false, - "label": "Steady Laundry Detergent", - "value": "Steady Laundry Detergent" - }, - { - "selected": false, - "label": "Steady Mint Mouthwash", - "value": "Steady Mint Mouthwash" - }, - { - "selected": false, - "label": "Steady Multi-Symptom Cold Remedy", - "value": "Steady Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Steady Silky Smooth Hair Conditioner", - "value": "Steady Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Steady Tartar Control Toothpaste", - "value": "Steady Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Steady Toothpaste", - "value": "Steady Toothpaste" - }, - { - "selected": false, - "label": "Steady Whitening Toothpast", - "value": "Steady Whitening Toothpast" - }, - { - "selected": false, - "label": "Sunset 100 Watt Lightbulb", - "value": "Sunset 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 25 Watt Lightbulb", - "value": "Sunset 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 60 Watt Lightbulb", - "value": "Sunset 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 75 Watt Lightbulb", - "value": "Sunset 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset AAA-Size Batteries", - "value": "Sunset AAA-Size Batteries" - }, - { - "selected": false, - "label": "Sunset AA-Size Batteries", - "value": "Sunset AA-Size Batteries" - }, - { - "selected": false, - "label": "Sunset Bees Wax Candles", - "value": "Sunset Bees Wax Candles" - }, - { - "selected": false, - "label": "Sunset Copper Cleaner", - "value": "Sunset Copper Cleaner" - }, - { - "selected": false, - "label": "Sunset Copper Pot Scrubber", - "value": "Sunset Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Sunset Counter Cleaner", - "value": "Sunset Counter Cleaner" - }, - { - "selected": false, - "label": "Sunset C-Size Batteries", - "value": "Sunset C-Size Batteries" - }, - { - "selected": false, - "label": "Sunset D-Size Batteries", - "value": "Sunset D-Size Batteries" - }, - { - "selected": false, - "label": "Sunset Economy Toilet Brush", - "value": "Sunset Economy Toilet Brush" - }, - { - "selected": false, - "label": "Sunset Frying Pan", - "value": "Sunset Frying Pan" - }, - { - "selected": false, - "label": "Sunset Glass Cleaner", - "value": "Sunset Glass Cleaner" - }, - { - "selected": false, - "label": "Sunset Large Sponge", - "value": "Sunset Large Sponge" - }, - { - "selected": false, - "label": "Sunset Paper Cups", - "value": "Sunset Paper Cups" - }, - { - "selected": false, - "label": "Sunset Paper Plates", - "value": "Sunset Paper Plates" - }, - { - "selected": false, - "label": "Sunset Paper Towels", - "value": "Sunset Paper Towels" - }, - { - "selected": false, - "label": "Sunset Plastic Forks", - "value": "Sunset Plastic Forks" - }, - { - "selected": false, - "label": "Sunset Plastic Knives", - "value": "Sunset Plastic Knives" - }, - { - "selected": false, - "label": "Sunset Plastic Spoons", - "value": "Sunset Plastic Spoons" - }, - { - "selected": false, - "label": "Sunset Room Freshener", - "value": "Sunset Room Freshener" - }, - { - "selected": false, - "label": "Sunset Scented Tissue", - "value": "Sunset Scented Tissue" - }, - { - "selected": false, - "label": "Sunset Scented Toilet Tissue", - "value": "Sunset Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Sunset Scissors", - "value": "Sunset Scissors" - }, - { - "selected": false, - "label": "Sunset Screw Driver", - "value": "Sunset Screw Driver" - }, - { - "selected": false, - "label": "Sunset Silver Cleaner", - "value": "Sunset Silver Cleaner" - }, - { - "selected": false, - "label": "Sunset Soft Napkins", - "value": "Sunset Soft Napkins" - }, - { - "selected": false, - "label": "Sunset Tissues", - "value": "Sunset Tissues" - }, - { - "selected": false, - "label": "Sunset Toilet Bowl Cleaner", - "value": "Sunset Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Sunset Toilet Paper", - "value": "Sunset Toilet Paper" - }, - { - "selected": false, - "label": "Super Apple Butter", - "value": "Super Apple Butter" - }, - { - "selected": false, - "label": "Super Apple Jam", - "value": "Super Apple Jam" - }, - { - "selected": false, - "label": "Super Apple Jelly", - "value": "Super Apple Jelly" - }, - { - "selected": false, - "label": "Super Apple Preserves", - "value": "Super Apple Preserves" - }, - { - "selected": false, - "label": "Super Brown Sugar", - "value": "Super Brown Sugar" - }, - { - "selected": false, - "label": "Super Canola Oil", - "value": "Super Canola Oil" - }, - { - "selected": false, - "label": "Super Chunky Peanut Butter", - "value": "Super Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Super Columbian Coffee", - "value": "Super Columbian Coffee" - }, - { - "selected": false, - "label": "Super Corn Oil", - "value": "Super Corn Oil" - }, - { - "selected": false, - "label": "Super Creamy Peanut Butter", - "value": "Super Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Super Decaf Coffee", - "value": "Super Decaf Coffee" - }, - { - "selected": false, - "label": "Super Extra Chunky Peanut Butter", - "value": "Super Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Super French Roast Coffee", - "value": "Super French Roast Coffee" - }, - { - "selected": false, - "label": "Super Grape Jam", - "value": "Super Grape Jam" - }, - { - "selected": false, - "label": "Super Grape Jelly", - "value": "Super Grape Jelly" - }, - { - "selected": false, - "label": "Super Grape Preserves", - "value": "Super Grape Preserves" - }, - { - "selected": false, - "label": "Super Hot Chocolate", - "value": "Super Hot Chocolate" - }, - { - "selected": false, - "label": "Super Low Fat Apple Butter", - "value": "Super Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Super Oregano", - "value": "Super Oregano" - }, - { - "selected": false, - "label": "Super Pepper", - "value": "Super Pepper" - }, - { - "selected": false, - "label": "Super Regular Coffee", - "value": "Super Regular Coffee" - }, - { - "selected": false, - "label": "Super Salt", - "value": "Super Salt" - }, - { - "selected": false, - "label": "Super Sesame Oil", - "value": "Super Sesame Oil" - }, - { - "selected": false, - "label": "Super Strawberry Jam", - "value": "Super Strawberry Jam" - }, - { - "selected": false, - "label": "Super Strawberry Jelly", - "value": "Super Strawberry Jelly" - }, - { - "selected": false, - "label": "Super Strawberry Preserves", - "value": "Super Strawberry Preserves" - }, - { - "selected": false, - "label": "Super Tomato Sauce", - "value": "Super Tomato Sauce" - }, - { - "selected": false, - "label": "Super Vegetable Oil", - "value": "Super Vegetable Oil" - }, - { - "selected": false, - "label": "Super White Sugar", - "value": "Super White Sugar" - }, - { - "selected": false, - "label": "Swell Canned Mixed Fruit", - "value": "Swell Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Swell Canned Peaches", - "value": "Swell Canned Peaches" - }, - { - "selected": false, - "label": "Symphony Rosy Sunglasses", - "value": "Symphony Rosy Sunglasses" - }, - { - "selected": false, - "label": "Tell Tale Almonds", - "value": "Tell Tale Almonds" - }, - { - "selected": false, - "label": "Tell Tale Asparagus", - "value": "Tell Tale Asparagus" - }, - { - "selected": false, - "label": "Tell Tale Baby Onion", - "value": "Tell Tale Baby Onion" - }, - { - "selected": false, - "label": "Tell Tale Beets", - "value": "Tell Tale Beets" - }, - { - "selected": false, - "label": "Tell Tale Broccoli", - "value": "Tell Tale Broccoli" - }, - { - "selected": false, - "label": "Tell Tale Canned Peanuts", - "value": "Tell Tale Canned Peanuts" - }, - { - "selected": false, - "label": "Tell Tale Cantelope", - "value": "Tell Tale Cantelope" - }, - { - "selected": false, - "label": "Tell Tale Cauliflower", - "value": "Tell Tale Cauliflower" - }, - { - "selected": false, - "label": "Tell Tale Corn on the Cob", - "value": "Tell Tale Corn on the Cob" - }, - { - "selected": false, - "label": "Tell Tale Dried Mushrooms", - "value": "Tell Tale Dried Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale Elephant Garlic", - "value": "Tell Tale Elephant Garlic" - }, - { - "selected": false, - "label": "Tell Tale Fancy Plums", - "value": "Tell Tale Fancy Plums" - }, - { - "selected": false, - "label": "Tell Tale Firm Tofu", - "value": "Tell Tale Firm Tofu" - }, - { - "selected": false, - "label": "Tell Tale Fresh Lima Beans", - "value": "Tell Tale Fresh Lima Beans" - }, - { - "selected": false, - "label": "Tell Tale Fuji Apples", - "value": "Tell Tale Fuji Apples" - }, - { - "selected": false, - "label": "Tell Tale Garlic", - "value": "Tell Tale Garlic" - }, - { - "selected": false, - "label": "Tell Tale Golden Delcious Apples", - "value": "Tell Tale Golden Delcious Apples" - }, - { - "selected": false, - "label": "Tell Tale Green Pepper", - "value": "Tell Tale Green Pepper" - }, - { - "selected": false, - "label": "Tell Tale Honey Dew", - "value": "Tell Tale Honey Dew" - }, - { - "selected": false, - "label": "Tell Tale Lemons", - "value": "Tell Tale Lemons" - }, - { - "selected": false, - "label": "Tell Tale Lettuce", - "value": "Tell Tale Lettuce" - }, - { - "selected": false, - "label": "Tell Tale Limes", - "value": "Tell Tale Limes" - }, - { - "selected": false, - "label": "Tell Tale Macintosh Apples", - "value": "Tell Tale Macintosh Apples" - }, - { - "selected": false, - "label": "Tell Tale Mandarin Oranges", - "value": "Tell Tale Mandarin Oranges" - }, - { - "selected": false, - "label": "Tell Tale Mixed Nuts", - "value": "Tell Tale Mixed Nuts" - }, - { - "selected": false, - "label": "Tell Tale Mushrooms", - "value": "Tell Tale Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale New Potatos", - "value": "Tell Tale New Potatos" - }, - { - "selected": false, - "label": "Tell Tale Onions", - "value": "Tell Tale Onions" - }, - { - "selected": false, - "label": "Tell Tale Oranges", - "value": "Tell Tale Oranges" - }, - { - "selected": false, - "label": "Tell Tale Party Nuts", - "value": "Tell Tale Party Nuts" - }, - { - "selected": false, - "label": "Tell Tale Peaches", - "value": "Tell Tale Peaches" - }, - { - "selected": false, - "label": "Tell Tale Plums", - "value": "Tell Tale Plums" - }, - { - "selected": false, - "label": "Tell Tale Potatos", - "value": "Tell Tale Potatos" - }, - { - "selected": false, - "label": "Tell Tale Prepared Salad", - "value": "Tell Tale Prepared Salad" - }, - { - "selected": false, - "label": "Tell Tale Red Delcious Apples", - "value": "Tell Tale Red Delcious Apples" - }, - { - "selected": false, - "label": "Tell Tale Red Pepper", - "value": "Tell Tale Red Pepper" - }, - { - "selected": false, - "label": "Tell Tale Shitake Mushrooms", - "value": "Tell Tale Shitake Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale Squash", - "value": "Tell Tale Squash" - }, - { - "selected": false, - "label": "Tell Tale Summer Squash", - "value": "Tell Tale Summer Squash" - }, - { - "selected": false, - "label": "Tell Tale Sweet Onion", - "value": "Tell Tale Sweet Onion" - }, - { - "selected": false, - "label": "Tell Tale Sweet Peas", - "value": "Tell Tale Sweet Peas" - }, - { - "selected": false, - "label": "Tell Tale Tangerines", - "value": "Tell Tale Tangerines" - }, - { - "selected": false, - "label": "Tell Tale Tomatos", - "value": "Tell Tale Tomatos" - }, - { - "selected": false, - "label": "Tell Tale Walnuts", - "value": "Tell Tale Walnuts" - }, - { - "selected": false, - "label": "Thresher Bubble Gum", - "value": "Thresher Bubble Gum" - }, - { - "selected": false, - "label": "Thresher Malted Milk Balls", - "value": "Thresher Malted Milk Balls" - }, - { - "selected": false, - "label": "Thresher Mint Chocolate Bar", - "value": "Thresher Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Thresher Mints", - "value": "Thresher Mints" - }, - { - "selected": false, - "label": "Thresher Semi-Sweet Chocolate Bar", - "value": "Thresher Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Thresher Spicy Mints", - "value": "Thresher Spicy Mints" - }, - { - "selected": false, - "label": "Thresher Tasty Candy Bar", - "value": "Thresher Tasty Candy Bar" - }, - { - "selected": false, - "label": "Thresher White Chocolate Bar", - "value": "Thresher White Chocolate Bar" - }, - { - "selected": false, - "label": "Tip Top Lox", - "value": "Tip Top Lox" - }, - { - "selected": false, - "label": "Tip Top Scallops", - "value": "Tip Top Scallops" - }, - { - "selected": false, - "label": "Token Apple Drink", - "value": "Token Apple Drink" - }, - { - "selected": false, - "label": "Token Apple Juice", - "value": "Token Apple Juice" - }, - { - "selected": false, - "label": "Token Berry Juice", - "value": "Token Berry Juice" - }, - { - "selected": false, - "label": "Token Cola", - "value": "Token Cola" - }, - { - "selected": false, - "label": "Token Cranberry Juice", - "value": "Token Cranberry Juice" - }, - { - "selected": false, - "label": "Token Cream Soda", - "value": "Token Cream Soda" - }, - { - "selected": false, - "label": "Token Diet Cola", - "value": "Token Diet Cola" - }, - { - "selected": false, - "label": "Token Diet Soda", - "value": "Token Diet Soda" - }, - { - "selected": false, - "label": "Token Mango Drink", - "value": "Token Mango Drink" - }, - { - "selected": false, - "label": "Token Orange Juice", - "value": "Token Orange Juice" - }, - { - "selected": false, - "label": "Token Strawberry Drink", - "value": "Token Strawberry Drink" - }, - { - "selected": false, - "label": "Top Measure Chablis Wine", - "value": "Top Measure Chablis Wine" - }, - { - "selected": false, - "label": "Top Measure Chardonnay", - "value": "Top Measure Chardonnay" - }, - { - "selected": false, - "label": "Top Measure Chardonnay Wine", - "value": "Top Measure Chardonnay Wine" - }, - { - "selected": false, - "label": "Top Measure Imported Beer", - "value": "Top Measure Imported Beer" - }, - { - "selected": false, - "label": "Top Measure Light Beer", - "value": "Top Measure Light Beer" - }, - { - "selected": false, - "label": "Top Measure Light Wine", - "value": "Top Measure Light Wine" - }, - { - "selected": false, - "label": "Top Measure Merlot Wine", - "value": "Top Measure Merlot Wine" - }, - { - "selected": false, - "label": "Top Measure White Zinfandel Wine", - "value": "Top Measure White Zinfandel Wine" - }, - { - "selected": false, - "label": "Toretti Rosy Sunglasses", - "value": "Toretti Rosy Sunglasses" - }, - { - "selected": false, - "label": "Toucan Canned Mixed Fruit", - "value": "Toucan Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Toucan Canned Peaches", - "value": "Toucan Canned Peaches" - }, - { - "selected": false, - "label": "Tri-State Almonds", - "value": "Tri-State Almonds" - }, - { - "selected": false, - "label": "Tri-State Asparagus", - "value": "Tri-State Asparagus" - }, - { - "selected": false, - "label": "Tri-State Baby Onion", - "value": "Tri-State Baby Onion" - }, - { - "selected": false, - "label": "Tri-State Beets", - "value": "Tri-State Beets" - }, - { - "selected": false, - "label": "Tri-State Broccoli", - "value": "Tri-State Broccoli" - }, - { - "selected": false, - "label": "Tri-State Canned Peanuts", - "value": "Tri-State Canned Peanuts" - }, - { - "selected": false, - "label": "Tri-State Cantelope", - "value": "Tri-State Cantelope" - }, - { - "selected": false, - "label": "Tri-State Cauliflower", - "value": "Tri-State Cauliflower" - }, - { - "selected": false, - "label": "Tri-State Corn on the Cob", - "value": "Tri-State Corn on the Cob" - }, - { - "selected": false, - "label": "Tri-State Dried Mushrooms", - "value": "Tri-State Dried Mushrooms" - }, - { - "selected": false, - "label": "Tri-State Elephant Garlic", - "value": "Tri-State Elephant Garlic" - }, - { - "selected": false, - "label": "Tri-State Fancy Plums", - "value": "Tri-State Fancy Plums" - }, - { - "selected": false, - "label": "Tri-State Firm Tofu", - "value": "Tri-State Firm Tofu" - }, - { - "selected": false, - "label": "Tri-State Fresh Lima Beans", - "value": "Tri-State Fresh Lima Beans" - }, - { - "selected": false, - "label": "Tri-State Fuji Apples", - "value": "Tri-State Fuji Apples" - }, - { - "selected": false, - "label": "Tri-State Garlic", - "value": "Tri-State Garlic" - }, - { - "selected": false, - "label": "Tri-State Golden Delcious Apples", - "value": "Tri-State Golden Delcious Apples" - }, - { - "selected": false, - "label": "Tri-State Green Pepper", - "value": "Tri-State Green Pepper" - }, - { - "selected": false, - "label": "Tri-State Honey Dew", - "value": "Tri-State Honey Dew" - }, - { - "selected": false, - "label": "Tri-State Lemons", - "value": "Tri-State Lemons" - }, - { - "selected": false, - "label": "Tri-State Lettuce", - "value": "Tri-State Lettuce" - }, - { - "selected": false, - "label": "Tri-State Limes", - "value": "Tri-State Limes" - }, - { - "selected": false, - "label": "Tri-State Macintosh Apples", - "value": "Tri-State Macintosh Apples" - }, - { - "selected": false, - "label": "Tri-State Mandarin Oranges", - "value": "Tri-State Mandarin Oranges" - }, - { - "selected": false, - "label": "Tri-State Mixed Nuts", - "value": "Tri-State Mixed Nuts" - }, - { - "selected": false, - "label": "Tri-State Mushrooms", - "value": "Tri-State Mushrooms" - }, - { - "selected": false, - "label": "Tri-State New Potatos", - "value": "Tri-State New Potatos" - }, - { - "selected": false, - "label": "Tri-State Onions", - "value": "Tri-State Onions" - }, - { - "selected": false, - "label": "Tri-State Oranges", - "value": "Tri-State Oranges" - }, - { - "selected": false, - "label": "Tri-State Party Nuts", - "value": "Tri-State Party Nuts" - }, - { - "selected": false, - "label": "Tri-State Peaches", - "value": "Tri-State Peaches" - }, - { - "selected": false, - "label": "Tri-State Plums", - "value": "Tri-State Plums" - }, - { - "selected": false, - "label": "Tri-State Potatos", - "value": "Tri-State Potatos" - }, - { - "selected": false, - "label": "Tri-State Prepared Salad", - "value": "Tri-State Prepared Salad" - }, - { - "selected": false, - "label": "Tri-State Red Delcious Apples", - "value": "Tri-State Red Delcious Apples" - }, - { - "selected": false, - "label": "Tri-State Red Pepper", - "value": "Tri-State Red Pepper" - }, - { - "selected": false, - "label": "Tri-State Shitake Mushrooms", - "value": "Tri-State Shitake Mushrooms" - }, - { - "selected": false, - "label": "Tri-State Squash", - "value": "Tri-State Squash" - }, - { - "selected": false, - "label": "Tri-State Summer Squash", - "value": "Tri-State Summer Squash" - }, - { - "selected": false, - "label": "Tri-State Sweet Onion", - "value": "Tri-State Sweet Onion" - }, - { - "selected": false, - "label": "Tri-State Sweet Peas", - "value": "Tri-State Sweet Peas" - }, - { - "selected": false, - "label": "Tri-State Tangerines", - "value": "Tri-State Tangerines" - }, - { - "selected": false, - "label": "Tri-State Tomatos", - "value": "Tri-State Tomatos" - }, - { - "selected": false, - "label": "Tri-State Walnuts", - "value": "Tri-State Walnuts" - }, - { - "selected": false, - "label": "Urban Egg Substitute", - "value": "Urban Egg Substitute" - }, - { - "selected": false, - "label": "Urban Large Brown Eggs", - "value": "Urban Large Brown Eggs" - }, - { - "selected": false, - "label": "Urban Large Eggs", - "value": "Urban Large Eggs" - }, - { - "selected": false, - "label": "Urban Small Brown Eggs", - "value": "Urban Small Brown Eggs" - }, - { - "selected": false, - "label": "Urban Small Eggs", - "value": "Urban Small Eggs" - }, - { - "selected": false, - "label": "Walrus Chablis Wine", - "value": "Walrus Chablis Wine" - }, - { - "selected": false, - "label": "Walrus Chardonnay", - "value": "Walrus Chardonnay" - }, - { - "selected": false, - "label": "Walrus Chardonnay Wine", - "value": "Walrus Chardonnay Wine" - }, - { - "selected": false, - "label": "Walrus Imported Beer", - "value": "Walrus Imported Beer" - }, - { - "selected": false, - "label": "Walrus Light Beer", - "value": "Walrus Light Beer" - }, - { - "selected": false, - "label": "Walrus Light Wine", - "value": "Walrus Light Wine" - }, - { - "selected": false, - "label": "Walrus Merlot Wine", - "value": "Walrus Merlot Wine" - }, - { - "selected": false, - "label": "Walrus White Zinfandel Wine", - "value": "Walrus White Zinfandel Wine" - }, - { - "selected": false, - "label": "Washington Apple Drink", - "value": "Washington Apple Drink" - }, - { - "selected": false, - "label": "Washington Apple Juice", - "value": "Washington Apple Juice" - }, - { - "selected": false, - "label": "Washington Berry Juice", - "value": "Washington Berry Juice" - }, - { - "selected": false, - "label": "Washington Cola", - "value": "Washington Cola" - }, - { - "selected": false, - "label": "Washington Cranberry Juice", - "value": "Washington Cranberry Juice" - }, - { - "selected": false, - "label": "Washington Cream Soda", - "value": "Washington Cream Soda" - }, - { - "selected": false, - "label": "Washington Diet Cola", - "value": "Washington Diet Cola" - }, - { - "selected": false, - "label": "Washington Diet Soda", - "value": "Washington Diet Soda" - }, - { - "selected": false, - "label": "Washington Mango Drink", - "value": "Washington Mango Drink" - }, - { - "selected": false, - "label": "Washington Orange Juice", - "value": "Washington Orange Juice" - }, - { - "selected": false, - "label": "Washington Strawberry Drink", - "value": "Washington Strawberry Drink" - } - ] + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:11", + "updateDate": "2014-05-14T17:38:49", + "label": "01. Geographic Results by Segment", + "description": "Sample HTML5 multi-axis column chart from Domain showing Sales, Units, and $ Per Square Foot by Country and Store Type with various filters", + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment", + "resourceType": "adhocDataView" }, { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", - "id": "sales__product__recyclable_package_1", - "options": [ - { - "selected": true, - "label": "true", - "value": "true" - }, - { - "selected": true, - "label": "false", - "value": "false" - } - ] + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:12", + "updateDate": "2014-04-25T16:06:57", + "label": "03. Store Segment Performance Report", + "description": "Sample OLAP chart with HTML5 Grouped Bar chart and Filter. Created from an Ad Hoc View.", + "uri": "/public/Samples/Reports/03._Store_Segment_Performance_Report", + "resourceType": "reportUnit" }, { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", - "id": "sales__product__low_fat_1", - "options": [ - { - "selected": true, - "label": "true", - "value": "true" - }, - { - "selected": true, - "label": "false", - "value": "false" - } - ] + "version": 1, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:37", + "updateDate": "2015-05-04T21:05:55", + "label": "1. Supermart Dashboard", + "description": "Sample containing 5 Dashlets and Filter wiring. One Dashlet is a report with hyperlinks, the other Dashlets are defined as part of the Dashboard.", + "uri": "/public/Samples/Dashboards/1._Supermart_Dashboard", + "resourceType": "dashboard" }, { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", - "id": "sales_fact_ALL__store_sales_2013_1", - "value": "19" + "version": 1, + "permissionMask": 1, + "creationDate": "2015-06-05T07:21:39", + "updateDate": "2015-04-20T20:46:58", + "label": "3.1 Sales Metrics", + "description": "Sample containing Sales related data, hyperlinks, and a hidden filter for embedded Visualize.js demo.", + "uri": "/public/Samples/Dashboards/3.1_Sales_Metrics", + "resourceType": "legacyDashboard" + }, + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-04T13:26:23", + "updateDate": "2015-05-27T22:03:29", + "label": "A4 Landscape", + "uri": "/public/templates/a4_landscape.510.jrxml", + "resourceType": "file" + }, + { + "version": 0, + "permissionMask": 1, + "creationDate": "2015-01-13T01:00:33", + "updateDate": "2014-12-18T09:59:47", + "label": "Ad Hoc Components", + "description": "Ad Hoc Components", + "uri": "/public/adhoc", + "resourceType": "folder" + }, + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-04T13:26:25", + "updateDate": "2015-05-27T22:03:38", + "label": "Audit Archive Domain", + "description": "Use this domain to build audit archive reports", + "uri": "/public/audit/domains/AuditArchiveDomain", + "resourceType": "semanticLayerDataSource" + }, + { + "version": 2, + "permissionMask": 1, + "creationDate": "2015-06-04T13:26:24", + "updateDate": "2015-05-27T22:03:36", + "label": "Audit Data Source", + "description": "Audit Data Source", + "uri": "/public/audit/datasources/AuditDataSource", + "resourceType": "jndiJdbcDataSource" } ] } \ No newline at end of file diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 356bfdd9..8bb6c14d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -28,7 +28,9 @@ import android.support.annotation.Nullable; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; /** * @author Tom Koptel @@ -38,10 +40,10 @@ public final class SearchCriteria { private static final int DEFAULT_OFFSET = 0; private static final int DEFAULT_LIMIT = 100; + public static int ALL = 1; public static int REPORT = (1 << 1); public static int DASHBOARD = (1 << 2); public static int LEGACY_DASHBOARD = (1 << 3); - public static int ALL = REPORT | DASHBOARD | LEGACY_DASHBOARD; private final int mLimit; private final int mOffset; @@ -148,8 +150,8 @@ public SearchCriteria.Builder newBuilder() { } @NonNull - public Map toMap() { - Map params = new HashMap<>(); + public Map toMap() { + Map params = new HashMap<>(); if (mLimit != DEFAULT_LIMIT) { params.put("limit", String.valueOf(mLimit)); @@ -180,21 +182,27 @@ public Map toMap() { return params; } - private void populateTypes(Map params) { + private void populateTypes(Map params) { + Set types = new HashSet<>(); + boolean includeReport = (mResourceMask & REPORT) == REPORT || (mResourceMask & ALL) == ALL; if (includeReport) { - params.put("type", "reportUnit"); + types.add("reportUnit"); } boolean includeDashboard = (mResourceMask & DASHBOARD) == DASHBOARD || (mResourceMask & ALL) == ALL; if (includeDashboard) { - params.put("type", "dashboard"); + types.add("dashboard"); } boolean includeLegacyDashboard = (mResourceMask & LEGACY_DASHBOARD) == LEGACY_DASHBOARD || (mResourceMask & ALL) == ALL; if (includeLegacyDashboard) { - params.put("type", "legacyDashboard"); + types.add("legacyDashboard"); + } + + if (!types.isEmpty()) { + params.put("type", types); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index 06178fc9..a9271e2b 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -27,8 +27,11 @@ import org.junit.Test; import org.junit.runner.RunWith; +import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import junitparams.JUnitParamsRunner; import junitparams.Parameters; @@ -49,7 +52,7 @@ public void shouldIncludeCountInParams() { .limit(101) .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("limit", "101"); assertThat(criteria.toMap(), is(resultMap)); @@ -61,7 +64,7 @@ public void shouldIncludeOffsetInParams() { .offset(100) .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("offset", "100"); assertThat(criteria.toMap(), is(resultMap)); @@ -73,7 +76,7 @@ public void shouldIncludeRecursiveInParams() { .recursive(true) .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("recursive", "true"); assertThat(criteria.toMap(), is(resultMap)); @@ -85,7 +88,7 @@ public void shouldIncludeForceFullPageInParams() { .forceFullPage(true) .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("forceFullPage", "true"); assertThat(criteria.toMap(), is(resultMap)); @@ -97,7 +100,7 @@ public void shouldIncludeForceTotalCountPageInParams() { .forceTotalCount(true) .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("forceTotalCount", "true"); assertThat(criteria.toMap(), is(resultMap)); @@ -109,7 +112,7 @@ public void shouldIncludeQueryPageInParams() { .query("any") .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("q", "any"); assertThat(criteria.toMap(), is(resultMap)); @@ -121,7 +124,7 @@ public void shouldIncludeSortByLabelInParams() { .sortByLabel() .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("sortBy", "label"); assertThat(criteria.toMap(), is(resultMap)); @@ -133,7 +136,7 @@ public void shouldIncludeSortByCreationDateInParams() { .sortByCreationDate() .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("sortBy", "creationDate"); assertThat(criteria.toMap(), is(resultMap)); @@ -145,7 +148,7 @@ public void shouldIncludeFolderUriInParams() { .folderUri("/") .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); resultMap.put("folderUri", "/"); assertThat(criteria.toMap(), is(resultMap)); @@ -157,7 +160,7 @@ public void shouldIgnoreEmptyQuery() { .query("") .create(); - Map emptytMap = new HashMap<>(); + Map emptytMap = new HashMap<>(); assertThat(criteria.toMap(), is(emptytMap)); } @@ -167,23 +170,30 @@ public void shouldIgnoreEmptyQuery() { "DASHBOARD|dashboard", "LEGACY_DASHBOARD|legacyDashboard", "ALL|reportUnit:dashboard:legacyDashboard", + "REPORT:DASHBOARD|reportUnit:dashboard", }) - public void criteriaShouldIncludeTypeInParams(String flag, String types) throws Exception { - Integer resource = (Integer) SearchCriteria.class.getField(flag).get(null); + public void criteriaShouldIncludeTypeInParams(String flags, String types) throws Exception { + int mask = 0; + if (flags.contains(":")) { + for (String flag : flags.split(":")) { + mask |= (Integer) SearchCriteria.class.getField(flag).get(null); + } + } else { + mask = (Integer) SearchCriteria.class.getField(flags).get(null); + } SearchCriteria criteria = SearchCriteria.builder() - .resourceMask(resource) + .resourceMask(mask) .create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); + Set typeSet = new HashSet<>(); if (types.contains(":")) { - for (String type : types.split(":")) { - resultMap.put("type", type); - } + typeSet.addAll(Arrays.asList(types.split(":"))); } else { - resultMap.put("type", types); + typeSet.add(types); } - + resultMap.put("type", typeSet); assertThat(criteria.toMap(), is(resultMap)); } @@ -191,7 +201,7 @@ public void criteriaShouldIncludeTypeInParams(String flag, String types) throws @Test public void shouldReturnEmptyParamsIfNoSupplied() { SearchCriteria criteria = SearchCriteria.builder().create(); - Map resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); assertThat(criteria.toMap(), is(resultMap)); } From 36bc0ca48ccbabd643f9baa770a7554be746f5e1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 10:39:33 +0300 Subject: [PATCH 155/457] Add intial implementation of Emerald2 searc starategy --- .../repository/EmeraldMR2SearchStrategy.java | 91 ++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index f632fe32..9553aa63 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -26,22 +26,111 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedList; +import java.util.List; import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel * @since 2.0 */ final class EmeraldMR2SearchStrategy implements SearchStrategy { + private final RepositoryRestApi.Factory mRepoFactory; + private final SearchCriteria mInitialCriteria; + private final int mLimit; + + private int mNextOffset; + private boolean mFirstCall; + public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { + mRepoFactory = repositoryApiFactory; + mInitialCriteria = criteria.newBuilder().create(); + + mNextOffset = criteria.getOffset(); + mLimit = criteria.getLimit(); + mFirstCall = true; } @Override public Observable> search() { - return null; + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + return Observable.just(performAlignedRequests()); + } + }); + } + + private Collection performAlignedRequests() { + ResourceSearchResponse response = makeCall(); + + List collectionFromApi = response.getResources(); + if (collectionFromApi.isEmpty()) { + return collectionFromApi; + } + + Collection buffer = new LinkedList<>(); + buffer.addAll(collectionFromApi); + + if (mLimit == 0) { + return buffer; + } else { + if (buffer.size() == mLimit) { + return buffer; + } else { + return alignResponse(buffer); + } + } + } + + private Collection alignResponse(Collection buffer) { + ResourceSearchResponse response = makeCall(); + List collectionFromApi = response.getResources(); + if (collectionFromApi.isEmpty()) { + return buffer; + } + + buffer.addAll(collectionFromApi); + int actual = buffer.size(); + + if (actual < mLimit) { + return alignResponse(buffer); + } + if (actual > mLimit) { + List resources = new ArrayList<>(buffer); + Collection aligned = resources.subList(0, mLimit - 1); + mNextOffset -= (actual - mLimit); + return aligned; + } + return buffer; + } + + private ResourceSearchResponse makeCall() { + SearchCriteria newSearchCriteria = resolveNextCriteria(); + RepositoryRestApi api = mRepoFactory.get(); + return api.searchResources(newSearchCriteria.toMap()); + } + + private void updateNextOffset() { + if (!mFirstCall) { + mNextOffset += mLimit; + } + mFirstCall = false; + } + + private SearchCriteria resolveNextCriteria() { + updateNextOffset(); + + SearchCriteria.Builder newCriteriaBuilder = mInitialCriteria.newBuilder(); + newCriteriaBuilder.offset(mNextOffset); + + return newCriteriaBuilder.create(); } } From 031e9b09d0108078e06f64756a599d66265fcda7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 11:45:14 +0300 Subject: [PATCH 156/457] Handle custom user offset --- .../repository/EmeraldMR3SearchStrategy.java | 52 +++++++-- .../EmeraldMR3SearchStrategyTest.java | 106 ++++++++++++++++++ 2 files changed, 146 insertions(+), 12 deletions(-) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 38ef8618..d60013b6 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.service.repository; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; @@ -38,10 +40,13 @@ * @since 2.0 */ final class EmeraldMR3SearchStrategy implements SearchStrategy { + private final static int UNDEFINED = -1; + private final RepositoryRestApi.Factory mRepoFactory; private final SearchCriteria mInitialCriteria; - private int mNextOffset; + private int mUserOffset; + private int mInternalOffset = UNDEFINED; public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { mRepoFactory = repositoryApiFactory; @@ -49,7 +54,7 @@ public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, mInitialCriteria = criteria.newBuilder() .forceFullPage(true) .create(); - mNextOffset = criteria.getOffset(); + mUserOffset = criteria.getOffset(); } @Override @@ -57,31 +62,54 @@ public Observable> search() { return Observable.defer(new Func0>>() { @Override public Observable> call() { - return Observable.just(makeApiCall()); + if (mInternalOffset == UNDEFINED) { + defineInternalOffset(); + } + return Observable.just(performLookup()); } }); } - private Collection makeApiCall() { - SearchCriteria newSearchCriteria = resolveNextCriteria(); - RepositoryRestApi api = mRepoFactory.get(); - ResourceSearchResponse result = api.searchResources(newSearchCriteria.toMap()); - updateNextOffset(result); + @NonNull + private Collection performLookup() { + SearchCriteria newSearchCriteria = createNextCriteria(); + ResourceSearchResponse result = performApiCall(newSearchCriteria); + updateInternalOffset(result); return result.getResources(); } - private void updateNextOffset(ResourceSearchResponse result) { + @NonNull + private ResourceSearchResponse performApiCall(SearchCriteria newSearchCriteria) { + RepositoryRestApi api = mRepoFactory.get(); + return api.searchResources(newSearchCriteria.toMap()); + } + + private void defineInternalOffset() { + if (mUserOffset == 0) { + mInternalOffset = mUserOffset; + } else { + SearchCriteria newCriteria = mInitialCriteria.newBuilder() + .limit(mUserOffset) + .offset(0) + .create(); + ResourceSearchResponse result = performApiCall(newCriteria); + mInternalOffset = result.getNextOffset(); + } + } + + private void updateInternalOffset(ResourceSearchResponse result) { int nextOffset = result.getNextOffset(); boolean endReached = (nextOffset == 0); if (!endReached) { - mNextOffset = nextOffset; + mInternalOffset = nextOffset; } } - private SearchCriteria resolveNextCriteria() { + @NonNull + private SearchCriteria createNextCriteria() { SearchCriteria.Builder newCriteriaBuilder = mInitialCriteria.newBuilder(); - newCriteriaBuilder.offset(mNextOffset); + newCriteriaBuilder.offset(mInternalOffset); return newCriteriaBuilder.create(); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java new file mode 100644 index 00000000..a0c0041d --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -0,0 +1,106 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import rx.observers.TestSubscriber; + +import static org.mockito.Matchers.anyMap; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(ResourceSearchResponse.class) +public class EmeraldMR3SearchStrategyTest { + + @Mock + RepositoryRestApi.Factory mApiFactory; + @Mock + RepositoryRestApi mApi; + @Mock + ResourceSearchResponse mResponse; + + @Before + public void setupMocks() { + MockitoAnnotations.initMocks(this); + + when(mApi.searchResources(anyMap())).thenReturn(mResponse); + when(mApiFactory.get()).thenReturn(mApi); + when(mResponse.getResources()).thenReturn(Collections.emptyList()); + } + + @Test + public void shouldMakeImmediateCallOnApiForUserOffsetZero() { + SearchCriteria searchCriteria = SearchCriteria.builder().offset(0).create(); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); + + when(mApi.searchResources(anyMap())).thenReturn(mResponse); + + performSearch(strategy); + + Map params = new HashMap<>(); + params.put("forceFullPage", "true"); + + verify(mApi, times(1)).searchResources(params); + } + + @Test + public void makesAdditionalCallOnApiIfUserOffsetNotZero() { + SearchCriteria searchCriteria = SearchCriteria.builder().offset(5).create(); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); + + performSearch(strategy); + + Map params = new HashMap<>(); + params.put("forceFullPage", "true"); + params.put("limit", "5"); + + verify(mApi, times(1)).searchResources(params); + } + + @Test + public void secondSearchLookupShouldUseNextOffset() { + SearchCriteria searchCriteria = SearchCriteria.builder().offset(0).create(); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); + + when(mResponse.getNextOffset()).thenReturn(133); + performSearch(strategy); + + when(mResponse.getNextOffset()).thenReturn(233); + performSearch(strategy); + + + Map params = new HashMap<>(); + params.put("forceFullPage", "true"); + params.put("offset", "133"); + + verify(mApiFactory, times(2)).get(); + verify(mResponse, times(2)).getNextOffset(); + verify(mApi, times(1)).searchResources(params); + } + + private void performSearch(EmeraldMR3SearchStrategy strategy) { + TestSubscriber> testSubscriber = new TestSubscriber<>(); + strategy.search().subscribe(testSubscriber); + testSubscriber.assertNoErrors(); + } +} \ No newline at end of file From 97c1ed22e127a683fdff5231709e4d253d0e081a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 11:57:30 +0300 Subject: [PATCH 157/457] Return empty collection if reached end on API --- .../repository/EmeraldMR3SearchStrategy.java | 10 ++++-- .../EmeraldMR3SearchStrategyTest.java | 31 +++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index d60013b6..8cfb179e 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -31,6 +31,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import java.util.Collection; +import java.util.Collections; import rx.Observable; import rx.functions.Func0; @@ -40,6 +41,7 @@ * @since 2.0 */ final class EmeraldMR3SearchStrategy implements SearchStrategy { + public static final Collection EMPTY_RESPONSE = Collections.emptyList(); private final static int UNDEFINED = -1; private final RepositoryRestApi.Factory mRepoFactory; @@ -47,6 +49,7 @@ final class EmeraldMR3SearchStrategy implements SearchStrategy { private int mUserOffset; private int mInternalOffset = UNDEFINED; + private boolean mEndReached; public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { mRepoFactory = repositoryApiFactory; @@ -65,6 +68,9 @@ public Observable> call() { if (mInternalOffset == UNDEFINED) { defineInternalOffset(); } + if (mEndReached){ + return Observable.just(EMPTY_RESPONSE); + } return Observable.just(performLookup()); } }); @@ -100,8 +106,8 @@ private void defineInternalOffset() { private void updateInternalOffset(ResourceSearchResponse result) { int nextOffset = result.getNextOffset(); - boolean endReached = (nextOffset == 0); - if (!endReached) { + mEndReached = (nextOffset == 0); + if (!mEndReached) { mInternalOffset = nextOffset; } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index a0c0041d..c28abaa8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -15,10 +15,14 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import rx.observers.TestSubscriber; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; import static org.mockito.Matchers.anyMap; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -45,7 +49,9 @@ public void setupMocks() { when(mApi.searchResources(anyMap())).thenReturn(mResponse); when(mApiFactory.get()).thenReturn(mApi); - when(mResponse.getResources()).thenReturn(Collections.emptyList()); + + List stubLookup = Collections.singletonList(new ResourceLookupResponse()); + when(mResponse.getResources()).thenReturn(stubLookup); } @Test @@ -98,9 +104,30 @@ public void secondSearchLookupShouldUseNextOffset() { verify(mApi, times(1)).searchResources(params); } - private void performSearch(EmeraldMR3SearchStrategy strategy) { + @Test + public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, SearchCriteria.none()); + + when(mResponse.getNextOffset()).thenReturn(133); + performSearch(strategy); + + when(mResponse.getNextOffset()).thenReturn(0); + performSearch(strategy); + + List> events = performSearch(strategy).getOnNextEvents(); + Collection response = events.get(0); + assertThat(response, is(empty())); + + verify(mApiFactory, times(2)).get(); + verify(mResponse, times(2)).getNextOffset(); + verify(mApi, times(2)).searchResources(anyMap()); + } + + private TestSubscriber performSearch(EmeraldMR3SearchStrategy strategy) { TestSubscriber> testSubscriber = new TestSubscriber<>(); strategy.search().subscribe(testSubscriber); testSubscriber.assertNoErrors(); + + return testSubscriber; } } \ No newline at end of file From c9a79d56365302940f2fc42ae143a6c502f85f76 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 12:00:00 +0300 Subject: [PATCH 158/457] Add 'hasNext' api for search strategy --- .../sdk/service/repository/EmeraldMR2SearchStrategy.java | 9 +++++++-- .../sdk/service/repository/EmeraldMR3SearchStrategy.java | 7 ++++++- .../android/sdk/service/repository/SearchStrategy.java | 7 ++++--- .../android/sdk/service/repository/SearchTask.java | 2 +- .../service/repository/EmeraldMR3SearchStrategyTest.java | 3 ++- .../android/sdk/service/repository/SearchTaskTest.java | 8 ++++---- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 9553aa63..f3ef8249 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -59,7 +59,7 @@ public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, } @Override - public Observable> search() { + public Observable> searchNext() { return Observable.defer(new Func0>>() { @Override public Observable> call() { @@ -68,6 +68,11 @@ public Observable> call() { }); } + @Override + public boolean hasNext() { + throw new UnsupportedOperationException("Not implemented"); + } + private Collection performAlignedRequests() { ResourceSearchResponse response = makeCall(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 8cfb179e..1ccadf09 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -61,7 +61,7 @@ public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, } @Override - public Observable> search() { + public Observable> searchNext() { return Observable.defer(new Func0>>() { @Override public Observable> call() { @@ -76,6 +76,11 @@ public Observable> call() { }); } + @Override + public boolean hasNext() { + return !mEndReached; + } + @NonNull private Collection performLookup() { SearchCriteria newSearchCriteria = createNextCriteria(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 2c7c9082..5a31fcc3 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -37,7 +37,8 @@ * @since 2.0 */ interface SearchStrategy { - Observable> search(); + Observable> searchNext(); + boolean hasNext(); class Factory { public static SearchStrategy get(String serverVersion, @@ -50,7 +51,7 @@ public static SearchStrategy get(String serverVersion, if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { return new EmeraldMR3SearchStrategy(repositoryApiFactory, criteria); } - throw new UnsupportedOperationException("Could not resolve search strategy for serverVersion: " + serverVersion); + throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + serverVersion); } } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 423dfaad..2ccd2bb0 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -57,7 +57,7 @@ public Observable> nextLookup() { return defineSearchStrategy().flatMap(new Func1>>() { @Override public Observable> call(SearchStrategy searchStrategy) { - return searchStrategy.search(); + return searchStrategy.searchNext(); } }); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index c28abaa8..b4e99b46 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -117,6 +117,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { List> events = performSearch(strategy).getOnNextEvents(); Collection response = events.get(0); assertThat(response, is(empty())); + assertThat(strategy.hasNext(), is(false)); verify(mApiFactory, times(2)).get(); verify(mResponse, times(2)).getNextOffset(); @@ -125,7 +126,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { private TestSubscriber performSearch(EmeraldMR3SearchStrategy strategy) { TestSubscriber> testSubscriber = new TestSubscriber<>(); - strategy.search().subscribe(testSubscriber); + strategy.searchNext().subscribe(testSubscriber); testSubscriber.assertNoErrors(); return testSubscriber; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java index 9ba730c6..516dddbe 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -79,7 +79,7 @@ public void setup() { when(mInfoApiFactory.get()).thenReturn(mInfoApi); Observable> resultObservable = Observable.just(null); - when(mSearchStrategy.search()).thenReturn(resultObservable); + when(mSearchStrategy.searchNext()).thenReturn(resultObservable); PowerMockito.mockStatic(SearchStrategy.Factory.class); PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.Factory.class), any(SearchCriteria.class))).thenReturn(mSearchStrategy); @@ -95,7 +95,7 @@ public void nextLookupShouldDefineSearchStrategy() { verify(mInfoApi, times(1)).requestVersion(); verify(mInfoApiFactory, times(1)).get(); - verify(mSearchStrategy, times(1)).search(); + verify(mSearchStrategy, times(1)).searchNext(); } @Test @@ -110,6 +110,6 @@ public void secondLookupShouldUseCachedStrategy() { verify(mInfoApi, times(1)).requestVersion(); verify(mInfoApiFactory, times(1)).get(); - verify(mSearchStrategy, times(2)).search(); + verify(mSearchStrategy, times(2)).searchNext(); } } \ No newline at end of file From 2dfa0d411e126385718f082b279bab52aeb96a73 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 14:33:53 +0300 Subject: [PATCH 159/457] Caching remained part for reuse in EmeraldMR2SearchStrategy --- .../repository/EmeraldMR2SearchStrategy.java | 119 +++++++++++------- .../service/repository/SearchCriteria.java | 2 +- 2 files changed, 72 insertions(+), 49 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index f3ef8249..4fc1cbb2 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -24,12 +24,14 @@ package com.jaspersoft.android.sdk.service.repository; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; -import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -41,12 +43,16 @@ * @since 2.0 */ final class EmeraldMR2SearchStrategy implements SearchStrategy { + private static final Collection EMPTY_RESPONSE = Collections.emptyList(); + private static final int RETRY_COUNT = 5; + private final RepositoryRestApi.Factory mRepoFactory; private final SearchCriteria mInitialCriteria; private final int mLimit; private int mNextOffset; - private boolean mFirstCall; + private boolean mEndReached; + private Collection tempBuffer = Collections.emptyList(); public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { mRepoFactory = repositoryApiFactory; @@ -54,8 +60,6 @@ public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, mNextOffset = criteria.getOffset(); mLimit = criteria.getLimit(); - - mFirstCall = true; } @Override @@ -63,6 +67,9 @@ public Observable> searchNext() { return Observable.defer(new Func0>>() { @Override public Observable> call() { + if (mEndReached){ + return Observable.just(EMPTY_RESPONSE); + } return Observable.just(performAlignedRequests()); } }); @@ -70,72 +77,88 @@ public Observable> call() { @Override public boolean hasNext() { - throw new UnsupportedOperationException("Not implemented"); + return !mEndReached; } private Collection performAlignedRequests() { - ResourceSearchResponse response = makeCall(); + SearchCriteria newSearchCriteria = createNextCriteria(); + ResourceSearchResponse response = performApiCall(newSearchCriteria); List collectionFromApi = response.getResources(); - if (collectionFromApi.isEmpty()) { - return collectionFromApi; - } - Collection buffer = new LinkedList<>(); - buffer.addAll(collectionFromApi); + List localBuffer = new LinkedList<>(); + localBuffer.addAll(collectionFromApi); - if (mLimit == 0) { - return buffer; + Collection result; + int count = 0; + if (tempBuffer.isEmpty()) { + result = alignBuffer(localBuffer, count); } else { - if (buffer.size() == mLimit) { - return buffer; - } else { - return alignResponse(buffer); - } + List accumulatedBuffer = new LinkedList<>(tempBuffer); + accumulatedBuffer.addAll(localBuffer); + result = alignBuffer(accumulatedBuffer, count); } - } - private Collection alignResponse(Collection buffer) { - ResourceSearchResponse response = makeCall(); - List collectionFromApi = response.getResources(); - if (collectionFromApi.isEmpty()) { - return buffer; - } - - buffer.addAll(collectionFromApi); - int actual = buffer.size(); + return result; + } - if (actual < mLimit) { - return alignResponse(buffer); - } - if (actual > mLimit) { - List resources = new ArrayList<>(buffer); - Collection aligned = resources.subList(0, mLimit - 1); - mNextOffset -= (actual - mLimit); - return aligned; + private Collection alignBuffer(List accumulatedBuffer, int count) { + if (accumulatedBuffer.size() > mLimit) { + return cacheRemainedBuffer(accumulatedBuffer); + } else if (accumulatedBuffer.size() < mLimit) { + return alignBufferWithResponse(accumulatedBuffer, count); + } else { + return accumulatedBuffer; } - return buffer; } - private ResourceSearchResponse makeCall() { - SearchCriteria newSearchCriteria = resolveNextCriteria(); - RepositoryRestApi api = mRepoFactory.get(); - return api.searchResources(newSearchCriteria.toMap()); + @NonNull + private Collection cacheRemainedBuffer(List buffer) { + Collection leftPart = buffer.subList(0, mLimit - 1); + Collection rightPart = buffer.subList(mLimit - 1, buffer.size()); + tempBuffer = rightPart; + return leftPart; } - private void updateNextOffset() { - if (!mFirstCall) { - mNextOffset += mLimit; + private Collection alignBufferWithResponse(List resources, int count) { + count++; + + SearchCriteria newSearchCriteria = createNextCriteria(); + ResourceSearchResponse response = performApiCall(newSearchCriteria); + List collectionFromApi = response.getResources(); + resources.addAll(collectionFromApi); + + /** + * This is ugly condition. API for 5.5 is broken and there is no way to + * determine weather we reached total count value. + * + * Corresponding situation happens if API has returned 204 for request. + * We are trying to retry request 5 times. If 5 times sequentially + * received 204 we consider that API has no more items for client to consume + */ + mEndReached = (count == RETRY_COUNT); + if (mEndReached) { + return resources; } - mFirstCall = false; - } - private SearchCriteria resolveNextCriteria() { - updateNextOffset(); + return alignBuffer(resources, count); + } + private SearchCriteria createNextCriteria() { SearchCriteria.Builder newCriteriaBuilder = mInitialCriteria.newBuilder(); newCriteriaBuilder.offset(mNextOffset); return newCriteriaBuilder.create(); } + + private ResourceSearchResponse performApiCall(SearchCriteria criteria) { + RepositoryRestApi api = mRepoFactory.get(); + ResourceSearchResponse response = api.searchResources(criteria.toMap()); + updateNextOffset(); + return response; + } + + private void updateNextOffset() { + mNextOffset += mLimit; + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 8bb6c14d..8e3184e8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -289,7 +289,7 @@ Builder forceFullPage(boolean forceFullPage) { * @param forceTotalCount either true or false * @return chain builder instance */ - Builder forceTotalCount(@Nullable Boolean forceTotalCount) { + Builder forceTotalCount(boolean forceTotalCount) { this.forceTotalCount = forceTotalCount; return this; } From 04fe77c85814aae51fd709b2e6a385efc917ed07 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 16:35:54 +0300 Subject: [PATCH 160/457] Add custom offset support for EmeraldMR2SearchStrategy --- .../repository/EmeraldMR2SearchStrategy.java | 77 ++++++++++++------- .../sdk/service/repository/SearchTask.java | 26 +++++-- 2 files changed, 70 insertions(+), 33 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 4fc1cbb2..303719c8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -45,21 +45,23 @@ final class EmeraldMR2SearchStrategy implements SearchStrategy { private static final Collection EMPTY_RESPONSE = Collections.emptyList(); private static final int RETRY_COUNT = 5; + private final static int UNDEFINED = -1; private final RepositoryRestApi.Factory mRepoFactory; private final SearchCriteria mInitialCriteria; - private final int mLimit; - private int mNextOffset; + private int mUserOffset; + private int mInternalOffset = UNDEFINED; private boolean mEndReached; + private Collection tempBuffer = Collections.emptyList(); + private SearchCriteria mNextCriteria; public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { mRepoFactory = repositoryApiFactory; mInitialCriteria = criteria.newBuilder().create(); - mNextOffset = criteria.getOffset(); - mLimit = criteria.getLimit(); + mUserOffset = criteria.getOffset(); } @Override @@ -67,9 +69,15 @@ public Observable> searchNext() { return Observable.defer(new Func0>>() { @Override public Observable> call() { + if (mInternalOffset == UNDEFINED) { + defineInternalOffset(); + } if (mEndReached){ return Observable.just(EMPTY_RESPONSE); } + mNextCriteria = mInitialCriteria.newBuilder() + .offset(mInternalOffset) + .create(); return Observable.just(performAlignedRequests()); } }); @@ -80,9 +88,20 @@ public boolean hasNext() { return !mEndReached; } + private void defineInternalOffset() { + mInternalOffset = 0; + if (mUserOffset != 0) { + mNextCriteria = mInitialCriteria.newBuilder() + .limit(mUserOffset) + .offset(0) + .create(); + performAlignedRequests(); + } + } + private Collection performAlignedRequests() { - SearchCriteria newSearchCriteria = createNextCriteria(); - ResourceSearchResponse response = performApiCall(newSearchCriteria); + int emptyRequestCount = 1; + ResourceSearchResponse response = performApiCall(); List collectionFromApi = response.getResources(); @@ -90,41 +109,41 @@ private Collection performAlignedRequests() { localBuffer.addAll(collectionFromApi); Collection result; - int count = 0; + if (tempBuffer.isEmpty()) { - result = alignBuffer(localBuffer, count); + result = alignBuffer(localBuffer, emptyRequestCount); } else { List accumulatedBuffer = new LinkedList<>(tempBuffer); accumulatedBuffer.addAll(localBuffer); - result = alignBuffer(accumulatedBuffer, count); + result = alignBuffer(accumulatedBuffer, emptyRequestCount); } return result; } private Collection alignBuffer(List accumulatedBuffer, int count) { - if (accumulatedBuffer.size() > mLimit) { + int limit = mNextCriteria.getLimit(); + if (accumulatedBuffer.size() > limit) { return cacheRemainedBuffer(accumulatedBuffer); - } else if (accumulatedBuffer.size() < mLimit) { + } else if (accumulatedBuffer.size() < limit) { return alignBufferWithResponse(accumulatedBuffer, count); } else { + tempBuffer = Collections.emptyList(); return accumulatedBuffer; } } @NonNull private Collection cacheRemainedBuffer(List buffer) { - Collection leftPart = buffer.subList(0, mLimit - 1); - Collection rightPart = buffer.subList(mLimit - 1, buffer.size()); + int limit = mNextCriteria.getLimit(); + Collection leftPart = buffer.subList(0, limit - 1); + Collection rightPart = buffer.subList(limit - 1, buffer.size()); tempBuffer = rightPart; return leftPart; } private Collection alignBufferWithResponse(List resources, int count) { - count++; - - SearchCriteria newSearchCriteria = createNextCriteria(); - ResourceSearchResponse response = performApiCall(newSearchCriteria); + ResourceSearchResponse response = performApiCall(); List collectionFromApi = response.getResources(); resources.addAll(collectionFromApi); @@ -141,24 +160,28 @@ private Collection alignBufferWithResponse(List searchStrategyObservable; + @Nullable + private SearchStrategy strategy; SearchTask(SearchCriteria criteria, RepositoryRestApi.Factory repositoryApiFactory, @@ -62,17 +65,28 @@ public Observable> call(SearchStrategy search }); } + public boolean hasNext() { + /** + * Strategy not defined only, if user has not made any lookup requests. + * There is no 100% guarantee that API has items until we made request. + */ + if (strategy != null) { + return strategy.hasNext(); + } + return true; + } + private Observable defineSearchStrategy() { - if (searchStrategyObservable == null) { - searchStrategyObservable = requestServerVersion().flatMap(new Func1>() { + if (strategy == null) { + return requestServerVersion().flatMap(new Func1>() { @Override public Observable call(String version) { - SearchStrategy strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); + strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); return Observable.just(strategy); } - }).cache(); + }); } - return searchStrategyObservable; + return Observable.just(strategy); } private Observable requestServerVersion() { From 1ef3deaf95e65d9e537c06bbb7e19b48e0c5c5a8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 17:10:23 +0300 Subject: [PATCH 161/457] Simplifying EmeraldMR2SearchStrategy initial condition --- .../repository/EmeraldMR2SearchStrategy_.java | 100 ++++++++++++++++++ .../service/repository/SearchStrategy.java | 2 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java new file mode 100644 index 00000000..b4f677fe --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java @@ -0,0 +1,100 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import rx.Observable; +import rx.functions.Func0; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class EmeraldMR2SearchStrategy_ implements SearchStrategy { + public static final int MAX_RETRY_COUNT = 5; + private final RepositoryRestApi.Factory mRepoFactory; + private final SearchCriteria mInitialCriteria; + + private int mServerDisposition; + private List mBuffer = new LinkedList<>(); + private boolean mEndReached; + + public EmeraldMR2SearchStrategy_(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { + mRepoFactory = repositoryApiFactory; + mInitialCriteria = criteria.newBuilder().create(); + mEndReached = false; + } + + @Override + public Observable> searchNext() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + return Observable.just(internalSearch()); + } + }); + } + + @Override + public boolean hasNext() { + return !mEndReached; + } + + private Collection internalSearch() { + int limit = mInitialCriteria.getLimit(); + + int count = 0; + while (mBuffer.size() < limit && hasNext()) { + ResourceSearchResponse response = performSearch(); + mBuffer.addAll(response.getResources()); + mServerDisposition += limit; + + if (response.getResources().isEmpty()) { + mEndReached = (count == MAX_RETRY_COUNT); + count++; + } + } + + int measure = Math.min(limit, mBuffer.size()); + Collection result = mBuffer.subList(0, measure); + mBuffer = mBuffer.subList(measure, mBuffer.size()); + return result; + } + + private ResourceSearchResponse performSearch() { + SearchCriteria nextCriteria = mInitialCriteria.newBuilder() + .offset(mServerDisposition) + .create(); + RepositoryRestApi api = mRepoFactory.get(); + return api.searchResources(nextCriteria.toMap()); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 5a31fcc3..b848892c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -46,7 +46,7 @@ public static SearchStrategy get(String serverVersion, SearchCriteria criteria) { ServerVersion version = ServerVersion.defaultParser().parse(serverVersion); if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { - return new EmeraldMR2SearchStrategy(repositoryApiFactory, criteria); + return new EmeraldMR2SearchStrategy_(repositoryApiFactory, criteria); } if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { return new EmeraldMR3SearchStrategy(repositoryApiFactory, criteria); From 57289b9df5a70a43cf2aed46946edb7577b9fc54 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 17:30:12 +0300 Subject: [PATCH 162/457] Simplify custom offset case for EmeraldMR2SearchStrategy --- .../repository/EmeraldMR2SearchStrategy_.java | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java index b4f677fe..8ec9afe7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -40,7 +41,9 @@ * @since 2.0 */ final class EmeraldMR2SearchStrategy_ implements SearchStrategy { - public static final int MAX_RETRY_COUNT = 5; + private static final Collection EMPTY_RESPONSE = Collections.emptyList(); + private static final int MAX_RETRY_COUNT = 5; + private final RepositoryRestApi.Factory mRepoFactory; private final SearchCriteria mInitialCriteria; @@ -59,7 +62,15 @@ public Observable> searchNext() { return Observable.defer(new Func0>>() { @Override public Observable> call() { - return Observable.just(internalSearch()); + int limit = mInitialCriteria.getLimit(); + int offset = mInitialCriteria.getOffset(); + + if (mEndReached || limit == 0) { + return Observable.just(EMPTY_RESPONSE); + } + + calculateDisposition(offset); + return Observable.just(internalSearch(limit)); } }); } @@ -69,16 +80,29 @@ public boolean hasNext() { return !mEndReached; } - private Collection internalSearch() { - int limit = mInitialCriteria.getLimit(); + private void calculateDisposition(int offset) { + boolean serverDispositionUndefined = offset >= mServerDisposition; + if (serverDispositionUndefined) { + internalSearch(offset); + } + } + private Collection internalSearch(int limit) { int count = 0; while (mBuffer.size() < limit && hasNext()) { - ResourceSearchResponse response = performSearch(); + ResourceSearchResponse response = performSearch(limit); mBuffer.addAll(response.getResources()); mServerDisposition += limit; if (response.getResources().isEmpty()) { + /** + * This is ugly condition. API for 5.5 is broken and there is no way to + * determine weather we reached total count value. + * + * Corresponding situation happens if API has returned 204 for request. + * We are trying to retry request 5 times. If 5 times sequentially + * received 204 we consider that API has no more items for client to consume + */ mEndReached = (count == MAX_RETRY_COUNT); count++; } @@ -90,9 +114,10 @@ private Collection internalSearch() { return result; } - private ResourceSearchResponse performSearch() { + private ResourceSearchResponse performSearch(int limit) { SearchCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) + .limit(limit) .create(); RepositoryRestApi api = mRepoFactory.get(); return api.searchResources(nextCriteria.toMap()); From fd16105974c026542362d36534161fc70beaacc9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 25 Sep 2015 17:30:42 +0300 Subject: [PATCH 163/457] Remove deprecated EmeraldMR2SearchStrategy --- .../repository/EmeraldMR2SearchStrategy.java | 148 +++++------------- .../repository/EmeraldMR2SearchStrategy_.java | 125 --------------- .../service/repository/SearchStrategy.java | 2 +- 3 files changed, 44 insertions(+), 231 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 303719c8..37f17815 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; @@ -44,24 +42,19 @@ */ final class EmeraldMR2SearchStrategy implements SearchStrategy { private static final Collection EMPTY_RESPONSE = Collections.emptyList(); - private static final int RETRY_COUNT = 5; - private final static int UNDEFINED = -1; + private static final int MAX_RETRY_COUNT = 5; private final RepositoryRestApi.Factory mRepoFactory; private final SearchCriteria mInitialCriteria; - private int mUserOffset; - private int mInternalOffset = UNDEFINED; + private int mServerDisposition; + private List mBuffer = new LinkedList<>(); private boolean mEndReached; - private Collection tempBuffer = Collections.emptyList(); - private SearchCriteria mNextCriteria; - public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { mRepoFactory = repositoryApiFactory; mInitialCriteria = criteria.newBuilder().create(); - - mUserOffset = criteria.getOffset(); + mEndReached = false; } @Override @@ -69,16 +62,15 @@ public Observable> searchNext() { return Observable.defer(new Func0>>() { @Override public Observable> call() { - if (mInternalOffset == UNDEFINED) { - defineInternalOffset(); - } - if (mEndReached){ + int limit = mInitialCriteria.getLimit(); + int offset = mInitialCriteria.getOffset(); + + if (mEndReached || limit == 0) { return Observable.just(EMPTY_RESPONSE); } - mNextCriteria = mInitialCriteria.newBuilder() - .offset(mInternalOffset) - .create(); - return Observable.just(performAlignedRequests()); + + calculateDisposition(offset); + return Observable.just(internalSearch(limit)); } }); } @@ -88,100 +80,46 @@ public boolean hasNext() { return !mEndReached; } - private void defineInternalOffset() { - mInternalOffset = 0; - if (mUserOffset != 0) { - mNextCriteria = mInitialCriteria.newBuilder() - .limit(mUserOffset) - .offset(0) - .create(); - performAlignedRequests(); + private void calculateDisposition(int offset) { + boolean serverDispositionUndefined = offset >= mServerDisposition; + if (serverDispositionUndefined) { + internalSearch(offset); } } - private Collection performAlignedRequests() { - int emptyRequestCount = 1; - ResourceSearchResponse response = performApiCall(); - - List collectionFromApi = response.getResources(); - - List localBuffer = new LinkedList<>(); - localBuffer.addAll(collectionFromApi); - - Collection result; - - if (tempBuffer.isEmpty()) { - result = alignBuffer(localBuffer, emptyRequestCount); - } else { - List accumulatedBuffer = new LinkedList<>(tempBuffer); - accumulatedBuffer.addAll(localBuffer); - result = alignBuffer(accumulatedBuffer, emptyRequestCount); + private Collection internalSearch(int limit) { + int count = 0; + while (mBuffer.size() < limit && hasNext()) { + ResourceSearchResponse response = performSearch(limit); + mBuffer.addAll(response.getResources()); + mServerDisposition += limit; + + if (response.getResources().isEmpty()) { + /** + * This is ugly condition. API for 5.5 is broken and there is no way to + * determine weather we reached total count value. + * + * Corresponding situation happens if API has returned 204 for request. + * We are trying to retry request 5 times. If 5 times sequentially + * received 204 we consider that API has no more items for client to consume + */ + mEndReached = (count == MAX_RETRY_COUNT); + count++; + } } + int measure = Math.min(limit, mBuffer.size()); + Collection result = mBuffer.subList(0, measure); + mBuffer = mBuffer.subList(measure, mBuffer.size()); return result; } - private Collection alignBuffer(List accumulatedBuffer, int count) { - int limit = mNextCriteria.getLimit(); - if (accumulatedBuffer.size() > limit) { - return cacheRemainedBuffer(accumulatedBuffer); - } else if (accumulatedBuffer.size() < limit) { - return alignBufferWithResponse(accumulatedBuffer, count); - } else { - tempBuffer = Collections.emptyList(); - return accumulatedBuffer; - } - } - - @NonNull - private Collection cacheRemainedBuffer(List buffer) { - int limit = mNextCriteria.getLimit(); - Collection leftPart = buffer.subList(0, limit - 1); - Collection rightPart = buffer.subList(limit - 1, buffer.size()); - tempBuffer = rightPart; - return leftPart; - } - - private Collection alignBufferWithResponse(List resources, int count) { - ResourceSearchResponse response = performApiCall(); - List collectionFromApi = response.getResources(); - resources.addAll(collectionFromApi); - - /** - * This is ugly condition. API for 5.5 is broken and there is no way to - * determine weather we reached total count value. - * - * Corresponding situation happens if API has returned 204 for request. - * We are trying to retry request 5 times. If 5 times sequentially - * received 204 we consider that API has no more items for client to consume - */ - mEndReached = (count == RETRY_COUNT); - if (mEndReached) { - return resources; - } - - if (collectionFromApi.isEmpty()) { - count++; - } - - return alignBuffer(resources, count); - } - - private ResourceSearchResponse performApiCall() { - RepositoryRestApi api = mRepoFactory.get(); - ResourceSearchResponse response = api.searchResources(mNextCriteria.toMap()); - updateNextOffset(); - updateNextCriteria(); - return response; - } - - private void updateNextOffset() { - mInternalOffset += mNextCriteria.getLimit(); - } - - private void updateNextCriteria() { - mNextCriteria = mNextCriteria.newBuilder() - .offset(mInternalOffset) + private ResourceSearchResponse performSearch(int limit) { + SearchCriteria nextCriteria = mInitialCriteria.newBuilder() + .offset(mServerDisposition) + .limit(limit) .create(); + RepositoryRestApi api = mRepoFactory.get(); + return api.searchResources(nextCriteria.toMap()); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java deleted file mode 100644 index 8ec9afe7..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy_.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import rx.Observable; -import rx.functions.Func0; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class EmeraldMR2SearchStrategy_ implements SearchStrategy { - private static final Collection EMPTY_RESPONSE = Collections.emptyList(); - private static final int MAX_RETRY_COUNT = 5; - - private final RepositoryRestApi.Factory mRepoFactory; - private final SearchCriteria mInitialCriteria; - - private int mServerDisposition; - private List mBuffer = new LinkedList<>(); - private boolean mEndReached; - - public EmeraldMR2SearchStrategy_(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { - mRepoFactory = repositoryApiFactory; - mInitialCriteria = criteria.newBuilder().create(); - mEndReached = false; - } - - @Override - public Observable> searchNext() { - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - int limit = mInitialCriteria.getLimit(); - int offset = mInitialCriteria.getOffset(); - - if (mEndReached || limit == 0) { - return Observable.just(EMPTY_RESPONSE); - } - - calculateDisposition(offset); - return Observable.just(internalSearch(limit)); - } - }); - } - - @Override - public boolean hasNext() { - return !mEndReached; - } - - private void calculateDisposition(int offset) { - boolean serverDispositionUndefined = offset >= mServerDisposition; - if (serverDispositionUndefined) { - internalSearch(offset); - } - } - - private Collection internalSearch(int limit) { - int count = 0; - while (mBuffer.size() < limit && hasNext()) { - ResourceSearchResponse response = performSearch(limit); - mBuffer.addAll(response.getResources()); - mServerDisposition += limit; - - if (response.getResources().isEmpty()) { - /** - * This is ugly condition. API for 5.5 is broken and there is no way to - * determine weather we reached total count value. - * - * Corresponding situation happens if API has returned 204 for request. - * We are trying to retry request 5 times. If 5 times sequentially - * received 204 we consider that API has no more items for client to consume - */ - mEndReached = (count == MAX_RETRY_COUNT); - count++; - } - } - - int measure = Math.min(limit, mBuffer.size()); - Collection result = mBuffer.subList(0, measure); - mBuffer = mBuffer.subList(measure, mBuffer.size()); - return result; - } - - private ResourceSearchResponse performSearch(int limit) { - SearchCriteria nextCriteria = mInitialCriteria.newBuilder() - .offset(mServerDisposition) - .limit(limit) - .create(); - RepositoryRestApi api = mRepoFactory.get(); - return api.searchResources(nextCriteria.toMap()); - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index b848892c..5a31fcc3 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -46,7 +46,7 @@ public static SearchStrategy get(String serverVersion, SearchCriteria criteria) { ServerVersion version = ServerVersion.defaultParser().parse(serverVersion); if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { - return new EmeraldMR2SearchStrategy_(repositoryApiFactory, criteria); + return new EmeraldMR2SearchStrategy(repositoryApiFactory, criteria); } if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { return new EmeraldMR3SearchStrategy(repositoryApiFactory, criteria); From 4b4dc2bc66d8d383cc53f70eb3903f54e824acaa Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 28 Sep 2015 10:14:06 +0300 Subject: [PATCH 164/457] Implement additional criteria for limit and offset fields --- .../android/sdk/service/Preconditions.java | 38 +++++++++---------- .../service/repository/SearchCriteria.java | 4 ++ .../repository/SearchCriteriaTest.java | 21 +++++++++- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java index 738b2e29..f317e0f4 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java @@ -1,31 +1,25 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2007 The Guava Authors * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This program is part of Jaspersoft Mobile for Android. + * http://www.apache.org/licenses/LICENSE-2.0 * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.jaspersoft.android.sdk.service; +import android.support.annotation.Nullable; + /** - * @author Tom Koptel + * @author Kevin Bourrillion * @since 2.0 */ public final class Preconditions { @@ -38,4 +32,10 @@ public static T checkNotNull(T object, String message) { } return object; } + + public static void checkArgument(boolean expression, @Nullable Object errorMessage) { + if (!expression) { + throw new IllegalArgumentException(String.valueOf(errorMessage)); + } + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 8e3184e8..0299d1c0 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -32,6 +32,8 @@ import java.util.Map; import java.util.Set; +import static com.jaspersoft.android.sdk.service.Preconditions.checkArgument; + /** * @author Tom Koptel * @since 2.0 @@ -225,11 +227,13 @@ public static class Builder { private String folderUri; public Builder limit(int limit) { + checkArgument(limit >= 0, "Limit should be positive"); this.limit = limit; return this; } public Builder offset(int offset) { + checkArgument(offset >= 0, "Offset should be positive"); this.offset = offset; return this; } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index a9271e2b..645845f7 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,7 +24,9 @@ package com.jaspersoft.android.sdk.service.repository; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import java.util.Arrays; @@ -46,6 +48,9 @@ @RunWith(JUnitParamsRunner.class) public class SearchCriteriaTest { + @Rule + public ExpectedException mThrowsException = ExpectedException.none(); + @Test public void shouldIncludeCountInParams() { SearchCriteria criteria = SearchCriteria.builder() @@ -164,6 +169,20 @@ public void shouldIgnoreEmptyQuery() { assertThat(criteria.toMap(), is(emptytMap)); } + @Test + public void shouldNotAcceptNegativeOffset() { + mThrowsException.expect(IllegalArgumentException.class); + mThrowsException.expectMessage("Offset should be positive"); + SearchCriteria.builder().offset(-1).create(); + } + + @Test + public void shouldNotAcceptNegativeLimit() { + mThrowsException.expect(IllegalArgumentException.class); + mThrowsException.expectMessage("Limit should be positive"); + SearchCriteria.builder().limit(-1).create(); + } + @Test @Parameters({ "REPORT|reportUnit", From 34db733da1acab56170b34c5d78e17f6fcff7632 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 28 Sep 2015 10:52:15 +0300 Subject: [PATCH 165/457] Implementing test for EmeraldMR2SearchStrategy --- .../repository/EmeraldMR2SearchStrategy.java | 12 +- .../EmeraldMR2SearchStrategyTest.java | 166 ++++++++++++++++++ 2 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 37f17815..42e1a23a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.service.repository; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; @@ -53,7 +55,7 @@ final class EmeraldMR2SearchStrategy implements SearchStrategy { public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { mRepoFactory = repositoryApiFactory; - mInitialCriteria = criteria.newBuilder().create(); + mInitialCriteria = criteria; mEndReached = false; } @@ -87,6 +89,7 @@ private void calculateDisposition(int offset) { } } + @NonNull private Collection internalSearch(int limit) { int count = 0; while (mBuffer.size() < limit && hasNext()) { @@ -108,12 +111,13 @@ private Collection internalSearch(int limit) { } } - int measure = Math.min(limit, mBuffer.size()); - Collection result = mBuffer.subList(0, measure); - mBuffer = mBuffer.subList(measure, mBuffer.size()); + int median = Math.min(limit, mBuffer.size()); + Collection result = mBuffer.subList(0, median); + mBuffer = mBuffer.subList(median, mBuffer.size()); return result; } + @NonNull private ResourceSearchResponse performSearch(int limit) { SearchCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java new file mode 100644 index 00000000..b615065d --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -0,0 +1,166 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyMap; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ResourceSearchResponse.class}) +public class EmeraldMR2SearchStrategyTest { + + @Mock + RepositoryRestApi.Factory mApiFactory; + @Mock + RepositoryRestApi mApi; + @Mock + ResourceSearchResponse mResponse; + + /** + * Objects under test + */ + private EmeraldMR2SearchStrategy search10itemsStrategy; + private EmeraldMR2SearchStrategy search10itemsStrategyWithUserOffset5; + public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); + + @Before + public void setupMocks() { + MockitoAnnotations.initMocks(this); + + when(mApi.searchResources(anyMap())).thenReturn(mResponse); + when(mApiFactory.get()).thenReturn(mApi); + + List stubLookup = Collections.singletonList(new ResourceLookupResponse()); + when(mResponse.getResources()).thenReturn(stubLookup); + + SearchCriteria criteria = SearchCriteria.builder().limit(10).create(); + search10itemsStrategy = new EmeraldMR2SearchStrategy(mApiFactory, criteria); + + SearchCriteria userCriteria = criteria.newBuilder().offset(5).create(); + search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); + } + + @Test + public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exception { + when(mResponse.getResources()).thenReturn(FIVE_ITEMS); + + Collection result = search10itemsStrategy.searchNext().toBlocking().first(); + assertThat(result.size(), is(10)); + + Map params = new HashMap<>(); + params.put("limit", "10"); + verify(mApi).searchResources(params); + + params = new HashMap<>(); + params.put("limit", "10"); + params.put("offset", "10"); + verify(mApi).searchResources(params); + + verify(mApiFactory, times(2)).get(); + } + + @Test + public void willRetry5timesIfApiReturnsNoElements()throws Exception { + when(mResponse.getResources()).thenReturn(Collections.emptyList()); + + Collection result = search10itemsStrategy.searchNext().toBlocking().first(); + assertThat(search10itemsStrategy.hasNext(), is(false)); + + assertThat(result, is(empty())); + verify(mApiFactory, times(6)).get(); + verify(mApi, times(6)).searchResources(anyMap()); + } + + @Test + public void willReturnAsMuchElementsAsLeftIfEndReached()throws Exception { + when(mResponse.getResources()).then(OnlyTwoItems.INSTANCE); + + Collection result = search10itemsStrategy.searchNext().toBlocking().first(); + assertThat(result.size(), is(2)); + + verify(mApiFactory, times(6)).get(); + verify(mApi, times(6)).searchResources(anyMap()); + } + + @Test + public void forCustomOffsetShouldCalculateServerDisposition()throws Exception { + when(mResponse.getResources()).thenReturn(FIVE_ITEMS); + + search10itemsStrategyWithUserOffset5.searchNext().toBlocking().first(); + + Map params1 = new HashMap<>(); + params1.put("limit", "5"); + verify(mApi).searchResources(params1); + + Map params2 = new HashMap<>(); + params2.put("limit", "10"); + params2.put("offset", "5"); + verify(mApi).searchResources(params2); + + Map params3 = new HashMap<>(); + params3.put("limit", "10"); + params3.put("offset", "15"); + verify(mApi).searchResources(params3); + + verify(mApi, times(3)).searchResources(anyMap()); + verifyNoMoreInteractions(mApi); + } + + @Test + public void shouldReturnEmptyCollectionForZeroLimit() { + SearchCriteria userCriteria = SearchCriteria.builder().limit(0).offset(5).create(); + EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); + + Collection result = strategy.searchNext().toBlocking().first(); + assertThat(result, is(empty())); + + verifyZeroInteractions(mApi); + } + + private static class OnlyTwoItems implements Answer> { + public static final OnlyTwoItems INSTANCE = new OnlyTwoItems(); + + private final List twoItems = Arrays.asList(null, null); + private final List zeroItems = Collections.emptyList(); + + private int count = 0; + @Override + public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { + if (count == 0) { + count++; + return twoItems; + } + return zeroItems; + } + } +} \ No newline at end of file From e921ddd1324ee3b364d40d2a451b9f775b1c716d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 28 Sep 2015 11:16:33 +0300 Subject: [PATCH 166/457] Add limit == 0 case support for EmeraldMR3SearchStrategy --- .../repository/EmeraldMR3SearchStrategy.java | 6 +-- .../EmeraldMR3SearchStrategyTest.java | 13 ++++++ .../repository/RepositoryServiceTest.java | 41 +++++++++---------- .../repository/SearchStrategyTest.java | 4 +- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 1ccadf09..006f8318 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -65,12 +65,12 @@ public Observable> searchNext() { return Observable.defer(new Func0>>() { @Override public Observable> call() { + if (mEndReached || mInitialCriteria.getLimit() == 0){ + return Observable.just(EMPTY_RESPONSE); + } if (mInternalOffset == UNDEFINED) { defineInternalOffset(); } - if (mEndReached){ - return Observable.just(EMPTY_RESPONSE); - } return Observable.just(performLookup()); } }); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index b4e99b46..ed5de0df 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -4,6 +4,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,6 +27,7 @@ import static org.mockito.Matchers.anyMap; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; /** @@ -124,6 +126,17 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { verify(mApi, times(2)).searchResources(anyMap()); } + @Test + public void shouldReturnEmptyCollectionForZeroLimit() { + SearchCriteria userCriteria = SearchCriteria.builder().limit(0).offset(5).create(); + SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, userCriteria); + + Collection result = strategy.searchNext().toBlocking().first(); + assertThat(result, Matchers.is(Matchers.empty())); + + verifyZeroInteractions(mApi); + } + private TestSubscriber performSearch(EmeraldMR3SearchStrategy strategy) { TestSubscriber> testSubscriber = new TestSubscriber<>(); strategy.searchNext().subscribe(testSubscriber); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index a11faf28..7c0362a5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -26,11 +26,15 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.service.TokenProvider; -import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; +import org.junit.Before; import org.junit.Test; import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNull.notNullValue; /** * @author Tom Koptel @@ -38,28 +42,21 @@ */ public class RepositoryServiceTest { @Mock - TokenProvider mTokenProvider; + RepositoryRestApi.Factory repoApi; + @Mock + ServerRestApi.Factory infoApi; - String mServerUrl = "http://localhost"; + private RepositoryService objectUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new RepositoryService(repoApi, infoApi); + } @Test public void shouldProvideListOfResources() { - RepositoryRestApi.Factory repoApi = new RepositoryRestApiFactory(mServerUrl, mTokenProvider); - ServerRestApi.Factory infoApi = new ServerRestApiFactory(mServerUrl); - RepositoryService service = new RepositoryService(repoApi, infoApi); - - SearchCriteria criteria = SearchCriteria.builder() - .limit(10) - .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) - .create(); - SearchTask task = service.search(criteria); - // 10 - task.nextLookup().subscribe(); - // 20 - task.nextLookup().subscribe(); - // 5 - task.nextLookup().subscribe(); - // 0 - task.nextLookup().subscribe(); + SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); + assertThat(searchTask, is(notNullValue())); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index 43996b10..1cb6b748 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -43,7 +43,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public final class SearchStrategyTest { +public class SearchStrategyTest { @Mock RepositoryRestApi.Factory mFactory; From 464392f8057ba3a2086993baa2ccff55cbb4c2fc Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 28 Sep 2015 14:47:10 +0300 Subject: [PATCH 167/457] Add request folder and report API for RepositoryService --- .../entity/resource/FolderLookupResponse.java | 6 ++- .../entity/resource/ReportLookupResponse.java | 4 +- .../jaspersoft/android/sdk/service/Utils.java | 41 ------------------- .../service/repository/RepositoryService.java | 31 +++++++++++++- .../repository/RepositoryServiceTest.java | 38 ++++++++++++++++- 5 files changed, 73 insertions(+), 47 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/Utils.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java index 7ffcb5c9..83edd3f5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -28,7 +28,9 @@ * @author Tom Koptel * @since 2.0 */ -public final class FolderLookupResponse extends ResourceLookupResponse { +public class FolderLookupResponse extends ResourceLookupResponse { + + public FolderLookupResponse() {} @Override public String getResourceType() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java index e94c194f..dc935833 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java @@ -33,7 +33,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportLookupResponse extends ResourceLookupResponse { +public class ReportLookupResponse extends ResourceLookupResponse { @Expose private DataSource dataSource; @@ -50,6 +50,8 @@ public final class ReportLookupResponse extends ResourceLookupResponse { @Expose private List resources; + public ReportLookupResponse() {} + @Override public String getResourceType() { return "reportUnit"; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Utils.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Utils.java deleted file mode 100644 index ebb1494a..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Utils.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class Utils { - private Utils() { - } - - public static T checkNotNull(T object, String message) { - if (object == null) { - throw new NullPointerException(message); - } - return object; - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 58de003f..d40afed6 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,8 +24,15 @@ package com.jaspersoft.android.sdk.service.repository; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; + +import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel @@ -44,4 +51,26 @@ public RepositoryService(RepositoryRestApi.Factory repositoryApiFactory, public SearchTask search(SearchCriteria criteria) { return new SearchTask(criteria, mRepositoryApiFactory, mInfoApiFactory); } + + public Observable requestFolder(@NonNull final String folderUri) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + FolderLookupResponse result = mRepositoryApiFactory.get() + .requestFolderResource(folderUri); + return Observable.just(result); + } + }); + } + + public Observable requestReport(@NonNull final String folderUri) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + ReportLookupResponse result = mRepositoryApiFactory.get() + .requestReportResource(folderUri); + return Observable.just(result); + } + }); + } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 7c0362a5..732040b2 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -26,7 +26,10 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -35,6 +38,9 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; /** * @author Tom Koptel @@ -42,16 +48,24 @@ */ public class RepositoryServiceTest { @Mock - RepositoryRestApi.Factory repoApi; + RepositoryRestApi.Factory repoApiFactory; + @Mock + RepositoryRestApi repoApi; @Mock ServerRestApi.Factory infoApi; + @Mock + FolderLookupResponse mFolderResponse; + @Mock + ReportLookupResponse mReportResponse; + private RepositoryService objectUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new RepositoryService(repoApi, infoApi); + when(repoApiFactory.get()).thenReturn(repoApi); + objectUnderTest = new RepositoryService(repoApiFactory, infoApi); } @Test @@ -59,4 +73,24 @@ public void shouldProvideListOfResources() { SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); assertThat(searchTask, is(notNullValue())); } + + @Test + public void shouldProvideFolder() { + when(repoApi.requestFolderResource(anyString())).thenReturn(mFolderResponse); + + FolderLookupResponse result = objectUnderTest.requestFolder("/uri").toBlocking().first(); + assertThat(result, is(Matchers.notNullValue())); + + verify(repoApi).requestFolderResource("/uri"); + } + + @Test + public void shouldProvideReport() { + when(repoApi.requestReportResource(anyString())).thenReturn(mReportResponse); + + ReportLookupResponse result = objectUnderTest.requestReport("/uri").toBlocking().first(); + assertThat(result, is(Matchers.notNullValue())); + + verify(repoApi).requestReportResource("/uri"); + } } \ No newline at end of file From 2200ed7b04d9d7283e2ef74e597a3bb8d4f84796 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 28 Sep 2015 15:19:56 +0300 Subject: [PATCH 168/457] Separating user criteria from internal criteria --- .../repository/EmeraldMR2SearchStrategy.java | 6 +- .../repository/EmeraldMR3SearchStrategy.java | 16 +- .../service/repository/InternalCriteria.java | 296 +++++++++++++++++ .../service/repository/RepositoryService.java | 2 +- .../service/repository/SearchCriteria.java | 147 +------- .../service/repository/SearchStrategy.java | 2 +- .../sdk/service/repository/SearchTask.java | 6 +- .../EmeraldMR2SearchStrategyTest.java | 6 +- .../EmeraldMR3SearchStrategyTest.java | 11 +- .../InternalSearchCriteriaTest.java | 313 ++++++++++++++++++ .../repository/SearchCriteriaTest.java | 255 +------------- .../repository/SearchStrategyTest.java | 6 +- .../service/repository/SearchTaskTest.java | 11 +- 13 files changed, 655 insertions(+), 422 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 42e1a23a..f68cc1f5 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -47,13 +47,13 @@ final class EmeraldMR2SearchStrategy implements SearchStrategy { private static final int MAX_RETRY_COUNT = 5; private final RepositoryRestApi.Factory mRepoFactory; - private final SearchCriteria mInitialCriteria; + private final InternalCriteria mInitialCriteria; private int mServerDisposition; private List mBuffer = new LinkedList<>(); private boolean mEndReached; - public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { + public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, InternalCriteria criteria) { mRepoFactory = repositoryApiFactory; mInitialCriteria = criteria; mEndReached = false; @@ -119,7 +119,7 @@ private Collection internalSearch(int limit) { @NonNull private ResourceSearchResponse performSearch(int limit) { - SearchCriteria nextCriteria = mInitialCriteria.newBuilder() + InternalCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) .limit(limit) .create(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 006f8318..0861e7cc 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -45,13 +45,13 @@ final class EmeraldMR3SearchStrategy implements SearchStrategy { private final static int UNDEFINED = -1; private final RepositoryRestApi.Factory mRepoFactory; - private final SearchCriteria mInitialCriteria; + private final InternalCriteria mInitialCriteria; private int mUserOffset; private int mInternalOffset = UNDEFINED; private boolean mEndReached; - public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, SearchCriteria criteria) { + public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, InternalCriteria criteria) { mRepoFactory = repositoryApiFactory; // Internally enabling 'forceFullPageFlag' mInitialCriteria = criteria.newBuilder() @@ -83,14 +83,14 @@ public boolean hasNext() { @NonNull private Collection performLookup() { - SearchCriteria newSearchCriteria = createNextCriteria(); + InternalCriteria newSearchCriteria = createNextCriteria(); ResourceSearchResponse result = performApiCall(newSearchCriteria); updateInternalOffset(result); return result.getResources(); } @NonNull - private ResourceSearchResponse performApiCall(SearchCriteria newSearchCriteria) { + private ResourceSearchResponse performApiCall(InternalCriteria newSearchCriteria) { RepositoryRestApi api = mRepoFactory.get(); return api.searchResources(newSearchCriteria.toMap()); } @@ -99,7 +99,7 @@ private void defineInternalOffset() { if (mUserOffset == 0) { mInternalOffset = mUserOffset; } else { - SearchCriteria newCriteria = mInitialCriteria.newBuilder() + InternalCriteria newCriteria = mInitialCriteria.newBuilder() .limit(mUserOffset) .offset(0) .create(); @@ -118,8 +118,8 @@ private void updateInternalOffset(ResourceSearchResponse result) { } @NonNull - private SearchCriteria createNextCriteria() { - SearchCriteria.Builder newCriteriaBuilder = mInitialCriteria.newBuilder(); + private InternalCriteria createNextCriteria() { + InternalCriteria.Builder newCriteriaBuilder = mInitialCriteria.newBuilder(); newCriteriaBuilder.offset(mInternalOffset); return newCriteriaBuilder.create(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java new file mode 100644 index 00000000..121859c8 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -0,0 +1,296 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.repository; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.ALL; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DASHBOARD; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_LIMIT; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_OFFSET; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.LEGACY_DASHBOARD; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.REPORT; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class InternalCriteria { + private final int mLimit; + private final int mOffset; + private final int mResourceMask; + private final Boolean mRecursive; + private final Boolean mForceFullPage; + private final Boolean mForceTotalCount; + private final String mQuery; + private final String mSortBy; + private final String mFolderUri; + + private InternalCriteria(Builder builder) { + mLimit = builder.limit; + mOffset = builder.offset; + mResourceMask = builder.resourceMask; + mRecursive = builder.recursive; + mForceFullPage = builder.forceFullPage; + mForceTotalCount = builder.forceTotalCount; + mQuery = builder.query; + mSortBy = builder.sort; + mFolderUri = builder.folderUri; + } + + @NonNull + public static InternalCriteria.Builder builder() { + return new InternalCriteria.Builder(); + } + + @NonNull + public static InternalCriteria from(SearchCriteria criteria) { + return InternalCriteria.builder() + .limit(criteria.getLimit()) + .offset(criteria.getOffset()) + .resourceMask(criteria.getResourceMask()) + .recursive(criteria.getRecursive()) + .folderUri(criteria.getFolderUri()) + .query(criteria.getQuery()) + .sortBy(criteria.getSortBy()) + .create(); + } + + public int getLimit() { + return mLimit; + } + + public int getOffset() { + return mOffset; + } + + @Nullable + public String getFolderUri() { + return mFolderUri; + } + + @Nullable + public Boolean getForceFullPage() { + return mForceFullPage; + } + + @Nullable + public Boolean getForceTotalCount() { + return mForceTotalCount; + } + + @Nullable + public String getQuery() { + return mQuery; + } + + @Nullable + public Boolean getRecursive() { + return mRecursive; + } + + public int getResourceMask() { + return mResourceMask; + } + + public String getSortBy() { + return mSortBy; + } + + @NonNull + public InternalCriteria.Builder newBuilder() { + InternalCriteria.Builder builder = builder(); + + if (mRecursive != null) { + builder.recursive(mRecursive); + } + if (mForceFullPage != null) { + builder.forceFullPage(mForceFullPage); + } + if (mForceTotalCount != null) { + builder.forceTotalCount(mForceTotalCount); + } + if (mQuery != null) { + builder.query(mQuery); + } + if (mSortBy != null) { + builder.sortBy(mSortBy); + } + if (mFolderUri != null) { + builder.folderUri(mFolderUri); + } + + builder.resourceMask(mResourceMask); + builder.limit(mLimit); + builder.offset(mOffset); + + return builder; + } + + @NonNull + public Map toMap() { + Map params = new HashMap<>(); + + if (mLimit != DEFAULT_LIMIT) { + params.put("limit", String.valueOf(mLimit)); + } + if (mOffset != DEFAULT_OFFSET) { + params.put("offset", String.valueOf(mOffset)); + } + if (mRecursive != null) { + params.put("recursive", String.valueOf(mRecursive)); + } + if (mForceFullPage != null) { + params.put("forceFullPage", String.valueOf(mForceFullPage)); + } + if (mForceTotalCount != null) { + params.put("forceTotalCount", String.valueOf(mForceTotalCount)); + } + if (mQuery != null && mQuery.length() > 0) { + params.put("q", mQuery); + } + if (mSortBy != null) { + params.put("sortBy", mSortBy); + } + if (mFolderUri != null) { + params.put("folderUri", mFolderUri); + } + + populateTypes(params); + return params; + } + + private void populateTypes(Map params) { + Set types = new HashSet<>(); + + boolean includeReport = + (mResourceMask & REPORT) == REPORT || (mResourceMask & ALL) == ALL; + if (includeReport) { + types.add("reportUnit"); + } + boolean includeDashboard = + (mResourceMask & DASHBOARD) == DASHBOARD || (mResourceMask & ALL) == ALL; + if (includeDashboard) { + types.add("dashboard"); + } + boolean includeLegacyDashboard = + (mResourceMask & LEGACY_DASHBOARD) == LEGACY_DASHBOARD || (mResourceMask & ALL) == ALL; + if (includeLegacyDashboard) { + types.add("legacyDashboard"); + } + + if (!types.isEmpty()) { + params.put("type", types); + } + } + + public static class Builder { + private int limit = DEFAULT_LIMIT; + private int offset = DEFAULT_OFFSET; + private int resourceMask = Integer.MIN_VALUE; + + @Nullable + private Boolean recursive; + @Nullable + private Boolean forceFullPage; + @Nullable + public Boolean forceTotalCount; + @Nullable + private String query; + @Nullable + private String sort; + @Nullable + private String folderUri; + + public Builder limit(int limit) { + this.limit = limit; + return this; + } + + public Builder offset(int offset) { + this.offset = offset; + return this; + } + + public Builder resourceMask(int resourceMask) { + this.resourceMask = resourceMask; + return this; + } + + public Builder recursive(Boolean recursive) { + this.recursive = recursive; + return this; + } + + public Builder query(@Nullable String query) { + this.query = query; + return this; + } + + public Builder folderUri(@Nullable String folderUri) { + this.folderUri = folderUri; + return this; + } + + /** + * Internal use. Mutating sortBy value. + * @param sort either 'label' or 'creationDate' + * @return chain builder instance + */ + public Builder sortBy(String sort) { + this.sort = sort; + return this; + } + + /** + * Internal use. Mutating forceFullPage value. + * @param forceFullPage either true or false + * @return chain builder instance + */ + public Builder forceFullPage(Boolean forceFullPage) { + this.forceFullPage = forceFullPage; + return this; + } + + /** + * Internal use. Mutating forceTotalCount value. + * @param forceTotalCount either true or false + * @return chain builder instance + */ + public Builder forceTotalCount(Boolean forceTotalCount) { + this.forceTotalCount = forceTotalCount; + return this; + } + + public InternalCriteria create() { + return new InternalCriteria(this); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index d40afed6..cabdb4ec 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -49,7 +49,7 @@ public RepositoryService(RepositoryRestApi.Factory repositoryApiFactory, } public SearchTask search(SearchCriteria criteria) { - return new SearchTask(criteria, mRepositoryApiFactory, mInfoApiFactory); + return new SearchTask(InternalCriteria.from(criteria), mRepositoryApiFactory, mInfoApiFactory); } public Observable requestFolder(@NonNull final String folderUri) { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 0299d1c0..c6ee0a1e 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,11 +27,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - import static com.jaspersoft.android.sdk.service.Preconditions.checkArgument; /** @@ -39,8 +34,8 @@ * @since 2.0 */ public final class SearchCriteria { - private static final int DEFAULT_OFFSET = 0; - private static final int DEFAULT_LIMIT = 100; + static final int DEFAULT_OFFSET = 0; + static final int DEFAULT_LIMIT = 100; public static int ALL = 1; public static int REPORT = (1 << 1); @@ -51,8 +46,7 @@ public final class SearchCriteria { private final int mOffset; private final int mResourceMask; private final Boolean mRecursive; - private final Boolean mForceFullPage; - private final Boolean mForceTotalCount; + private final String mQuery; private final String mSortBy; private final String mFolderUri; @@ -62,8 +56,6 @@ private SearchCriteria(Builder builder) { mOffset = builder.offset; mResourceMask = builder.resourceMask; mRecursive = builder.recursive; - mForceFullPage = builder.forceFullPage; - mForceTotalCount = builder.forceTotalCount; mQuery = builder.query; mSortBy = builder.sort; mFolderUri = builder.folderUri; @@ -87,16 +79,6 @@ public int getOffset() { return mOffset; } - @Nullable - public Boolean getForceFullPage() { - return mForceFullPage; - } - - @Nullable - public Boolean getForceTotalCount() { - return mForceTotalCount; - } - @Nullable public String getQuery() { return mQuery; @@ -121,93 +103,6 @@ public String getFolderUri() { return mFolderUri; } - @NonNull - public SearchCriteria.Builder newBuilder() { - SearchCriteria.Builder builder = builder(); - - if (mRecursive != null) { - builder.recursive(mRecursive); - } - if (mForceFullPage != null) { - builder.forceFullPage(mForceFullPage); - } - if (mForceTotalCount != null) { - builder.forceTotalCount(mForceTotalCount); - } - if (mQuery != null) { - builder.query(mQuery); - } - if (mSortBy != null) { - builder.sortBy(mSortBy); - } - if (mFolderUri != null) { - builder.folderUri(mFolderUri); - } - - builder.resourceMask(mResourceMask); - builder.limit(mLimit); - builder.offset(mOffset); - - return builder; - } - - @NonNull - public Map toMap() { - Map params = new HashMap<>(); - - if (mLimit != DEFAULT_LIMIT) { - params.put("limit", String.valueOf(mLimit)); - } - if (mOffset != DEFAULT_OFFSET) { - params.put("offset", String.valueOf(mOffset)); - } - if (mRecursive != null) { - params.put("recursive", String.valueOf(mRecursive)); - } - if (mForceFullPage != null) { - params.put("forceFullPage", String.valueOf(mForceFullPage)); - } - if (mForceTotalCount != null) { - params.put("forceTotalCount", String.valueOf(mForceTotalCount)); - } - if (mQuery != null && mQuery.length() > 0) { - params.put("q", mQuery); - } - if (mSortBy != null) { - params.put("sortBy", mSortBy); - } - if (mFolderUri != null) { - params.put("folderUri", mFolderUri); - } - - populateTypes(params); - return params; - } - - private void populateTypes(Map params) { - Set types = new HashSet<>(); - - boolean includeReport = - (mResourceMask & REPORT) == REPORT || (mResourceMask & ALL) == ALL; - if (includeReport) { - types.add("reportUnit"); - } - boolean includeDashboard = - (mResourceMask & DASHBOARD) == DASHBOARD || (mResourceMask & ALL) == ALL; - if (includeDashboard) { - types.add("dashboard"); - } - boolean includeLegacyDashboard = - (mResourceMask & LEGACY_DASHBOARD) == LEGACY_DASHBOARD || (mResourceMask & ALL) == ALL; - if (includeLegacyDashboard) { - types.add("legacyDashboard"); - } - - if (!types.isEmpty()) { - params.put("type", types); - } - } - public static class Builder { private int limit = DEFAULT_LIMIT; private int offset = DEFAULT_OFFSET; @@ -216,10 +111,6 @@ public static class Builder { @Nullable private Boolean recursive; @Nullable - private Boolean forceFullPage; - @Nullable - public Boolean forceTotalCount; - @Nullable private String query; @Nullable private String sort; @@ -268,36 +159,6 @@ public Builder folderUri(@Nullable String folderUri) { return this; } - /** - * Internal use. Mutating sortBy value. - * @param sort either 'label' or 'creationDate' - * @return chain builder instance - */ - Builder sortBy(String sort) { - this.sort = sort; - return this; - } - - /** - * Internal use. Mutating forceFullPage value. - * @param forceFullPage either true or false - * @return chain builder instance - */ - Builder forceFullPage(boolean forceFullPage) { - this.forceFullPage = forceFullPage; - return this; - } - - /** - * Internal use. Mutating forceTotalCount value. - * @param forceTotalCount either true or false - * @return chain builder instance - */ - Builder forceTotalCount(boolean forceTotalCount) { - this.forceTotalCount = forceTotalCount; - return this; - } - public SearchCriteria create() { return new SearchCriteria(this); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 5a31fcc3..605f2c97 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -43,7 +43,7 @@ interface SearchStrategy { class Factory { public static SearchStrategy get(String serverVersion, RepositoryRestApi.Factory repositoryApiFactory, - SearchCriteria criteria) { + InternalCriteria criteria) { ServerVersion version = ServerVersion.defaultParser().parse(serverVersion); if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { return new EmeraldMR2SearchStrategy(repositoryApiFactory, criteria); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 2791d106..b6abaa20 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -41,14 +41,14 @@ * @since 2.0 */ public final class SearchTask { - private final SearchCriteria mCriteria; + private final InternalCriteria mCriteria; private final RepositoryRestApi.Factory mRepositoryApiFactory; private final ServerRestApi.Factory mInfoApiFactory; @Nullable private SearchStrategy strategy; - SearchTask(SearchCriteria criteria, + SearchTask(InternalCriteria criteria, RepositoryRestApi.Factory repositoryApiFactory, ServerRestApi.Factory infoApiFactory) { mCriteria = criteria; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index b615065d..1b592a66 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -63,10 +63,10 @@ public void setupMocks() { List stubLookup = Collections.singletonList(new ResourceLookupResponse()); when(mResponse.getResources()).thenReturn(stubLookup); - SearchCriteria criteria = SearchCriteria.builder().limit(10).create(); + InternalCriteria criteria = InternalCriteria.builder().limit(10).create(); search10itemsStrategy = new EmeraldMR2SearchStrategy(mApiFactory, criteria); - SearchCriteria userCriteria = criteria.newBuilder().offset(5).create(); + InternalCriteria userCriteria = criteria.newBuilder().offset(5).create(); search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); } @@ -138,7 +138,7 @@ public void forCustomOffsetShouldCalculateServerDisposition()throws Exception { @Test public void shouldReturnEmptyCollectionForZeroLimit() { - SearchCriteria userCriteria = SearchCriteria.builder().limit(0).offset(5).create(); + InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); Collection result = strategy.searchNext().toBlocking().first(); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index ed5de0df..a370328a 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -37,6 +37,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest(ResourceSearchResponse.class) public class EmeraldMR3SearchStrategyTest { + private static final InternalCriteria NO_CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock RepositoryRestApi.Factory mApiFactory; @@ -58,7 +59,7 @@ public void setupMocks() { @Test public void shouldMakeImmediateCallOnApiForUserOffsetZero() { - SearchCriteria searchCriteria = SearchCriteria.builder().offset(0).create(); + InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); when(mApi.searchResources(anyMap())).thenReturn(mResponse); @@ -73,7 +74,7 @@ public void shouldMakeImmediateCallOnApiForUserOffsetZero() { @Test public void makesAdditionalCallOnApiIfUserOffsetNotZero() { - SearchCriteria searchCriteria = SearchCriteria.builder().offset(5).create(); + InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); performSearch(strategy); @@ -87,7 +88,7 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() { @Test public void secondSearchLookupShouldUseNextOffset() { - SearchCriteria searchCriteria = SearchCriteria.builder().offset(0).create(); + InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); when(mResponse.getNextOffset()).thenReturn(133); @@ -108,7 +109,7 @@ public void secondSearchLookupShouldUseNextOffset() { @Test public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, SearchCriteria.none()); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, NO_CRITERIA); when(mResponse.getNextOffset()).thenReturn(133); performSearch(strategy); @@ -128,7 +129,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { @Test public void shouldReturnEmptyCollectionForZeroLimit() { - SearchCriteria userCriteria = SearchCriteria.builder().limit(0).offset(5).create(); + InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, userCriteria); Collection result = strategy.searchNext().toBlocking().first(); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java new file mode 100644 index 00000000..1fc5ea35 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java @@ -0,0 +1,313 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class InternalSearchCriteriaTest { + + @Test + public void shouldIncludeCountInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .limit(101) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("limit", "101"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeOffsetInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .offset(100) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("offset", "100"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeRecursiveInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .recursive(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("recursive", "true"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeForceFullPageInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .forceFullPage(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("forceFullPage", "true"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeForceTotalCountPageInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .forceTotalCount(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("forceTotalCount", "true"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeQueryPageInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .query("any") + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("q", "any"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIncludeFolderUriInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .folderUri("/") + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("folderUri", "/"); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldIgnoreEmptyQuery() { + InternalCriteria criteria = InternalCriteria.builder() + .query("") + .create(); + + Map emptytMap = new HashMap<>(); + assertThat(criteria.toMap(), is(emptytMap)); + } + + @Test + @Parameters({ + "REPORT|reportUnit", + "DASHBOARD|dashboard", + "LEGACY_DASHBOARD|legacyDashboard", + "ALL|reportUnit:dashboard:legacyDashboard", + "REPORT:DASHBOARD|reportUnit:dashboard", + }) + public void criteriaShouldIncludeTypeInParams(String flags, String types) throws Exception { + int mask = 0; + if (flags.contains(":")) { + for (String flag : flags.split(":")) { + mask |= (Integer) SearchCriteria.class.getField(flag).get(null); + } + } else { + mask = (Integer) SearchCriteria.class.getField(flags).get(null); + } + + InternalCriteria criteria = InternalCriteria.builder() + .resourceMask(mask) + .create(); + + Map resultMap = new HashMap<>(); + Set typeSet = new HashSet<>(); + if (types.contains(":")) { + typeSet.addAll(Arrays.asList(types.split(":"))); + } else { + typeSet.add(types); + } + resultMap.put("type", typeSet); + + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void shouldReturnEmptyParamsIfNoSupplied() { + InternalCriteria criteria = InternalCriteria.builder().create(); + Map resultMap = new HashMap<>(); + assertThat(criteria.toMap(), is(resultMap)); + } + + @Test + public void newBuilderShouldCopyCount() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .limit(100) + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getLimit(), is(100)); + } + + @Test + public void newBuilderShouldCopyOffset() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .offset(100) + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getOffset(), is(100)); + } + + @Test + public void newBuilderShouldCopyForceFullPageFlag() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .forceFullPage(true) + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getForceFullPage(), is(true)); + } + + @Test + public void newBuilderShouldCopyQuery() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .query("q") + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getQuery(), is("q")); + } + + @Test + public void newBuilderShouldCopyRecursiveFlag() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .recursive(true) + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getRecursive(), is(true)); + } + + @Test + public void newBuilderShouldCopySortBy() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .sortBy("creationDate") + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getSortBy(), is("creationDate")); + } + + @Test + public void newBuilderShouldCopyResourceMask() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getResourceMask(), is(SearchCriteria.REPORT | SearchCriteria.DASHBOARD)); + } + + @Test + public void newBuilderShouldCopyForceTotalPageFlag() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .forceTotalCount(true) + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getForceTotalCount(), is(true)); + } + + @Test + public void newBuilderShouldCopyFolderUri() { + InternalCriteria searchCriteria = InternalCriteria.builder() + .folderUri("/") + .create(); + InternalCriteria newCriteria = searchCriteria.newBuilder().create(); + assertThat(newCriteria.getFolderUri(), is("/")); + } + + @Test + public void shouldAdaptFromUserCriteriaFieldLimit() { + SearchCriteria searchCriteria = SearchCriteria.builder().limit(1).create(); + InternalCriteria criteria = InternalCriteria.from(searchCriteria); + assertThat(criteria.getLimit(), is(1)); + } + + @Test + public void shouldAdaptFromUserCriteriaFieldOffset() { + SearchCriteria searchCriteria = SearchCriteria.builder().offset(2).create(); + InternalCriteria criteria = InternalCriteria.from(searchCriteria); + assertThat(criteria.getOffset(), is(2)); + } + + @Test + public void shouldAdaptFromUserCriteriaFieldResourceMask() { + SearchCriteria searchCriteria = SearchCriteria.builder().resourceMask(SearchCriteria.REPORT).create(); + InternalCriteria criteria = InternalCriteria.from(searchCriteria); + assertThat(criteria.getResourceMask(), is(SearchCriteria.REPORT)); + } + + @Test + public void shouldAdaptFromUserCriteriaFieldRecursive() { + SearchCriteria searchCriteria = SearchCriteria.builder().recursive(true).create(); + InternalCriteria criteria = InternalCriteria.from(searchCriteria); + assertThat(criteria.getRecursive(), is(true)); + } + + @Test + public void shouldAdaptFromUserCriteriaFieldFolderUri() { + SearchCriteria searchCriteria = SearchCriteria.builder().folderUri("/").create(); + InternalCriteria criteria = InternalCriteria.from(searchCriteria); + assertThat(criteria.getFolderUri(), is("/")); + } + + @Test + public void shouldAdaptFromUserCriteriaFieldQuery() { + SearchCriteria searchCriteria = SearchCriteria.builder().query("query").create(); + InternalCriteria criteria = InternalCriteria.from(searchCriteria); + assertThat(criteria.getQuery(), is("query")); + } + + @Test + public void shouldAdaptFromUserCriteriaFieldSortBy() { + SearchCriteria searchCriteria = SearchCriteria.builder().sortByCreationDate().create(); + InternalCriteria criteria = InternalCriteria.from(searchCriteria); + assertThat(criteria.getSortBy(), is("creationDate")); + } +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index 645845f7..e460afee 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -21,22 +21,11 @@ * along with Jaspersoft Mobile for Android. If not, see * . */ - package com.jaspersoft.android.sdk.service.repository; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -45,94 +34,16 @@ * @author Tom Koptel * @since 2.0 */ -@RunWith(JUnitParamsRunner.class) public class SearchCriteriaTest { - @Rule - public ExpectedException mThrowsException = ExpectedException.none(); - - @Test - public void shouldIncludeCountInParams() { - SearchCriteria criteria = SearchCriteria.builder() - .limit(101) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("limit", "101"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeOffsetInParams() { - SearchCriteria criteria = SearchCriteria.builder() - .offset(100) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("offset", "100"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeRecursiveInParams() { - SearchCriteria criteria = SearchCriteria.builder() - .recursive(true) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("recursive", "true"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeForceFullPageInParams() { - SearchCriteria criteria = SearchCriteria.builder() - .forceFullPage(true) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("forceFullPage", "true"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeForceTotalCountPageInParams() { - SearchCriteria criteria = SearchCriteria.builder() - .forceTotalCount(true) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("forceTotalCount", "true"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeQueryPageInParams() { - SearchCriteria criteria = SearchCriteria.builder() - .query("any") - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("q", "any"); - - assertThat(criteria.toMap(), is(resultMap)); - } + public ExpectedException mExpectedException = ExpectedException.none(); @Test public void shouldIncludeSortByLabelInParams() { SearchCriteria criteria = SearchCriteria.builder() .sortByLabel() .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("sortBy", "label"); - - assertThat(criteria.toMap(), is(resultMap)); + assertThat(criteria.getSortBy(), is("label")); } @Test @@ -140,168 +51,20 @@ public void shouldIncludeSortByCreationDateInParams() { SearchCriteria criteria = SearchCriteria.builder() .sortByCreationDate() .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("sortBy", "creationDate"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeFolderUriInParams() { - SearchCriteria criteria = SearchCriteria.builder() - .folderUri("/") - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("folderUri", "/"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIgnoreEmptyQuery() { - SearchCriteria criteria = SearchCriteria.builder() - .query("") - .create(); - - Map emptytMap = new HashMap<>(); - assertThat(criteria.toMap(), is(emptytMap)); + assertThat(criteria.getSortBy(), is("creationDate")); } @Test public void shouldNotAcceptNegativeOffset() { - mThrowsException.expect(IllegalArgumentException.class); - mThrowsException.expectMessage("Offset should be positive"); + mExpectedException.expect(IllegalArgumentException.class); + mExpectedException.expectMessage("Offset should be positive"); SearchCriteria.builder().offset(-1).create(); } @Test public void shouldNotAcceptNegativeLimit() { - mThrowsException.expect(IllegalArgumentException.class); - mThrowsException.expectMessage("Limit should be positive"); + mExpectedException.expect(IllegalArgumentException.class); + mExpectedException.expectMessage("Limit should be positive"); SearchCriteria.builder().limit(-1).create(); } - - @Test - @Parameters({ - "REPORT|reportUnit", - "DASHBOARD|dashboard", - "LEGACY_DASHBOARD|legacyDashboard", - "ALL|reportUnit:dashboard:legacyDashboard", - "REPORT:DASHBOARD|reportUnit:dashboard", - }) - public void criteriaShouldIncludeTypeInParams(String flags, String types) throws Exception { - int mask = 0; - if (flags.contains(":")) { - for (String flag : flags.split(":")) { - mask |= (Integer) SearchCriteria.class.getField(flag).get(null); - } - } else { - mask = (Integer) SearchCriteria.class.getField(flags).get(null); - } - - SearchCriteria criteria = SearchCriteria.builder() - .resourceMask(mask) - .create(); - - Map resultMap = new HashMap<>(); - Set typeSet = new HashSet<>(); - if (types.contains(":")) { - typeSet.addAll(Arrays.asList(types.split(":"))); - } else { - typeSet.add(types); - } - resultMap.put("type", typeSet); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldReturnEmptyParamsIfNoSupplied() { - SearchCriteria criteria = SearchCriteria.builder().create(); - Map resultMap = new HashMap<>(); - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void newBuilderShouldCopyCount() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .limit(100) - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getLimit(), is(100)); - } - - @Test - public void newBuilderShouldCopyOffset() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .offset(100) - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getOffset(), is(100)); - } - - @Test - public void newBuilderShouldCopyForceFullPageFlag() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .forceFullPage(true) - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getForceFullPage(), is(true)); - } - - @Test - public void newBuilderShouldCopyQuery() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .query("q") - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getQuery(), is("q")); - } - - @Test - public void newBuilderShouldCopyRecursiveFlag() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .recursive(true) - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getRecursive(), is(true)); - } - - @Test - public void newBuilderShouldCopySortBy() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .sortByCreationDate() - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getSortBy(), is("creationDate")); - } - - @Test - public void newBuilderShouldCopyResourceMask() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getResourceMask(), is(SearchCriteria.REPORT | SearchCriteria.DASHBOARD)); - } - - @Test - public void newBuilderShouldCopyForceTotalPageFlag() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .forceTotalCount(true) - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getForceTotalCount(), is(true)); - } - - @Test - public void newBuilderShouldCopyFolderUri() { - SearchCriteria searchCriteria = SearchCriteria.builder() - .folderUri("/") - .create(); - SearchCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getFolderUri(), is("/")); - } -} \ No newline at end of file +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index 1cb6b748..d44fb484 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -44,10 +44,10 @@ */ @RunWith(JUnitParamsRunner.class) public class SearchStrategyTest { + private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock RepositoryRestApi.Factory mFactory; - SearchCriteria mSearchCriteria = SearchCriteria.builder().create(); @Before public void before() { @@ -60,7 +60,7 @@ public void before() { "5.5", }) public void factoryCreatesEmeraldMR2Strategy(String version) { - SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, mSearchCriteria); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, CRITERIA); assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); } @@ -70,7 +70,7 @@ public void factoryCreatesEmeraldMR2Strategy(String version) { "6.0.1", }) public void factoryCreatesEmeraldMR3Strategy(String version) { - SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, mSearchCriteria); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, CRITERIA); assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java index 516dddbe..cfc8505d 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java @@ -55,8 +55,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest(SearchStrategy.Factory.class) public class SearchTaskTest { - - SearchCriteria mSearchCriteria = SearchCriteria.none(); + private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock RepositoryRestApi.Factory mRepoApiFactory; @@ -74,7 +73,7 @@ public class SearchTaskTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchTask(mSearchCriteria, mRepoApiFactory, mInfoApiFactory); + objectUnderTest = new SearchTask(CRITERIA, mRepoApiFactory, mInfoApiFactory); when(mRepoApiFactory.get()).thenReturn(mRepoApi); when(mInfoApiFactory.get()).thenReturn(mInfoApi); @@ -82,7 +81,7 @@ public void setup() { when(mSearchStrategy.searchNext()).thenReturn(resultObservable); PowerMockito.mockStatic(SearchStrategy.Factory.class); - PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.Factory.class), any(SearchCriteria.class))).thenReturn(mSearchStrategy); + PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.Factory.class), any(InternalCriteria.class))).thenReturn(mSearchStrategy); } @Test @@ -91,7 +90,7 @@ public void nextLookupShouldDefineSearchStrategy() { objectUnderTest.nextLookup().toBlocking().first(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(mSearchCriteria)); + SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(CRITERIA)); verify(mInfoApi, times(1)).requestVersion(); verify(mInfoApiFactory, times(1)).get(); @@ -106,7 +105,7 @@ public void secondLookupShouldUseCachedStrategy() { objectUnderTest.nextLookup().toBlocking().first(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(mSearchCriteria)); + SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(CRITERIA)); verify(mInfoApi, times(1)).requestVersion(); verify(mInfoApiFactory, times(1)).get(); From fd1301eb7b6e9e0dfd242519a61c4847555f3cbb Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 28 Sep 2015 15:22:48 +0300 Subject: [PATCH 169/457] Add search task abstraction --- .../service/repository/RepositoryService.java | 2 +- .../sdk/service/repository/SearchTask.java | 71 +----------- .../service/repository/SearchTaskImpl.java | 105 ++++++++++++++++++ ...hTaskTest.java => SearchTaskImplTest.java} | 6 +- 4 files changed, 115 insertions(+), 69 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java rename client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/{SearchTaskTest.java => SearchTaskImplTest.java} (95%) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index cabdb4ec..2cf41527 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -49,7 +49,7 @@ public RepositoryService(RepositoryRestApi.Factory repositoryApiFactory, } public SearchTask search(SearchCriteria criteria) { - return new SearchTask(InternalCriteria.from(criteria), mRepositoryApiFactory, mInfoApiFactory); + return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryApiFactory, mInfoApiFactory); } public Observable requestFolder(@NonNull final String folderUri) { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index b6abaa20..da08c103 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -21,81 +21,22 @@ * along with Jaspersoft Mobile for Android. If not, see * . */ - package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.Nullable; +import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import java.util.Collection; import rx.Observable; -import rx.functions.Func0; -import rx.functions.Func1; /** * @author Tom Koptel * @since 2.0 */ -public final class SearchTask { - private final InternalCriteria mCriteria; - private final RepositoryRestApi.Factory mRepositoryApiFactory; - private final ServerRestApi.Factory mInfoApiFactory; - - @Nullable - private SearchStrategy strategy; - - SearchTask(InternalCriteria criteria, - RepositoryRestApi.Factory repositoryApiFactory, - ServerRestApi.Factory infoApiFactory) { - mCriteria = criteria; - mRepositoryApiFactory = repositoryApiFactory; - mInfoApiFactory = infoApiFactory; - } - - public Observable> nextLookup() { - return defineSearchStrategy().flatMap(new Func1>>() { - @Override - public Observable> call(SearchStrategy searchStrategy) { - return searchStrategy.searchNext(); - } - }); - } - - public boolean hasNext() { - /** - * Strategy not defined only, if user has not made any lookup requests. - * There is no 100% guarantee that API has items until we made request. - */ - if (strategy != null) { - return strategy.hasNext(); - } - return true; - } - - private Observable defineSearchStrategy() { - if (strategy == null) { - return requestServerVersion().flatMap(new Func1>() { - @Override - public Observable call(String version) { - strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); - return Observable.just(strategy); - } - }); - } - return Observable.just(strategy); - } - - private Observable requestServerVersion() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - String version = mInfoApiFactory.get().requestVersion(); - return Observable.just(version); - } - }); - } +public interface SearchTask { + @NonNull + Observable> nextLookup(); + boolean hasNext(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java new file mode 100644 index 00000000..20b6f1e3 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -0,0 +1,105 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; + +import java.util.Collection; + +import rx.Observable; +import rx.functions.Func0; +import rx.functions.Func1; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class SearchTaskImpl implements SearchTask { + private final InternalCriteria mCriteria; + private final RepositoryRestApi.Factory mRepositoryApiFactory; + private final ServerRestApi.Factory mInfoApiFactory; + + @Nullable + private SearchStrategy strategy; + + SearchTaskImpl(InternalCriteria criteria, + RepositoryRestApi.Factory repositoryApiFactory, + ServerRestApi.Factory infoApiFactory) { + mCriteria = criteria; + mRepositoryApiFactory = repositoryApiFactory; + mInfoApiFactory = infoApiFactory; + } + + @NonNull + @Override + public Observable> nextLookup() { + return defineSearchStrategy().flatMap(new Func1>>() { + @Override + public Observable> call(SearchStrategy searchStrategy) { + return searchStrategy.searchNext(); + } + }); + } + + @Override + public boolean hasNext() { + /** + * Strategy not defined only, if user has not made any lookup requests. + * There is no 100% guarantee that API has items until we made request. + */ + if (strategy != null) { + return strategy.hasNext(); + } + return true; + } + + private Observable defineSearchStrategy() { + if (strategy == null) { + return requestServerVersion().flatMap(new Func1>() { + @Override + public Observable call(String version) { + strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); + return Observable.just(strategy); + } + }); + } + return Observable.just(strategy); + } + + private Observable requestServerVersion() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + String version = mInfoApiFactory.get().requestVersion(); + return Observable.just(version); + } + }); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java similarity index 95% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index cfc8505d..23401eb3 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -54,7 +54,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest(SearchStrategy.Factory.class) -public class SearchTaskTest { +public class SearchTaskImplTest { private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock @@ -68,12 +68,12 @@ public class SearchTaskTest { @Mock SearchStrategy mSearchStrategy; - private SearchTask objectUnderTest; + private SearchTaskImpl objectUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchTask(CRITERIA, mRepoApiFactory, mInfoApiFactory); + objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApiFactory, mInfoApiFactory); when(mRepoApiFactory.get()).thenReturn(mRepoApi); when(mInfoApiFactory.get()).thenReturn(mInfoApi); From 2891f68c72ea29136882d6dca496d9a1794ca98c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 28 Sep 2015 15:32:12 +0300 Subject: [PATCH 170/457] Add precondtion for folder/report API --- .../service/repository/RepositoryService.java | 9 ++++++--- .../repository/RepositoryServiceTest.java | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 2cf41527..d5b9d889 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -24,12 +24,13 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.service.Preconditions; import rx.Observable; import rx.functions.Func0; @@ -52,7 +53,8 @@ public SearchTask search(SearchCriteria criteria) { return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryApiFactory, mInfoApiFactory); } - public Observable requestFolder(@NonNull final String folderUri) { + public Observable requestFolder(@Nullable final String folderUri) { + Preconditions.checkNotNull(folderUri, "Folder URI should not be null"); return Observable.defer(new Func0>() { @Override public Observable call() { @@ -63,7 +65,8 @@ public Observable call() { }); } - public Observable requestReport(@NonNull final String folderUri) { + public Observable requestReport(@Nullable final String folderUri) { + Preconditions.checkNotNull(folderUri, "Report URI should not be null"); return Observable.defer(new Func0>() { @Override public Observable call() { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 732040b2..92a63774 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -31,7 +31,9 @@ import org.hamcrest.Matchers; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -61,6 +63,9 @@ public class RepositoryServiceTest { private RepositoryService objectUnderTest; + @Rule + public ExpectedException mExpectedException = ExpectedException.none(); + @Before public void setup() { MockitoAnnotations.initMocks(this); @@ -93,4 +98,18 @@ public void shouldProvideReport() { verify(repoApi).requestReportResource("/uri"); } + + @Test + public void shouldNotAcceptNullUriForFolder() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Folder URI should not be null"); + objectUnderTest.requestFolder(null); + } + + @Test + public void shouldNotAcceptNullUriForReport() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Report URI should not be null"); + objectUnderTest.requestReport(null); + } } \ No newline at end of file From 6d583390c02f5b599dc756fb637683225f44f020 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 29 Sep 2015 16:25:10 +0300 Subject: [PATCH 171/457] Remove 'requestFolder' and 'requestReport' --- .../service/repository/RepositoryService.java | 32 ----------------- .../repository/RepositoryServiceTest.java | 34 ------------------- 2 files changed, 66 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index d5b9d889..b7576aa9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -24,16 +24,8 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.Nullable; - import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.service.Preconditions; - -import rx.Observable; -import rx.functions.Func0; /** * @author Tom Koptel @@ -52,28 +44,4 @@ public RepositoryService(RepositoryRestApi.Factory repositoryApiFactory, public SearchTask search(SearchCriteria criteria) { return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryApiFactory, mInfoApiFactory); } - - public Observable requestFolder(@Nullable final String folderUri) { - Preconditions.checkNotNull(folderUri, "Folder URI should not be null"); - return Observable.defer(new Func0>() { - @Override - public Observable call() { - FolderLookupResponse result = mRepositoryApiFactory.get() - .requestFolderResource(folderUri); - return Observable.just(result); - } - }); - } - - public Observable requestReport(@Nullable final String folderUri) { - Preconditions.checkNotNull(folderUri, "Report URI should not be null"); - return Observable.defer(new Func0>() { - @Override - public Observable call() { - ReportLookupResponse result = mRepositoryApiFactory.get() - .requestReportResource(folderUri); - return Observable.just(result); - } - }); - } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 92a63774..917bbefc 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -78,38 +78,4 @@ public void shouldProvideListOfResources() { SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); assertThat(searchTask, is(notNullValue())); } - - @Test - public void shouldProvideFolder() { - when(repoApi.requestFolderResource(anyString())).thenReturn(mFolderResponse); - - FolderLookupResponse result = objectUnderTest.requestFolder("/uri").toBlocking().first(); - assertThat(result, is(Matchers.notNullValue())); - - verify(repoApi).requestFolderResource("/uri"); - } - - @Test - public void shouldProvideReport() { - when(repoApi.requestReportResource(anyString())).thenReturn(mReportResponse); - - ReportLookupResponse result = objectUnderTest.requestReport("/uri").toBlocking().first(); - assertThat(result, is(Matchers.notNullValue())); - - verify(repoApi).requestReportResource("/uri"); - } - - @Test - public void shouldNotAcceptNullUriForFolder() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Folder URI should not be null"); - objectUnderTest.requestFolder(null); - } - - @Test - public void shouldNotAcceptNullUriForReport() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Report URI should not be null"); - objectUnderTest.requestReport(null); - } } \ No newline at end of file From 1b9d09d1061ec400d3a7afb9fa64ca4633f150c9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 29 Sep 2015 16:28:01 +0300 Subject: [PATCH 172/457] Remove 'SearchResult' --- .../sdk/service/repository/SearchResult.java | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java deleted file mode 100644 index 66f1e43c..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResult.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; - -import java.util.Collections; -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class SearchResult { - private static final SearchResult EMPTY = new SearchResult(Collections.emptyList(), false); - - private final List mResult; - private final boolean mReachedEnd; - - private SearchResult(List raw, boolean endResult) { - mResult = raw; - mReachedEnd = endResult; - } - - public List getResult() { - return mResult; - } - - public boolean hasReachedEnd() { - return mReachedEnd; - } - - public static SearchResult reachedEnd(ResourceSearchResponse response) { - return new SearchResult(response.getResources(), true); - } - - public static SearchResult create(ResourceSearchResponse response) { - return new SearchResult(response.getResources(), false); - } -} From 7b06f2b2d7454ef8793dad27dcf77433c7302c57 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 1 Oct 2015 11:16:54 +0300 Subject: [PATCH 173/457] Provide encoded true flag for report option label --- .../sdk/network/api/AdapterBuilder.java | 5 ++++- .../network/api/ReportOptionRestApiTest.java | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java index 1f2879eb..eb086dca 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java @@ -78,7 +78,10 @@ Retrofit.Builder getAdapter() { OkHttpClient client = clientBuilder.build(); mRestAdapterBuilder.client(client); mRestAdapterBuilder.baseUrl(baseUrl); - mRestAdapterBuilder.addConverterFactory(mStringConverterFactory); + /** + * TODO this is broken + */ +// mRestAdapterBuilder.addConverterFactory(mStringConverterFactory); mRestAdapterBuilder.addConverterFactory(mGsonConverterFactory); return mRestAdapterBuilder; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index c853ed80..db16cece 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -27,6 +27,8 @@ import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.RecordedRequest; import org.junit.Before; import org.junit.Rule; @@ -36,6 +38,12 @@ import org.mockito.MockitoAnnotations; import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; /** * @author Tom Koptel @@ -152,4 +160,17 @@ public void deleteReportOptionShouldNotAllowNullOptionId() { mExpectedException.expectMessage("Option id should not be null"); restApiUnderTest.deleteReportOption("any_id", null); } + + @Test + public void shouldNotEncodeReportOptionLabelDuringCreation() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200(); + mWebMockRule.enqueue(mockResponse); + + Map> params = new HashMap<>(); + params.put("key", Collections.emptySet()); + + restApiUnderTest.createReportOption("/any/uri", "my label", params, true); + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options?label=my%20label&overwrite=true")); + } } From b7dec32177612ca9da7404ef41fb61c7b0008c13 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 1 Oct 2015 12:09:50 +0300 Subject: [PATCH 174/457] Fixing StringConverter type resolution issue --- .../sdk/network/api/AdapterBuilder.java | 6 +- .../network/api/StringConverterFactory.java | 7 +- .../sdk/network/api/ServerRestApiTest.java | 128 +++++++++++++++++- 3 files changed, 129 insertions(+), 12 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java index eb086dca..992f5045 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java @@ -78,10 +78,8 @@ Retrofit.Builder getAdapter() { OkHttpClient client = clientBuilder.build(); mRestAdapterBuilder.client(client); mRestAdapterBuilder.baseUrl(baseUrl); - /** - * TODO this is broken - */ -// mRestAdapterBuilder.addConverterFactory(mStringConverterFactory); + + mRestAdapterBuilder.addConverterFactory(mStringConverterFactory); mRestAdapterBuilder.addConverterFactory(mGsonConverterFactory); return mRestAdapterBuilder; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java index 47afed62..ff3d7cd0 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network.api; +import com.google.gson.reflect.TypeToken; import com.squareup.okhttp.MediaType; import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.ResponseBody; @@ -47,8 +48,8 @@ public static StringConverterFactory create() { @Override public Converter get(Type type) { - Class cls = (Class) type; - if (String.class.isAssignableFrom(cls)) { + Type stringType = new TypeToken() {}.getType(); + if (stringType.equals(type)) { return new StringConverter(); } return null; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java index 83b2cb30..69a69afc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java @@ -31,7 +31,9 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.MockitoAnnotations; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; /** * @author Tom Koptel @@ -44,16 +46,132 @@ public class ServerRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); + private ServerRestApi objectUnderTest; + + @Before + public void setup() { + objectUnderTest = new ServerRestApi.Builder() + .baseUrl(mWebMockRule.getRootUrl()) + .build(); + } + @Test public void shouldThroughRestErrorForHttpError() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - ServerRestApi restApi = new ServerRestApi.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .build(); - restApi.requestServerInfo(); + objectUnderTest.requestServerInfo(); + } + + @Test + public void shouldHandlePlainTextResponseForBuild() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("Enterprise for AWS") + ); + String editionName = objectUnderTest.requestBuild(); + assertThat(editionName, is("Enterprise for AWS")); + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/build")); + } + + @Test + public void shouldHandlePlainTextResponseForDateFormatPattern() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("yyyy-MM-dd") + ); + String editionName = objectUnderTest.requestDateFormatPattern(); + assertThat(editionName, is("yyyy-MM-dd")); + + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/dateFormatPattern")); + } + + @Test + public void shouldHandlePlainTextResponseForDatetimeFormatPattern() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("yyyy-MM-dd'T'HH:mm:ss") + ); + String editionName = objectUnderTest.requestDateTimeFormatPattern(); + assertThat(editionName, is("yyyy-MM-dd'T'HH:mm:ss")); + + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/datetimeFormatPattern")); + } + + @Test + public void shouldHandlePlainTextResponseForEdition() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("PRO") + ); + String editionName = objectUnderTest.requestEdition(); + assertThat(editionName, is("PRO")); + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/edition")); + } + + + @Test + public void shouldHandlePlainTextResponseForEditionName() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("Enterprise for AWS") + ); + String editionName = objectUnderTest.requestEditionName(); + assertThat(editionName, is("Enterprise for AWS")); + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/editionName")); + } + + @Test + public void shouldHandlePlainTextResponseForExpiration() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("1000") + ); + String editionName = objectUnderTest.requestExpiration(); + assertThat(editionName, is("1000")); + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/expiration")); } + @Test + public void shouldHandlePlainTextResponseForFeatures() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("Fusion AHD EXP DB ANA AUD MT ") + ); + String editionName = objectUnderTest.requestFeatures(); + assertThat(editionName, is("Fusion AHD EXP DB ANA AUD MT ")); + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/features")); + } + + @Test + public void shouldHandlePlainTextResponseForLicenseType() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("Commercial") + ); + String editionName = objectUnderTest.requestLicenseType(); + assertThat(editionName, is("Commercial")); + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/licenseType")); + } + + @Test + public void shouldHandlePlainTextResponseFor() throws Exception { + mWebMockRule.enqueue( + MockResponseFactory.create200().setBody("5.5.0") + ); + String editionName = objectUnderTest.requestVersion(); + assertThat(editionName, is("5.5.0")); + + String path = mWebMockRule.get().takeRequest().getPath(); + assertThat(path, is("/rest_v2/serverInfo/version")); + } } From 78a0f8e4e205ed8a2b9c7c548c0cec79e7b2ff66 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 11:07:54 +0300 Subject: [PATCH 175/457] Removing RxJava dependency --- client-service/build.gradle | 1 - .../sdk/service/GreedyInfoProvider.java | 5 +-- .../sdk/service/ServerInfoService.java | 26 ++----------- .../android/sdk/service/auth/AuthService.java | 3 +- .../sdk/service/auth/SpringAuthService.java | 27 ++----------- .../repository/EmeraldMR2SearchStrategy.java | 27 +++++-------- .../repository/EmeraldMR3SearchStrategy.java | 25 +++++------- .../service/repository/SearchStrategy.java | 4 +- .../sdk/service/repository/SearchTask.java | 4 +- .../service/repository/SearchTaskImpl.java | 38 ++++--------------- .../sdk/service/ServerInfoServiceTest.java | 2 +- .../service/auth/SpringAuthServiceTest.java | 4 +- .../EmeraldMR2SearchStrategyTest.java | 10 ++--- .../EmeraldMR3SearchStrategyTest.java | 27 ++++--------- .../repository/RepositoryServiceTest.java | 3 -- .../repository/SearchTaskImplTest.java | 14 ++----- 16 files changed, 57 insertions(+), 163 deletions(-) diff --git a/client-service/build.gradle b/client-service/build.gradle index e7ff8b54..cc06e56b 100644 --- a/client-service/build.gradle +++ b/client-service/build.gradle @@ -35,7 +35,6 @@ android { dependencies { compile project(':js-android-sdk-client-network') compile 'com.android.support:support-annotations:22.2.0' - compile 'io.reactivex:rxjava:1.0.14' testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java index 95714a60..0922f641 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -53,7 +53,6 @@ public static InfoProvider newInstance(String serverUrl) { @NonNull @WorkerThread public ServerInfo provideInfo() { - return mServerInfoService.requestServerInfo() - .toBlocking().first(); + return mServerInfoService.requestServerInfo(); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index e72f6378..861f63a6 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -6,10 +6,6 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import rx.Observable; -import rx.functions.Func0; -import rx.functions.Func1; - /** * @author Tom Koptel * @since 2.0 @@ -36,24 +32,8 @@ public static ServerInfoService newInstance(String baseUrl) { return new ServerInfoService(restApi, ServerInfoTransformer.getInstance()); } - /** - * TODO: Replace with abstract ASYNC policy - */ - public rx.Observable requestServerInfo() { - return requestApiCall().flatMap(new Func1>() { - @Override - public Observable call(ServerInfoResponse response) { - return Observable.just(mTransformer.transform(response)); - } - }); - } - - private rx.Observable requestApiCall() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - return Observable.just(mRestApi.requestServerInfo()); - } - }); + public ServerInfo requestServerInfo() { + ServerInfoResponse response = mRestApi.requestServerInfo(); + return mTransformer.transform(response); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 35c95573..993d2252 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.api.auth.Token; -import rx.Observable; /** * @author Tom Koptel @@ -36,5 +35,5 @@ */ public interface AuthService { @NonNull - Observable> authenticate(); + Token authenticate(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index fabcbe17..4dea3583 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -40,10 +40,6 @@ import java.util.Map; import java.util.TimeZone; -import rx.Observable; -import rx.functions.Func0; -import rx.functions.Func1; - import static com.jaspersoft.android.sdk.service.Preconditions.checkNotNull; /** @@ -80,26 +76,9 @@ public final class SpringAuthService implements AuthService { @NonNull @Override - public Observable> authenticate() { - return authenticationCall() - .flatMap(new Func1>>() { - @Override - public Observable> call(AuthResponse authResponse) { - Token cookieToken = CookieToken.create(authResponse.getToken()); - return Observable.just(cookieToken); - } - }); - } - - @NonNull - private Observable authenticationCall() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - AuthResponse response = invokeAuthentication(); - return Observable.just(response); - } - }); + public Token authenticate() { + AuthResponse authResponse = invokeAuthentication(); + return CookieToken.create(authResponse.getToken()); } @NonNull diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index f68cc1f5..b2c5cfb9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -35,9 +35,6 @@ import java.util.LinkedList; import java.util.List; -import rx.Observable; -import rx.functions.Func0; - /** * @author Tom Koptel * @since 2.0 @@ -60,21 +57,15 @@ public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, } @Override - public Observable> searchNext() { - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - int limit = mInitialCriteria.getLimit(); - int offset = mInitialCriteria.getOffset(); - - if (mEndReached || limit == 0) { - return Observable.just(EMPTY_RESPONSE); - } - - calculateDisposition(offset); - return Observable.just(internalSearch(limit)); - } - }); + public Collection searchNext() { + int limit = mInitialCriteria.getLimit(); + int offset = mInitialCriteria.getOffset(); + + if (mEndReached || limit == 0) { + return EMPTY_RESPONSE; + } + calculateDisposition(offset); + return internalSearch(limit); } @Override diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 0861e7cc..a874cf8a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -33,9 +33,6 @@ import java.util.Collection; import java.util.Collections; -import rx.Observable; -import rx.functions.Func0; - /** * @author Tom Koptel * @since 2.0 @@ -61,19 +58,15 @@ public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, } @Override - public Observable> searchNext() { - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - if (mEndReached || mInitialCriteria.getLimit() == 0){ - return Observable.just(EMPTY_RESPONSE); - } - if (mInternalOffset == UNDEFINED) { - defineInternalOffset(); - } - return Observable.just(performLookup()); - } - }); + public Collection searchNext() { + if (mEndReached || mInitialCriteria.getLimit() == 0){ + return EMPTY_RESPONSE; + } + if (mInternalOffset == UNDEFINED) { + defineInternalOffset(); + } + + return performLookup(); } @Override diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 605f2c97..a48b397b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -30,14 +30,12 @@ import java.util.Collection; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 */ interface SearchStrategy { - Observable> searchNext(); + Collection searchNext(); boolean hasNext(); class Factory { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index da08c103..25bdb31b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -29,14 +29,12 @@ import java.util.Collection; -import rx.Observable; - /** * @author Tom Koptel * @since 2.0 */ public interface SearchTask { @NonNull - Observable> nextLookup(); + Collection nextLookup(); boolean hasNext(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 20b6f1e3..b7e0604d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -33,10 +33,6 @@ import java.util.Collection; -import rx.Observable; -import rx.functions.Func0; -import rx.functions.Func1; - /** * @author Tom Koptel * @since 2.0 @@ -59,13 +55,8 @@ final class SearchTaskImpl implements SearchTask { @NonNull @Override - public Observable> nextLookup() { - return defineSearchStrategy().flatMap(new Func1>>() { - @Override - public Observable> call(SearchStrategy searchStrategy) { - return searchStrategy.searchNext(); - } - }); + public Collection nextLookup() { + return defineSearchStrategy().searchNext(); } @Override @@ -80,26 +71,13 @@ public boolean hasNext() { return true; } - private Observable defineSearchStrategy() { + private SearchStrategy defineSearchStrategy() { if (strategy == null) { - return requestServerVersion().flatMap(new Func1>() { - @Override - public Observable call(String version) { - strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); - return Observable.just(strategy); - } - }); - } - return Observable.just(strategy); - } + String version = mInfoApiFactory.get().requestVersion(); + strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); - private Observable requestServerVersion() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - String version = mInfoApiFactory.get().requestVersion(); - return Observable.just(version); - } - }); + + } + return strategy; } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java index a467514f..f8a0c524 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java @@ -42,7 +42,7 @@ public void setup() { public void requestInfoShouldProvideServerInfoDataObject() { when(mockApi.requestServerInfo()).thenReturn(mockResponse); - serviceUnderTest.requestServerInfo().subscribe(); + serviceUnderTest.requestServerInfo(); verify(mockTransformer, times(1)).transform(mockResponse); verify(mockApi, times(1)).requestServerInfo(); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index b24c6180..e527bafd 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -82,7 +82,7 @@ public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { when(mKey.getModulus()).thenReturn("m"); when(mAlgorithm.encrypt(anyString(), anyString(), anyString())).thenReturn("hashed password"); - objectUnderTest.authenticate().subscribe(); + objectUnderTest.authenticate(); verify(mRestApi, times(1)).authenticate("user", "hashed password", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); @@ -93,7 +93,7 @@ public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() { when(mKey.isAvailable()).thenReturn(false); - objectUnderTest.authenticate().subscribe(); + objectUnderTest.authenticate(); verify(mRestApi, times(1)).authenticate("user", "1234", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index 1b592a66..69ee55da 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -74,7 +74,7 @@ public void setupMocks() { public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); - Collection result = search10itemsStrategy.searchNext().toBlocking().first(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(10)); Map params = new HashMap<>(); @@ -93,7 +93,7 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce public void willRetry5timesIfApiReturnsNoElements()throws Exception { when(mResponse.getResources()).thenReturn(Collections.emptyList()); - Collection result = search10itemsStrategy.searchNext().toBlocking().first(); + Collection result = search10itemsStrategy.searchNext(); assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); @@ -105,7 +105,7 @@ public void willRetry5timesIfApiReturnsNoElements()throws Exception { public void willReturnAsMuchElementsAsLeftIfEndReached()throws Exception { when(mResponse.getResources()).then(OnlyTwoItems.INSTANCE); - Collection result = search10itemsStrategy.searchNext().toBlocking().first(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(2)); verify(mApiFactory, times(6)).get(); @@ -116,7 +116,7 @@ public void willReturnAsMuchElementsAsLeftIfEndReached()throws Exception { public void forCustomOffsetShouldCalculateServerDisposition()throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); - search10itemsStrategyWithUserOffset5.searchNext().toBlocking().first(); + search10itemsStrategyWithUserOffset5.searchNext(); Map params1 = new HashMap<>(); params1.put("limit", "5"); @@ -141,7 +141,7 @@ public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); - Collection result = strategy.searchNext().toBlocking().first(); + Collection result = strategy.searchNext(); assertThat(result, is(empty())); verifyZeroInteractions(mApi); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index a370328a..56a2f2d1 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -19,8 +19,6 @@ import java.util.List; import java.util.Map; -import rx.observers.TestSubscriber; - import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -64,7 +62,7 @@ public void shouldMakeImmediateCallOnApiForUserOffsetZero() { when(mApi.searchResources(anyMap())).thenReturn(mResponse); - performSearch(strategy); + strategy.searchNext(); Map params = new HashMap<>(); params.put("forceFullPage", "true"); @@ -77,7 +75,7 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); - performSearch(strategy); + strategy.searchNext(); Map params = new HashMap<>(); params.put("forceFullPage", "true"); @@ -92,10 +90,10 @@ public void secondSearchLookupShouldUseNextOffset() { EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); when(mResponse.getNextOffset()).thenReturn(133); - performSearch(strategy); + strategy.searchNext(); when(mResponse.getNextOffset()).thenReturn(233); - performSearch(strategy); + strategy.searchNext(); Map params = new HashMap<>(); @@ -112,13 +110,12 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, NO_CRITERIA); when(mResponse.getNextOffset()).thenReturn(133); - performSearch(strategy); + strategy.searchNext(); when(mResponse.getNextOffset()).thenReturn(0); - performSearch(strategy); + strategy.searchNext(); - List> events = performSearch(strategy).getOnNextEvents(); - Collection response = events.get(0); + Collection response = strategy.searchNext(); assertThat(response, is(empty())); assertThat(strategy.hasNext(), is(false)); @@ -132,17 +129,9 @@ public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, userCriteria); - Collection result = strategy.searchNext().toBlocking().first(); + Collection result = strategy.searchNext(); assertThat(result, Matchers.is(Matchers.empty())); verifyZeroInteractions(mApi); } - - private TestSubscriber performSearch(EmeraldMR3SearchStrategy strategy) { - TestSubscriber> testSubscriber = new TestSubscriber<>(); - strategy.searchNext().subscribe(testSubscriber); - testSubscriber.assertNoErrors(); - - return testSubscriber; - } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 917bbefc..562730c8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -29,7 +29,6 @@ import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; -import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -40,8 +39,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index 23401eb3..ed716617 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; import org.junit.Before; import org.junit.Test; @@ -37,10 +36,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import java.util.Collection; - -import rx.Observable; - import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -77,8 +72,7 @@ public void setup() { when(mRepoApiFactory.get()).thenReturn(mRepoApi); when(mInfoApiFactory.get()).thenReturn(mInfoApi); - Observable> resultObservable = Observable.just(null); - when(mSearchStrategy.searchNext()).thenReturn(resultObservable); + when(mSearchStrategy.searchNext()).thenReturn(null); PowerMockito.mockStatic(SearchStrategy.Factory.class); PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.Factory.class), any(InternalCriteria.class))).thenReturn(mSearchStrategy); @@ -87,7 +81,7 @@ public void setup() { @Test public void nextLookupShouldDefineSearchStrategy() { when(mInfoApi.requestVersion()).thenReturn("5.5"); - objectUnderTest.nextLookup().toBlocking().first(); + objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(CRITERIA)); @@ -101,8 +95,8 @@ public void nextLookupShouldDefineSearchStrategy() { public void secondLookupShouldUseCachedStrategy() { when(mInfoApi.requestVersion()).thenReturn("5.5"); - objectUnderTest.nextLookup().toBlocking().first(); - objectUnderTest.nextLookup().toBlocking().first(); + objectUnderTest.nextLookup(); + objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(CRITERIA)); From 8602915a7be3d307ebb6a4aba0bc9ee9a9986228 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 11:12:11 +0300 Subject: [PATCH 176/457] Fix broken SpringAuthBuilder validation error --- .../android/sdk/service/auth/SpringAuthServiceBuilderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java index 0270d587..f5f59981 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java @@ -120,7 +120,7 @@ public void serviceShouldThrowIfBuildWithNullPassword() { @Test public void serviceShouldThrowIfBuildWithNullRestApi() { mException.expect(IllegalStateException.class); - mException.expectMessage("Rest api should not be null. Either set it or call withDefaultApiProvider(url)"); + mException.expectMessage("Rest api should not be null. Either set it or call useDefaultApi(url)"); objectUnderTest.username(""); objectUnderTest.password(""); From e64c65eb855f10acfc1fbe4037d173eab0fd271d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 11:44:07 +0300 Subject: [PATCH 177/457] Add initial API for report execution --- .../network/api/ReportExecutionRestApi.java | 4 ++ .../execution/ExecutionRequestOptions.java | 12 ++-- .../sdk/service/report/ExecutionSession.java | 50 ++++++++++++++ .../report/ReportOptionRestApiFactory.java | 50 ++++++++++++++ .../sdk/service/report/ReportService.java | 68 +++++++++++++++++++ 5 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionRestApiFactory.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index daeb8804..a48c5053 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -67,6 +67,10 @@ public interface ReportExecutionRestApi { @WorkerThread ReportExecutionSearchResponse searchReportExecution(Map params); + interface Factory { + ReportExecutionRestApi get(); + } + final class Builder extends GenericAuthBuilder { @Override ReportExecutionRestApi createApi() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 815ed4cc..1738730c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -28,7 +28,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.Arrays; +import java.util.Map; import java.util.Set; /** @@ -62,7 +62,7 @@ public class ExecutionRequestOptions { @Expose protected String attachmentsPrefix; @Expose - protected ReportParameters parameters; + protected Map> parameters; protected ExecutionRequestOptions() {} @@ -95,8 +95,8 @@ public ExecutionRequestOptions withSaveDataSnapshot(boolean saveDataSnapshot) { return this; } - public ExecutionRequestOptions withParameters(Set parameters) { - this.parameters = ReportParameters.wrap(parameters); + public ExecutionRequestOptions withParameters(Map> parameters) { + this.parameters = parameters; return this; } @@ -185,8 +185,8 @@ public String getPages() { return pages; } - public Set getParameters() { - return parameters.getReportParameters(); + public Map> getParameters() { + return parameters; } public Boolean getSaveDataSnapshot() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java new file mode 100644 index 00000000..afd13c40 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java @@ -0,0 +1,50 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExecutionSession { + private final ReportExecutionRestApi.Factory mExecutionApiFactory; + private final String mId; + + public ExecutionSession(ReportExecutionRestApi.Factory executionApiFactory, ReportExecutionDetailsResponse details) { + mExecutionApiFactory = executionApiFactory; + mId = details.getExecutionId(); + } + + public ReportExecutionDetailsResponse requestDetails() { + return mExecutionApiFactory.get().requestReportExecutionDetails(mId); + } + + public ExecutionStatusResponse requestStatus() { + return mExecutionApiFactory.get().requestReportExecutionStatus(mId); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionRestApiFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionRestApiFactory.java new file mode 100644 index 00000000..29bfd7be --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionRestApiFactory.java @@ -0,0 +1,50 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.service.TokenProvider; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportOptionRestApiFactory implements ReportExecutionRestApi.Factory { + + private final TokenProvider mTokenProvider; + private final String mServerUrl; + + ReportOptionRestApiFactory(String serverUrl, TokenProvider tokenProvider) { + mServerUrl = serverUrl; + mTokenProvider = tokenProvider; + } + + @Override + public ReportExecutionRestApi get() { + return new ReportExecutionRestApi.Builder() + .baseUrl(mServerUrl) + .token(mTokenProvider.provideToken()) + .build(); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java new file mode 100644 index 00000000..a6e924b3 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -0,0 +1,68 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.TokenProvider; +import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; + +import java.util.Map; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportService { + private final ReportExecutionRestApi.Factory mExecutionApiFactory; + private final ServerRestApi.Factory mInfoApiFactory; + private final String mBaseUrl; + + public ReportService(String serverUrl, TokenProvider tokenProvider) { + mBaseUrl = serverUrl; + mExecutionApiFactory = new ReportOptionRestApiFactory(serverUrl, tokenProvider); + mInfoApiFactory = new ServerRestApiFactory(serverUrl); + } + + public ExecutionSession run(String reportUri, Map> reportParameter) { + ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); + options.withBaseUrl(mBaseUrl); + options.withParameters(reportParameter); + options.withAsync(true); + options.withIgnorePagination(false); + + // TODO: following parameters should be configurable + options.withFreshData(true); + options.withInteractive(true); + options.withSaveDataSnapshot(true); + options.withOutputFormat("HTML"); + options.withPages("1"); + + ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); + return new ExecutionSession(mExecutionApiFactory, details); + } +} From c8b76daea7f0fa2cc4627290127db91a9c59a96e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 12:28:56 +0300 Subject: [PATCH 178/457] Introducing ExecutionConfiguration --- .../report/ExecutionConfiguration.java | 126 ++++++++++++++++++ .../report/ExecutionOptionsDataMapper.java | 58 ++++++++ .../sdk/service/report/ReportService.java | 37 ++--- .../report/ExecutionConfigurationTest.java | 53 ++++++++ 4 files changed, 257 insertions(+), 17 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java new file mode 100644 index 00000000..30b258ea --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java @@ -0,0 +1,126 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExecutionConfiguration { + + private final boolean mFreshData; + private final boolean mInteractive; + private final boolean mSaveSnapshot; + private final int mFormat; + private final String mPages; + + ExecutionConfiguration(Builder builder) { + mFreshData = builder.freshData; + mInteractive = builder.interactive; + mSaveSnapshot = builder.saveSnapshot; + mFormat = builder.format; + mPages = builder.pages; + } + + public static class Format { + public static int NONE = 0; + public static int HTML = 1; + public static int PDF = 2; + public static int XLS = 3; + + private Format() { + } + } + + @NonNull + public static Builder builder() { + return new Builder(); + } + + public int getFormat() { + return mFormat; + } + + public boolean isFreshData() { + return mFreshData; + } + + public boolean isInteractive() { + return mInteractive; + } + + @Nullable + public String getPages() { + return mPages; + } + + public boolean isSaveSnapshot() { + return mSaveSnapshot; + } + + public static class Builder { + private boolean freshData; + private boolean interactive; + private boolean saveSnapshot; + private int format; + private String pages; + + public Builder() { + interactive = true; + format = Format.NONE; + } + + public Builder freshData(boolean freshData) { + this.freshData = freshData; + return this; + } + + public Builder interactive(boolean interactive) { + this.interactive = interactive; + return this; + } + + public Builder saveSnapshot(boolean saveSnapshot) { + this.saveSnapshot = saveSnapshot; + return this; + } + + public Builder format(int format) { + this.format = format; + return this; + } + + public Builder pages(@Nullable String pages) { + this.pages = pages; + return this; + } + + public ExecutionConfiguration create() { + return new ExecutionConfiguration(this); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java new file mode 100644 index 00000000..71162d7f --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -0,0 +1,58 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; + +import java.util.Map; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ExecutionOptionsDataMapper { + + private static class InstanceHolder { + private static ExecutionOptionsDataMapper INSTANCE = new ExecutionOptionsDataMapper(); + } + + private ExecutionOptionsDataMapper() { + // single instance + } + + public static ExecutionOptionsDataMapper getInstance() { + return InstanceHolder.INSTANCE; + } + + public ReportExecutionRequestOptions transform(@NonNull String baseUrl, + @NonNull String uri, + @NonNull ExecutionConfiguration criteria, + @Nullable Map> reportParameter) { + throw new UnsupportedOperationException(); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index a6e924b3..2d7ed0a8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -23,6 +23,8 @@ */ package com.jaspersoft.android.sdk.service.report; +import android.support.annotation.VisibleForTesting; + import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; @@ -41,27 +43,28 @@ public class ReportService { private final ReportExecutionRestApi.Factory mExecutionApiFactory; private final ServerRestApi.Factory mInfoApiFactory; private final String mBaseUrl; + private final ExecutionOptionsDataMapper mExecutionOptionsMapper; - public ReportService(String serverUrl, TokenProvider tokenProvider) { - mBaseUrl = serverUrl; - mExecutionApiFactory = new ReportOptionRestApiFactory(serverUrl, tokenProvider); - mInfoApiFactory = new ServerRestApiFactory(serverUrl); + @VisibleForTesting + ReportService(String baseUrl, + ReportExecutionRestApi.Factory executionApiFactory, + ServerRestApi.Factory infoApiFactory, + ExecutionOptionsDataMapper executionOptionsMapper) { + mExecutionApiFactory = executionApiFactory; + mInfoApiFactory = infoApiFactory; + mBaseUrl = baseUrl; + mExecutionOptionsMapper = executionOptionsMapper; } - public ExecutionSession run(String reportUri, Map> reportParameter) { - ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); - options.withBaseUrl(mBaseUrl); - options.withParameters(reportParameter); - options.withAsync(true); - options.withIgnorePagination(false); - - // TODO: following parameters should be configurable - options.withFreshData(true); - options.withInteractive(true); - options.withSaveDataSnapshot(true); - options.withOutputFormat("HTML"); - options.withPages("1"); + public static ReportService create(String serverUrl, TokenProvider tokenProvider) { + ReportOptionRestApiFactory executionApiFactory = new ReportOptionRestApiFactory(serverUrl, tokenProvider); + ServerRestApiFactory infoApiFactory = new ServerRestApiFactory(serverUrl); + ExecutionOptionsDataMapper executionOptionsMapper = ExecutionOptionsDataMapper.getInstance(); + return new ReportService(serverUrl, executionApiFactory, infoApiFactory, executionOptionsMapper); + } + public ExecutionSession run(String reportUri, ExecutionConfiguration configuration, Map> reportParameter) { + ReportExecutionRequestOptions options = mExecutionOptionsMapper.transform(mBaseUrl, reportUri, configuration, reportParameter); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); return new ExecutionSession(mExecutionApiFactory, details); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java new file mode 100644 index 00000000..8fa3b879 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ExecutionConfigurationTest { + private ExecutionConfiguration objectUnderTest; + + @Before + public void setUp() throws Exception { + objectUnderTest = ExecutionConfiguration.builder().create(); + } + + @Test + public void interactiveShouldBeTrueByDefault() { + assertThat(objectUnderTest.isInteractive(), is(true)); + } + + @Test + public void interactiveShouldBeNoneByDefault() { + assertThat(objectUnderTest.getFormat(), is(ExecutionConfiguration.Format.NONE)); + } +} From 39288346346f18bcdcaddc1c1bdba3afb1959c33 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 13:50:53 +0300 Subject: [PATCH 179/457] Add implementation of Options mapper --- .../execution/ExecutionRequestOptions.java | 29 +------ .../ReportExecutionRequestOptions.java | 8 +- .../ReportExecutionRequestOptionsTest.java | 6 -- .../report/ExecutionConfiguration.java | 52 +++++++++---- .../report/ExecutionOptionsDataMapper.java | 50 +++++++++--- .../sdk/service/report/ReportService.java | 13 ++-- .../report/ExecutionConfigurationTest.java | 5 -- .../ExecutionOptionsDataMapperTest.java | 63 +++++++++++++++ .../sdk/service/report/ReportServiceTest.java | 76 +++++++++++++++++++ 9 files changed, 228 insertions(+), 74 deletions(-) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 1738730c..ab83bb1f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -26,8 +26,6 @@ import com.google.gson.annotations.Expose; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.Map; import java.util.Set; @@ -64,7 +62,8 @@ public class ExecutionRequestOptions { @Expose protected Map> parameters; - protected ExecutionRequestOptions() {} + protected ExecutionRequestOptions() { + } public static ExecutionRequestOptions create() { return new ExecutionRequestOptions(); @@ -101,53 +100,31 @@ public ExecutionRequestOptions withParameters(Map> parameter } public ExecutionRequestOptions withAttachmentsPrefix(String attachmentsPrefix) { - if (attachmentsPrefix == null || attachmentsPrefix.length() == 0) { - throw new IllegalArgumentException("Attachment prefix should not be null or empty"); - } - try { - this.attachmentsPrefix = URLEncoder.encode(attachmentsPrefix, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException("This should not be possible", e); - } + this.attachmentsPrefix = attachmentsPrefix; return this; } public ExecutionRequestOptions withOutputFormat(String outputFormat) { - if (outputFormat == null || outputFormat.length() == 0) { - throw new IllegalArgumentException("Output format should not be null or empty"); - } this.outputFormat = outputFormat; return this; } public ExecutionRequestOptions withPages(String pages) { - if (pages == null || pages.length() == 0) { - throw new IllegalArgumentException("Pages should not be null or empty"); - } this.pages = pages; return this; } public ExecutionRequestOptions withTransformerKey(String transformerKey) { - if (transformerKey == null || transformerKey.length() == 0) { - throw new IllegalArgumentException("Transform key should not be null or empty"); - } this.transformerKey = transformerKey; return this; } public ExecutionRequestOptions withAnchor(String anchor) { - if (anchor == null || anchor.length() == 0) { - throw new IllegalArgumentException("Anchor should not be null or empty"); - } this.anchor = anchor; return this; } public ExecutionRequestOptions withBaseUrl(String baseUrl) { - if (baseUrl == null || baseUrl.length() == 0) { - throw new IllegalArgumentException("Base url should not be null or empty"); - } this.baseUrl = baseUrl; return this; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java index 61f9fe6f..5035ec11 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java @@ -30,7 +30,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportExecutionRequestOptions extends ExecutionRequestOptions { +public class ReportExecutionRequestOptions extends ExecutionRequestOptions { @Expose private final String reportUnitUri; @@ -39,9 +39,13 @@ private ReportExecutionRequestOptions(String reportUnitUri) { } public static ReportExecutionRequestOptions newRequest(String uri) { - if (uri == null || uri.length() == 0) { + if (uri == null) { throw new IllegalArgumentException("Uri should not be null"); } return new ReportExecutionRequestOptions(uri); } + + public String getReportUnitUri() { + return reportUnitUri; + } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java index 8049efc4..3f8364a1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java @@ -41,10 +41,4 @@ public void factoryMethodShouldNotAllowNull() { mExpectedException.expect(IllegalArgumentException.class); ReportExecutionRequestOptions.newRequest(null); } - - @Test - public void factoryMethodShouldNotAllowEmptyString() { - mExpectedException.expect(IllegalArgumentException.class); - ReportExecutionRequestOptions.newRequest(""); - } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java index 30b258ea..d5fe0394 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java @@ -26,6 +26,9 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import java.util.Map; +import java.util.Set; + /** * @author Tom Koptel * @since 2.0 @@ -35,8 +38,10 @@ public final class ExecutionConfiguration { private final boolean mFreshData; private final boolean mInteractive; private final boolean mSaveSnapshot; - private final int mFormat; + private final Format mFormat; private final String mPages; + private final Map> mParams; + private final String mAttachmentPrefix; ExecutionConfiguration(Builder builder) { mFreshData = builder.freshData; @@ -44,16 +49,12 @@ public final class ExecutionConfiguration { mSaveSnapshot = builder.saveSnapshot; mFormat = builder.format; mPages = builder.pages; + mParams = builder.params; + mAttachmentPrefix = builder.attachmentPrefix; } - public static class Format { - public static int NONE = 0; - public static int HTML = 1; - public static int PDF = 2; - public static int XLS = 3; - - private Format() { - } + public enum Format { + HTML, PDF, XLS } @NonNull @@ -61,7 +62,7 @@ public static Builder builder() { return new Builder(); } - public int getFormat() { + public Format getFormat() { return mFormat; } @@ -73,25 +74,36 @@ public boolean isInteractive() { return mInteractive; } + public boolean isSaveSnapshot() { + return mSaveSnapshot; + } + @Nullable public String getPages() { return mPages; } - public boolean isSaveSnapshot() { - return mSaveSnapshot; + @Nullable + public Map> getParams() { + return mParams; + } + + @Nullable + public String getAttachmentPrefix() { + return mAttachmentPrefix; } public static class Builder { private boolean freshData; private boolean interactive; private boolean saveSnapshot; - private int format; + private Format format; private String pages; + public Map> params; + public String attachmentPrefix; public Builder() { interactive = true; - format = Format.NONE; } public Builder freshData(boolean freshData) { @@ -109,7 +121,7 @@ public Builder saveSnapshot(boolean saveSnapshot) { return this; } - public Builder format(int format) { + public Builder format(Format format) { this.format = format; return this; } @@ -119,6 +131,16 @@ public Builder pages(@Nullable String pages) { return this; } + public Builder params(Map> params) { + this.params = params; + return this; + } + + public Builder attachmentPrefix(String prefix) { + this.attachmentPrefix = prefix; + return this; + } + public ExecutionConfiguration create() { return new ExecutionConfiguration(this); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 71162d7f..a9147e13 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -24,12 +24,11 @@ package com.jaspersoft.android.sdk.service.report; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import java.util.Map; -import java.util.Set; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; /** * @author Tom Koptel @@ -41,18 +40,45 @@ private static class InstanceHolder { private static ExecutionOptionsDataMapper INSTANCE = new ExecutionOptionsDataMapper(); } - private ExecutionOptionsDataMapper() { - // single instance - } - public static ExecutionOptionsDataMapper getInstance() { return InstanceHolder.INSTANCE; } - public ReportExecutionRequestOptions transform(@NonNull String baseUrl, - @NonNull String uri, - @NonNull ExecutionConfiguration criteria, - @Nullable Map> reportParameter) { - throw new UnsupportedOperationException(); + public ReportExecutionRequestOptions transform(@NonNull String reportUri, @NonNull String serverUrl, @NonNull ExecutionConfiguration criteria) { + ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); + + options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); + options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); + + options.withFreshData(criteria.isFreshData()); + options.withSaveDataSnapshot(criteria.isSaveSnapshot()); + options.withInteractive(criteria.isInteractive()); + options.withPages(criteria.getPages()); + options.withParameters(criteria.getParams()); + + options.withAsync(true); + options.withBaseUrl(serverUrl); + + return options; + } + + static class Helper { + static String adaptFormat(ExecutionConfiguration.Format format) { + if (format == null) { + return null; + } + return format.toString(); + } + + static String adaptAttachmentPrefix(String attachmentsPrefix) { + if (attachmentsPrefix == null) { + return null; + } + try { + return URLEncoder.encode(attachmentsPrefix, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new IllegalStateException("This should not be possible", e); + } + } } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 2d7ed0a8..b449a689 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -32,9 +32,6 @@ import com.jaspersoft.android.sdk.service.TokenProvider; import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; -import java.util.Map; -import java.util.Set; - /** * @author Tom Koptel * @since 2.0 @@ -47,9 +44,9 @@ public class ReportService { @VisibleForTesting ReportService(String baseUrl, - ReportExecutionRestApi.Factory executionApiFactory, - ServerRestApi.Factory infoApiFactory, - ExecutionOptionsDataMapper executionOptionsMapper) { + ReportExecutionRestApi.Factory executionApiFactory, + ServerRestApi.Factory infoApiFactory, + ExecutionOptionsDataMapper executionOptionsMapper) { mExecutionApiFactory = executionApiFactory; mInfoApiFactory = infoApiFactory; mBaseUrl = baseUrl; @@ -63,8 +60,8 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider return new ReportService(serverUrl, executionApiFactory, infoApiFactory, executionOptionsMapper); } - public ExecutionSession run(String reportUri, ExecutionConfiguration configuration, Map> reportParameter) { - ReportExecutionRequestOptions options = mExecutionOptionsMapper.transform(mBaseUrl, reportUri, configuration, reportParameter); + public ExecutionSession run(String reportUri, ExecutionConfiguration configuration) { + ReportExecutionRequestOptions options = mExecutionOptionsMapper.transform(reportUri, mBaseUrl, configuration); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); return new ExecutionSession(mExecutionApiFactory, details); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java index 8fa3b879..50980eb1 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java @@ -45,9 +45,4 @@ public void setUp() throws Exception { public void interactiveShouldBeTrueByDefault() { assertThat(objectUnderTest.isInteractive(), is(true)); } - - @Test - public void interactiveShouldBeNoneByDefault() { - assertThat(objectUnderTest.getFormat(), is(ExecutionConfiguration.Format.NONE)); - } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java new file mode 100644 index 00000000..09a5b83f --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -0,0 +1,63 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; + +import org.junit.Before; +import org.junit.Test; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ExecutionOptionsDataMapperTest { + + private static final String REPORT_URI = "/report/uri"; + private static final String BASE_URL = "http:://localhost"; + public static final Map> REPORT_PARAMS = Collections.emptyMap(); + + private ExecutionOptionsDataMapper mapper; + + @Before + public void setUp() throws Exception { + mapper = ExecutionOptionsDataMapper.getInstance(); + } + + @Test + public void shouldMapExecConfigurationOnOptions() { + ExecutionConfiguration configuration = ExecutionConfiguration.builder() + .format(ExecutionConfiguration.Format.HTML) + .freshData(true) + .interactive(false) + .saveSnapshot(true) + .pages("1-100") + .params(REPORT_PARAMS) + .attachmentPrefix("./") + .create(); + + ReportExecutionRequestOptions options = mapper.transform(REPORT_URI, BASE_URL, configuration); + + assertThat(options.getReportUnitUri(), is(REPORT_URI)); + assertThat(options.getFreshData(), is(true)); + assertThat(options.getSaveDataSnapshot(), is(true)); + assertThat(options.getInteractive(), is(false)); + assertThat(options.getSaveDataSnapshot(), is(true)); + assertThat(options.getAsync(), is(true)); + + assertThat(options.getAllowInlineScripts(), is(nullValue())); + assertThat(options.getTransformerKey(), is(nullValue())); + + assertThat(options.getBaseUrl(), is(BASE_URL)); + assertThat(options.getAttachmentsPrefix(), is(".%2F")); + assertThat(options.getOutputFormat(), is("HTML")); + assertThat(options.getPages(), is("1-100")); + assertThat(options.getParameters(), is(REPORT_PARAMS)); + } +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java new file mode 100644 index 00000000..d99a3e7f --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -0,0 +1,76 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.spy; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ExecutionConfiguration.class, ReportExecutionDetailsResponse.class, ExecutionOptionsDataMapper.class}) +public class ReportServiceTest { + + @Mock + ReportExecutionRestApi.Factory executionApiFactory; + @Mock + ReportExecutionRestApi executionApi; + @Mock + ServerRestApi.Factory infoApiFactory; + @Mock + ServerRestApi infoApi; + + @Mock + ExecutionConfiguration configuration; + @Mock + ReportExecutionDetailsResponse details; + + ReportService objectUnderTest; + + private ExecutionOptionsDataMapper mapper; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + when(executionApiFactory.get()).thenReturn(executionApi); + when(infoApiFactory.get()).thenReturn(infoApi); + + mapper = spy(ExecutionOptionsDataMapper.getInstance()); + objectUnderTest = new ReportService("http:://localhost", + executionApiFactory, + infoApiFactory, + mapper); + } + + @Test + public void testRunShouldCreateActiveSession() { + when(details.getExecutionId()).thenReturn("any_id"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(details); + + ExecutionSession session = objectUnderTest.run("/report/uri", configuration); + assertThat(session, is(notNullValue())); + + verify(mapper).transform("/report/uri", "http:://localhost", configuration); + verify(executionApi).runReportExecution(any(ReportExecutionRequestOptions.class)); + } + +} \ No newline at end of file From 5263672df18a0a6dc734c154c406dd9fcbed5464 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 13:57:18 +0300 Subject: [PATCH 180/457] Add ExecutionSession test --- .../service/report/ExecutionSessionTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java new file mode 100644 index 00000000..7684ad1e --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java @@ -0,0 +1,55 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ReportExecutionDetailsResponse.class}) +public class ExecutionSessionTest { + private static final String REQUEST_ID = "any_id"; + + @Mock + ReportExecutionRestApi.Factory executionApiFactory; + @Mock + ReportExecutionRestApi executionApi; + @Mock + ReportExecutionDetailsResponse mDetails; + + private ExecutionSession objectUnderTest; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + when(executionApiFactory.get()).thenReturn(executionApi); + when(mDetails.getExecutionId()).thenReturn(REQUEST_ID); + objectUnderTest = new ExecutionSession(executionApiFactory, mDetails); + } + + @Test + public void testRequestDetails() throws Exception { + objectUnderTest.requestDetails(); + verify(executionApi).requestReportExecutionDetails(REQUEST_ID); + } + + @Test + public void testRequestStatus() throws Exception { + objectUnderTest.requestStatus(); + verify(executionApi).requestReportExecutionStatus(REQUEST_ID); + } +} \ No newline at end of file From 49b364a413e1730dfd68618141a15573d377c67c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 14:14:50 +0300 Subject: [PATCH 181/457] Preparing report export API --- .../sdk/network/api/ReportExportRestApi.java | 4 ++ .../sdk/service/report/ExecutionSession.java | 12 ++++- .../sdk/service/report/ReportExport.java | 40 +++++++++++++++ .../report/ReportExportRestApiFactory.java | 49 +++++++++++++++++++ .../sdk/service/report/ReportService.java | 9 +++- .../service/report/ExecutionSessionTest.java | 7 ++- .../sdk/service/report/ReportExportTest.java | 32 ++++++++++++ .../sdk/service/report/ReportServiceTest.java | 5 ++ 8 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportRestApiFactory.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 3b2fed32..c0010c28 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -55,6 +55,10 @@ public interface ReportExportRestApi { @WorkerThread ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); + interface Factory { + ReportExportRestApi get(); + } + final class Builder extends GenericAuthBuilder { @Override ReportExportRestApi createApi() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java index afd13c40..9609ee4a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; @@ -33,10 +34,15 @@ */ public final class ExecutionSession { private final ReportExecutionRestApi.Factory mExecutionApiFactory; + private final ReportExportRestApi.Factory mExportApiFactory; private final String mId; - public ExecutionSession(ReportExecutionRestApi.Factory executionApiFactory, ReportExecutionDetailsResponse details) { + public ExecutionSession( + ReportExecutionRestApi.Factory executionApiFactory, + ReportExportRestApi.Factory exportApiFactory, + ReportExecutionDetailsResponse details) { mExecutionApiFactory = executionApiFactory; + mExportApiFactory = exportApiFactory; mId = details.getExecutionId(); } @@ -47,4 +53,8 @@ public ReportExecutionDetailsResponse requestDetails() { public ExecutionStatusResponse requestStatus() { return mExecutionApiFactory.get().requestReportExecutionStatus(mId); } + + public ReportExport requestExport(ExecutionConfiguration configuration) { + return new ReportExport(mId, mExportApiFactory); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java new file mode 100644 index 00000000..96210041 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -0,0 +1,40 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExport { + private final String mExecutionId; + private final ReportExportRestApi.Factory mExportApiFactory; + + public ReportExport(String executionId, ReportExportRestApi.Factory exportApiFactory) { + mExecutionId = executionId; + mExportApiFactory = exportApiFactory; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportRestApiFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportRestApiFactory.java new file mode 100644 index 00000000..2db94805 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportRestApiFactory.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.service.TokenProvider; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExportRestApiFactory implements ReportExportRestApi.Factory { + private final TokenProvider mTokenProvider; + private final String mServerUrl; + + public ReportExportRestApiFactory(String serverUrl, TokenProvider tokenProvider) { + mServerUrl = serverUrl; + mTokenProvider = tokenProvider; + } + + @Override + public ReportExportRestApi get() { + return new ReportExportRestApi.Builder() + .baseUrl(mServerUrl) + .token(mTokenProvider.provideToken()) + .build(); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index b449a689..b239af29 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -26,6 +26,7 @@ import android.support.annotation.VisibleForTesting; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; @@ -38,6 +39,7 @@ */ public class ReportService { private final ReportExecutionRestApi.Factory mExecutionApiFactory; + private final ReportExportRestApi.Factory mExportApiFactory; private final ServerRestApi.Factory mInfoApiFactory; private final String mBaseUrl; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; @@ -45,9 +47,11 @@ public class ReportService { @VisibleForTesting ReportService(String baseUrl, ReportExecutionRestApi.Factory executionApiFactory, + ReportExportRestApi.Factory exportApiFactory, ServerRestApi.Factory infoApiFactory, ExecutionOptionsDataMapper executionOptionsMapper) { mExecutionApiFactory = executionApiFactory; + mExportApiFactory = exportApiFactory; mInfoApiFactory = infoApiFactory; mBaseUrl = baseUrl; mExecutionOptionsMapper = executionOptionsMapper; @@ -55,14 +59,15 @@ public class ReportService { public static ReportService create(String serverUrl, TokenProvider tokenProvider) { ReportOptionRestApiFactory executionApiFactory = new ReportOptionRestApiFactory(serverUrl, tokenProvider); + ReportExportRestApiFactory exportApiFactory = new ReportExportRestApiFactory(serverUrl, tokenProvider); ServerRestApiFactory infoApiFactory = new ServerRestApiFactory(serverUrl); ExecutionOptionsDataMapper executionOptionsMapper = ExecutionOptionsDataMapper.getInstance(); - return new ReportService(serverUrl, executionApiFactory, infoApiFactory, executionOptionsMapper); + return new ReportService(serverUrl, executionApiFactory, exportApiFactory, infoApiFactory, executionOptionsMapper); } public ExecutionSession run(String reportUri, ExecutionConfiguration configuration) { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transform(reportUri, mBaseUrl, configuration); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); - return new ExecutionSession(mExecutionApiFactory, details); + return new ExecutionSession(mExecutionApiFactory, mExportApiFactory, details); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java index 7684ad1e..132f4820 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java @@ -1,6 +1,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import org.junit.Before; @@ -23,6 +24,10 @@ public class ExecutionSessionTest { private static final String REQUEST_ID = "any_id"; + + @Mock + ReportExportRestApi.Factory mExportApiFactory; + @Mock ReportExecutionRestApi.Factory executionApiFactory; @Mock @@ -38,7 +43,7 @@ public void setUp() throws Exception { when(executionApiFactory.get()).thenReturn(executionApi); when(mDetails.getExecutionId()).thenReturn(REQUEST_ID); - objectUnderTest = new ExecutionSession(executionApiFactory, mDetails); + objectUnderTest = new ExecutionSession(executionApiFactory, mExportApiFactory, mDetails); } @Test diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java new file mode 100644 index 00000000..57cc1aa9 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -0,0 +1,32 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; + +import org.junit.Before; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportExportTest { + private static final String EXECUTION_ID = "any_id"; + + @Mock + ReportExportRestApi.Factory mExportApiFactory; + @Mock + ReportExportRestApi mExportRestApi; + + private ReportExport objectUnderTest; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + when(mExportApiFactory.get()).thenReturn(mExportRestApi); + objectUnderTest = new ReportExport(EXECUTION_ID, mExportApiFactory); + } +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index d99a3e7f..c5323a30 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -1,6 +1,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; @@ -38,6 +39,9 @@ public class ReportServiceTest { @Mock ServerRestApi infoApi; + @Mock + ReportExportRestApi.Factory mExportApiFactory; + @Mock ExecutionConfiguration configuration; @Mock @@ -57,6 +61,7 @@ public void setUp() throws Exception { mapper = spy(ExecutionOptionsDataMapper.getInstance()); objectUnderTest = new ReportService("http:://localhost", executionApiFactory, + mExportApiFactory, infoApiFactory, mapper); } From 8a605a4c27707e6795db8e8d35af644bc61e9279 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 6 Oct 2015 14:42:34 +0300 Subject: [PATCH 182/457] Implementing export download API --- .../report/ExecutionOptionsDataMapper.java | 15 ++++-- .../sdk/service/report/ExecutionSession.java | 18 ++++++-- .../sdk/service/report/ReportExport.java | 9 +++- .../sdk/service/report/ReportService.java | 11 +++-- .../ExecutionOptionsDataMapperTest.java | 26 +++++++++-- .../service/report/ExecutionSessionTest.java | 46 ++++++++++++++----- .../sdk/service/report/ReportExportTest.java | 23 ++++++++-- .../sdk/service/report/ReportServiceTest.java | 2 +- 8 files changed, 119 insertions(+), 31 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index a9147e13..c44c33ca 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -25,6 +25,7 @@ import android.support.annotation.NonNull; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import java.io.UnsupportedEncodingException; @@ -44,9 +45,19 @@ public static ExecutionOptionsDataMapper getInstance() { return InstanceHolder.INSTANCE; } - public ReportExecutionRequestOptions transform(@NonNull String reportUri, @NonNull String serverUrl, @NonNull ExecutionConfiguration criteria) { + public ReportExecutionRequestOptions transformReportOptions(@NonNull String reportUri, @NonNull String serverUrl, @NonNull ExecutionConfiguration configuration) { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); + adaptFields(serverUrl, configuration, options); + return options; + } + public ExecutionRequestOptions transformExportOptions(@NonNull String serverUrl, @NonNull ExecutionConfiguration configuration) { + ExecutionRequestOptions options = ExecutionRequestOptions.create(); + adaptFields(serverUrl, configuration, options); + return options; + } + + private void adaptFields(@NonNull String serverUrl, @NonNull ExecutionConfiguration criteria, ExecutionRequestOptions options) { options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); @@ -58,8 +69,6 @@ public ReportExecutionRequestOptions transform(@NonNull String reportUri, @NonNu options.withAsync(true); options.withBaseUrl(serverUrl); - - return options; } static class Helper { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java index 9609ee4a..f8bd50b9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java @@ -25,8 +25,10 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; /** * @author Tom Koptel @@ -35,15 +37,21 @@ public final class ExecutionSession { private final ReportExecutionRestApi.Factory mExecutionApiFactory; private final ReportExportRestApi.Factory mExportApiFactory; + private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + + private final String mBaseUrl; private final String mId; - public ExecutionSession( + ExecutionSession( + String baseUrl, ReportExecutionRestApi.Factory executionApiFactory, ReportExportRestApi.Factory exportApiFactory, - ReportExecutionDetailsResponse details) { + ExecutionOptionsDataMapper executionOptionsMapper, String executionId) { + mBaseUrl = baseUrl; mExecutionApiFactory = executionApiFactory; mExportApiFactory = exportApiFactory; - mId = details.getExecutionId(); + mExecutionOptionsMapper = executionOptionsMapper; + mId = executionId; } public ReportExecutionDetailsResponse requestDetails() { @@ -55,6 +63,8 @@ public ExecutionStatusResponse requestStatus() { } public ReportExport requestExport(ExecutionConfiguration configuration) { - return new ReportExport(mId, mExportApiFactory); + ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, configuration); + ReportExportExecutionResponse details = mExportApiFactory.get().runExportExecution(mId, options); + return new ReportExport(mId, details.getExportId(), mExportApiFactory); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 96210041..00a68314 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; /** * @author Tom Koptel @@ -32,9 +33,15 @@ public final class ReportExport { private final String mExecutionId; private final ReportExportRestApi.Factory mExportApiFactory; + private final String mId; - public ReportExport(String executionId, ReportExportRestApi.Factory exportApiFactory) { + public ReportExport(String executionId, String exportId, ReportExportRestApi.Factory exportApiFactory) { + mId = exportId; mExecutionId = executionId; mExportApiFactory = exportApiFactory; } + + public ExportResourceResponse download() { + return mExportApiFactory.get().requestExportOutput(mExecutionId, mId); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index b239af29..8b52b2f8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -50,10 +50,10 @@ public class ReportService { ReportExportRestApi.Factory exportApiFactory, ServerRestApi.Factory infoApiFactory, ExecutionOptionsDataMapper executionOptionsMapper) { + mBaseUrl = baseUrl; mExecutionApiFactory = executionApiFactory; mExportApiFactory = exportApiFactory; mInfoApiFactory = infoApiFactory; - mBaseUrl = baseUrl; mExecutionOptionsMapper = executionOptionsMapper; } @@ -66,8 +66,13 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider } public ExecutionSession run(String reportUri, ExecutionConfiguration configuration) { - ReportExecutionRequestOptions options = mExecutionOptionsMapper.transform(reportUri, mBaseUrl, configuration); + ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformReportOptions(reportUri, mBaseUrl, configuration); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); - return new ExecutionSession(mExecutionApiFactory, mExportApiFactory, details); + return new ExecutionSession( + mBaseUrl, + mExecutionApiFactory, + mExportApiFactory, + mExecutionOptionsMapper, + details.getExecutionId()); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 09a5b83f..c9b45db5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -1,5 +1,6 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import org.junit.Before; @@ -24,15 +25,13 @@ public class ExecutionOptionsDataMapperTest { public static final Map> REPORT_PARAMS = Collections.emptyMap(); private ExecutionOptionsDataMapper mapper; + private ExecutionConfiguration configuration; @Before public void setUp() throws Exception { mapper = ExecutionOptionsDataMapper.getInstance(); - } - @Test - public void shouldMapExecConfigurationOnOptions() { - ExecutionConfiguration configuration = ExecutionConfiguration.builder() + configuration = ExecutionConfiguration.builder() .format(ExecutionConfiguration.Format.HTML) .freshData(true) .interactive(false) @@ -41,10 +40,27 @@ public void shouldMapExecConfigurationOnOptions() { .params(REPORT_PARAMS) .attachmentPrefix("./") .create(); + } + + @Test + public void shouldMapExecConfigurationOnOptions() { - ReportExecutionRequestOptions options = mapper.transform(REPORT_URI, BASE_URL, configuration); + } + @Test + public void testTransformReportOptions() throws Exception { + ReportExecutionRequestOptions options = mapper.transformReportOptions(REPORT_URI, BASE_URL, configuration); assertThat(options.getReportUnitUri(), is(REPORT_URI)); + assertOptions(options); + } + + @Test + public void testTransformExportOptions() throws Exception { + ExecutionRequestOptions options = mapper.transformExportOptions(BASE_URL, configuration); + assertOptions(options); + } + + private void assertOptions(ExecutionRequestOptions options) { assertThat(options.getFreshData(), is(true)); assertThat(options.getSaveDataSnapshot(), is(true)); assertThat(options.getInteractive(), is(false)); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java index 132f4820..3f98dac8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java @@ -2,7 +2,8 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; import org.junit.Before; import org.junit.Test; @@ -12,7 +13,11 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; /** @@ -20,41 +25,60 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ReportExecutionDetailsResponse.class}) +@PrepareForTest({ExecutionConfiguration.class, ExecutionOptionsDataMapper.class, ReportExportExecutionResponse.class}) public class ExecutionSessionTest { - private static final String REQUEST_ID = "any_id"; - + @Mock + ExecutionConfiguration configuration; + @Mock + ReportExportExecutionResponse mExecDetails; @Mock ReportExportRestApi.Factory mExportApiFactory; - + @Mock + ReportExportRestApi mExportRestApi; @Mock ReportExecutionRestApi.Factory executionApiFactory; @Mock ReportExecutionRestApi executionApi; - @Mock - ReportExecutionDetailsResponse mDetails; private ExecutionSession objectUnderTest; + private ExecutionOptionsDataMapper mapper; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(executionApiFactory.get()).thenReturn(executionApi); - when(mDetails.getExecutionId()).thenReturn(REQUEST_ID); - objectUnderTest = new ExecutionSession(executionApiFactory, mExportApiFactory, mDetails); + when(mExportApiFactory.get()).thenReturn(mExportRestApi); + + mapper = spy(ExecutionOptionsDataMapper.getInstance()); + objectUnderTest = new ExecutionSession( + "http:://localhost", + executionApiFactory, + mExportApiFactory, + mapper, + "execution_id"); } @Test public void testRequestDetails() throws Exception { objectUnderTest.requestDetails(); - verify(executionApi).requestReportExecutionDetails(REQUEST_ID); + verify(executionApi).requestReportExecutionDetails("execution_id"); } @Test public void testRequestStatus() throws Exception { objectUnderTest.requestStatus(); - verify(executionApi).requestReportExecutionStatus(REQUEST_ID); + verify(executionApi).requestReportExecutionStatus("execution_id"); + } + + @Test + public void testRequestExport() throws Exception { + when(mExecDetails.getExportId()).thenReturn("export_id"); + when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExecDetails); + objectUnderTest.requestExport(configuration); + + verify(mapper).transformExportOptions("http:://localhost", configuration); + verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 57cc1aa9..c4075cd6 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -1,24 +1,34 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.powermock.api.mockito.PowerMockito.when; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ExportResourceResponse.class}) public class ReportExportTest { - private static final String EXECUTION_ID = "any_id"; - @Mock ReportExportRestApi.Factory mExportApiFactory; @Mock ReportExportRestApi mExportRestApi; + @Mock + ExportResourceResponse mExportResourceResponse; private ReportExport objectUnderTest; @@ -27,6 +37,13 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mExportApiFactory.get()).thenReturn(mExportRestApi); - objectUnderTest = new ReportExport(EXECUTION_ID, mExportApiFactory); + objectUnderTest = new ReportExport("report_execution_id", "export_id", mExportApiFactory); + } + + @Test + public void testDownload() throws Exception { + objectUnderTest.download(); + verify(mExportRestApi).requestExportOutput(eq("report_execution_id"), eq("export_id")); + verifyNoMoreInteractions(mExportRestApi); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index c5323a30..d41fed4c 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -74,7 +74,7 @@ public void testRunShouldCreateActiveSession() { ExecutionSession session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); - verify(mapper).transform("/report/uri", "http:://localhost", configuration); + verify(mapper).transformReportOptions("/report/uri", "http:://localhost", configuration); verify(executionApi).runReportExecution(any(ReportExecutionRequestOptions.class)); } From af362cc2d96e1ffded0bc8941ab103c6fbc8ed70 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 7 Oct 2015 12:16:04 +0300 Subject: [PATCH 183/457] Remove 'requestDetails' API --- .../android/sdk/service/report/ExecutionSession.java | 4 ---- .../android/sdk/service/report/ExecutionSessionTest.java | 6 ------ 2 files changed, 10 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java index f8bd50b9..826db166 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java @@ -58,10 +58,6 @@ public ReportExecutionDetailsResponse requestDetails() { return mExecutionApiFactory.get().requestReportExecutionDetails(mId); } - public ExecutionStatusResponse requestStatus() { - return mExecutionApiFactory.get().requestReportExecutionStatus(mId); - } - public ReportExport requestExport(ExecutionConfiguration configuration) { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, configuration); ReportExportExecutionResponse details = mExportApiFactory.get().runExportExecution(mId, options); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java index 3f98dac8..c9be7485 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java @@ -66,12 +66,6 @@ public void testRequestDetails() throws Exception { verify(executionApi).requestReportExecutionDetails("execution_id"); } - @Test - public void testRequestStatus() throws Exception { - objectUnderTest.requestStatus(); - verify(executionApi).requestReportExecutionStatus("execution_id"); - } - @Test public void testRequestExport() throws Exception { when(mExecDetails.getExportId()).thenReturn("export_id"); From 9bd08c0cdd3e7e4b03a90554a98b3a99b84414d3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 7 Oct 2015 12:17:01 +0300 Subject: [PATCH 184/457] Refactor name 'ExecutionSession' -> 'ReportExecution' --- .../report/{ExecutionSession.java => ReportExecution.java} | 5 ++--- .../android/sdk/service/report/ReportService.java | 4 ++-- .../{ExecutionSessionTest.java => ReportExecutionTest.java} | 6 +++--- .../android/sdk/service/report/ReportServiceTest.java | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/report/{ExecutionSession.java => ReportExecution.java} (95%) rename client-service/src/test/java/com/jaspersoft/android/sdk/service/report/{ExecutionSessionTest.java => ReportExecutionTest.java} (95%) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java similarity index 95% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 826db166..ebca6f01 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionSession.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; @@ -34,7 +33,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExecutionSession { +public final class ReportExecution { private final ReportExecutionRestApi.Factory mExecutionApiFactory; private final ReportExportRestApi.Factory mExportApiFactory; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; @@ -42,7 +41,7 @@ public final class ExecutionSession { private final String mBaseUrl; private final String mId; - ExecutionSession( + ReportExecution( String baseUrl, ReportExecutionRestApi.Factory executionApiFactory, ReportExportRestApi.Factory exportApiFactory, diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 8b52b2f8..3500e2e7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -65,10 +65,10 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider return new ReportService(serverUrl, executionApiFactory, exportApiFactory, infoApiFactory, executionOptionsMapper); } - public ExecutionSession run(String reportUri, ExecutionConfiguration configuration) { + public ReportExecution run(String reportUri, ExecutionConfiguration configuration) { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformReportOptions(reportUri, mBaseUrl, configuration); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); - return new ExecutionSession( + return new ReportExecution( mBaseUrl, mExecutionApiFactory, mExportApiFactory, diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java similarity index 95% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index c9be7485..25f4ea2e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionSessionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -26,7 +26,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({ExecutionConfiguration.class, ExecutionOptionsDataMapper.class, ReportExportExecutionResponse.class}) -public class ExecutionSessionTest { +public class ReportExecutionTest { @Mock ExecutionConfiguration configuration; @Mock @@ -41,7 +41,7 @@ public class ExecutionSessionTest { @Mock ReportExecutionRestApi executionApi; - private ExecutionSession objectUnderTest; + private ReportExecution objectUnderTest; private ExecutionOptionsDataMapper mapper; @Before @@ -52,7 +52,7 @@ public void setUp() throws Exception { when(mExportApiFactory.get()).thenReturn(mExportRestApi); mapper = spy(ExecutionOptionsDataMapper.getInstance()); - objectUnderTest = new ExecutionSession( + objectUnderTest = new ReportExecution( "http:://localhost", executionApiFactory, mExportApiFactory, diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index d41fed4c..cd0707e8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -71,7 +71,7 @@ public void testRunShouldCreateActiveSession() { when(details.getExecutionId()).thenReturn("any_id"); when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(details); - ExecutionSession session = objectUnderTest.run("/report/uri", configuration); + ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); verify(mapper).transformReportOptions("/report/uri", "http:://localhost", configuration); From 7e5552b8af3b94a56860e3437c534b75d0b8c028 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 7 Oct 2015 12:18:16 +0300 Subject: [PATCH 185/457] Refactor name 'ExecutionConfiguration' -> 'ExecutionCriteria' --- ...ExecutionConfiguration.java => ExecutionCriteria.java} | 8 ++++---- .../sdk/service/report/ExecutionOptionsDataMapper.java | 8 ++++---- .../android/sdk/service/report/ReportExecution.java | 2 +- .../android/sdk/service/report/ReportService.java | 2 +- ...nConfigurationTest.java => ExecutionCriteriaTest.java} | 6 +++--- .../service/report/ExecutionOptionsDataMapperTest.java | 6 +++--- .../android/sdk/service/report/ReportExecutionTest.java | 4 ++-- .../android/sdk/service/report/ReportServiceTest.java | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/report/{ExecutionConfiguration.java => ExecutionCriteria.java} (95%) rename client-service/src/test/java/com/jaspersoft/android/sdk/service/report/{ExecutionConfigurationTest.java => ExecutionCriteriaTest.java} (89%) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java similarity index 95% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java index d5fe0394..2b5ec94e 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionConfiguration.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java @@ -33,7 +33,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExecutionConfiguration { +public final class ExecutionCriteria { private final boolean mFreshData; private final boolean mInteractive; @@ -43,7 +43,7 @@ public final class ExecutionConfiguration { private final Map> mParams; private final String mAttachmentPrefix; - ExecutionConfiguration(Builder builder) { + ExecutionCriteria(Builder builder) { mFreshData = builder.freshData; mInteractive = builder.interactive; mSaveSnapshot = builder.saveSnapshot; @@ -141,8 +141,8 @@ public Builder attachmentPrefix(String prefix) { return this; } - public ExecutionConfiguration create() { - return new ExecutionConfiguration(this); + public ExecutionCriteria create() { + return new ExecutionCriteria(this); } } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index c44c33ca..0a316bfe 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -45,19 +45,19 @@ public static ExecutionOptionsDataMapper getInstance() { return InstanceHolder.INSTANCE; } - public ReportExecutionRequestOptions transformReportOptions(@NonNull String reportUri, @NonNull String serverUrl, @NonNull ExecutionConfiguration configuration) { + public ReportExecutionRequestOptions transformReportOptions(@NonNull String reportUri, @NonNull String serverUrl, @NonNull ExecutionCriteria configuration) { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); adaptFields(serverUrl, configuration, options); return options; } - public ExecutionRequestOptions transformExportOptions(@NonNull String serverUrl, @NonNull ExecutionConfiguration configuration) { + public ExecutionRequestOptions transformExportOptions(@NonNull String serverUrl, @NonNull ExecutionCriteria configuration) { ExecutionRequestOptions options = ExecutionRequestOptions.create(); adaptFields(serverUrl, configuration, options); return options; } - private void adaptFields(@NonNull String serverUrl, @NonNull ExecutionConfiguration criteria, ExecutionRequestOptions options) { + private void adaptFields(@NonNull String serverUrl, @NonNull ExecutionCriteria criteria, ExecutionRequestOptions options) { options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); @@ -72,7 +72,7 @@ private void adaptFields(@NonNull String serverUrl, @NonNull ExecutionConfigurat } static class Helper { - static String adaptFormat(ExecutionConfiguration.Format format) { + static String adaptFormat(ExecutionCriteria.Format format) { if (format == null) { return null; } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index ebca6f01..faf700cc 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -57,7 +57,7 @@ public ReportExecutionDetailsResponse requestDetails() { return mExecutionApiFactory.get().requestReportExecutionDetails(mId); } - public ReportExport requestExport(ExecutionConfiguration configuration) { + public ReportExport requestExport(ExecutionCriteria configuration) { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, configuration); ReportExportExecutionResponse details = mExportApiFactory.get().runExportExecution(mId, options); return new ReportExport(mId, details.getExportId(), mExportApiFactory); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 3500e2e7..87c1ab83 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -65,7 +65,7 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider return new ReportService(serverUrl, executionApiFactory, exportApiFactory, infoApiFactory, executionOptionsMapper); } - public ReportExecution run(String reportUri, ExecutionConfiguration configuration) { + public ReportExecution run(String reportUri, ExecutionCriteria configuration) { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformReportOptions(reportUri, mBaseUrl, configuration); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); return new ReportExecution( diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteriaTest.java similarity index 89% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteriaTest.java index 50980eb1..542d381c 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionConfigurationTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteriaTest.java @@ -33,12 +33,12 @@ * @author Tom Koptel * @since 2.0 */ -public class ExecutionConfigurationTest { - private ExecutionConfiguration objectUnderTest; +public class ExecutionCriteriaTest { + private ExecutionCriteria objectUnderTest; @Before public void setUp() throws Exception { - objectUnderTest = ExecutionConfiguration.builder().create(); + objectUnderTest = ExecutionCriteria.builder().create(); } @Test diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index c9b45db5..614c2af5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -25,14 +25,14 @@ public class ExecutionOptionsDataMapperTest { public static final Map> REPORT_PARAMS = Collections.emptyMap(); private ExecutionOptionsDataMapper mapper; - private ExecutionConfiguration configuration; + private ExecutionCriteria configuration; @Before public void setUp() throws Exception { mapper = ExecutionOptionsDataMapper.getInstance(); - configuration = ExecutionConfiguration.builder() - .format(ExecutionConfiguration.Format.HTML) + configuration = ExecutionCriteria.builder() + .format(ExecutionCriteria.Format.HTML) .freshData(true) .interactive(false) .saveSnapshot(true) diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 25f4ea2e..b548308a 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -25,10 +25,10 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionConfiguration.class, ExecutionOptionsDataMapper.class, ReportExportExecutionResponse.class}) +@PrepareForTest({ExecutionCriteria.class, ExecutionOptionsDataMapper.class, ReportExportExecutionResponse.class}) public class ReportExecutionTest { @Mock - ExecutionConfiguration configuration; + ExecutionCriteria configuration; @Mock ReportExportExecutionResponse mExecDetails; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index cd0707e8..ce20aed4 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -27,7 +27,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionConfiguration.class, ReportExecutionDetailsResponse.class, ExecutionOptionsDataMapper.class}) +@PrepareForTest({ExecutionCriteria.class, ReportExecutionDetailsResponse.class, ExecutionOptionsDataMapper.class}) public class ReportServiceTest { @Mock @@ -43,7 +43,7 @@ public class ReportServiceTest { ReportExportRestApi.Factory mExportApiFactory; @Mock - ExecutionConfiguration configuration; + ExecutionCriteria configuration; @Mock ReportExecutionDetailsResponse details; From 44d1e6b6a0b4d9ea5e0ac78d5cc97b01699455c6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 7 Oct 2015 13:22:27 +0300 Subject: [PATCH 186/457] Refactoring ExecutionCriteria --- client-service/build.gradle | 4 +- .../sdk/service/report/ExecutionCriteria.java | 89 ++------------ .../report/ExecutionOptionsDataMapper.java | 12 +- .../sdk/service/report/ReportExecution.java | 4 +- .../sdk/service/report/ReportService.java | 4 +- .../sdk/service/report/RunExportCriteria.java | 90 ++++++++++++++ .../sdk/service/report/RunReportCriteria.java | 113 ++++++++++++++++++ .../ExecutionOptionsDataMapperTest.java | 29 ++--- .../service/report/ReportExecutionTest.java | 9 +- .../sdk/service/report/ReportServiceTest.java | 6 +- .../service/report/RunExportCriteriaTest.java | 48 ++++++++ ...iaTest.java => RunReportCriteriaTest.java} | 4 +- 12 files changed, 301 insertions(+), 111 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java rename client-service/src/test/java/com/jaspersoft/android/sdk/service/report/{ExecutionCriteriaTest.java => RunReportCriteriaTest.java} (93%) diff --git a/client-service/build.gradle b/client-service/build.gradle index cc06e56b..7d97e8c1 100644 --- a/client-service/build.gradle +++ b/client-service/build.gradle @@ -44,9 +44,9 @@ dependencies { exclude group: 'org.hamcrest' exclude group: 'org.objenesis' } - testCompile('org.powermock:powermock-api-mockito:1.6.2') { + testCompile('org.powermock:powermock-api-mockito:1.6.3') { exclude group: 'org.mockito' } - testCompile 'org.powermock:powermock-module-junit4:1.6.2' + testCompile 'org.powermock:powermock-module-junit4:1.6.3' testCompile 'org.robolectric:shadows-support-v4:3.0' } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java index 2b5ec94e..03fc9f50 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java @@ -23,45 +23,39 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import java.util.Map; -import java.util.Set; - /** * @author Tom Koptel * @since 2.0 */ -public final class ExecutionCriteria { +public abstract class ExecutionCriteria { private final boolean mFreshData; private final boolean mInteractive; private final boolean mSaveSnapshot; private final Format mFormat; private final String mPages; - private final Map> mParams; private final String mAttachmentPrefix; - ExecutionCriteria(Builder builder) { - mFreshData = builder.freshData; - mInteractive = builder.interactive; - mSaveSnapshot = builder.saveSnapshot; - mFormat = builder.format; - mPages = builder.pages; - mParams = builder.params; - mAttachmentPrefix = builder.attachmentPrefix; + protected ExecutionCriteria(boolean freshData, + boolean interactive, + boolean saveSnapshot, + Format format, + String pages, + String attachmentPrefix) { + mFreshData = freshData; + mInteractive = interactive; + mSaveSnapshot = saveSnapshot; + mFormat = format; + mPages = pages; + mAttachmentPrefix = attachmentPrefix; } public enum Format { HTML, PDF, XLS } - @NonNull - public static Builder builder() { - return new Builder(); - } - public Format getFormat() { return mFormat; } @@ -83,66 +77,9 @@ public String getPages() { return mPages; } - @Nullable - public Map> getParams() { - return mParams; - } - @Nullable public String getAttachmentPrefix() { return mAttachmentPrefix; } - public static class Builder { - private boolean freshData; - private boolean interactive; - private boolean saveSnapshot; - private Format format; - private String pages; - public Map> params; - public String attachmentPrefix; - - public Builder() { - interactive = true; - } - - public Builder freshData(boolean freshData) { - this.freshData = freshData; - return this; - } - - public Builder interactive(boolean interactive) { - this.interactive = interactive; - return this; - } - - public Builder saveSnapshot(boolean saveSnapshot) { - this.saveSnapshot = saveSnapshot; - return this; - } - - public Builder format(Format format) { - this.format = format; - return this; - } - - public Builder pages(@Nullable String pages) { - this.pages = pages; - return this; - } - - public Builder params(Map> params) { - this.params = params; - return this; - } - - public Builder attachmentPrefix(String prefix) { - this.attachmentPrefix = prefix; - return this; - } - - public ExecutionCriteria create() { - return new ExecutionCriteria(this); - } - } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 0a316bfe..4cf6fcfc 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -45,19 +45,20 @@ public static ExecutionOptionsDataMapper getInstance() { return InstanceHolder.INSTANCE; } - public ReportExecutionRequestOptions transformReportOptions(@NonNull String reportUri, @NonNull String serverUrl, @NonNull ExecutionCriteria configuration) { + public ReportExecutionRequestOptions transformRunReportOptions(@NonNull String reportUri, @NonNull String serverUrl, @NonNull RunReportCriteria criteria) { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); - adaptFields(serverUrl, configuration, options); + mapCommonCriterion(serverUrl, criteria, options); + options.withParameters(criteria.getParams()); return options; } - public ExecutionRequestOptions transformExportOptions(@NonNull String serverUrl, @NonNull ExecutionCriteria configuration) { + public ExecutionRequestOptions transformExportOptions(@NonNull String serverUrl, @NonNull RunExportCriteria configuration) { ExecutionRequestOptions options = ExecutionRequestOptions.create(); - adaptFields(serverUrl, configuration, options); + mapCommonCriterion(serverUrl, configuration, options); return options; } - private void adaptFields(@NonNull String serverUrl, @NonNull ExecutionCriteria criteria, ExecutionRequestOptions options) { + private void mapCommonCriterion(@NonNull String serverUrl, @NonNull ExecutionCriteria criteria, ExecutionRequestOptions options) { options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); @@ -65,7 +66,6 @@ private void adaptFields(@NonNull String serverUrl, @NonNull ExecutionCriteria c options.withSaveDataSnapshot(criteria.isSaveSnapshot()); options.withInteractive(criteria.isInteractive()); options.withPages(criteria.getPages()); - options.withParameters(criteria.getParams()); options.withAsync(true); options.withBaseUrl(serverUrl); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index faf700cc..68d41db9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -57,8 +57,8 @@ public ReportExecutionDetailsResponse requestDetails() { return mExecutionApiFactory.get().requestReportExecutionDetails(mId); } - public ReportExport requestExport(ExecutionCriteria configuration) { - ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, configuration); + public ReportExport requestExport(RunExportCriteria criteria) { + ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); ReportExportExecutionResponse details = mExportApiFactory.get().runExportExecution(mId, options); return new ReportExport(mId, details.getExportId(), mExportApiFactory); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 87c1ab83..5e2b9dd6 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -65,8 +65,8 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider return new ReportService(serverUrl, executionApiFactory, exportApiFactory, infoApiFactory, executionOptionsMapper); } - public ReportExecution run(String reportUri, ExecutionCriteria configuration) { - ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformReportOptions(reportUri, mBaseUrl, configuration); + public ReportExecution run(String reportUri, RunReportCriteria criteria) { + ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, mBaseUrl, criteria); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); return new ReportExecution( mBaseUrl, diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java new file mode 100644 index 00000000..1b2c58c4 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -0,0 +1,90 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RunExportCriteria extends ExecutionCriteria { + private RunExportCriteria(boolean freshData, boolean interactive, boolean saveSnapshot, Format format, String pages, String attachmentPrefix) { + super(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); + } + + @NonNull + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private boolean freshData; + private boolean interactive; + private boolean saveSnapshot; + private Format format; + private String pages; + public String attachmentPrefix; + + public Builder() { + interactive = true; + } + + public Builder freshData(boolean freshData) { + this.freshData = freshData; + return this; + } + + public Builder interactive(boolean interactive) { + this.interactive = interactive; + return this; + } + + public Builder saveSnapshot(boolean saveSnapshot) { + this.saveSnapshot = saveSnapshot; + return this; + } + + public Builder format(Format format) { + this.format = format; + return this; + } + + public Builder pages(@Nullable String pages) { + this.pages = pages; + return this; + } + + + public Builder attachmentPrefix(String prefix) { + this.attachmentPrefix = prefix; + return this; + } + + public RunExportCriteria create() { + return new RunExportCriteria(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java new file mode 100644 index 00000000..95dff958 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -0,0 +1,113 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.Map; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RunReportCriteria extends ExecutionCriteria { + private final Map> mParams; + + private RunReportCriteria(boolean freshData, + boolean interactive, + boolean saveSnapshot, + Format format, + String pages, + String attachmentPrefix, + Map> params + ) { + super(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); + mParams = params; + } + + @NonNull + public static Builder builder() { + return new Builder(); + } + + @Nullable + public Map> getParams() { + return mParams; + } + + public static class Builder { + private boolean freshData; + private boolean interactive; + private boolean saveSnapshot; + private Format format; + private String pages; + public Map> params; + public String attachmentPrefix; + + public Builder() { + interactive = true; + } + + public Builder freshData(boolean freshData) { + this.freshData = freshData; + return this; + } + + public Builder interactive(boolean interactive) { + this.interactive = interactive; + return this; + } + + public Builder saveSnapshot(boolean saveSnapshot) { + this.saveSnapshot = saveSnapshot; + return this; + } + + public Builder format(Format format) { + this.format = format; + return this; + } + + public Builder pages(@Nullable String pages) { + this.pages = pages; + return this; + } + + public Builder params(Map> params) { + this.params = params; + return this; + } + + public Builder attachmentPrefix(String prefix) { + this.attachmentPrefix = prefix; + return this; + } + + public RunReportCriteria create() { + return new RunReportCriteria(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix, params); + } + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 614c2af5..32beaf6c 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -25,13 +25,15 @@ public class ExecutionOptionsDataMapperTest { public static final Map> REPORT_PARAMS = Collections.emptyMap(); private ExecutionOptionsDataMapper mapper; - private ExecutionCriteria configuration; @Before public void setUp() throws Exception { mapper = ExecutionOptionsDataMapper.getInstance(); + } - configuration = ExecutionCriteria.builder() + @Test + public void testTransformReportOptions() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder() .format(ExecutionCriteria.Format.HTML) .freshData(true) .interactive(false) @@ -40,23 +42,23 @@ public void setUp() throws Exception { .params(REPORT_PARAMS) .attachmentPrefix("./") .create(); - } - - @Test - public void shouldMapExecConfigurationOnOptions() { - - } - - @Test - public void testTransformReportOptions() throws Exception { - ReportExecutionRequestOptions options = mapper.transformReportOptions(REPORT_URI, BASE_URL, configuration); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions(REPORT_URI, BASE_URL, criteria); assertThat(options.getReportUnitUri(), is(REPORT_URI)); + assertThat(options.getParameters(), is(REPORT_PARAMS)); assertOptions(options); } @Test public void testTransformExportOptions() throws Exception { - ExecutionRequestOptions options = mapper.transformExportOptions(BASE_URL, configuration); + RunExportCriteria criteria = RunExportCriteria.builder() + .format(ExecutionCriteria.Format.HTML) + .freshData(true) + .interactive(false) + .saveSnapshot(true) + .pages("1-100") + .attachmentPrefix("./") + .create(); + ExecutionRequestOptions options = mapper.transformExportOptions(BASE_URL, criteria); assertOptions(options); } @@ -74,6 +76,5 @@ private void assertOptions(ExecutionRequestOptions options) { assertThat(options.getAttachmentsPrefix(), is(".%2F")); assertThat(options.getOutputFormat(), is("HTML")); assertThat(options.getPages(), is("1-100")); - assertThat(options.getParameters(), is(REPORT_PARAMS)); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index b548308a..f989362a 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -25,10 +25,11 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionCriteria.class, ExecutionOptionsDataMapper.class, ReportExportExecutionResponse.class}) +@PrepareForTest({ExecutionOptionsDataMapper.class, ReportExportExecutionResponse.class}) public class ReportExecutionTest { + @Mock - ExecutionCriteria configuration; + RunExportCriteria exportCriteria; @Mock ReportExportExecutionResponse mExecDetails; @@ -70,9 +71,9 @@ public void testRequestDetails() throws Exception { public void testRequestExport() throws Exception { when(mExecDetails.getExportId()).thenReturn("export_id"); when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExecDetails); - objectUnderTest.requestExport(configuration); + objectUnderTest.requestExport(exportCriteria); - verify(mapper).transformExportOptions("http:://localhost", configuration); + verify(mapper).transformExportOptions("http:://localhost", exportCriteria); verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index ce20aed4..b0dce8f5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -27,7 +27,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionCriteria.class, ReportExecutionDetailsResponse.class, ExecutionOptionsDataMapper.class}) +@PrepareForTest({ReportExecutionDetailsResponse.class, ExecutionOptionsDataMapper.class}) public class ReportServiceTest { @Mock @@ -43,7 +43,7 @@ public class ReportServiceTest { ReportExportRestApi.Factory mExportApiFactory; @Mock - ExecutionCriteria configuration; + RunReportCriteria configuration; @Mock ReportExecutionDetailsResponse details; @@ -74,7 +74,7 @@ public void testRunShouldCreateActiveSession() { ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); - verify(mapper).transformReportOptions("/report/uri", "http:://localhost", configuration); + verify(mapper).transformRunReportOptions("/report/uri", "http:://localhost", configuration); verify(executionApi).runReportExecution(any(ReportExecutionRequestOptions.class)); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java new file mode 100644 index 00000000..e885a6ad --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java @@ -0,0 +1,48 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RunExportCriteriaTest { + private ExecutionCriteria objectUnderTest; + + @Before + public void setUp() throws Exception { + objectUnderTest = RunExportCriteria.builder().create(); + } + + @Test + public void interactiveShouldBeTrueByDefault() { + assertThat(objectUnderTest.isInteractive(), is(true)); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java similarity index 93% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteriaTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java index 542d381c..445bea36 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java @@ -33,12 +33,12 @@ * @author Tom Koptel * @since 2.0 */ -public class ExecutionCriteriaTest { +public class RunReportCriteriaTest { private ExecutionCriteria objectUnderTest; @Before public void setUp() throws Exception { - objectUnderTest = ExecutionCriteria.builder().create(); + objectUnderTest = RunReportCriteria.builder().create(); } @Test From 64048df6a801a8019f232d236c1119e9299b28e1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 7 Oct 2015 13:32:01 +0300 Subject: [PATCH 187/457] Refactor 'requestExport' -> 'export' --- .../jaspersoft/android/sdk/service/report/ReportExecution.java | 2 +- .../android/sdk/service/report/ReportExecutionTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 68d41db9..fe5d777f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -57,7 +57,7 @@ public ReportExecutionDetailsResponse requestDetails() { return mExecutionApiFactory.get().requestReportExecutionDetails(mId); } - public ReportExport requestExport(RunExportCriteria criteria) { + public ReportExport export(RunExportCriteria criteria) { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); ReportExportExecutionResponse details = mExportApiFactory.get().runExportExecution(mId, options); return new ReportExport(mId, details.getExportId(), mExportApiFactory); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index f989362a..79ad1de8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -71,7 +71,7 @@ public void testRequestDetails() throws Exception { public void testRequestExport() throws Exception { when(mExecDetails.getExportId()).thenReturn("export_id"); when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExecDetails); - objectUnderTest.requestExport(exportCriteria); + objectUnderTest.export(exportCriteria); verify(mapper).transformExportOptions("http:://localhost", exportCriteria); verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); From 9100b97c21534340b6b239bc5289b15d3cee5e25 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 7 Oct 2015 16:13:12 +0300 Subject: [PATCH 188/457] Implementing ReportExport 'getAttachments()' --- .../export/ReportExportExecutionResponse.java | 6 + .../exception/ExportCancelledException.java | 34 +++++ .../exception/ExportFailedException.java | 38 ++++++ .../sdk/service/report/ReportExecution.java | 83 +++++++++++- .../sdk/service/report/ReportExport.java | 24 +++- .../sdk/service/report/ReportService.java | 5 +- .../service/report/ReportExecutionTest.java | 127 ++++++++++++++++-- .../sdk/service/report/ReportExportTest.java | 12 +- 8 files changed, 304 insertions(+), 25 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java index 465c4668..2e3c4132 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java @@ -37,6 +37,8 @@ public final class ReportExportExecutionResponse { @SerializedName("id") private String exportId; @Expose + private String status; + @Expose private ExecutionRequestOptions options; public String getExportId() { @@ -46,4 +48,8 @@ public String getExportId() { public ExecutionRequestOptions getOptions() { return options; } + + public String getStatus() { + return status; + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java new file mode 100644 index 00000000..ca4c01ca --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java @@ -0,0 +1,34 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.exception; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExportCancelledException extends RuntimeException { + public ExportCancelledException(String reportUri) { + super(String.format("Export for report '%s' was cancelled", reportUri)); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java new file mode 100644 index 00000000..32a07a58 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java @@ -0,0 +1,38 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.exception; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExportFailedException extends RuntimeException { + public ExportFailedException(String reportUri) { + super(String.format("Export for report '%s' failed on server side", reportUri)); + } + + public ExportFailedException(String reportUri, Throwable throwable) { + super(String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()), throwable); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index fe5d777f..14bb6812 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -23,11 +23,19 @@ */ package com.jaspersoft.android.sdk.service.report; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; + import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.service.exception.ExportCancelledException; +import com.jaspersoft.android.sdk.service.exception.ExportFailedException; /** * @author Tom Koptel @@ -39,27 +47,88 @@ public final class ReportExecution { private final ExecutionOptionsDataMapper mExecutionOptionsMapper; private final String mBaseUrl; - private final String mId; + private final long mDelay; + private final ReportExecutionDetailsResponse mState; + @VisibleForTesting ReportExecution( String baseUrl, + long delay, ReportExecutionRestApi.Factory executionApiFactory, ReportExportRestApi.Factory exportApiFactory, - ExecutionOptionsDataMapper executionOptionsMapper, String executionId) { + ExecutionOptionsDataMapper executionOptionsMapper, + ReportExecutionDetailsResponse details) { mBaseUrl = baseUrl; + mDelay = delay; mExecutionApiFactory = executionApiFactory; mExportApiFactory = exportApiFactory; mExecutionOptionsMapper = executionOptionsMapper; - mId = executionId; + mState = details; } public ReportExecutionDetailsResponse requestDetails() { - return mExecutionApiFactory.get().requestReportExecutionDetails(mId); + return mExecutionApiFactory.get().requestReportExecutionDetails(mState.getExecutionId()); } public ReportExport export(RunExportCriteria criteria) { - ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); - ReportExportExecutionResponse details = mExportApiFactory.get().runExportExecution(mId, options); - return new ReportExport(mId, details.getExportId(), mExportApiFactory); + final ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); + ReportExportExecutionResponse exportDetails = mExportApiFactory.get().runExportExecution(mState.getExecutionId(), options); + + final String exportId = exportDetails.getExportId(); + final String executionId = mState.getExecutionId(); + final String reportUri = mState.getReportURI(); + + String status = exportDetails.getStatus(); + // execution, ready, cancelled, failed, queued + if (status.equals("cancelled")) { + throw new ExportCancelledException(reportUri); + } + if (status.equals("failed")) { + throw new ExportFailedException(reportUri); + } + if (status.equals("ready")) { + return createExport(exportId); + } + + // status is "execution" or "queued" + while (!status.equals("ready")) { + try { + Thread.sleep(mDelay); + } catch (InterruptedException ex) { + throw new ExportFailedException(reportUri, ex); + } + ExecutionStatusResponse exportStatus = mExportApiFactory.get() + .checkExportExecutionStatus(executionId, exportId); + + status = exportStatus.getStatus(); + if (status.equals("cancelled")) { + throw new ExportCancelledException(reportUri); + } + if (status.equals("failed")) { + throw new ExportFailedException(reportUri); + } + } + + return createExport(exportId); + } + + @NonNull + private ReportExport createExport(String exportId) { + ReportExecutionDetailsResponse currentDetails = requestDetails(); + ExportExecution export = findExportExecution(currentDetails, exportId); + if (export == null) { + throw new ExportFailedException(mState.getReportURI()); + } + return new ReportExport(mState, export, mExportApiFactory); + } + + @Nullable + private ExportExecution findExportExecution(ReportExecutionDetailsResponse currentDetails, String exportId) { + for (ExportExecution export : currentDetails.getExports()) { + if (exportId.equals(export.getId())) { + return export; + } + } + return null; } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 00a68314..a17de9a3 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -24,24 +24,36 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; +import java.util.Collection; + /** * @author Tom Koptel * @since 2.0 */ public final class ReportExport { - private final String mExecutionId; private final ReportExportRestApi.Factory mExportApiFactory; - private final String mId; + private final ReportExecutionDetailsResponse mExecutionDetails; + private final ExportExecution mExportDetails; - public ReportExport(String executionId, String exportId, ReportExportRestApi.Factory exportApiFactory) { - mId = exportId; - mExecutionId = executionId; + ReportExport(ReportExecutionDetailsResponse executionDetails, + ExportExecution exportDetails, + ReportExportRestApi.Factory exportApiFactory) { + mExecutionDetails = executionDetails; + mExportDetails = exportDetails; mExportApiFactory = exportApiFactory; } + public Collection getAttachments() { + return mExportDetails.getAttachments(); + } + public ExportResourceResponse download() { - return mExportApiFactory.get().requestExportOutput(mExecutionId, mId); + return mExportApiFactory.get() + .requestExportOutput(mExecutionDetails.getExecutionId(), mExportDetails.getId()); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 5e2b9dd6..79128b5a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -33,6 +33,8 @@ import com.jaspersoft.android.sdk.service.TokenProvider; import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; +import java.util.concurrent.TimeUnit; + /** * @author Tom Koptel * @since 2.0 @@ -70,9 +72,10 @@ public ReportExecution run(String reportUri, RunReportCriteria criteria) { ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); return new ReportExecution( mBaseUrl, + TimeUnit.SECONDS.toMillis(2), mExecutionApiFactory, mExportApiFactory, mExecutionOptionsMapper, - details.getExecutionId()); + details); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 79ad1de8..44a75acd 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -3,19 +3,33 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.service.exception.ExportCancelledException; +import com.jaspersoft.android.sdk.service.exception.ExportFailedException; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.Collections; +import java.util.Set; +import java.util.concurrent.TimeUnit; + import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; @@ -25,13 +39,24 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionOptionsDataMapper.class, ReportExportExecutionResponse.class}) +@PrepareForTest({ + ExecutionStatusResponse.class, + ReportExecutionDetailsResponse.class, + ExportExecution.class, + ExecutionOptionsDataMapper.class, + ReportExportExecutionResponse.class}) public class ReportExecutionTest { @Mock RunExportCriteria exportCriteria; @Mock - ReportExportExecutionResponse mExecDetails; + ReportExportExecutionResponse mExportExecDetails; + @Mock + ReportExecutionDetailsResponse mExecDetails; + @Mock + ExportExecution mExportExecution; + @Mock + ExecutionStatusResponse mExecutionStatusResponse; @Mock ReportExportRestApi.Factory mExportApiFactory; @@ -40,40 +65,124 @@ public class ReportExecutionTest { @Mock ReportExecutionRestApi.Factory executionApiFactory; @Mock - ReportExecutionRestApi executionApi; + ReportExecutionRestApi mExecutionApi; private ReportExecution objectUnderTest; private ExecutionOptionsDataMapper mapper; + @Rule + public ExpectedException mException = ExpectedException.none(); + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - when(executionApiFactory.get()).thenReturn(executionApi); + when(executionApiFactory.get()).thenReturn(mExecutionApi); when(mExportApiFactory.get()).thenReturn(mExportRestApi); + when(mExecDetails.getExecutionId()).thenReturn("execution_id"); mapper = spy(ExecutionOptionsDataMapper.getInstance()); + objectUnderTest = new ReportExecution( "http:://localhost", + TimeUnit.SECONDS.toMillis(0), executionApiFactory, mExportApiFactory, mapper, - "execution_id"); + mExecDetails); } @Test public void testRequestDetails() throws Exception { objectUnderTest.requestDetails(); - verify(executionApi).requestReportExecutionDetails("execution_id"); + verify(mExecutionApi).requestReportExecutionDetails("execution_id"); } @Test - public void testRequestExport() throws Exception { - when(mExecDetails.getExportId()).thenReturn("export_id"); - when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExecDetails); + public void testRequestExportIdealCase() throws Exception { + // execution details request + Set exports = Collections.singleton(mExportExecution); + when(mExportExecution.getStatus()).thenReturn("ready"); + when(mExportExecution.getId()).thenReturn("export_id"); + when(mExecDetails.getExports()).thenReturn(exports); + when(mExecutionApi.requestReportExecutionDetails(anyString())).thenReturn(mExecDetails); + + // export run request + when(mExportExecDetails.getExportId()).thenReturn("export_id"); + when(mExportExecDetails.getStatus()).thenReturn("ready"); + when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + objectUnderTest.export(exportCriteria); verify(mapper).transformExportOptions("http:://localhost", exportCriteria); verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); + verify(mExecutionApi).requestReportExecutionDetails(eq("execution_id")); + } + + @Test + public void testRequestRunExportFailedCase() throws Exception { + mException.expect(ExportFailedException.class); + + // export run request + when(mExportExecDetails.getExportId()).thenReturn("export_id"); + when(mExportExecDetails.getStatus()).thenReturn("failed"); + when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + + objectUnderTest.export(exportCriteria); + verify(mapper).transformExportOptions("http:://localhost", exportCriteria); + verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); + verify(mExecutionApi).requestReportExecutionDetails(eq("execution_id")); + } + + @Test + public void testRequestRunExportCancelledCase() throws Exception { + mException.expect(ExportCancelledException.class); + + // export run request + when(mExportExecDetails.getExportId()).thenReturn("export_id"); + when(mExportExecDetails.getStatus()).thenReturn("cancelled"); + when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + + objectUnderTest.export(exportCriteria); + verify(mapper).transformExportOptions("http:://localhost", exportCriteria); + verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); + verify(mExecutionApi).requestReportExecutionDetails(eq("execution_id")); + } + + @Test + public void testRunReportPendingCase() throws Exception { + // export run request + when(mExportExecDetails.getExportId()).thenReturn("export_id"); + when(mExportExecDetails.getStatus()).thenReturn("queued"); + when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + + Answer queueReadyAnswer = new Answer() { + private int invocationCount = 0; + @Override + public ExecutionStatusResponse answer(InvocationOnMock invocation) throws Throwable { + if (invocationCount == 0) { + when(mExecutionStatusResponse.getStatus()).thenReturn("queued"); + invocationCount++; + } else { + when(mExecutionStatusResponse.getStatus()).thenReturn("ready"); + } + return mExecutionStatusResponse; + } + }; + when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).then(queueReadyAnswer); + + Set exports = Collections.singleton(mExportExecution); + when(mExportExecution.getStatus()).thenReturn("ready"); + when(mExportExecution.getId()).thenReturn("export_id"); + when(mExecDetails.getExports()).thenReturn(exports); + when(mExecutionApi.requestReportExecutionDetails(anyString())).thenReturn(mExecDetails); + + objectUnderTest.export(exportCriteria); + + verify(mapper).transformExportOptions("http:://localhost", exportCriteria); + verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); + verify(mExecutionApi).requestReportExecutionDetails(eq("execution_id")); + + verify(mExportRestApi, times(2)).checkExportExecutionStatus(eq("execution_id"), eq("export_id")); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index c4075cd6..a2029ef4 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -1,6 +1,8 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import org.junit.Before; @@ -21,7 +23,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ExportResourceResponse.class}) +@PrepareForTest({ExportResourceResponse.class, ReportExecutionDetailsResponse.class, ExportExecution.class}) public class ReportExportTest { @Mock ReportExportRestApi.Factory mExportApiFactory; @@ -29,6 +31,10 @@ public class ReportExportTest { ReportExportRestApi mExportRestApi; @Mock ExportResourceResponse mExportResourceResponse; + @Mock + ReportExecutionDetailsResponse execDetails; + @Mock + ExportExecution exportDetails; private ReportExport objectUnderTest; @@ -37,7 +43,9 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mExportApiFactory.get()).thenReturn(mExportRestApi); - objectUnderTest = new ReportExport("report_execution_id", "export_id", mExportApiFactory); + when(execDetails.getExecutionId()).thenReturn("report_execution_id"); + when(exportDetails.getId()).thenReturn("export_id"); + objectUnderTest = new ReportExport(execDetails, exportDetails, mExportApiFactory); } @Test From b4dfc4139c51ac37a96a5aea0bac57158d5311d6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 8 Oct 2015 11:55:37 +0300 Subject: [PATCH 189/457] Gerifying ExportException --- .../exception/ExportCancelledException.java | 4 +- .../service/exception/ExportException.java | 42 +++++++++++++++++++ .../exception/ExportFailedException.java | 4 +- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportException.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java index ca4c01ca..448e6bb5 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,7 +27,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExportCancelledException extends RuntimeException { +public final class ExportCancelledException extends ExportException { public ExportCancelledException(String reportUri) { super(String.format("Export for report '%s' was cancelled", reportUri)); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportException.java new file mode 100644 index 00000000..6cc5aafb --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportException.java @@ -0,0 +1,42 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.exception; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class ExportException extends RuntimeException { + public ExportException() { + super(); + } + + public ExportException(String detailMessage) { + super(detailMessage); + } + + public ExportException(String detailMessage, Throwable throwable) { + super(detailMessage, throwable); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java index 32a07a58..3a1be111 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,7 +27,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExportFailedException extends RuntimeException { +public final class ExportFailedException extends ExportException { public ExportFailedException(String reportUri) { super(String.format("Export for report '%s' failed on server side", reportUri)); } From 8fe62612dd64850877d2e8d38489b8d1f769a627 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 8 Oct 2015 11:58:38 +0300 Subject: [PATCH 190/457] Remove hardcoded async option for export criteria mapping --- .../android/sdk/service/report/ExecutionOptionsDataMapper.java | 2 +- .../sdk/service/report/ExecutionOptionsDataMapperTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 4cf6fcfc..0b6eab19 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -48,6 +48,7 @@ public static ExecutionOptionsDataMapper getInstance() { public ReportExecutionRequestOptions transformRunReportOptions(@NonNull String reportUri, @NonNull String serverUrl, @NonNull RunReportCriteria criteria) { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); mapCommonCriterion(serverUrl, criteria, options); + options.withAsync(true); options.withParameters(criteria.getParams()); return options; } @@ -67,7 +68,6 @@ private void mapCommonCriterion(@NonNull String serverUrl, @NonNull ExecutionCri options.withInteractive(criteria.isInteractive()); options.withPages(criteria.getPages()); - options.withAsync(true); options.withBaseUrl(serverUrl); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 32beaf6c..e102f75b 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -45,6 +45,7 @@ public void testTransformReportOptions() throws Exception { ReportExecutionRequestOptions options = mapper.transformRunReportOptions(REPORT_URI, BASE_URL, criteria); assertThat(options.getReportUnitUri(), is(REPORT_URI)); assertThat(options.getParameters(), is(REPORT_PARAMS)); + assertThat(options.getAsync(), is(true)); assertOptions(options); } @@ -67,7 +68,6 @@ private void assertOptions(ExecutionRequestOptions options) { assertThat(options.getSaveDataSnapshot(), is(true)); assertThat(options.getInteractive(), is(false)); assertThat(options.getSaveDataSnapshot(), is(true)); - assertThat(options.getAsync(), is(true)); assertThat(options.getAllowInlineScripts(), is(nullValue())); assertThat(options.getTransformerKey(), is(nullValue())); From 2bbca49731d590ed4ac27a5ccb3cb00dc83ec3d8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 8 Oct 2015 14:00:57 +0300 Subject: [PATCH 191/457] Refactoring ExportException -> ExecutionException --- ....java => ExecutionCancelledException.java} | 14 +++-- ...Exception.java => ExecutionException.java} | 8 +-- .../exception/ExecutionFailedException.java | 56 +++++++++++++++++++ .../exception/ExportCancelledException.java | 34 ----------- .../sdk/service/report/ReportExecution.java | 16 +++--- .../service/report/ReportExecutionTest.java | 11 ++-- 6 files changed, 84 insertions(+), 55 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/{ExportFailedException.java => ExecutionCancelledException.java} (67%) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/{ExportException.java => ExecutionException.java} (84%) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java similarity index 67% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java index 3a1be111..8e064660 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportFailedException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java @@ -27,12 +27,16 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExportFailedException extends ExportException { - public ExportFailedException(String reportUri) { - super(String.format("Export for report '%s' failed on server side", reportUri)); +public final class ExecutionCancelledException extends ExecutionException { + private ExecutionCancelledException(String message) { + super(message); } - public ExportFailedException(String reportUri, Throwable throwable) { - super(String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()), throwable); + public static ExecutionCancelledException forReportExport(String reportUri) { + return new ExecutionCancelledException(String.format("Export for report '%s' was cancelled", reportUri)); + } + + public static ExecutionCancelledException forReport(String reportUri) { + return new ExecutionCancelledException(String.format("Report '%s' was cancelled", reportUri)); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java similarity index 84% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportException.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java index 6cc5aafb..38fac13a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java @@ -27,16 +27,16 @@ * @author Tom Koptel * @since 2.0 */ -public abstract class ExportException extends RuntimeException { - public ExportException() { +public abstract class ExecutionException extends RuntimeException { + public ExecutionException() { super(); } - public ExportException(String detailMessage) { + public ExecutionException(String detailMessage) { super(detailMessage); } - public ExportException(String detailMessage, Throwable throwable) { + public ExecutionException(String detailMessage, Throwable throwable) { super(detailMessage, throwable); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java new file mode 100644 index 00000000..9751605a --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java @@ -0,0 +1,56 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.exception; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExecutionFailedException extends ExecutionException { + private ExecutionFailedException(String message) { + super(message); + } + + private ExecutionFailedException(String message, Throwable throwable) { + super(message, throwable); + } + + public static ExecutionFailedException forReportExport(String reportUri) { + return new ExecutionFailedException(String.format("Export for report '%s' failed on server side", reportUri)); + } + + public static ExecutionFailedException forReport(String reportUri) { + return new ExecutionFailedException(String.format("Report '%s' failed on server side", reportUri)); + } + + public static ExecutionFailedException forReportExport(String reportUri, Throwable throwable) { + String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); + return new ExecutionFailedException(message); + } + + public static ExecutionFailedException forReport(String reportUri, Throwable throwable) { + String message = String.format("Report '%s' execution failed. Reason: %s", reportUri, throwable.getMessage()); + return new ExecutionFailedException(message); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java deleted file mode 100644 index 448e6bb5..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExportCancelledException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.exception; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ExportCancelledException extends ExportException { - public ExportCancelledException(String reportUri) { - super(String.format("Export for report '%s' was cancelled", reportUri)); - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 14bb6812..00acedbb 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -34,8 +34,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.service.exception.ExportCancelledException; -import com.jaspersoft.android.sdk.service.exception.ExportFailedException; +import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; +import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; /** * @author Tom Koptel @@ -81,10 +81,10 @@ public ReportExport export(RunExportCriteria criteria) { String status = exportDetails.getStatus(); // execution, ready, cancelled, failed, queued if (status.equals("cancelled")) { - throw new ExportCancelledException(reportUri); + throw ExecutionCancelledException.forReportExport(reportUri); } if (status.equals("failed")) { - throw new ExportFailedException(reportUri); + throw ExecutionFailedException.forReportExport(reportUri); } if (status.equals("ready")) { return createExport(exportId); @@ -95,17 +95,17 @@ public ReportExport export(RunExportCriteria criteria) { try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw new ExportFailedException(reportUri, ex); + throw ExecutionFailedException.forReportExport(reportUri, ex); } ExecutionStatusResponse exportStatus = mExportApiFactory.get() .checkExportExecutionStatus(executionId, exportId); status = exportStatus.getStatus(); if (status.equals("cancelled")) { - throw new ExportCancelledException(reportUri); + throw ExecutionCancelledException.forReportExport(reportUri); } if (status.equals("failed")) { - throw new ExportFailedException(reportUri); + throw ExecutionFailedException.forReportExport(reportUri); } } @@ -117,7 +117,7 @@ private ReportExport createExport(String exportId) { ReportExecutionDetailsResponse currentDetails = requestDetails(); ExportExecution export = findExportExecution(currentDetails, exportId); if (export == null) { - throw new ExportFailedException(mState.getReportURI()); + throw ExecutionFailedException.forReportExport(mState.getReportURI()); } return new ReportExport(mState, export, mExportApiFactory); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 44a75acd..789c1be2 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -7,8 +7,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.service.exception.ExportCancelledException; -import com.jaspersoft.android.sdk.service.exception.ExportFailedException; +import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; +import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; import org.junit.Before; import org.junit.Rule; @@ -80,6 +80,7 @@ public void setUp() throws Exception { when(executionApiFactory.get()).thenReturn(mExecutionApi); when(mExportApiFactory.get()).thenReturn(mExportRestApi); when(mExecDetails.getExecutionId()).thenReturn("execution_id"); + when(mExecDetails.getReportURI()).thenReturn("/my/uri"); mapper = spy(ExecutionOptionsDataMapper.getInstance()); @@ -121,7 +122,8 @@ public void testRequestExportIdealCase() throws Exception { @Test public void testRequestRunExportFailedCase() throws Exception { - mException.expect(ExportFailedException.class); + mException.expect(ExecutionFailedException.class); + mException.expectMessage("Export for report '/my/uri' failed on server side"); // export run request when(mExportExecDetails.getExportId()).thenReturn("export_id"); @@ -136,7 +138,8 @@ public void testRequestRunExportFailedCase() throws Exception { @Test public void testRequestRunExportCancelledCase() throws Exception { - mException.expect(ExportCancelledException.class); + mException.expect(ExecutionCancelledException.class); + mException.expectMessage("Export for report '/my/uri' was cancelled"); // export run request when(mExportExecDetails.getExportId()).thenReturn("export_id"); From e052e4a7b21b51ed74cf71c624e95e6cc0ff9de9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 8 Oct 2015 14:41:31 +0300 Subject: [PATCH 192/457] Await until report execution receives 'execution' state --- .../ExecutionCancelledException.java | 2 +- .../exception/ExecutionFailedException.java | 2 +- .../sdk/service/report/ReportService.java | 44 ++++++- .../sdk/service/report/ReportServiceTest.java | 111 +++++++++++++++++- 4 files changed, 152 insertions(+), 7 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java index 8e064660..24118920 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java @@ -37,6 +37,6 @@ public static ExecutionCancelledException forReportExport(String reportUri) { } public static ExecutionCancelledException forReport(String reportUri) { - return new ExecutionCancelledException(String.format("Report '%s' was cancelled", reportUri)); + return new ExecutionCancelledException(String.format("Report execution '%s' was cancelled", reportUri)); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java index 9751605a..6ed1d5c2 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java @@ -41,7 +41,7 @@ public static ExecutionFailedException forReportExport(String reportUri) { } public static ExecutionFailedException forReport(String reportUri) { - return new ExecutionFailedException(String.format("Report '%s' failed on server side", reportUri)); + return new ExecutionFailedException(String.format("Report execution '%s' failed on server side", reportUri)); } public static ExecutionFailedException forReportExport(String reportUri, Throwable throwable) { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 79128b5a..3988b2b1 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -28,9 +28,12 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.TokenProvider; +import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; +import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; import java.util.concurrent.TimeUnit; @@ -45,14 +48,17 @@ public class ReportService { private final ServerRestApi.Factory mInfoApiFactory; private final String mBaseUrl; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + private final long mDelay; @VisibleForTesting ReportService(String baseUrl, + long delay, ReportExecutionRestApi.Factory executionApiFactory, ReportExportRestApi.Factory exportApiFactory, ServerRestApi.Factory infoApiFactory, ExecutionOptionsDataMapper executionOptionsMapper) { mBaseUrl = baseUrl; + mDelay = delay; mExecutionApiFactory = executionApiFactory; mExportApiFactory = exportApiFactory; mInfoApiFactory = infoApiFactory; @@ -64,12 +70,44 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider ReportExportRestApiFactory exportApiFactory = new ReportExportRestApiFactory(serverUrl, tokenProvider); ServerRestApiFactory infoApiFactory = new ServerRestApiFactory(serverUrl); ExecutionOptionsDataMapper executionOptionsMapper = ExecutionOptionsDataMapper.getInstance(); - return new ReportService(serverUrl, executionApiFactory, exportApiFactory, infoApiFactory, executionOptionsMapper); + return new ReportService(serverUrl, + TimeUnit.SECONDS.toMillis(1), + executionApiFactory, + exportApiFactory, + infoApiFactory, + executionOptionsMapper); } public ReportExecution run(String reportUri, RunReportCriteria criteria) { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, mBaseUrl, criteria); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); + String executionStatus = details.getStatus(); + + if (executionStatus.equals("cancelled")) { + throw ExecutionCancelledException.forReport(reportUri); + } + if (executionStatus.equals("failed")) { + throw ExecutionFailedException.forReport(reportUri); + } + + String executionId = details.getExecutionId(); + executionStatus = requestDetails(executionId).getStatus(); + + while (!executionStatus.equals("ready") && !executionStatus.equals("execution")) { + try { + Thread.sleep(mDelay); + } catch (InterruptedException ex) { + throw ExecutionFailedException.forReport(reportUri, ex); + } + executionStatus = requestDetails(executionId).getStatus(); + if (executionStatus.equals("cancelled")) { + throw ExecutionCancelledException.forReport(reportUri); + } + if (executionStatus.equals("failed")) { + throw ExecutionFailedException.forReport(reportUri); + } + } + return new ReportExecution( mBaseUrl, TimeUnit.SECONDS.toMillis(2), @@ -78,4 +116,8 @@ public ReportExecution run(String reportUri, RunReportCriteria criteria) { mExecutionOptionsMapper, details); } + + private ExecutionStatusResponse requestDetails(String executionId) { + return mExecutionApiFactory.get().requestReportExecutionStatus(executionId); + } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index b0dce8f5..dcf130ec 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -3,21 +3,32 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; +import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.concurrent.TimeUnit; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; @@ -27,7 +38,10 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ReportExecutionDetailsResponse.class, ExecutionOptionsDataMapper.class}) +@PrepareForTest({ + ExecutionStatusResponse.class, + ReportExecutionDetailsResponse.class, + ExecutionOptionsDataMapper.class}) public class ReportServiceTest { @Mock @@ -45,10 +59,15 @@ public class ReportServiceTest { @Mock RunReportCriteria configuration; @Mock - ReportExecutionDetailsResponse details; + ReportExecutionDetailsResponse initDetails; + @Mock + ExecutionStatusResponse statusDetails; ReportService objectUnderTest; + @Rule + public ExpectedException mException = ExpectedException.none(); + private ExecutionOptionsDataMapper mapper; @Before @@ -60,6 +79,7 @@ public void setUp() throws Exception { mapper = spy(ExecutionOptionsDataMapper.getInstance()); objectUnderTest = new ReportService("http:://localhost", + TimeUnit.MILLISECONDS.toMillis(0), executionApiFactory, mExportApiFactory, infoApiFactory, @@ -68,8 +88,12 @@ public void setUp() throws Exception { @Test public void testRunShouldCreateActiveSession() { - when(details.getExecutionId()).thenReturn("any_id"); - when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(details); + when(initDetails.getStatus()).thenReturn("execution"); + when(initDetails.getExecutionId()).thenReturn("exec_id"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + + when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); + when(statusDetails.getStatus()).thenReturn("ready"); ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); @@ -78,4 +102,83 @@ public void testRunShouldCreateActiveSession() { verify(executionApi).runReportExecution(any(ReportExecutionRequestOptions.class)); } + @Test + public void testRunThrowsFailedStatusImmediately() { + mException.expect(ExecutionFailedException.class); + mException.expectMessage("Report execution '/report/uri' failed on server side"); + + when(initDetails.getExecutionId()).thenReturn("exec_id"); + when(initDetails.getStatus()).thenReturn("failed"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + + objectUnderTest.run("/report/uri", configuration); + } + + @Test + public void testRunShouldThrowFailedIfStatusFailed() { + mException.expect(ExecutionFailedException.class); + mException.expectMessage("Report execution '/report/uri' failed on server side"); + + when(initDetails.getStatus()).thenReturn("execution"); + when(initDetails.getExecutionId()).thenReturn("exec_id"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + + when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); + when(statusDetails.getStatus()).thenReturn("failed"); + + objectUnderTest.run("/report/uri", configuration); + } + + @Test + public void testRunThrowsCancelledStatusImmediately() { + mException.expect(ExecutionCancelledException.class); + mException.expectMessage("Report execution '/report/uri' was cancelled"); + + when(initDetails.getExecutionId()).thenReturn("exec_id"); + when(initDetails.getStatus()).thenReturn("cancelled"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + + objectUnderTest.run("/report/uri", configuration); + } + + @Test + public void testRunShouldThrowCancelledIfStatusCancelled() { + mException.expect(ExecutionCancelledException.class); + mException.expectMessage("Report execution '/report/uri' was cancelled"); + + when(initDetails.getStatus()).thenReturn("execution"); + when(initDetails.getExecutionId()).thenReturn("exec_id"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + + when(statusDetails.getStatus()).thenReturn("cancelled"); + when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); + + objectUnderTest.run("/report/uri", configuration); + } + + @Test + public void testRunShouldLoopUntilStatusExecution() { + when(initDetails.getStatus()).thenReturn("queued"); + when(initDetails.getExecutionId()).thenReturn("exec_id"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + + + when(statusDetails.getStatus()).then(new Answer() { + private int count = 0; + + @Override + public String answer(InvocationOnMock invocation) throws Throwable { + if (count > 0) { + return "execution"; + } else { + count++; + return "queued"; + } + } + }); + when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); + + objectUnderTest.run("/report/uri", configuration); + verify(executionApi, times(2)).requestReportExecutionStatus(eq("exec_id")); + } } \ No newline at end of file From d6d400ed33df3cb96a68ac16f1a0aff57d84622e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 11:11:59 +0300 Subject: [PATCH 193/457] Refactor report service execution event --- .../sdk/service/report/ReportService.java | 46 +++++++------- .../android/sdk/service/report/Status.java | 60 +++++++++++++++++++ .../sdk/service/report/ReportServiceTest.java | 5 +- 3 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 3988b2b1..62d8a50f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -81,43 +81,39 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider public ReportExecution run(String reportUri, RunReportCriteria criteria) { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, mBaseUrl, criteria); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); - String executionStatus = details.getStatus(); - if (executionStatus.equals("cancelled")) { - throw ExecutionCancelledException.forReport(reportUri); - } - if (executionStatus.equals("failed")) { - throw ExecutionFailedException.forReport(reportUri); - } + waitForReportExecutionStart(reportUri, details); + + return new ReportExecution( + mBaseUrl, + TimeUnit.SECONDS.toMillis(2), + mExecutionApiFactory, + mExportApiFactory, + mExecutionOptionsMapper, + details); + } + private void waitForReportExecutionStart(String reportUri, ReportExecutionDetailsResponse details) { String executionId = details.getExecutionId(); - executionStatus = requestDetails(executionId).getStatus(); + Status status = Status.wrap(details.getStatus()); - while (!executionStatus.equals("ready") && !executionStatus.equals("execution")) { + while (!status.isReady() && !status.isExecution()) { + if (status.isCancelled()) { + throw ExecutionCancelledException.forReport(reportUri); + } + if (status.isFailed()) { + throw ExecutionFailedException.forReport(reportUri); + } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { throw ExecutionFailedException.forReport(reportUri, ex); } - executionStatus = requestDetails(executionId).getStatus(); - if (executionStatus.equals("cancelled")) { - throw ExecutionCancelledException.forReport(reportUri); - } - if (executionStatus.equals("failed")) { - throw ExecutionFailedException.forReport(reportUri); - } + status = Status.wrap(requestStatus(executionId).getStatus()); } - - return new ReportExecution( - mBaseUrl, - TimeUnit.SECONDS.toMillis(2), - mExecutionApiFactory, - mExportApiFactory, - mExecutionOptionsMapper, - details); } - private ExecutionStatusResponse requestDetails(String executionId) { + private ExecutionStatusResponse requestStatus(String executionId) { return mExecutionApiFactory.get().requestReportExecutionStatus(executionId); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java new file mode 100644 index 00000000..e956129b --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java @@ -0,0 +1,60 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class Status { + private final String mStatus; + + private Status(String status) { + mStatus = status; + } + + public static Status wrap(String status) { + return new Status(status); + } + + public boolean isQueued() { + return mStatus.equals("queued"); + } + + public boolean isExecution() { + return mStatus.equals("execution"); + } + + public boolean isCancelled() { + return mStatus.equals("cancelled"); + } + + public boolean isFailed() { + return mStatus.equals("failed"); + } + + public boolean isReady() { + return mStatus.equals("ready"); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index dcf130ec..5ee62d98 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -119,7 +119,7 @@ public void testRunShouldThrowFailedIfStatusFailed() { mException.expect(ExecutionFailedException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); - when(initDetails.getStatus()).thenReturn("execution"); + when(initDetails.getStatus()).thenReturn("queued"); when(initDetails.getExecutionId()).thenReturn("exec_id"); when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); @@ -146,7 +146,7 @@ public void testRunShouldThrowCancelledIfStatusCancelled() { mException.expect(ExecutionCancelledException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); - when(initDetails.getStatus()).thenReturn("execution"); + when(initDetails.getStatus()).thenReturn("queued"); when(initDetails.getExecutionId()).thenReturn("exec_id"); when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); @@ -162,7 +162,6 @@ public void testRunShouldLoopUntilStatusExecution() { when(initDetails.getExecutionId()).thenReturn("exec_id"); when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); - when(statusDetails.getStatus()).then(new Answer() { private int count = 0; From 0e48fbef79c67d78d6c3e4e20f607e45a4b4542e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 11:49:21 +0300 Subject: [PATCH 194/457] Add missing tests for loop exceptions --- .../service/report/ReportExecutionTest.java | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 789c1be2..65eb801d 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -121,7 +121,7 @@ public void testRequestExportIdealCase() throws Exception { } @Test - public void testRequestRunExportFailedCase() throws Exception { + public void testRunThrowsFailedStatusImmediately() throws Exception { mException.expect(ExecutionFailedException.class); mException.expectMessage("Export for report '/my/uri' failed on server side"); @@ -131,13 +131,24 @@ public void testRequestRunExportFailedCase() throws Exception { when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); objectUnderTest.export(exportCriteria); - verify(mapper).transformExportOptions("http:://localhost", exportCriteria); - verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); - verify(mExecutionApi).requestReportExecutionDetails(eq("execution_id")); } @Test - public void testRequestRunExportCancelledCase() throws Exception { + public void testRunShouldThrowFailedIfStatusFailed() { + mException.expect(ExecutionFailedException.class); + mException.expectMessage("Export for report '/my/uri' failed on server side"); + + when(mExportExecDetails.getExportId()).thenReturn("export_id"); + when(mExportExecDetails.getStatus()).thenReturn("queued"); + when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + + when(mExecutionStatusResponse.getStatus()).thenReturn("failed"); + when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); + objectUnderTest.export(exportCriteria); + } + + @Test + public void testRunThrowsCancelledStatusImmediately() throws Exception { mException.expect(ExecutionCancelledException.class); mException.expectMessage("Export for report '/my/uri' was cancelled"); @@ -147,9 +158,20 @@ public void testRequestRunExportCancelledCase() throws Exception { when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); objectUnderTest.export(exportCriteria); - verify(mapper).transformExportOptions("http:://localhost", exportCriteria); - verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); - verify(mExecutionApi).requestReportExecutionDetails(eq("execution_id")); + } + + @Test + public void testRunShouldThrowCancelledIfStatusCancelled() { + mException.expect(ExecutionCancelledException.class); + mException.expectMessage("Export for report '/my/uri' was cancelled"); + + when(mExportExecDetails.getExportId()).thenReturn("export_id"); + when(mExportExecDetails.getStatus()).thenReturn("queued"); + when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + + when(mExecutionStatusResponse.getStatus()).thenReturn("cancelled"); + when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); + objectUnderTest.export(exportCriteria); } @Test From a183a4d36abcb2c72ad2b646fa5afb2b10b23aee Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 11:50:58 +0300 Subject: [PATCH 195/457] Simplifying exception handling flow for export --- .../sdk/service/report/ReportExecution.java | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 00acedbb..e573bdbe 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -78,20 +78,16 @@ public ReportExport export(RunExportCriteria criteria) { final String executionId = mState.getExecutionId(); final String reportUri = mState.getReportURI(); - String status = exportDetails.getStatus(); - // execution, ready, cancelled, failed, queued - if (status.equals("cancelled")) { - throw ExecutionCancelledException.forReportExport(reportUri); - } - if (status.equals("failed")) { - throw ExecutionFailedException.forReportExport(reportUri); - } - if (status.equals("ready")) { - return createExport(exportId); - } + Status status = Status.wrap(exportDetails.getStatus()); // status is "execution" or "queued" - while (!status.equals("ready")) { + while (!status.isReady()) { + if (status.isCancelled()) { + throw ExecutionCancelledException.forReportExport(reportUri); + } + if (status.isFailed()) { + throw ExecutionFailedException.forReportExport(reportUri); + } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { @@ -100,13 +96,7 @@ public ReportExport export(RunExportCriteria criteria) { ExecutionStatusResponse exportStatus = mExportApiFactory.get() .checkExportExecutionStatus(executionId, exportId); - status = exportStatus.getStatus(); - if (status.equals("cancelled")) { - throw ExecutionCancelledException.forReportExport(reportUri); - } - if (status.equals("failed")) { - throw ExecutionFailedException.forReportExport(reportUri); - } + status = Status.wrap(exportStatus.getStatus()); } return createExport(exportId); From 9884f410a3f25b3bd06efaf36e64703b53d5fedc Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 12:32:06 +0300 Subject: [PATCH 196/457] Refactor execution tests --- .../service/report/ReportExecutionTest.java | 80 ++++++------------- .../sdk/service/report/StatusChain.java | 54 +++++++++++++ 2 files changed, 80 insertions(+), 54 deletions(-) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 65eb801d..2edf3688 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -17,8 +17,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -101,17 +99,8 @@ public void testRequestDetails() throws Exception { @Test public void testRequestExportIdealCase() throws Exception { - // execution details request - Set exports = Collections.singleton(mExportExecution); - when(mExportExecution.getStatus()).thenReturn("ready"); - when(mExportExecution.getId()).thenReturn("export_id"); - when(mExecDetails.getExports()).thenReturn(exports); - when(mExecutionApi.requestReportExecutionDetails(anyString())).thenReturn(mExecDetails); - - // export run request - when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).thenReturn("ready"); - when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + mockReportExecutionDetails(); + mockRunReportExecution("ready"); objectUnderTest.export(exportCriteria); @@ -126,9 +115,7 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { mException.expectMessage("Export for report '/my/uri' failed on server side"); // export run request - when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).thenReturn("failed"); - when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + mockRunReportExecution("failed"); objectUnderTest.export(exportCriteria); } @@ -138,12 +125,9 @@ public void testRunShouldThrowFailedIfStatusFailed() { mException.expect(ExecutionFailedException.class); mException.expectMessage("Export for report '/my/uri' failed on server side"); - when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).thenReturn("queued"); - when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + mockRunReportExecution("queued"); - when(mExecutionStatusResponse.getStatus()).thenReturn("failed"); - when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); + mockCheckExportExecStatus("failed"); objectUnderTest.export(exportCriteria); } @@ -153,9 +137,7 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { mException.expectMessage("Export for report '/my/uri' was cancelled"); // export run request - when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).thenReturn("cancelled"); - when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + mockRunReportExecution("cancelled"); objectUnderTest.export(exportCriteria); } @@ -165,49 +147,39 @@ public void testRunShouldThrowCancelledIfStatusCancelled() { mException.expect(ExecutionCancelledException.class); mException.expectMessage("Export for report '/my/uri' was cancelled"); - when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).thenReturn("queued"); - when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + mockRunReportExecution("queued"); + mockCheckExportExecStatus("cancelled"); - when(mExecutionStatusResponse.getStatus()).thenReturn("cancelled"); - when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); objectUnderTest.export(exportCriteria); } @Test public void testRunReportPendingCase() throws Exception { - // export run request + mockRunReportExecution("queued"); + mockCheckExportExecStatus("queued", "ready"); + mockReportExecutionDetails(); + + objectUnderTest.export(exportCriteria); + + verify(mExportRestApi, times(2)).checkExportExecutionStatus(eq("execution_id"), eq("export_id")); + } + + private void mockCheckExportExecStatus(String... statusChain) { + when(mExecutionStatusResponse.getStatus()).then(StatusChain.of(statusChain)); + when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); + } + + private void mockRunReportExecution(String... statusChain) { when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).thenReturn("queued"); + when(mExportExecDetails.getStatus()).then(StatusChain.of(statusChain)); when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + } - Answer queueReadyAnswer = new Answer() { - private int invocationCount = 0; - @Override - public ExecutionStatusResponse answer(InvocationOnMock invocation) throws Throwable { - if (invocationCount == 0) { - when(mExecutionStatusResponse.getStatus()).thenReturn("queued"); - invocationCount++; - } else { - when(mExecutionStatusResponse.getStatus()).thenReturn("ready"); - } - return mExecutionStatusResponse; - } - }; - when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).then(queueReadyAnswer); - + private void mockReportExecutionDetails() { Set exports = Collections.singleton(mExportExecution); when(mExportExecution.getStatus()).thenReturn("ready"); when(mExportExecution.getId()).thenReturn("export_id"); when(mExecDetails.getExports()).thenReturn(exports); when(mExecutionApi.requestReportExecutionDetails(anyString())).thenReturn(mExecDetails); - - objectUnderTest.export(exportCriteria); - - verify(mapper).transformExportOptions("http:://localhost", exportCriteria); - verify(mExportRestApi).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); - verify(mExecutionApi).requestReportExecutionDetails(eq("execution_id")); - - verify(mExportRestApi, times(2)).checkExportExecutionStatus(eq("execution_id"), eq("export_id")); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java new file mode 100644 index 00000000..ebb046a3 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java @@ -0,0 +1,54 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class StatusChain implements Answer { + private final String[] mChain; + private int invocationCount = 0; + + private StatusChain(String... chain) { + mChain = chain; + } + + public static StatusChain of(String... statuses) { + return new StatusChain(statuses); + } + + @Override + public String answer(InvocationOnMock invocation) throws Throwable { + int statusIndex = invocationCount; + if (statusIndex >= mChain.length) { + statusIndex = mChain.length - 1; + } + invocationCount++; + return mChain[statusIndex]; + } +} \ No newline at end of file From 333b73d2ad61e753dbe7664356ff9b7671d5a1c2 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 12:48:37 +0300 Subject: [PATCH 197/457] Rerun export one time during cancelled event --- .../sdk/service/report/ReportExecution.java | 14 +++++++++++++- .../sdk/service/report/ReportExecutionTest.java | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index e573bdbe..25b354dc 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -71,6 +71,19 @@ public ReportExecutionDetailsResponse requestDetails() { } public ReportExport export(RunExportCriteria criteria) { + try { + return performExport(criteria); + } catch (ExecutionCancelledException ex) { + /** + * Cancelled by technical reason. User applied Jive(for e.g. have applied new filter). + * Cancelled when report execution finished. This event flags that we need rerun export. + */ + return performExport(criteria); + } + } + + @NonNull + private ReportExport performExport(RunExportCriteria criteria) { final ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); ReportExportExecutionResponse exportDetails = mExportApiFactory.get().runExportExecution(mState.getExecutionId(), options); @@ -80,7 +93,6 @@ public ReportExport export(RunExportCriteria criteria) { Status status = Status.wrap(exportDetails.getStatus()); - // status is "execution" or "queued" while (!status.isReady()) { if (status.isCancelled()) { throw ExecutionCancelledException.forReportExport(reportUri); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 2edf3688..f9190a0e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -164,6 +164,16 @@ public void testRunReportPendingCase() throws Exception { verify(mExportRestApi, times(2)).checkExportExecutionStatus(eq("execution_id"), eq("export_id")); } + @Test + public void ensureThatExportCancelledEventWillBeResolved() { + mockRunReportExecution("cancelled", "ready"); + mockReportExecutionDetails(); + + objectUnderTest.export(exportCriteria); + + verify(mExportRestApi, times(2)).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); + } + private void mockCheckExportExecStatus(String... statusChain) { when(mExecutionStatusResponse.getStatus()).then(StatusChain.of(statusChain)); when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); From a1f76046bebe7c961211bd9521a7b64145610f1c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 12:55:19 +0300 Subject: [PATCH 198/457] Add status test --- .../sdk/service/report/StatusTest.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java new file mode 100644 index 00000000..22e9c6c9 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java @@ -0,0 +1,66 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class StatusTest { + @Test + public void testStatusShouldBeQueued() { + Status status = Status.wrap("queued"); + assertThat(status.isQueued(), is(true)); + } + + @Test + public void testStatusShouldBeExecution() { + Status status = Status.wrap("execution"); + assertThat(status.isExecution(), is(true)); + } + + @Test + public void testStatusShouldBeCancelled() { + Status status = Status.wrap("cancelled"); + assertThat(status.isCancelled(), is(true)); + } + + @Test + public void testStatusShouldBeFailed() { + Status status = Status.wrap("failed"); + assertThat(status.isFailed(), is(true)); + } + + @Test + public void testStatusShouldBeReady() { + Status status = Status.wrap("ready"); + assertThat(status.isReady(), is(true)); + } +} From 9c414d50b2b38007e80a90ece2f1352e17bad6ff Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 13:01:12 +0300 Subject: [PATCH 199/457] Refactor ReportServiceTest --- .../sdk/service/report/ReportServiceTest.java | 67 +++++++------------ 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 5ee62d98..d7d783ce 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -16,8 +16,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -30,6 +28,7 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; @@ -88,18 +87,15 @@ public void setUp() throws Exception { @Test public void testRunShouldCreateActiveSession() { - when(initDetails.getStatus()).thenReturn("execution"); - when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); - - when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); - when(statusDetails.getStatus()).thenReturn("ready"); + mockRunReportExecution("execution"); + mockRunReportExecution("ready"); ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); verify(mapper).transformRunReportOptions("/report/uri", "http:://localhost", configuration); verify(executionApi).runReportExecution(any(ReportExecutionRequestOptions.class)); + verifyNoMoreInteractions(executionApi); } @Test @@ -107,9 +103,7 @@ public void testRunThrowsFailedStatusImmediately() { mException.expect(ExecutionFailedException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); - when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(initDetails.getStatus()).thenReturn("failed"); - when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + mockRunReportExecution("failed"); objectUnderTest.run("/report/uri", configuration); } @@ -119,12 +113,8 @@ public void testRunShouldThrowFailedIfStatusFailed() { mException.expect(ExecutionFailedException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); - when(initDetails.getStatus()).thenReturn("queued"); - when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); - - when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); - when(statusDetails.getStatus()).thenReturn("failed"); + mockRunReportExecution("queued"); + mockReportExecutionStatus("failed"); objectUnderTest.run("/report/uri", configuration); } @@ -134,9 +124,7 @@ public void testRunThrowsCancelledStatusImmediately() { mException.expect(ExecutionCancelledException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); - when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(initDetails.getStatus()).thenReturn("cancelled"); - when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + mockRunReportExecution("cancelled"); objectUnderTest.run("/report/uri", configuration); } @@ -146,38 +134,29 @@ public void testRunShouldThrowCancelledIfStatusCancelled() { mException.expect(ExecutionCancelledException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); - when(initDetails.getStatus()).thenReturn("queued"); - when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); - - when(statusDetails.getStatus()).thenReturn("cancelled"); - when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); + mockRunReportExecution("queued"); + mockReportExecutionStatus("cancelled"); objectUnderTest.run("/report/uri", configuration); } @Test public void testRunShouldLoopUntilStatusExecution() { - when(initDetails.getStatus()).thenReturn("queued"); - when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); - - when(statusDetails.getStatus()).then(new Answer() { - private int count = 0; - - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - if (count > 0) { - return "execution"; - } else { - count++; - return "queued"; - } - } - }); - when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); + mockRunReportExecution("queued"); + mockReportExecutionStatus("queued", "execution"); objectUnderTest.run("/report/uri", configuration); verify(executionApi, times(2)).requestReportExecutionStatus(eq("exec_id")); } + + private void mockReportExecutionStatus(String... statusChain) { + when(statusDetails.getStatus()).then(StatusChain.of(statusChain)); + when(executionApi.requestReportExecutionStatus(any(String.class))).thenReturn(statusDetails); + } + + private void mockRunReportExecution(String execution) { + when(initDetails.getStatus()).thenReturn(execution); + when(initDetails.getExecutionId()).thenReturn("exec_id"); + when(executionApi.runReportExecution(any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + } } \ No newline at end of file From 7cf72a6b15b46b6c1115ace678531448b2b5fe06 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 13:23:51 +0300 Subject: [PATCH 200/457] Generifying execution exception --- .../ExecutionCancelledException.java | 42 ------- .../service/exception/ExecutionException.java | 106 ++++++++++++++++-- .../exception/ExecutionFailedException.java | 56 --------- .../sdk/service/report/ReportExecution.java | 26 +++-- .../sdk/service/report/ReportService.java | 9 +- .../service/report/ReportExecutionTest.java | 11 +- .../sdk/service/report/ReportServiceTest.java | 11 +- 7 files changed, 126 insertions(+), 135 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java deleted file mode 100644 index 24118920..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionCancelledException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.exception; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ExecutionCancelledException extends ExecutionException { - private ExecutionCancelledException(String message) { - super(message); - } - - public static ExecutionCancelledException forReportExport(String reportUri) { - return new ExecutionCancelledException(String.format("Export for report '%s' was cancelled", reportUri)); - } - - public static ExecutionCancelledException forReport(String reportUri) { - return new ExecutionCancelledException(String.format("Report execution '%s' was cancelled", reportUri)); - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java index 38fac13a..caca09f4 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -27,16 +27,106 @@ * @author Tom Koptel * @since 2.0 */ -public abstract class ExecutionException extends RuntimeException { - public ExecutionException() { - super(); +public final class ExecutionException extends RuntimeException { + private final Kind mKind; + + private ExecutionException(Kind kind, String message) { + super(message); + mKind = kind; + } + + private ExecutionException(Kind kind, String message, Throwable throwable) { + super(message, throwable); + mKind = kind; + } + + public static ExecutionException reportFailed(String reportUri) { + return Kind.FAILED.report(reportUri); + } + + public static ExecutionException reportFailed(String reportUri, Throwable throwable) { + return Kind.FAILED.report(reportUri, throwable); } - public ExecutionException(String detailMessage) { - super(detailMessage); + public static ExecutionException exportFailed(String reportUri) { + return Kind.FAILED.export(reportUri); } - public ExecutionException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); + public static ExecutionException exportFailed(String reportUri, Throwable throwable) { + return Kind.FAILED.export(reportUri, throwable); + } + + public static ExecutionException reportCancelled(String reportUri) { + return Kind.CANCELLED.report(reportUri); + } + + public static ExecutionException exportCancelled(String reportUri) { + return Kind.CANCELLED.export(reportUri); + } + + public boolean isCancelled() { + return Kind.CANCELLED == mKind; + } + + public boolean isFailed() { + return Kind.FAILED == mKind; + } + + private enum Kind { + FAILED { + @Override + public ExecutionException report(String reportUri) { + String message = String.format("Report execution '%s' failed on server side", reportUri); + return new ExecutionException(this, message); + } + + @Override + public ExecutionException report(String reportUri, Throwable throwable) { + String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); + return new ExecutionException(this, message, throwable); + } + + @Override + public ExecutionException export(String reportUri) { + String message = String.format("Export for report '%s' failed on server side", reportUri); + return new ExecutionException(this, message); + } + + @Override + public ExecutionException export(String reportUri, Throwable throwable) { + String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); + return new ExecutionException(this, message, throwable); + } + }, CANCELLED { + @Override + public ExecutionException report(String reportUri) { + String message = String.format("Report execution '%s' was cancelled", reportUri); + return new ExecutionException(this, message); + } + + @Override + public ExecutionException report(String reportUri, Throwable throwable) { + throw new UnsupportedOperationException(); + } + + @Override + public ExecutionException export(String reportUri) { + String message = String.format("Export for report '%s' was cancelled", reportUri); + return new ExecutionException(this, message); + } + + @Override + public ExecutionException export(String reportUri, Throwable throwable) { + throw new UnsupportedOperationException(); + } + }; + + public abstract ExecutionException report(String reportUri); + + public abstract ExecutionException report(String reportUri, Throwable throwable); + + public abstract ExecutionException export(String reportUri); + + public abstract ExecutionException export(String reportUri, Throwable throwable); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java deleted file mode 100644 index 6ed1d5c2..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionFailedException.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.exception; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ExecutionFailedException extends ExecutionException { - private ExecutionFailedException(String message) { - super(message); - } - - private ExecutionFailedException(String message, Throwable throwable) { - super(message, throwable); - } - - public static ExecutionFailedException forReportExport(String reportUri) { - return new ExecutionFailedException(String.format("Export for report '%s' failed on server side", reportUri)); - } - - public static ExecutionFailedException forReport(String reportUri) { - return new ExecutionFailedException(String.format("Report execution '%s' failed on server side", reportUri)); - } - - public static ExecutionFailedException forReportExport(String reportUri, Throwable throwable) { - String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); - return new ExecutionFailedException(message); - } - - public static ExecutionFailedException forReport(String reportUri, Throwable throwable) { - String message = String.format("Report '%s' execution failed. Reason: %s", reportUri, throwable.getMessage()); - return new ExecutionFailedException(message); - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 25b354dc..0c3b25f9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -34,8 +34,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; -import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; +import com.jaspersoft.android.sdk.service.exception.ExecutionException; /** * @author Tom Koptel @@ -73,12 +72,15 @@ public ReportExecutionDetailsResponse requestDetails() { public ReportExport export(RunExportCriteria criteria) { try { return performExport(criteria); - } catch (ExecutionCancelledException ex) { - /** - * Cancelled by technical reason. User applied Jive(for e.g. have applied new filter). - * Cancelled when report execution finished. This event flags that we need rerun export. - */ - return performExport(criteria); + } catch (ExecutionException ex) { + if (ex.isCancelled()) { + /** + * Cancelled by technical reason. User applied Jive(for e.g. have applied new filter). + * Cancelled when report execution finished. This event flags that we need rerun export. + */ + return performExport(criteria); + } + throw ex; } } @@ -95,15 +97,15 @@ private ReportExport performExport(RunExportCriteria criteria) { while (!status.isReady()) { if (status.isCancelled()) { - throw ExecutionCancelledException.forReportExport(reportUri); + throw ExecutionException.exportCancelled(reportUri); } if (status.isFailed()) { - throw ExecutionFailedException.forReportExport(reportUri); + throw ExecutionException.exportFailed(reportUri); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw ExecutionFailedException.forReportExport(reportUri, ex); + throw ExecutionException.exportFailed(reportUri, ex); } ExecutionStatusResponse exportStatus = mExportApiFactory.get() .checkExportExecutionStatus(executionId, exportId); @@ -119,7 +121,7 @@ private ReportExport createExport(String exportId) { ReportExecutionDetailsResponse currentDetails = requestDetails(); ExportExecution export = findExportExecution(currentDetails, exportId); if (export == null) { - throw ExecutionFailedException.forReportExport(mState.getReportURI()); + throw ExecutionException.exportFailed(mState.getReportURI()); } return new ReportExport(mState, export, mExportApiFactory); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 62d8a50f..c0b6702b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -32,8 +32,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.TokenProvider; -import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; -import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; +import com.jaspersoft.android.sdk.service.exception.ExecutionException; import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; import java.util.concurrent.TimeUnit; @@ -99,15 +98,15 @@ private void waitForReportExecutionStart(String reportUri, ReportExecutionDetail while (!status.isReady() && !status.isExecution()) { if (status.isCancelled()) { - throw ExecutionCancelledException.forReport(reportUri); + throw ExecutionException.reportCancelled(reportUri); } if (status.isFailed()) { - throw ExecutionFailedException.forReport(reportUri); + throw ExecutionException.reportFailed(reportUri); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw ExecutionFailedException.forReport(reportUri, ex); + throw ExecutionException.reportFailed(reportUri, ex); } status = Status.wrap(requestStatus(executionId).getStatus()); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index f9190a0e..075166bc 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -7,8 +7,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; -import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; +import com.jaspersoft.android.sdk.service.exception.ExecutionException; import org.junit.Before; import org.junit.Rule; @@ -111,7 +110,7 @@ public void testRequestExportIdealCase() throws Exception { @Test public void testRunThrowsFailedStatusImmediately() throws Exception { - mException.expect(ExecutionFailedException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Export for report '/my/uri' failed on server side"); // export run request @@ -122,7 +121,7 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { @Test public void testRunShouldThrowFailedIfStatusFailed() { - mException.expect(ExecutionFailedException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Export for report '/my/uri' failed on server side"); mockRunReportExecution("queued"); @@ -133,7 +132,7 @@ public void testRunShouldThrowFailedIfStatusFailed() { @Test public void testRunThrowsCancelledStatusImmediately() throws Exception { - mException.expect(ExecutionCancelledException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Export for report '/my/uri' was cancelled"); // export run request @@ -144,7 +143,7 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { @Test public void testRunShouldThrowCancelledIfStatusCancelled() { - mException.expect(ExecutionCancelledException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Export for report '/my/uri' was cancelled"); mockRunReportExecution("queued"); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index d7d783ce..fd6f91d1 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -6,8 +6,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.exception.ExecutionCancelledException; -import com.jaspersoft.android.sdk.service.exception.ExecutionFailedException; +import com.jaspersoft.android.sdk.service.exception.ExecutionException; import org.junit.Before; import org.junit.Rule; @@ -100,7 +99,7 @@ public void testRunShouldCreateActiveSession() { @Test public void testRunThrowsFailedStatusImmediately() { - mException.expect(ExecutionFailedException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); mockRunReportExecution("failed"); @@ -110,7 +109,7 @@ public void testRunThrowsFailedStatusImmediately() { @Test public void testRunShouldThrowFailedIfStatusFailed() { - mException.expect(ExecutionFailedException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); mockRunReportExecution("queued"); @@ -121,7 +120,7 @@ public void testRunShouldThrowFailedIfStatusFailed() { @Test public void testRunThrowsCancelledStatusImmediately() { - mException.expect(ExecutionCancelledException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); mockRunReportExecution("cancelled"); @@ -131,7 +130,7 @@ public void testRunThrowsCancelledStatusImmediately() { @Test public void testRunShouldThrowCancelledIfStatusCancelled() { - mException.expect(ExecutionCancelledException.class); + mException.expect(ExecutionException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); mockRunReportExecution("queued"); From bc30b684b262e0c67fcdf67ae2df1bea7ded9ac3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 20:12:13 +0300 Subject: [PATCH 201/457] Incapsulating ExecutionException --- .../ExecutionException.java | 96 +++++++++--------- .../sdk/service/report/ReportExecution.java | 9 +- .../sdk/service/report/ReportService.java | 11 ++- .../exception/ReportExportException.java | 34 +++++++ .../report/exception/ReportRunException.java | 34 +++++++ .../report/ExecutionExceptionTest.java | 97 +++++++++++++++++++ .../service/report/ReportExecutionTest.java | 10 +- .../sdk/service/report/ReportServiceTest.java | 10 +- 8 files changed, 240 insertions(+), 61 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/{exception => report}/ExecutionException.java (58%) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java similarity index 58% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java index caca09f4..29812d44 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/exception/ExecutionException.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java @@ -21,13 +21,16 @@ * along with Jaspersoft Mobile for Android. If not, see * . */ -package com.jaspersoft.android.sdk.service.exception; +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; +import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; /** * @author Tom Koptel * @since 2.0 */ -public final class ExecutionException extends RuntimeException { +final class ExecutionException extends RuntimeException { private final Kind mKind; private ExecutionException(Kind kind, String message) { @@ -41,92 +44,91 @@ private ExecutionException(Kind kind, String message, Throwable throwable) { } public static ExecutionException reportFailed(String reportUri) { - return Kind.FAILED.report(reportUri); + return Kind.REPORT_FAILED.exception(reportUri); } public static ExecutionException reportFailed(String reportUri, Throwable throwable) { - return Kind.FAILED.report(reportUri, throwable); + return Kind.REPORT_FAILED.exception(reportUri, throwable); } - public static ExecutionException exportFailed(String reportUri) { - return Kind.FAILED.export(reportUri); + public static ExecutionException reportCancelled(String reportUri) { + return Kind.REPORT_CANCELLED.exception(reportUri); } - public static ExecutionException exportFailed(String reportUri, Throwable throwable) { - return Kind.FAILED.export(reportUri, throwable); + public static ExecutionException exportFailed(String reportUri) { + return Kind.EXPORT_FAILED.exception(reportUri); } - public static ExecutionException reportCancelled(String reportUri) { - return Kind.CANCELLED.report(reportUri); + public static ExecutionException exportFailed(String reportUri, Throwable throwable) { + return Kind.EXPORT_FAILED.exception(reportUri, throwable); } public static ExecutionException exportCancelled(String reportUri) { - return Kind.CANCELLED.export(reportUri); + return Kind.EXPORT_CANCELLED.exception(reportUri); } public boolean isCancelled() { - return Kind.CANCELLED == mKind; + return Kind.EXPORT_CANCELLED == mKind || Kind.REPORT_CANCELLED == mKind; } - public boolean isFailed() { - return Kind.FAILED == mKind; + public RuntimeException adaptToClientException() { + switch (mKind) { + case REPORT_FAILED: + case REPORT_CANCELLED: + return new ReportRunException(getMessage(), getCause()); + case EXPORT_FAILED: + case EXPORT_CANCELLED: + return new ReportExportException(getMessage(), getCause()); + } + return new UnsupportedOperationException("Unexpected type of kind: " + mKind); } private enum Kind { - FAILED { + REPORT_FAILED { @Override - public ExecutionException report(String reportUri) { + public ExecutionException exception(String reportUri) { String message = String.format("Report execution '%s' failed on server side", reportUri); return new ExecutionException(this, message); } - @Override - public ExecutionException report(String reportUri, Throwable throwable) { - String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); + public ExecutionException exception(String reportUri, Throwable throwable) { + String message = String.format("Report execution '%s' failed. Reason: %s", reportUri, throwable.getMessage()); return new ExecutionException(this, message, throwable); } - + }, + REPORT_CANCELLED { @Override - public ExecutionException export(String reportUri) { - String message = String.format("Export for report '%s' failed on server side", reportUri); + public ExecutionException exception(String reportUri) { + String message = String.format("Report execution '%s' was cancelled", reportUri); return new ExecutionException(this, message); } - - @Override - public ExecutionException export(String reportUri, Throwable throwable) { - String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); - return new ExecutionException(this, message, throwable); - } - }, CANCELLED { + }, + EXPORT_FAILED { @Override - public ExecutionException report(String reportUri) { - String message = String.format("Report execution '%s' was cancelled", reportUri); + public ExecutionException exception(String reportUri) { + String message = String.format("Export for report '%s' failed on server side", reportUri); return new ExecutionException(this, message); } - @Override - public ExecutionException report(String reportUri, Throwable throwable) { - throw new UnsupportedOperationException(); + public ExecutionException exception(String reportUri, Throwable throwable) { + String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); + return new ExecutionException(this, message, throwable); } - + }, + EXPORT_CANCELLED { @Override - public ExecutionException export(String reportUri) { + public ExecutionException exception(String reportUri) { String message = String.format("Export for report '%s' was cancelled", reportUri); return new ExecutionException(this, message); } - - @Override - public ExecutionException export(String reportUri, Throwable throwable) { - throw new UnsupportedOperationException(); - } }; - public abstract ExecutionException report(String reportUri); - - public abstract ExecutionException report(String reportUri, Throwable throwable); - - public abstract ExecutionException export(String reportUri); + public ExecutionException exception(String message) { + throw new UnsupportedOperationException(); + } - public abstract ExecutionException export(String reportUri, Throwable throwable); + public ExecutionException exception(String message, Throwable throwable) { + throw new UnsupportedOperationException(); + } } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 0c3b25f9..9f37fcc4 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -34,7 +34,6 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.service.exception.ExecutionException; /** * @author Tom Koptel @@ -78,9 +77,13 @@ public ReportExport export(RunExportCriteria criteria) { * Cancelled by technical reason. User applied Jive(for e.g. have applied new filter). * Cancelled when report execution finished. This event flags that we need rerun export. */ - return performExport(criteria); + try { + return performExport(criteria); + } catch (ExecutionException nestedEx) { + throw nestedEx.adaptToClientException(); + } } - throw ex; + throw ex.adaptToClientException(); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index c0b6702b..ce71f75d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -23,6 +23,7 @@ */ package com.jaspersoft.android.sdk.service.report; +import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; @@ -32,7 +33,6 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.TokenProvider; -import com.jaspersoft.android.sdk.service.exception.ExecutionException; import com.jaspersoft.android.sdk.service.server.ServerRestApiFactory; import java.util.concurrent.TimeUnit; @@ -78,6 +78,15 @@ public static ReportService create(String serverUrl, TokenProvider tokenProvider } public ReportExecution run(String reportUri, RunReportCriteria criteria) { + try { + return performRun(reportUri, criteria); + } catch (ExecutionException ex) { + throw ex.adaptToClientException(); + } + } + + @NonNull + private ReportExecution performRun(String reportUri, RunReportCriteria criteria) { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, mBaseUrl, criteria); ReportExecutionDetailsResponse details = mExecutionApiFactory.get().runReportExecution(options); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java new file mode 100644 index 00000000..2d58685d --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java @@ -0,0 +1,34 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report.exception; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExportException extends RuntimeException { + public ReportExportException(String detailMessage, Throwable throwable) { + super(detailMessage, throwable); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java new file mode 100644 index 00000000..ab697481 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java @@ -0,0 +1,34 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report.exception; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportRunException extends RuntimeException { + public ReportRunException(String detailMessage, Throwable throwable) { + super(detailMessage, throwable); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java new file mode 100644 index 00000000..06fe40e5 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java @@ -0,0 +1,97 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; +import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ExecutionExceptionTest { + + @Test + public void testReportFailed() throws Exception { + ExecutionException ex = ExecutionException.reportFailed("/my/uri"); + assertThat(ex.getMessage(), is("Report execution '/my/uri' failed on server side")); + } + + @Test + public void testReportFailedWithThrowable() throws Exception { + ExecutionException ex = ExecutionException.reportFailed("/my/uri", new InterruptedException("interrupted")); + assertThat(ex.getMessage(), is("Report execution '/my/uri' failed. Reason: interrupted")); + assertThat(ex.getCause(), is(instanceOf(InterruptedException.class))); + } + + @Test + public void testReportCancelled() throws Exception { + ExecutionException ex = ExecutionException.reportCancelled("/my/uri"); + assertThat(ex.getMessage(), is("Report execution '/my/uri' was cancelled")); + } + + @Test + public void testExportFailed() throws Exception { + ExecutionException ex = ExecutionException.exportFailed("/my/uri"); + assertThat(ex.getMessage(), is("Export for report '/my/uri' failed on server side")); + } + + @Test + public void testExportFailedWithThrowable() throws Exception { + ExecutionException ex = ExecutionException.exportFailed("/my/uri", new InterruptedException("interrupted")); + assertThat(ex.getMessage(), is("Export for report '/my/uri' failed. Reason: interrupted")); + } + + @Test + public void testExportCancelled() throws Exception { + ExecutionException ex = ExecutionException.exportCancelled("/my/uri"); + assertThat(ex.getMessage(), is("Export for report '/my/uri' was cancelled")); + + } + + @Test + public void testIsCancelled() throws Exception { + ExecutionException exportEx = ExecutionException.exportCancelled("/my/uri"); + assertThat(exportEx.isCancelled(), is(true)); + + ExecutionException reportEx = ExecutionException.reportCancelled("/my/uri"); + assertThat(reportEx.isCancelled(), is(true)); + } + + @Test + public void testReportCancelledAdaptsToClientEx() throws Exception { + ExecutionException ex = ExecutionException.reportCancelled("/"); + RuntimeException runtimeException = ex.adaptToClientException(); + assertThat(runtimeException.getMessage(), is(notNullValue())); + assertThat(runtimeException, is(instanceOf(ReportRunException.class))); + } + + @Test + public void testReportFailedAdaptsToClientEx() throws Exception { + ExecutionException ex = ExecutionException.reportFailed("/"); + RuntimeException runtimeException = ex.adaptToClientException(); + assertThat(runtimeException.getMessage(), is(notNullValue())); + assertThat(runtimeException, is(instanceOf(ReportRunException.class))); + } + + @Test + public void testExportCancelledAdaptsToClientEx() throws Exception { + ExecutionException ex = ExecutionException.exportCancelled("/"); + RuntimeException runtimeException = ex.adaptToClientException(); + assertThat(runtimeException.getMessage(), is(notNullValue())); + assertThat(runtimeException, is(instanceOf(ReportExportException.class))); + } + + @Test + public void testExportFailedAdaptsToClientEx() throws Exception { + ExecutionException ex = ExecutionException.exportFailed("/"); + RuntimeException runtimeException = ex.adaptToClientException(); + assertThat(runtimeException.getMessage(), is(notNullValue())); + assertThat(runtimeException, is(instanceOf(ReportExportException.class))); + } +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 075166bc..c5de18a0 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -7,7 +7,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; -import com.jaspersoft.android.sdk.service.exception.ExecutionException; +import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; import org.junit.Before; import org.junit.Rule; @@ -110,7 +110,7 @@ public void testRequestExportIdealCase() throws Exception { @Test public void testRunThrowsFailedStatusImmediately() throws Exception { - mException.expect(ExecutionException.class); + mException.expect(ReportExportException.class); mException.expectMessage("Export for report '/my/uri' failed on server side"); // export run request @@ -121,7 +121,7 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { @Test public void testRunShouldThrowFailedIfStatusFailed() { - mException.expect(ExecutionException.class); + mException.expect(ReportExportException.class); mException.expectMessage("Export for report '/my/uri' failed on server side"); mockRunReportExecution("queued"); @@ -132,7 +132,7 @@ public void testRunShouldThrowFailedIfStatusFailed() { @Test public void testRunThrowsCancelledStatusImmediately() throws Exception { - mException.expect(ExecutionException.class); + mException.expect(ReportExportException.class); mException.expectMessage("Export for report '/my/uri' was cancelled"); // export run request @@ -143,7 +143,7 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { @Test public void testRunShouldThrowCancelledIfStatusCancelled() { - mException.expect(ExecutionException.class); + mException.expect(ReportExportException.class); mException.expectMessage("Export for report '/my/uri' was cancelled"); mockRunReportExecution("queued"); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index fd6f91d1..ebc7fd14 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -6,7 +6,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.exception.ExecutionException; +import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; import org.junit.Before; import org.junit.Rule; @@ -99,7 +99,7 @@ public void testRunShouldCreateActiveSession() { @Test public void testRunThrowsFailedStatusImmediately() { - mException.expect(ExecutionException.class); + mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); mockRunReportExecution("failed"); @@ -109,7 +109,7 @@ public void testRunThrowsFailedStatusImmediately() { @Test public void testRunShouldThrowFailedIfStatusFailed() { - mException.expect(ExecutionException.class); + mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); mockRunReportExecution("queued"); @@ -120,7 +120,7 @@ public void testRunShouldThrowFailedIfStatusFailed() { @Test public void testRunThrowsCancelledStatusImmediately() { - mException.expect(ExecutionException.class); + mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); mockRunReportExecution("cancelled"); @@ -130,7 +130,7 @@ public void testRunThrowsCancelledStatusImmediately() { @Test public void testRunShouldThrowCancelledIfStatusCancelled() { - mException.expect(ExecutionException.class); + mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); mockRunReportExecution("queued"); From 95e068cbbadc1f4fac60470b8fa0387859959fe9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 20:15:20 +0300 Subject: [PATCH 202/457] Remove dual behavior from 'createExport' helper --- .../android/sdk/service/report/ReportExecution.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 9f37fcc4..29df5311 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -116,12 +116,12 @@ private ReportExport performExport(RunExportCriteria criteria) { status = Status.wrap(exportStatus.getStatus()); } - return createExport(exportId); + ReportExecutionDetailsResponse currentDetails = requestDetails(); + return createExport(currentDetails, exportId); } @NonNull - private ReportExport createExport(String exportId) { - ReportExecutionDetailsResponse currentDetails = requestDetails(); + private ReportExport createExport(ReportExecutionDetailsResponse currentDetails, String exportId) { ExportExecution export = findExportExecution(currentDetails, exportId); if (export == null) { throw ExecutionException.exportFailed(mState.getReportURI()); From 6827e6a95fd9635e7f5a1bb6fa73d9659788cb64 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 9 Oct 2015 20:25:57 +0300 Subject: [PATCH 203/457] Refactor 'ReportExecution' internal methods --- .../sdk/service/report/ReportExecution.java | 33 ++++++++++++------- .../service/report/ReportExecutionTest.java | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 29df5311..bac785be 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -64,10 +64,6 @@ public final class ReportExecution { mState = details; } - public ReportExecutionDetailsResponse requestDetails() { - return mExecutionApiFactory.get().requestReportExecutionDetails(mState.getExecutionId()); - } - public ReportExport export(RunExportCriteria criteria) { try { return performExport(criteria); @@ -89,15 +85,24 @@ public ReportExport export(RunExportCriteria criteria) { @NonNull private ReportExport performExport(RunExportCriteria criteria) { - final ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); - ReportExportExecutionResponse exportDetails = mExportApiFactory.get().runExportExecution(mState.getExecutionId(), options); + ReportExportExecutionResponse exportDetails = runExport(criteria); + waitForExportReadyStatus(exportDetails); + ReportExecutionDetailsResponse currentDetails = requestExecutionDetails(); + + return createExport(currentDetails, exportDetails); + } + + @NonNull + private ReportExecutionDetailsResponse requestExecutionDetails() { + return mExecutionApiFactory.get().requestReportExecutionDetails(mState.getExecutionId()); + } + private void waitForExportReadyStatus(ReportExportExecutionResponse exportDetails) { final String exportId = exportDetails.getExportId(); final String executionId = mState.getExecutionId(); final String reportUri = mState.getReportURI(); Status status = Status.wrap(exportDetails.getStatus()); - while (!status.isReady()) { if (status.isCancelled()) { throw ExecutionException.exportCancelled(reportUri); @@ -115,14 +120,12 @@ private ReportExport performExport(RunExportCriteria criteria) { status = Status.wrap(exportStatus.getStatus()); } - - ReportExecutionDetailsResponse currentDetails = requestDetails(); - return createExport(currentDetails, exportId); } @NonNull - private ReportExport createExport(ReportExecutionDetailsResponse currentDetails, String exportId) { - ExportExecution export = findExportExecution(currentDetails, exportId); + private ReportExport createExport(ReportExecutionDetailsResponse currentDetails, + ReportExportExecutionResponse exportDetails) { + ExportExecution export = findExportExecution(currentDetails, exportDetails.getExportId()); if (export == null) { throw ExecutionException.exportFailed(mState.getReportURI()); } @@ -138,4 +141,10 @@ private ExportExecution findExportExecution(ReportExecutionDetailsResponse curre } return null; } + + @NonNull + private ReportExportExecutionResponse runExport(RunExportCriteria criteria) { + ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); + return mExportApiFactory.get().runExportExecution(mState.getExecutionId(), options); + } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index c5de18a0..402d2e44 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -92,7 +92,7 @@ public void setUp() throws Exception { @Test public void testRequestDetails() throws Exception { - objectUnderTest.requestDetails(); + objectUnderTest.requestExecutionDetails(); verify(mExecutionApi).requestReportExecutionDetails("execution_id"); } From 6af2e57e960b76a0daa8ff3f0b0cd8d6ae3b2997 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Sun, 11 Oct 2015 20:49:55 +0300 Subject: [PATCH 204/457] Remove test on incapsulated method 'requstExecutionDetails' --- .../android/sdk/service/report/ReportExecutionTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 402d2e44..6ca6926e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -90,12 +90,6 @@ public void setUp() throws Exception { mExecDetails); } - @Test - public void testRequestDetails() throws Exception { - objectUnderTest.requestExecutionDetails(); - verify(mExecutionApi).requestReportExecutionDetails("execution_id"); - } - @Test public void testRequestExportIdealCase() throws Exception { mockReportExecutionDetails(); From 4e61e9814095a797072e588010a6f7ee155c1f41 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 12 Oct 2015 10:51:04 +0300 Subject: [PATCH 205/457] Implementing 'awaitCompleteReport' in ReportExecution --- .../service/data/report/ReportMetadata.java | 47 +++++++++ .../sdk/service/report/ReportExecution.java | 44 +++++++++ .../service/report/ReportExecutionTest.java | 95 +++++++++++++++---- 3 files changed, 168 insertions(+), 18 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java new file mode 100644 index 00000000..1cd57afc --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java @@ -0,0 +1,47 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportMetadata { + private final String uri; + private final int totalPages; + + public ReportMetadata(String uri, int totalPages) { + this.uri = uri; + this.totalPages = totalPages; + } + + public String getUri() { + return uri; + } + + public int getTotalPages() { + return totalPages; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index bac785be..a7c142a7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -34,6 +34,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; /** * @author Tom Koptel @@ -64,6 +65,16 @@ public final class ReportExecution { mState = details; } + @NonNull + public ReportMetadata awaitCompleteReport() { + try { + return performAwaitFoReport(); + } catch (ExecutionException ex) { + throw ex.adaptToClientException(); + } + } + + @NonNull public ReportExport export(RunExportCriteria criteria) { try { return performExport(criteria); @@ -147,4 +158,37 @@ private ReportExportExecutionResponse runExport(RunExportCriteria criteria) { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(mBaseUrl, criteria); return mExportApiFactory.get().runExportExecution(mState.getExecutionId(), options); } + + + @NonNull + private ReportMetadata performAwaitFoReport() { + ReportExecutionDetailsResponse details = requestExecutionDetails(); + ReportExecutionDetailsResponse completeDetails = waitForReportReadyStart(details); + return new ReportMetadata(completeDetails.getReportURI(), + completeDetails.getTotalPages()); + } + + @NonNull + private ReportExecutionDetailsResponse waitForReportReadyStart(final ReportExecutionDetailsResponse details) { + String reportUri = details.getReportURI(); + Status status = Status.wrap(details.getStatus()); + + ReportExecutionDetailsResponse resultDetails = details; + while (!status.isReady()) { + if (status.isCancelled()) { + throw ExecutionException.reportCancelled(reportUri); + } + if (status.isFailed()) { + throw ExecutionException.reportFailed(reportUri); + } + try { + Thread.sleep(mDelay); + } catch (InterruptedException ex) { + throw ExecutionException.reportFailed(reportUri, ex); + } + resultDetails = requestExecutionDetails(); + status = Status.wrap(details.getStatus()); + } + return resultDetails; + } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 6ca6926e..c473a8b8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -7,7 +7,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; +import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; import org.junit.Before; import org.junit.Rule; @@ -23,11 +25,14 @@ import java.util.Set; import java.util.concurrent.TimeUnit; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; @@ -77,7 +82,7 @@ public void setUp() throws Exception { when(executionApiFactory.get()).thenReturn(mExecutionApi); when(mExportApiFactory.get()).thenReturn(mExportRestApi); when(mExecDetails.getExecutionId()).thenReturn("execution_id"); - when(mExecDetails.getReportURI()).thenReturn("/my/uri"); + when(mExecDetails.getReportURI()).thenReturn("/report/uri"); mapper = spy(ExecutionOptionsDataMapper.getInstance()); @@ -92,8 +97,8 @@ public void setUp() throws Exception { @Test public void testRequestExportIdealCase() throws Exception { - mockReportExecutionDetails(); - mockRunReportExecution("ready"); + mockReportExecutionDetails("ready"); + mockRunExportExecution("ready"); objectUnderTest.export(exportCriteria); @@ -105,10 +110,10 @@ public void testRequestExportIdealCase() throws Exception { @Test public void testRunThrowsFailedStatusImmediately() throws Exception { mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/my/uri' failed on server side"); + mException.expectMessage("Export for report '/report/uri' failed on server side"); // export run request - mockRunReportExecution("failed"); + mockRunExportExecution("failed"); objectUnderTest.export(exportCriteria); } @@ -116,9 +121,9 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { @Test public void testRunShouldThrowFailedIfStatusFailed() { mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/my/uri' failed on server side"); + mException.expectMessage("Export for report '/report/uri' failed on server side"); - mockRunReportExecution("queued"); + mockRunExportExecution("queued"); mockCheckExportExecStatus("failed"); objectUnderTest.export(exportCriteria); @@ -127,10 +132,10 @@ public void testRunShouldThrowFailedIfStatusFailed() { @Test public void testRunThrowsCancelledStatusImmediately() throws Exception { mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/my/uri' was cancelled"); + mException.expectMessage("Export for report '/report/uri' was cancelled"); // export run request - mockRunReportExecution("cancelled"); + mockRunExportExecution("cancelled"); objectUnderTest.export(exportCriteria); } @@ -138,9 +143,9 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { @Test public void testRunShouldThrowCancelledIfStatusCancelled() { mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/my/uri' was cancelled"); + mException.expectMessage("Export for report '/report/uri' was cancelled"); - mockRunReportExecution("queued"); + mockRunExportExecution("queued"); mockCheckExportExecStatus("cancelled"); objectUnderTest.export(exportCriteria); @@ -148,9 +153,9 @@ public void testRunShouldThrowCancelledIfStatusCancelled() { @Test public void testRunReportPendingCase() throws Exception { - mockRunReportExecution("queued"); + mockRunExportExecution("queued"); mockCheckExportExecStatus("queued", "ready"); - mockReportExecutionDetails(); + mockReportExecutionDetails("ready"); objectUnderTest.export(exportCriteria); @@ -159,30 +164,84 @@ public void testRunReportPendingCase() throws Exception { @Test public void ensureThatExportCancelledEventWillBeResolved() { - mockRunReportExecution("cancelled", "ready"); - mockReportExecutionDetails(); + mockRunExportExecution("cancelled", "ready"); + mockReportExecutionDetails("ready"); objectUnderTest.export(exportCriteria); verify(mExportRestApi, times(2)).runExportExecution(eq("execution_id"), any(ExecutionRequestOptions.class)); } + @Test + public void testAwaitCompleteReport() throws Exception { + when(mExecDetails.getReportURI()).thenReturn("/report/uri"); + when(mExecDetails.getTotalPages()).thenReturn(100); + mockReportExecutionDetails("ready"); + + ReportMetadata metadata = objectUnderTest.awaitCompleteReport(); + assertThat(metadata.getTotalPages(), is(100)); + assertThat(metadata.getUri(), is("/report/uri")); + + verify(mExecutionApi).requestReportExecutionDetails(anyString()); + verifyNoMoreInteractions(mExecutionApi); + } + + @Test + public void testAwaitCompleteReportShouldLoopCalls() throws Exception { + mockReportExecutionDetails("execution", "ready"); + + objectUnderTest.awaitCompleteReport(); + + verify(mExecutionApi, times(2)).requestReportExecutionDetails(anyString()); + verifyNoMoreInteractions(mExecutionApi); + } + + @Test + public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() { + mException.expect(ReportRunException.class); + mException.expectMessage("Report execution '/report/uri' was cancelled"); + + mockReportExecutionDetails("execution", "cancelled"); + + objectUnderTest.awaitCompleteReport(); + } + + @Test + public void testAwaitCompleteReportThrowFailedIfStatusFailed() { + mException.expect(ReportRunException.class); + mException.expectMessage("Report execution '/report/uri' failed on server side"); + + mockReportExecutionDetails("execution", "failed"); + + objectUnderTest.awaitCompleteReport(); + } + private void mockCheckExportExecStatus(String... statusChain) { + ensureChain(statusChain); when(mExecutionStatusResponse.getStatus()).then(StatusChain.of(statusChain)); when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); } - private void mockRunReportExecution(String... statusChain) { + private void mockRunExportExecution(String... statusChain) { + ensureChain(statusChain); when(mExportExecDetails.getExportId()).thenReturn("export_id"); when(mExportExecDetails.getStatus()).then(StatusChain.of(statusChain)); when(mExportRestApi.runExportExecution(anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); } - private void mockReportExecutionDetails() { + private void mockReportExecutionDetails(String... statusChain) { + ensureChain(statusChain); Set exports = Collections.singleton(mExportExecution); - when(mExportExecution.getStatus()).thenReturn("ready"); + when(mExportExecution.getStatus()).thenReturn("execution"); when(mExportExecution.getId()).thenReturn("export_id"); when(mExecDetails.getExports()).thenReturn(exports); + when(mExecDetails.getStatus()).then(StatusChain.of(statusChain)); when(mExecutionApi.requestReportExecutionDetails(anyString())).thenReturn(mExecDetails); } + + private void ensureChain(String[] statusChain) { + if (statusChain.length == 0) { + throw new IllegalArgumentException("You should supply at least one status: ready, queued, execution, cancelled, failed"); + } + } } \ No newline at end of file From 6c78e6c1374b07d269b6b9786cadfc6dee6e437d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 12 Oct 2015 13:53:51 +0300 Subject: [PATCH 206/457] Implementing 'ReportAttachment' --- .../execution/ReportOutputResource.java | 22 +------ .../sdk/service/report/ReportAttachment.java | 55 +++++++++++++++++ .../service/report/ReportAttachmentTest.java | 61 +++++++++++++++++++ 3 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java index e913133f..ea8bfaa3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -44,26 +44,6 @@ public String getFileName() { return fileName; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ReportOutputResource that = (ReportOutputResource) o; - - if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) - return false; - return !(fileName != null ? !fileName.equals(that.fileName) : that.fileName != null); - - } - - @Override - public int hashCode() { - int result = contentType != null ? contentType.hashCode() : 0; - result = 31 * result + (fileName != null ? fileName.hashCode() : 0); - return result; - } - @Override public String toString() { return "ReportOutputResource{" + diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java new file mode 100644 index 00000000..79d64eed --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -0,0 +1,55 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.export.ExportInput; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportAttachment { + private final ReportExportRestApi.Factory mExportApiFactory; + private final String mFileName; + private final String mExportId; + private final String mExecutionId; + + ReportAttachment(String fileName, + String executionId, + String exportId, + ReportExportRestApi.Factory exportApiFactory) { + mFileName = fileName; + mExportId = exportId; + mExecutionId = executionId; + mExportApiFactory = exportApiFactory; + } + + @NonNull + public ExportInput download() { + return mExportApiFactory.get().requestExportAttachment(mExecutionId, mExportId, mFileName); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java new file mode 100644 index 00000000..860b200b --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -0,0 +1,61 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.export.ExportInput; +import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.*; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ExportInput.class}) +public class ReportAttachmentTest { + @Mock + ReportExportRestApi.Factory mExportApiFactory; + @Mock + ReportExportRestApi mExportRestApi; + @Mock + ExportInput input; + + private ReportAttachment objectUnderTest; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + when(mExportApiFactory.get()).thenReturn(mExportRestApi); + + objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", mExportApiFactory); + } + + @Test + public void testDownload() throws Exception { + when(mExportRestApi.requestExportAttachment(anyString(), anyString(), anyString())).thenReturn(input); + + ExportInput result = objectUnderTest.download(); + assertThat(result, is(notNullValue())); + + verify(mExportRestApi).requestExportAttachment(eq("exec_id"), eq("export_id"), eq("1.jpg")); + verifyNoMoreInteractions(mExportRestApi); + } +} \ No newline at end of file From 3a9e052fbda9802da2a855dc83777db7f1e350c5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 12 Oct 2015 14:08:41 +0300 Subject: [PATCH 207/457] Connection report attachments with report export --- .../sdk/service/report/ReportAttachment.java | 4 +-- .../sdk/service/report/ReportExecution.java | 24 ++++++++++++++++- .../sdk/service/report/ReportExport.java | 26 ++++++++++++------- .../sdk/service/report/ReportExportTest.java | 4 ++- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index 79d64eed..307aff02 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -35,16 +35,16 @@ public final class ReportAttachment { private final ReportExportRestApi.Factory mExportApiFactory; private final String mFileName; - private final String mExportId; private final String mExecutionId; + private final String mExportId; ReportAttachment(String fileName, String executionId, String exportId, ReportExportRestApi.Factory exportApiFactory) { mFileName = fileName; - mExportId = exportId; mExecutionId = executionId; + mExportId = exportId; mExportApiFactory = exportApiFactory; } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index bac785be..37d02de9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -33,8 +33,13 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ReportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; + /** * @author Tom Koptel * @since 2.0 @@ -129,7 +134,24 @@ private ReportExport createExport(ReportExecutionDetailsResponse currentDetails, if (export == null) { throw ExecutionException.exportFailed(mState.getReportURI()); } - return new ReportExport(mState, export, mExportApiFactory); + + String executionId = currentDetails.getExecutionId(); + String exportId = exportDetails.getExportId(); + Collection attachments = adaptAttachments(export); + return new ReportExport(executionId, exportId, attachments, mExportApiFactory); + } + + private Collection adaptAttachments(ExportExecution export) { + String executionId = mState.getExecutionId(); + String exportId = export.getId(); + Set rawAttachments = export.getAttachments(); + Collection attachments = new ArrayList<>(rawAttachments.size()); + for (ReportOutputResource attachment : rawAttachments) { + ReportAttachment reportAttachment = new ReportAttachment( + attachment.getFileName(), executionId, exportId, mExportApiFactory); + attachments.add(reportAttachment); + } + return attachments; } @Nullable diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index a17de9a3..b78fb1d9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -23,6 +23,8 @@ */ package com.jaspersoft.android.sdk.service.report; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExportExecution; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; @@ -37,23 +39,27 @@ */ public final class ReportExport { private final ReportExportRestApi.Factory mExportApiFactory; - private final ReportExecutionDetailsResponse mExecutionDetails; - private final ExportExecution mExportDetails; + private final Collection mAttachments; + private final String mExecutionId; + private final String mExportId; - ReportExport(ReportExecutionDetailsResponse executionDetails, - ExportExecution exportDetails, + ReportExport(String executionId, + String exportId, + Collection attachments, ReportExportRestApi.Factory exportApiFactory) { - mExecutionDetails = executionDetails; - mExportDetails = exportDetails; + mExecutionId = executionId; + mExportId = exportId; + mAttachments = attachments; mExportApiFactory = exportApiFactory; } - public Collection getAttachments() { - return mExportDetails.getAttachments(); + @NonNull + public Collection getAttachments() { + return mAttachments; } + @NonNull public ExportResourceResponse download() { - return mExportApiFactory.get() - .requestExportOutput(mExecutionDetails.getExecutionId(), mExportDetails.getId()); + return mExportApiFactory.get().requestExportOutput(mExecutionId, mExportId); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index a2029ef4..1747643c 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -13,6 +13,8 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.Collections; + import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -45,7 +47,7 @@ public void setUp() throws Exception { when(mExportApiFactory.get()).thenReturn(mExportRestApi); when(execDetails.getExecutionId()).thenReturn("report_execution_id"); when(exportDetails.getId()).thenReturn("export_id"); - objectUnderTest = new ReportExport(execDetails, exportDetails, mExportApiFactory); + objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), mExportApiFactory); } @Test From cf78f5e44734e15100e2dfc0638dc348c63f190e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 12 Oct 2015 14:15:59 +0300 Subject: [PATCH 208/457] Refactoring api 'awaitCompleteReport' -> 'waitForReportCompletion' --- .../android/sdk/service/report/ReportExecution.java | 2 +- .../android/sdk/service/report/ReportExecutionTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index a7c142a7..cb9b55de 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -66,7 +66,7 @@ public final class ReportExecution { } @NonNull - public ReportMetadata awaitCompleteReport() { + public ReportMetadata waitForReportCompletion() { try { return performAwaitFoReport(); } catch (ExecutionException ex) { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index c473a8b8..460ff3cc 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -178,7 +178,7 @@ public void testAwaitCompleteReport() throws Exception { when(mExecDetails.getTotalPages()).thenReturn(100); mockReportExecutionDetails("ready"); - ReportMetadata metadata = objectUnderTest.awaitCompleteReport(); + ReportMetadata metadata = objectUnderTest.waitForReportCompletion(); assertThat(metadata.getTotalPages(), is(100)); assertThat(metadata.getUri(), is("/report/uri")); @@ -190,7 +190,7 @@ public void testAwaitCompleteReport() throws Exception { public void testAwaitCompleteReportShouldLoopCalls() throws Exception { mockReportExecutionDetails("execution", "ready"); - objectUnderTest.awaitCompleteReport(); + objectUnderTest.waitForReportCompletion(); verify(mExecutionApi, times(2)).requestReportExecutionDetails(anyString()); verifyNoMoreInteractions(mExecutionApi); @@ -203,7 +203,7 @@ public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() { mockReportExecutionDetails("execution", "cancelled"); - objectUnderTest.awaitCompleteReport(); + objectUnderTest.waitForReportCompletion(); } @Test @@ -213,7 +213,7 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() { mockReportExecutionDetails("execution", "failed"); - objectUnderTest.awaitCompleteReport(); + objectUnderTest.waitForReportCompletion(); } private void mockCheckExportExecStatus(String... statusChain) { From 28a1d7513be1fd45b0102c58b124a80a5739d9b1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 12 Oct 2015 18:08:31 +0300 Subject: [PATCH 209/457] Refactoring DTO names for report execution API --- .../network/api/ReportExecutionRestApi.java | 10 +- .../api/ReportExecutionRestApiImpl.java | 26 ++-- .../sdk/network/api/ReportExportRestApi.java | 4 +- .../network/api/ReportExportRestApiImpl.java | 8 +- ...esource.java => AttachmentDescriptor.java} | 6 +- ...atusResponse.java => ExecutionStatus.java} | 10 +- .../entity/execution/ExportDescriptor.java | 73 +++++++++++ .../entity/execution/ExportExecution.java | 114 ------------------ .../execution/OutputResourceDescriptor.java | 51 ++++++++ ...se.java => ReportExecutionDescriptor.java} | 6 +- ...est.java => AttachmentDescriptorTest.java} | 4 +- ...onseTest.java => ExecutionStatusTest.java} | 4 +- ...ionTest.java => ExportDescriptorTest.java} | 4 +- .../OutputResourceDescriptorTest.java | 32 +++++ ...ava => ReportExecutionDescriptorTest.java} | 6 +- ...> ReportExportDescriptorResponseTest.java} | 2 +- .../api/ReportExecutionRestApiTest.java | 24 ++-- .../api/ReportExportRestApiTest.java | 16 +-- 18 files changed, 221 insertions(+), 179 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/{ReportOutputResource.java => AttachmentDescriptor.java} (93%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/{ExecutionStatusResponse.java => ExecutionStatus.java} (86%) create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecution.java create mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/{ReportExecutionDetailsResponse.java => ReportExecutionDescriptor.java} (93%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/{ReportOutputResourceTest.java => AttachmentDescriptorTest.java} (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/{ExecutionStatusResponseTest.java => ExecutionStatusTest.java} (93%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/{ExportExecutionTest.java => ExportDescriptorTest.java} (94%) create mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/{ReportExecutionDetailsResponseTest.java => ReportExecutionDescriptorTest.java} (90%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/{ReportExportExecutionResponseTest.java => ReportExportDescriptorResponseTest.java} (97%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index daeb8804..1eb5c37b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -27,8 +27,8 @@ import android.support.annotation.NonNull; import android.support.annotation.WorkerThread; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; @@ -44,15 +44,15 @@ public interface ReportExecutionRestApi { @NonNull @WorkerThread - ReportExecutionDetailsResponse runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); + ReportExecutionDescriptor runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); @NonNull @WorkerThread - ReportExecutionDetailsResponse requestReportExecutionDetails(@NonNull String executionId); + ReportExecutionDescriptor requestReportExecutionDetails(@NonNull String executionId); @NonNull @WorkerThread - ExecutionStatusResponse requestReportExecutionStatus(@NonNull String executionId); + ExecutionStatus requestReportExecutionStatus(@NonNull String executionId); @WorkerThread boolean cancelReportExecution(@NonNull String executionId); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 71597fb4..7d1959e9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -27,8 +27,8 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; @@ -64,28 +64,28 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NonNull @Override - public ReportExecutionDetailsResponse runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) { + public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) { checkNotNull(executionOptions, "Execution options should not be null"); - Call call = mRestApi.runReportExecution(executionOptions); + Call call = mRestApi.runReportExecution(executionOptions); return CallWrapper.wrap(call).body(); } @NonNull @Override - public ReportExecutionDetailsResponse requestReportExecutionDetails(@Nullable String executionId) { + public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - Call call = mRestApi.requestReportExecutionDetails(executionId); + Call call = mRestApi.requestReportExecutionDetails(executionId); return CallWrapper.wrap(call).body(); } @NonNull @Override - public ExecutionStatusResponse requestReportExecutionStatus(@Nullable String executionId) { + public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - Call call = mRestApi.requestReportExecutionStatus(executionId); + Call call = mRestApi.requestReportExecutionStatus(executionId); return CallWrapper.wrap(call).body(); } @@ -93,7 +93,7 @@ public ExecutionStatusResponse requestReportExecutionStatus(@Nullable String exe public boolean cancelReportExecution(@Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); - Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatusResponse.cancelledStatus()); + Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus()); Response response = CallWrapper.wrap(call).response(); int status = response.code(); return status != 204; @@ -128,17 +128,17 @@ interface RestApi { @NonNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions") - Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); + Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}") - Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId); + Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/status") - Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId); + Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId); @NonNull @Headers("Accept: application/json") @@ -150,7 +150,7 @@ Call updateReportExecution(@NonNull @Path(value = "executionId", encoded @Headers("Accept: application/json") @PUT("rest_v2/reportExecutions/{executionId}/status") Call cancelReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body ExecutionStatusResponse statusResponse); + @NonNull @Body ExecutionStatus statusResponse); @Headers("Accept: application/json") @GET("rest_v2/reportExecutions") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 3b2fed32..3204ecb8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -28,7 +28,7 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; @@ -45,7 +45,7 @@ public interface ReportExportRestApi { @NonNull @WorkerThread - ExecutionStatusResponse checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); + ExecutionStatus checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); @NonNull @WorkerThread diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index ddf5768d..329c6329 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -28,7 +28,7 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; @@ -69,11 +69,11 @@ public ReportExportExecutionResponse runExportExecution(@Nullable String executi @NonNull @Override - public ExecutionStatusResponse checkExportExecutionStatus(@Nullable String executionId, @Nullable String exportId) { + public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, @Nullable String exportId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); - Call call = mRestApi.checkReportExportStatus(executionId, exportId); + Call call = mRestApi.checkReportExportStatus(executionId, exportId); return CallWrapper.wrap(call).body(); } @@ -117,7 +117,7 @@ Call runReportExportExecution(@NonNull @Path("exe @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") - Call checkReportExportStatus(@NonNull @Path("executionId") String executionId, + Call checkReportExportStatus(@NonNull @Path("executionId") String executionId, @NonNull @Path("exportId") String exportId); /** diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java similarity index 93% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java index e913133f..b262f9e4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java @@ -30,7 +30,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportOutputResource { +public final class AttachmentDescriptor { @Expose private String contentType; @Expose @@ -49,7 +49,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ReportOutputResource that = (ReportOutputResource) o; + AttachmentDescriptor that = (AttachmentDescriptor) o; if (contentType != null ? !contentType.equals(that.contentType) : that.contentType != null) return false; @@ -66,7 +66,7 @@ public int hashCode() { @Override public String toString() { - return "ReportOutputResource{" + + return "AttachmentDescriptor{" + "contentType='" + contentType + '\'' + ", fileName='" + fileName + '\'' + '}'; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java similarity index 86% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java index 89bcf09d..36dc8ff1 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java @@ -30,21 +30,21 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExecutionStatusResponse { +public final class ExecutionStatus { @Expose private String value; @Expose private ErrorDescriptor errorDescriptor; - public ExecutionStatusResponse() {} + public ExecutionStatus() {} - private ExecutionStatusResponse(String value) { + private ExecutionStatus(String value) { this.value = value; } - public static ExecutionStatusResponse cancelledStatus() { - return new ExecutionStatusResponse("cancelled"); + public static ExecutionStatus cancelledStatus() { + return new ExecutionStatus("cancelled"); } public String getStatus() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java new file mode 100644 index 00000000..ab96d4cf --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java @@ -0,0 +1,73 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.execution; + +import com.google.gson.annotations.Expose; + +import java.util.Collections; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ExportDescriptor { + @Expose + private String id; + @Expose + private String status; + @Expose + private ExecutionRequestOptions options; + @Expose + private OutputResourceDescriptor outputResource; + @Expose + private Set attachments = Collections.emptySet(); + @Expose + private ErrorDescriptor errorDescriptor; + + public Set getAttachments() { + return attachments; + } + + public ErrorDescriptor getErrorDescriptor() { + return errorDescriptor; + } + + public String getId() { + return id; + } + + public ExecutionRequestOptions getOptions() { + return options; + } + + public OutputResourceDescriptor getOutputResource() { + return outputResource; + } + + public String getStatus() { + return status; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecution.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecution.java deleted file mode 100644 index 086e96ef..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecution.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.execution; - -import com.google.gson.annotations.Expose; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ExportExecution { - @Expose - private String id; - @Expose - private String status; - @Expose - private ExecutionRequestOptions options; - @Expose - private ReportOutputResource outputResource; - @Expose - private Set attachments = Collections.emptySet(); - @Expose - private ErrorDescriptor errorDescriptor; - - public Set getAttachments() { - return attachments; - } - - public ErrorDescriptor getErrorDescriptor() { - return errorDescriptor; - } - - public String getId() { - return id; - } - - public ExecutionRequestOptions getOptions() { - return options; - } - - public ReportOutputResource getOutputResource() { - return outputResource; - } - - public String getStatus() { - return status; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ExportExecution that = (ExportExecution) o; - - if (!id.equals(that.id)) return false; - if (!status.equals(that.status)) return false; - if (options != null ? !options.equals(that.options) : that.options != null) return false; - if (outputResource != null ? !outputResource.equals(that.outputResource) : that.outputResource != null) - return false; - if (attachments != null ? !attachments.equals(that.attachments) : that.attachments != null) - return false; - return !(errorDescriptor != null ? !errorDescriptor.equals(that.errorDescriptor) : that.errorDescriptor != null); - } - - @Override - public int hashCode() { - int result = id.hashCode(); - result = 31 * result + status.hashCode(); - result = 31 * result + (options != null ? options.hashCode() : 0); - result = 31 * result + (outputResource != null ? outputResource.hashCode() : 0); - result = 31 * result + (attachments != null ? attachments.hashCode() : 0); - result = 31 * result + (errorDescriptor != null ? errorDescriptor.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ExportExecution{" + - "attachments=" + Arrays.toString(attachments.toArray()) + - ", id='" + id + '\'' + - ", status='" + status + '\'' + - ", options=" + options + - ", outputResource=" + outputResource + - ", errorDescriptor=" + errorDescriptor + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java new file mode 100644 index 00000000..0c483306 --- /dev/null +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java @@ -0,0 +1,51 @@ +/* + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.network.entity.execution; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class OutputResourceDescriptor { + @Expose + private String contentType; + @Expose + private String fileName; + @Expose + private Boolean outputFinal; + + public String getContentType() { + return contentType; + } + + public String getFileName() { + return fileName; + } + + public Boolean getOutputFinal() { + return outputFinal; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java similarity index 93% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java index 26e72571..256a596c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java @@ -35,7 +35,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportExecutionDetailsResponse { +public final class ReportExecutionDescriptor { @Expose @SerializedName("requestId") private String executionId; @@ -48,7 +48,7 @@ public final class ReportExecutionDetailsResponse { @Expose private int totalPages; @Expose - private Set exports = Collections.emptySet(); + private Set exports = Collections.emptySet(); @Expose private ErrorDescriptor errorDescriptor; @@ -76,7 +76,7 @@ public ErrorDescriptor getErrorDescriptor() { return errorDescriptor; } - public Set getExports() { + public Set getExports() { return exports; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResourceTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResourceTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java index 8ef24a6f..2a5ff2a6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportOutputResourceTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java @@ -42,14 +42,14 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ReportOutputResourceTest { +public class AttachmentDescriptorTest { @Test @Parameters({ "contentType", "fileName", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ReportOutputResource.class.getDeclaredField(fieldName); + Field field = AttachmentDescriptor.class.getDeclaredField(fieldName); MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java similarity index 93% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java index 29d5ddf4..d04939f5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java @@ -42,14 +42,14 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ExecutionStatusResponseTest { +public class ExecutionStatusTest { @Test @Parameters({ "value", "errorDescriptor", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ExecutionStatusResponse.class.getDeclaredField(fieldName); + Field field = ExecutionStatus.class.getDeclaredField(fieldName); MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecutionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecutionTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java index d9da9094..ca75a564 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportExecutionTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java @@ -42,7 +42,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ExportExecutionTest { +public class ExportDescriptorTest { @Test @Parameters({ "id", @@ -52,7 +52,7 @@ public class ExportExecutionTest { "errorDescriptor", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ExportExecution.class.getDeclaredField(fieldName); + Field field = ExportDescriptor.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java new file mode 100644 index 00000000..2cef9ff4 --- /dev/null +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java @@ -0,0 +1,32 @@ +package com.jaspersoft.android.sdk.network.entity.execution; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class OutputResourceDescriptorTest { + @Test + @Parameters({ + "contentType", + "fileName", + "outputFinal", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = OutputResourceDescriptor.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java similarity index 90% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java index 0ef89d31..aa59a581 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDetailsResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java @@ -43,7 +43,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ReportExecutionDetailsResponseTest { +public class ReportExecutionDescriptorTest { @Test @Parameters({ "reportURI", @@ -55,13 +55,13 @@ public class ReportExecutionDetailsResponseTest { "errorDescriptor", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ReportExecutionDetailsResponse.class.getDeclaredField(fieldName); + Field field = ReportExecutionDescriptor.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } @Test public void executionIdFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { - Field field = ReportExecutionDetailsResponse.class.getDeclaredField("executionId"); + Field field = ReportExecutionDescriptor.class.getDeclaredField("executionId"); assertThat(field, hasSerializedName("requestId")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportDescriptorResponseTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportDescriptorResponseTest.java index efb834c0..92d269a8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportDescriptorResponseTest.java @@ -43,7 +43,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ReportExportExecutionResponseTest { +public class ReportExportDescriptorResponseTest { @Test @Parameters({ "exportId", diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 5ba33ed5..a81d2cb3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -28,8 +28,8 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.test.TestLogger; @@ -81,7 +81,7 @@ public void setup() { @Test public void shouldStartReportExecution() { - ReportExecutionDetailsResponse response = startExecution(); + ReportExecutionDescriptor response = startExecution(); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(notNullValue())); } @@ -91,25 +91,25 @@ public void shouldStartReportExecution() { */ @Ignore public void shouldCancelReportExecution() throws InterruptedException { - ReportExecutionDetailsResponse response = startExecution(); + ReportExecutionDescriptor response = startExecution(); boolean cancelled = apiUnderTest.cancelReportExecution(response.getExecutionId()); assertThat(cancelled, is(true)); } @Test public void shouldReturnReportExecutionDetails() throws IOException { - ReportExecutionDetailsResponse executionResponse = startExecution(); + ReportExecutionDescriptor executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - ReportExecutionDetailsResponse response = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId()); + ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId()); assertThat(response.getExecutionId(), is(executionId)); } @Test public void shouldCheckReportExecutionStatus() throws IOException { - ReportExecutionDetailsResponse executionResponse = startExecution(); + ReportExecutionDescriptor executionResponse = startExecution(); - ExecutionStatusResponse response = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId()); + ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId()); assertThat(response.getStatus(), is(notNullValue())); } @@ -118,7 +118,7 @@ public void shouldCheckReportExecutionStatus() throws IOException { */ @Ignore public void searchForExecutionShouldReturnResult() throws IOException { - ReportExecutionDetailsResponse executionResponse = startExecution(); + ReportExecutionDescriptor executionResponse = startExecution(); Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); @@ -129,7 +129,7 @@ public void searchForExecutionShouldReturnResult() throws IOException { @Test public void updateOfParametersForExecutionShouldReturnResult() { - ReportExecutionDetailsResponse executionResponse = startExecution(); + ReportExecutionDescriptor executionResponse = startExecution(); boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); assertThat(success, is(true)); @@ -140,12 +140,12 @@ public void updateOfParametersForExecutionShouldReturnResult() { */ @NonNull - private ReportExecutionDetailsResponse startExecution() { + private ReportExecutionDescriptor startExecution() { return startExecution(REPORT_URI1); } @NonNull - private ReportExecutionDetailsResponse startExecution(String uri) { + private ReportExecutionDescriptor startExecution(String uri) { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); return apiUnderTest.runReportExecution(executionRequestOptions); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index b97763e8..98a24225 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -30,8 +30,8 @@ import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; @@ -85,22 +85,22 @@ public void setup() { @Test public void runExportRequestShouldReturnResult() { - ReportExecutionDetailsResponse exec = startExecution(); + ReportExecutionDescriptor exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); assertThat(execDetails.getExportId(), is(notNullValue())); } @Test public void checkExportRequestStatusShouldReturnResult() throws IOException { - ReportExecutionDetailsResponse exec = startExecution(); + ReportExecutionDescriptor exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); - ExecutionStatusResponse response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); + ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); assertThat(response, is(notNullValue())); } @Test public void requestExportOutputShouldReturnResult() { - ReportExecutionDetailsResponse exec = startExecution(); + ReportExecutionDescriptor exec = startExecution(); ReportExportExecutionResponse execDetails = startExportExecution(exec); ExportResourceResponse output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); @@ -113,7 +113,7 @@ public void requestExportOutputShouldReturnResult() { * Helper methods */ @NonNull - private ReportExportExecutionResponse startExportExecution(ReportExecutionDetailsResponse exec) { + private ReportExportExecutionResponse startExportExecution(ReportExecutionDescriptor exec) { ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") .withOutputFormat("PDF"); @@ -121,7 +121,7 @@ private ReportExportExecutionResponse startExportExecution(ReportExecutionDetail } @NonNull - private ReportExecutionDetailsResponse startExecution() { + private ReportExecutionDescriptor startExecution() { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); return mExecApi.runReportExecution(executionRequestOptions); } From 8c8c72df993348b0ccdc6a103451868d29a79bec Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 12 Oct 2015 18:30:52 +0300 Subject: [PATCH 210/457] Refactoring DTO names for report export API --- .../sdk/network/api/ReportExportRestApi.java | 12 +++++----- .../network/api/ReportExportRestApiImpl.java | 22 +++++++++---------- ...Input.java => RetrofitOutputResource.java} | 6 ++--- ...se.java => ExportExecutionDescriptor.java} | 22 +++++++++++++++---- ...esponse.java => ExportOutputResource.java} | 16 +++++++------- .../{ExportInput.java => OutputResource.java} | 2 +- .../network/api/ReportExportRestApiTest.java | 10 ++++----- ...t.java => RetrofitOutputResourceTest.java} | 6 ++--- ...ava => ExportExecutionDescriptorTest.java} | 10 +++++---- .../api/ReportExportRestApiTest.java | 16 +++++++------- 10 files changed, 69 insertions(+), 53 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{RetrofitExportInput.java => RetrofitOutputResource.java} (89%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/{ReportExportExecutionResponse.java => ExportExecutionDescriptor.java} (70%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/{ExportResourceResponse.java => ExportOutputResource.java} (75%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/{ExportInput.java => OutputResource.java} (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/api/{RetrofitExportInputTest.java => RetrofitOutputResourceTest.java} (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/{ReportExportDescriptorResponseTest.java => ExportExecutionDescriptorTest.java} (87%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 3204ecb8..8ed24d36 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -29,9 +29,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.export.ExportInput; -import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; /** * @author Tom Koptel @@ -41,7 +41,7 @@ public interface ReportExportRestApi { @NonNull @WorkerThread - ReportExportExecutionResponse runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + ExportExecutionDescriptor runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); @NonNull @WorkerThread @@ -49,11 +49,11 @@ public interface ReportExportRestApi { @NonNull @WorkerThread - ExportResourceResponse requestExportOutput(@NonNull String executionId, @NonNull String exportId); + ExportOutputResource requestExportOutput(@NonNull String executionId, @NonNull String exportId); @NonNull @WorkerThread - ExportInput requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); + OutputResource requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); final class Builder extends GenericAuthBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index 329c6329..b3e293b8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -29,9 +29,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.export.ExportInput; -import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.squareup.okhttp.ResponseBody; import retrofit.Call; @@ -58,12 +58,12 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @NonNull @Override - public ReportExportExecutionResponse runExportExecution(@Nullable String executionId, + public ExportExecutionDescriptor runExportExecution(@Nullable String executionId, @Nullable ExecutionRequestOptions executionOptions) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(executionOptions, "Execution options should not be null"); - Call call = mRestApi.runReportExportExecution(executionId, executionOptions); + Call call = mRestApi.runReportExportExecution(executionId, executionOptions); return CallWrapper.wrap(call).body(); } @@ -79,7 +79,7 @@ public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, @NonNull @Override - public ExportResourceResponse requestExportOutput(@Nullable String executionId, @Nullable String exportId) { + public ExportOutputResource requestExportOutput(@Nullable String executionId, @Nullable String exportId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); @@ -87,16 +87,16 @@ public ExportResourceResponse requestExportOutput(@Nullable String executionId, Response rawResponse = CallWrapper.wrap(call).response(); com.squareup.okhttp.Headers headers = rawResponse.headers(); - RetrofitExportInput exportInput = new RetrofitExportInput(rawResponse.body()); + RetrofitOutputResource exportInput = new RetrofitOutputResource(rawResponse.body()); String pages = headers.get("report-pages"); boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); - return ExportResourceResponse.create(exportInput, pages, isFinal); + return ExportOutputResource.create(exportInput, pages, isFinal); } @NonNull @Override - public ExportInput requestExportAttachment(@Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) { + public OutputResource requestExportAttachment(@Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); checkNotNull(attachmentId, "Attachment id should not be null"); @@ -104,14 +104,14 @@ public ExportInput requestExportAttachment(@Nullable String executionId, @Nullab Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); Response rawResponse = CallWrapper.wrap(call).response(); ResponseBody body = rawResponse.body(); - return new RetrofitExportInput(body); + return new RetrofitOutputResource(body); } private interface RestApi { @NonNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/exports") - Call runReportExportExecution(@NonNull @Path("executionId") String executionId, + Call runReportExportExecution(@NonNull @Path("executionId") String executionId, @NonNull @Body ExecutionRequestOptions executionOptions); @NonNull diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResource.java similarity index 89% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResource.java index e0c37009..43436934 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInput.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResource.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.entity.export.ExportInput; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.squareup.okhttp.ResponseBody; import java.io.IOException; @@ -34,10 +34,10 @@ * @author Tom Koptel * @since 2.0 */ -final class RetrofitExportInput implements ExportInput { +final class RetrofitOutputResource implements OutputResource { private final ResponseBody mResponse; - public RetrofitExportInput(ResponseBody input) { + public RetrofitOutputResource(ResponseBody input) { mResponse = input; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java similarity index 70% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java index 465c4668..0a302241 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportExecutionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java @@ -26,24 +26,38 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.OutputResourceDescriptor; /** * @author Tom Koptel * @since 2.0 */ -public final class ReportExportExecutionResponse { +public final class ExportExecutionDescriptor { @Expose @SerializedName("id") private String exportId; @Expose - private ExecutionRequestOptions options; + private String status; + @Expose + private OutputResourceDescriptor outputResource; + @Expose + private ErrorDescriptor errorDescriptor; public String getExportId() { return exportId; } - public ExecutionRequestOptions getOptions() { - return options; + public String getStatus() { + return status; + } + + public OutputResourceDescriptor getOutputResource() { + return outputResource; + } + + public ErrorDescriptor getErrorDescriptor() { + return errorDescriptor; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java similarity index 75% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java index 5f42226a..e7cc165b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportResourceResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java @@ -28,23 +28,23 @@ * @author Tom Koptel * @since 2.0 */ -public final class ExportResourceResponse { - private final ExportInput mExportInput; +public final class ExportOutputResource { + private final OutputResource mOutputResource; private final boolean mFinal; private final String mPages; - private ExportResourceResponse(ExportInput exportInput, String pages, boolean finalOutput) { - mExportInput = exportInput; + private ExportOutputResource(OutputResource outputResource, String pages, boolean finalOutput) { + mOutputResource = outputResource; mFinal = finalOutput; mPages = pages; } - public static ExportResourceResponse create(ExportInput exportInput, String pages, boolean finalOutput) { - return new ExportResourceResponse(exportInput, pages, finalOutput); + public static ExportOutputResource create(OutputResource outputResource, String pages, boolean finalOutput) { + return new ExportOutputResource(outputResource, pages, finalOutput); } - public ExportInput getExportInput() { - return mExportInput; + public OutputResource getOutputResource() { + return mOutputResource; } public boolean isFinal() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java index e2dd0974..b46c13d6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportInput.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java @@ -31,7 +31,7 @@ * @author Tom Koptel * @since 2.0 */ -public interface ExportInput { +public interface OutputResource { String getMimeType(); /** diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index dff0c5d3..6a063155 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -26,8 +26,8 @@ import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.export.ExportInput; -import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -141,7 +141,7 @@ public void requestForOutputShouldParsePagesFromHeader() { .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); assertThat(resource.getPages(), is("1-10")); } @@ -152,7 +152,7 @@ public void requestForOutputShouldParseIsFinalHeader() { .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - ExportResourceResponse resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); assertThat(resource.isFinal(), is(true)); } @@ -162,7 +162,7 @@ public void requestForAttachmentShouldBeWrappedInsideInput() throws IOException .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - ExportInput resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); + OutputResource resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResourceTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResourceTest.java index 69b8de46..11653247 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitExportInputTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResourceTest.java @@ -49,9 +49,9 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({ResponseBody.class}) -public class RetrofitExportInputTest { +public class RetrofitOutputResourceTest { - private RetrofitExportInput objectUnderTest; + private RetrofitOutputResource objectUnderTest; private ResponseBody mTypedInput; @Mock private InputStream input; @@ -60,7 +60,7 @@ public class RetrofitExportInputTest { public void setup() { MockitoAnnotations.initMocks(this); mTypedInput = PowerMockito.mock(ResponseBody.class); - objectUnderTest = new RetrofitExportInput(mTypedInput); + objectUnderTest = new RetrofitOutputResource(mTypedInput); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportDescriptorResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java similarity index 87% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportDescriptorResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java index 92d269a8..ca02fc86 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ReportExportDescriptorResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java @@ -43,20 +43,22 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ReportExportDescriptorResponseTest { +public class ExportExecutionDescriptorTest { @Test @Parameters({ "exportId", - "options", + "status", + "outputResource", + "errorDescriptor", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ReportExportExecutionResponse.class.getDeclaredField(fieldName); + Field field = ExportExecutionDescriptor.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } @Test public void exportIdFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { - Field field = ReportExportExecutionResponse.class.getDeclaredField("exportId"); + Field field = ExportExecutionDescriptor.class.getDeclaredField("exportId"); assertThat(field, hasSerializedName("id")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 98a24225..cb921d3b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -33,8 +33,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; -import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -86,14 +86,14 @@ public void setup() { @Test public void runExportRequestShouldReturnResult() { ReportExecutionDescriptor exec = startExecution(); - ReportExportExecutionResponse execDetails = startExportExecution(exec); + ExportExecutionDescriptor execDetails = startExportExecution(exec); assertThat(execDetails.getExportId(), is(notNullValue())); } @Test public void checkExportRequestStatusShouldReturnResult() throws IOException { ReportExecutionDescriptor exec = startExecution(); - ReportExportExecutionResponse execDetails = startExportExecution(exec); + ExportExecutionDescriptor execDetails = startExportExecution(exec); ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); assertThat(response, is(notNullValue())); } @@ -101,10 +101,10 @@ public void checkExportRequestStatusShouldReturnResult() throws IOException { @Test public void requestExportOutputShouldReturnResult() { ReportExecutionDescriptor exec = startExecution(); - ReportExportExecutionResponse execDetails = startExportExecution(exec); - ExportResourceResponse output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); + ExportExecutionDescriptor execDetails = startExportExecution(exec); + ExportOutputResource output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); - assertThat(output.getExportInput(), is(notNullValue())); + assertThat(output.getOutputResource(), is(notNullValue())); assertThat(output.getPages(), is("1-2")); assertThat(output.isFinal(), is(false)); } @@ -113,7 +113,7 @@ public void requestExportOutputShouldReturnResult() { * Helper methods */ @NonNull - private ReportExportExecutionResponse startExportExecution(ReportExecutionDescriptor exec) { + private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor exec) { ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") .withOutputFormat("PDF"); From 4506a0a7c74acbfd2081a866db77eb2fa0f8a296 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 12 Oct 2015 18:55:37 +0300 Subject: [PATCH 211/457] Remove ReportParameter dto --- .../network/api/ReportExecutionRestApi.java | 5 +- .../api/ReportExecutionRestApiImpl.java | 7 +- .../execution/ExecutionRequestOptions.java | 11 +- .../entity/execution/ReportParameter.java | 81 ------------- .../entity/execution/ReportParameters.java | 61 ---------- .../api/ReportExecutionRestApiTest.java | 2 +- .../entity/execution/ReportParameterTest.java | 110 ------------------ .../execution/ReportParametersTest.java | 49 -------- .../api/ReportExecutionRestApiTest.java | 2 +- 9 files changed, 13 insertions(+), 315 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameter.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameters.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameterTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParametersTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 1eb5c37b..3be339cb 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -31,10 +31,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; -import java.util.Collection; import java.util.Map; +import java.util.Set; /** * @author Tom Koptel @@ -58,7 +57,7 @@ public interface ReportExecutionRestApi { boolean cancelReportExecution(@NonNull String executionId); @WorkerThread - boolean updateReportExecution(@NonNull String executionId, @NonNull Collection params); + boolean updateReportExecution(@NonNull String executionId, @NonNull Map> params); /** * TODO: API is broken requires investigation before release diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 7d1959e9..59778868 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -31,10 +31,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.entity.execution.ReportParameter; -import java.util.Collection; import java.util.Map; +import java.util.Set; import retrofit.Call; import retrofit.Response; @@ -100,7 +99,7 @@ public boolean cancelReportExecution(@Nullable String executionId) { } @Override - public boolean updateReportExecution(@Nullable String executionId, @Nullable Collection params) { + public boolean updateReportExecution(@Nullable String executionId, @Nullable Map> params) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(params, "Execution params id should not be null"); @@ -144,7 +143,7 @@ interface RestApi { @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/parameters") Call updateReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body Collection params); + @NonNull @Body Map> params); @NonNull @Headers("Accept: application/json") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 815ed4cc..956b0d8b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -29,6 +29,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; +import java.util.Map; import java.util.Set; /** @@ -62,7 +63,7 @@ public class ExecutionRequestOptions { @Expose protected String attachmentsPrefix; @Expose - protected ReportParameters parameters; + protected Map> parameters; protected ExecutionRequestOptions() {} @@ -95,8 +96,8 @@ public ExecutionRequestOptions withSaveDataSnapshot(boolean saveDataSnapshot) { return this; } - public ExecutionRequestOptions withParameters(Set parameters) { - this.parameters = ReportParameters.wrap(parameters); + public ExecutionRequestOptions withParameters(Map> parameters) { + this.parameters = parameters; return this; } @@ -185,8 +186,8 @@ public String getPages() { return pages; } - public Set getParameters() { - return parameters.getReportParameters(); + public Map> getParameters() { + return parameters; } public Boolean getSaveDataSnapshot() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameter.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameter.java deleted file mode 100644 index 9c8c731d..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameter.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.execution; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ReportParameter { - @Expose - private final String name; - - @Expose - @SerializedName("value") - private final Set values; - - private ReportParameter(String name, Set values) { - this.name = name; - this.values = values; - } - - @SuppressWarnings("unchecked") - public static ReportParameter emptyParameter(String name) { - return create(name, Collections.EMPTY_SET); - } - - public static ReportParameter create(String name, Set values) { - if (name == null || name.length() == 0) { - throw new IllegalArgumentException("Name should not be null"); - } - if (values == null) { - throw new IllegalArgumentException("Values should not be null. Otherwise use ReportParameter.emptyParameter()"); - } - return new ReportParameter(name, values); - } - - public String getName() { - return name; - } - - public Set getValues() { - return values; - } - - @Override - public String toString() { - return "ReportParameter{" + - "name='" + name + '\'' + - ", values=" + Arrays.toString(values.toArray()) + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameters.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameters.java deleted file mode 100644 index 5127e6c7..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameters.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.execution; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import java.util.Arrays; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ReportParameters { - @Expose - @SerializedName("reportParameter") - private final Set reportParameters; - - private ReportParameters(Set reportParameters) { - this.reportParameters = reportParameters; - } - - public Set getReportParameters() { - return reportParameters; - } - - public static ReportParameters wrap(Set params) { - if (params == null) { - throw new IllegalArgumentException("Parameters should not be null"); - } - return new ReportParameters(params); - } - - @Override - public String toString() { - return Arrays.toString(reportParameters.toArray()); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index 733f7385..4537bca3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -169,7 +169,7 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOEx public void executionUpdateRequestShouldBeSuccessIfResponseIs204() { mWebMockRule.enqueue(create204Response()); - boolean response = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_LIST); + boolean response = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_MAP); assertThat(response, is(true)); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameterTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameterTest.java deleted file mode 100644 index d29e51be..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParameterTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.execution; - -import com.google.gson.annotations.Expose; - -import org.hamcrest.MatcherAssert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; -import java.util.Collections; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.collection.IsEmptyCollection.empty; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@SuppressWarnings("unchecked") -@RunWith(JUnitParamsRunner.class) -public class ReportParameterTest { - - @Rule - public ExpectedException mExpectedException = ExpectedException.none(); - - @Test - public void factoryMethodShouldNotAllowEmptyName() { - mExpectedException.expect(IllegalArgumentException.class); - ReportParameter.create(null, Collections.EMPTY_SET); - } - - @Test - public void factoryMethodShouldNotAllowNullName() { - mExpectedException.expect(IllegalArgumentException.class); - ReportParameter.create("", Collections.EMPTY_SET); - } - - @Test - public void factoryMethodShouldNotAllowNullValueSet() { - mExpectedException.expect(IllegalArgumentException.class); - mExpectedException.expectMessage("Values should not be null. Otherwise use ReportParameter.emptyParameter()"); - ReportParameter.create("key", null); - } - - @Test - public void factoryMethodCanCreateParameterWithEmptyValueSet() { - ReportParameter reportParameter = ReportParameter.emptyParameter("key"); - assertThat(reportParameter.getValues(), is(empty())); - } - - @Test - public void factoryMethod1ShouldAssignName() { - ReportParameter reportParameter = ReportParameter.emptyParameter("key"); - assertThat(reportParameter.getName(), is("key")); - } - - @Test - public void factoryMethod2ShouldAssignName() { - ReportParameter reportParameter = ReportParameter.create("key", Collections.EMPTY_SET); - assertThat(reportParameter.getName(), is("key")); - } - - @Test - @Parameters({ - "name", - "values", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ReportParameter.class.getDeclaredField(fieldName); - MatcherAssert.assertThat(field, hasAnnotation(Expose.class)); - } - - @Test - public void valuesFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { - Field field = ReportParameter.class.getDeclaredField("values"); - assertThat(field, hasSerializedName("value")); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParametersTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParametersTest.java deleted file mode 100644 index 5c886aa3..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportParametersTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.execution; - -import org.junit.Test; - -import java.lang.reflect.Field; - -import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ReportParametersTest { - @Test(expected = IllegalArgumentException.class) - public void factoryMethodShouldNotAcceptNull() { - ReportParameters.wrap(null); - } - - @Test - public void reportParameterFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { - Field field = ReportParameters.class.getDeclaredField("reportParameters"); - assertThat(field, hasSerializedName("reportParameter")); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index a81d2cb3..4de1c599 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -131,7 +131,7 @@ public void searchForExecutionShouldReturnResult() throws IOException { public void updateOfParametersForExecutionShouldReturnResult() { ReportExecutionDescriptor executionResponse = startExecution(); - boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_LIST); + boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_MAP); assertThat(success, is(true)); } From e4197b660056eabe4cd5878af71dfce4661b9ff2 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 12:33:02 +0300 Subject: [PATCH 212/457] Refactoring DTO/API for input controls API --- .../sdk/network/api/InputControlRestApi.java | 10 +++--- .../network/api/InputControlRestApiImpl.java | 34 +++++++++++-------- ...ponse.java => InputControlCollection.java} | 5 +-- ....java => InputControlStateCollection.java} | 5 +-- .../entity/control/ValidationRule.java | 30 ---------------- ...nputControlResponseTypeAdapterFactory.java | 6 ++-- ...t.java => InputControlCollectionTest.java} | 31 ++++++++++------- .../api/InputControlRestApiTest.java | 26 +++++++------- 8 files changed, 66 insertions(+), 81 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/{InputControlResponse.java => InputControlCollection.java} (92%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/{InputControlValueResponse.java => InputControlStateCollection.java} (91%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/{InputControlResponseTest.java => InputControlCollectionTest.java} (75%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index d54afb10..0bfc713f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -28,10 +28,10 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import java.util.Collection; import java.util.Map; import java.util.Set; @@ -52,11 +52,11 @@ public interface InputControlRestApi { */ @NonNull @WorkerThread - InputControlResponse requestInputControls(@NonNull String reportUri, boolean excludeState); + Collection requestInputControls(@NonNull String reportUri, boolean excludeState); @NonNull @WorkerThread - InputControlValueResponse requestInputControlsInitialStates(@NonNull String reportUri, + Collection requestInputControlsInitialStates(@NonNull String reportUri, boolean freshData); /** @@ -70,7 +70,7 @@ InputControlValueResponse requestInputControlsInitialStates(@NonNull String repo */ @NonNull @WorkerThread - InputControlValueResponse requestInputControlsStates(@NonNull String reportUri, + Collection requestInputControlsStates(@NonNull String reportUri, @NonNull Map> controlsValues, boolean freshData); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 169951f3..d64c6ac2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -27,9 +27,12 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; -import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; +import java.util.Collection; import java.util.Map; import java.util.Set; @@ -57,54 +60,57 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override - public InputControlResponse requestInputControls(@Nullable String reportUri, boolean excludeState) { + public Collection requestInputControls(@Nullable String reportUri, boolean excludeState) { checkNotNull(reportUri, "Report URI should not be null"); - Call call = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); - return CallWrapper.wrap(call).body(); + Call call = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); + InputControlCollection response = CallWrapper.wrap(call).body(); + return response.get(); } @NonNull @Override - public InputControlValueResponse requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { + public Collection requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); - Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); - return CallWrapper.wrap(call).body(); + Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); + InputControlStateCollection response = CallWrapper.wrap(call).body(); + return response.get(); } @NonNull @Override - public InputControlValueResponse requestInputControlsStates(@Nullable String reportUri, + public Collection requestInputControlsStates(@Nullable String reportUri, @Nullable Map> controlsValues, boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); String ids = Utils.joinString(";", controlsValues.keySet()); - Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); - return CallWrapper.wrap(call).body(); + Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + InputControlStateCollection response = CallWrapper.wrap(call).body(); + return response.get(); } private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls") - Call requestInputControls( + Call requestInputControls( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("exclude") String state); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls/values") - Call requestInputControlsInitialValues( + Call requestInputControlsInitialValues( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("freshData") boolean freshData); @NonNull @Headers("Accept: application/json") @POST("rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") - Call requestInputControlsValues( + Call requestInputControlsValues( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @NonNull @Path(value = "controlsId", encoded = true) String ids, @NonNull @Body Map> controlsValues, diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java similarity index 92% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java index 5cf1b468..a11b5d29 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java @@ -27,6 +27,7 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -34,13 +35,13 @@ * @author Tom Koptel * @since 2.0 */ -public final class InputControlResponse { +public final class InputControlCollection { @Expose @SerializedName(value = "inputControl") private List mValues = Collections.emptyList(); - public List getValues() { + public Collection get() { return mValues; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlValueResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java similarity index 91% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlValueResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java index 5827f8e3..db14026d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlValueResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java @@ -27,6 +27,7 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -34,13 +35,13 @@ * @author Tom Koptel * @since 2.0 */ -public final class InputControlValueResponse { +public final class InputControlStateCollection { @Expose @SerializedName(value = "inputControlState") private List values = Collections.emptyList(); - public List getValues() { + public Collection get() { return values; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java index 4e8a6688..2d648e70 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java @@ -49,34 +49,4 @@ public String getType() { public String getValue() { return value; } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ValidationRule that = (ValidationRule) o; - - if (type != null ? !type.equals(that.type) : that.type != null) return false; - if (errorMessage != null ? !errorMessage.equals(that.errorMessage) : that.errorMessage != null) - return false; - return !(value != null ? !value.equals(that.value) : that.value != null); - } - - @Override - public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (errorMessage != null ? errorMessage.hashCode() : 0); - result = 31 * result + (value != null ? value.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ValidationRule{" + - "errorMessage='" + errorMessage + '\'' + - ", type='" + type + '\'' + - ", value='" + value + '\'' + - '}'; - } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java index b56eb329..74249fce 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java @@ -27,17 +27,17 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; /** * @author Tom Koptel * @since 2.0 */ -final class InputControlResponseTypeAdapterFactory extends CustomizedTypeAdapterFactory { +final class InputControlResponseTypeAdapterFactory extends CustomizedTypeAdapterFactory { private static final String[] RULE_TYPES = {"dateTimeFormatValidationRule", "mandatoryValidationRule"}; public InputControlResponseTypeAdapterFactory() { - super(InputControlResponse.class); + super(InputControlCollection.class); } @Override diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java similarity index 75% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java index 54450b9e..1fb86c0b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java @@ -2,11 +2,16 @@ import com.google.gson.Gson; import com.google.gson.annotations.Expose; +import com.google.gson.reflect.TypeToken; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import org.junit.Test; import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.Set; import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; @@ -19,28 +24,27 @@ * @author Tom Koptel * @since 2.0 */ -public class InputControlResponseTest { +public class InputControlCollectionTest { Gson mGson = GsonFactory.create(); @Test public void shouldHaveExposeAnnotationForFieldControls() throws NoSuchFieldException { - Field field = InputControlResponse.class.getDeclaredField("mValues"); + Field field = InputControlCollection.class.getDeclaredField("mValues"); assertThat(field, hasAnnotation(Expose.class)); } @Test public void valuesFieldShouldHaveSerializedNameAnnotationForFieldControls() throws NoSuchFieldException { - Field field = InputControlResponse.class.getDeclaredField("mValues"); + Field field = InputControlCollection.class.getDeclaredField("mValues"); assertThat(field, hasSerializedName("inputControl")); } @Test public void shouldProperlyAdaptMasterDependencies() { String json = "{\"inputControl\" : [ {\"masterDependencies\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}]}"; - InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + InputControl inputControl = deserializeInputControl(json); - InputControl inputControl = response.getValues().get(0); Set deps = inputControl.getMasterDependencies(); assertThat(deps, hasItem("Cascading_state_multi_select")); @@ -49,9 +53,8 @@ public void shouldProperlyAdaptMasterDependencies() { @Test public void shouldProperlyAdaptSlaveDependencies() { String json = "{\"inputControl\" : [ {\"slaveDependencies\":[\"Country_multi_select\",\"Cascading_state_multi_select\"]}]}"; - InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + InputControl inputControl = deserializeInputControl(json); - InputControl inputControl = response.getValues().get(0); Set deps = inputControl.getSlaveDependencies(); assertThat(deps, hasItem("Cascading_state_multi_select")); @@ -60,25 +63,29 @@ public void shouldProperlyAdaptSlaveDependencies() { @Test public void shouldProperlyAdaptDateTimeValidationRule() { String json = "{\"inputControl\" : [ {\"validationRules\" : [ { \"dateTimeFormatValidationRule\" : { \"errorMessage\" : \"This field is mandatory so you must enter data.\", \"format\": \"YYYY-mm-dd\" } }]} ]}"; - InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + InputControl inputControl = deserializeInputControl(json); - InputControl inputControl = response.getValues().get(0); ValidationRule rule = (ValidationRule) inputControl.getValidationRules().toArray()[0]; assertThat(rule.getErrorMessage(), is("This field is mandatory so you must enter data.")); assertThat(rule.getType(), is("dateTimeFormatValidationRule")); assertThat(rule.getValue(), is("YYYY-mm-dd")); } + @Test public void shouldProperlyAdaptMandatoryValidationRule() { String json = "{\"inputControl\" : [ {\"validationRules\" : [ { \"mandatoryValidationRule\" : { \"errorMessage\" : \"This field is mandatory so you must enter data.\" } }]} ]}"; - InputControlResponse response = mGson.fromJson(json, InputControlResponse.class); + InputControl inputControl = deserializeInputControl(json); - InputControl inputControl = response.getValues().get(0); ValidationRule rule = (ValidationRule) inputControl.getValidationRules().toArray()[0]; assertThat(rule.getErrorMessage(), is("This field is mandatory so you must enter data.")); assertThat(rule.getType(), is("mandatoryValidationRule")); } - + private InputControl deserializeInputControl(String json) { + Type type = new TypeToken>() { + }.getType(); + Collection response = mGson.fromJson(json, type); + return new ArrayList<>(response).get(0); + } } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index b540f3d9..ead0d954 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -27,8 +27,9 @@ import com.jaspersoft.android.sdk.network.api.InputControlRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; -import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; +import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -36,6 +37,8 @@ import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -79,11 +82,10 @@ public void setup() { @Test public void shouldProvideInputControlsList() { - InputControlResponse response = mRestApi.requestInputControls(REPORT_URI, false); - List controls = response.getValues(); + Collection controls = mRestApi.requestInputControls(REPORT_URI, false); assertThat(controls, is(not(empty()))); - InputControl control = controls.get(0); + InputControl control = new ArrayList<>(controls).get(0); assertThat(control.getState(), is(notNullValue())); } @@ -92,24 +94,22 @@ public void shouldProvideInputControlsList() { */ @Test public void shouldProvideInputControlsListIfStateExcluded() { - InputControlResponse response = mRestApi.requestInputControls(REPORT_URI, true); - - List controls = response.getValues(); + Collection controls = mRestApi.requestInputControls(REPORT_URI, true); assertThat(controls, is(not(empty()))); - InputControl control = controls.get(0); + InputControl control = new ArrayList<>(controls).get(0); assertThat(control.getState(), is(nullValue())); } @Test public void shouldProvideFreshInitialInputControlsValues() { - InputControlValueResponse response = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); - assertThat(response.getValues(), is(not(empty()))); + Collection states = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); + assertThat(states, is(not(empty()))); } @Test public void shouldProvideFreshStatesForInputControls() { - InputControlValueResponse response = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); - assertThat(response.getValues(), is(not(empty()))); + Collection states = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); + assertThat(states, is(not(empty()))); } } From 576fc28c3a5f2c670c8a60f691e3c21399cc1046 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 12:43:37 +0300 Subject: [PATCH 213/457] Refactoring DTO/API for report options api --- .../sdk/network/api/ReportOptionRestApi.java | 4 ++-- .../sdk/network/api/ReportOptionRestApiImpl.java | 14 ++++++++------ ...ortOptionResponse.java => ReportOptionSet.java} | 10 +++------- ...nResponseTest.java => ReportOptionSetTest.java} | 6 +++--- .../integration/api/ReportOptionRestApiTest.java | 4 ++-- 5 files changed, 18 insertions(+), 20 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/{ReportOptionResponse.java => ReportOptionSet.java} (86%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/{ReportOptionResponseTest.java => ReportOptionSetTest.java} (80%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 96cf334a..6ccfd4ed 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -28,7 +28,7 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import java.util.Map; import java.util.Set; @@ -41,7 +41,7 @@ public interface ReportOptionRestApi { @NonNull @WorkerThread - ReportOptionResponse requestReportOptionsList(@NonNull String reportUnitUri); + Set requestReportOptionsList(@NonNull String reportUnitUri); @NonNull @WorkerThread diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java index 31a4b266..ec507f92 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -29,9 +29,10 @@ import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import com.squareup.okhttp.Response; +import java.util.Collections; import java.util.Map; import java.util.Set; @@ -61,19 +62,20 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { @NonNull @Override - public ReportOptionResponse requestReportOptionsList(@Nullable String reportUnitUri) { + public Set requestReportOptionsList(@Nullable String reportUnitUri) { checkNotNull(reportUnitUri, "Report uri should not be null"); - Call call = mRestApi.requestReportOptionsList(reportUnitUri); + Call call = mRestApi.requestReportOptionsList(reportUnitUri); try { - return CallWrapper.wrap(call).body(); + ReportOptionSet options = CallWrapper.wrap(call).body(); + return options.get(); } catch (JsonSyntaxException ex) { /** * This possible when there is no report options * API responds with plain/text message: 'No options found for {URI}' * As soon as there 2 options to reserve this we decide to swallow exception and return empty object */ - return ReportOptionResponse.empty(); + return Collections.emptySet(); } } @@ -117,7 +119,7 @@ private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitUri}/options") - Call requestReportOptionsList( + Call requestReportOptionsList( @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); @NonNull diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java similarity index 86% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java index 0cca026e..6cd9cb7f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java @@ -36,20 +36,16 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportOptionResponse { +public final class ReportOptionSet { - private ReportOptionResponse() {} - - public static ReportOptionResponse empty() { - return new ReportOptionResponse(); - } + private ReportOptionSet() {} @Expose @SerializedName("reportOptionsSummary") private Set mOptions = Collections.emptySet(); @NonNull - public Set getOptions() { + public Set get() { return mOptions; } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java similarity index 80% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java index 2561984c..25336abe 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java @@ -14,16 +14,16 @@ * @author Tom Koptel * @since 2.0 */ -public class ReportOptionResponseTest { +public class ReportOptionSetTest { @Test public void shouldHaveExposeAnnotationForFieldOptions() throws NoSuchFieldException { - Field field = ReportOptionResponse.class.getDeclaredField("mOptions"); + Field field = ReportOptionSet.class.getDeclaredField("mOptions"); assertThat(field, hasAnnotation(Expose.class)); } @Test public void optionsFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { - Field field = ReportOptionResponse.class.getDeclaredField("mOptions"); + Field field = ReportOptionSet.class.getDeclaredField("mOptions"); assertThat(field, hasSerializedName("reportOptionsSummary")); } } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index a200e711..47efba97 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.api.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -80,7 +80,7 @@ public void setup() { @Test public void shouldRequestReportOptionsList() { - ReportOptionResponse response = apiUnderTest.requestReportOptionsList(REPORT_URI); + Set response = apiUnderTest.requestReportOptionsList(REPORT_URI); assertThat(response, is(not(nullValue()))); } From 6d33b1852313fa44bf3ac3a60ee1a54dafaffeda Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 12:47:09 +0300 Subject: [PATCH 214/457] Refactoring DTO/API for server api --- .../sdk/network/api/ServerRestApi.java | 4 +-- .../sdk/network/api/ServerRestApiImpl.java | 8 ++--- ...rInfoResponse.java => ServerInfoData.java} | 4 +-- ...ponseTest.java => ServerInfoDataTest.java} | 4 +-- .../test/integration/api/ServerRestTest.java | 4 +-- .../sdk/service/ServerInfoService.java | 4 +-- .../sdk/service/ServerInfoTransformer.java | 4 +-- .../sdk/service/ServerInfoServiceTest.java | 6 ++-- .../service/ServerInfoTransformerTest.java | 36 +++++++++---------- 9 files changed, 37 insertions(+), 37 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/{ServerInfoResponse.java => ServerInfoData.java} (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/{ServerInfoResponseTest.java => ServerInfoDataTest.java} (94%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 52765a2e..13e84f40 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -27,7 +27,7 @@ import android.support.annotation.NonNull; import android.support.annotation.WorkerThread; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; /** * @author Tom Koptel @@ -37,7 +37,7 @@ public interface ServerRestApi { @NonNull @WorkerThread - ServerInfoResponse requestServerInfo(); + ServerInfoData requestServerInfo(); @NonNull @WorkerThread String requestBuild(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java index 30a75ea8..235f2055 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import retrofit.Call; import retrofit.Retrofit; @@ -47,8 +47,8 @@ public ServerRestApiImpl(Retrofit retrofit) { @NonNull @Override - public ServerInfoResponse requestServerInfo() { - Call call = mApi.requestServerInfo(); + public ServerInfoData requestServerInfo() { + Call call = mApi.requestServerInfo(); return CallWrapper.wrap(call).body(); } @@ -110,7 +110,7 @@ private interface RestApi { @NonNull @Headers("Accept: application/json") @GET(value = "rest_v2/serverInfo") - Call requestServerInfo(); + Call requestServerInfo(); @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/edition") Call requestEdition(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java index 98f789a8..032b2e0d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java @@ -27,7 +27,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ServerInfoResponse { +public final class ServerInfoData { @Expose private String dateFormatPattern; @@ -87,7 +87,7 @@ public String getVersion() { @Override public String toString() { - return "ServerInfoResponse{" + + return "ServerInfoData{" + "build='" + build + '\'' + ", dateFormatPattern='" + dateFormatPattern + '\'' + ", datetimeFormatPattern='" + datetimeFormatPattern + '\'' + diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java index 0c4418be..6e2b03e6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java @@ -41,7 +41,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ServerInfoResponseTest { +public class ServerInfoDataTest { @Test @Parameters({ "dateFormatPattern", @@ -54,7 +54,7 @@ public class ServerInfoResponseTest { "features", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ServerInfoResponse.class.getDeclaredField(fieldName); + Field field = ServerInfoData.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 01cdc5b9..1f18110a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.test.TestLogger; import org.junit.Before; @@ -55,7 +55,7 @@ public void setup() { @Test public void shouldRequestServerInfo() throws Exception { - ServerInfoResponse response = apiUnderTest.requestServerInfo(); + ServerInfoData response = apiUnderTest.requestServerInfo(); assertThat(response, is(notNullValue())); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index 861f63a6..ce27dc7d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -3,7 +3,7 @@ import android.support.annotation.VisibleForTesting; import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; /** @@ -33,7 +33,7 @@ public static ServerInfoService newInstance(String baseUrl) { } public ServerInfo requestServerInfo() { - ServerInfoResponse response = mRestApi.requestServerInfo(); + ServerInfoData response = mRestApi.requestServerInfo(); return mTransformer.transform(response); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java index 17a98691..060fdeaa 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; /** @@ -45,7 +45,7 @@ public static ServerInfoTransformer getInstance() { return InstanceHolder.INSTANCE; } - public ServerInfo transform(ServerInfoResponse response) { + public ServerInfo transform(ServerInfoData response) { ServerInfo serverInfo = new ServerInfo(); serverInfo.setBuild(response.getBuild()); serverInfo.setDateFormatPattern(response.getDateFormatPattern()); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java index f8a0c524..a96c0245 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java @@ -1,7 +1,7 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import org.junit.Before; import org.junit.Test; @@ -20,7 +20,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ServerInfoResponse.class}) +@PrepareForTest({ServerInfoData.class}) public class ServerInfoServiceTest { @Mock @@ -28,7 +28,7 @@ public class ServerInfoServiceTest { @Mock ServerInfoTransformer mockTransformer; @Mock - ServerInfoResponse mockResponse; + ServerInfoData mockResponse; private ServerInfoService serviceUnderTest; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java index 4d0d2855..32649623 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoResponse; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; @@ -48,65 +48,65 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ServerInfoResponse.class}) +@PrepareForTest({ServerInfoData.class}) public class ServerInfoTransformerTest { - ServerInfoResponse mServerInfoResponse; + ServerInfoData mServerInfoData; private ServerInfoTransformer transformerUnderTest; @Before public void setup() { transformerUnderTest = ServerInfoTransformer.getInstance(); - mServerInfoResponse = PowerMockito.mock(ServerInfoResponse.class); - when(mServerInfoResponse.getBuild()).thenReturn("20150527_1447"); - when(mServerInfoResponse.getDateFormatPattern()).thenReturn("yyyy-MM-dd"); - when(mServerInfoResponse.getDatetimeFormatPattern()).thenReturn("yyyy-MM-dd'T'HH:mm:ss"); - when(mServerInfoResponse.getVersion()).thenReturn("6.1"); - when(mServerInfoResponse.getEdition()).thenReturn("PRO"); - when(mServerInfoResponse.getEditionName()).thenReturn("Enterprise for AWS"); - when(mServerInfoResponse.getFeatures()).thenReturn("Fusion"); + mServerInfoData = PowerMockito.mock(ServerInfoData.class); + when(mServerInfoData.getBuild()).thenReturn("20150527_1447"); + when(mServerInfoData.getDateFormatPattern()).thenReturn("yyyy-MM-dd"); + when(mServerInfoData.getDatetimeFormatPattern()).thenReturn("yyyy-MM-dd'T'HH:mm:ss"); + when(mServerInfoData.getVersion()).thenReturn("6.1"); + when(mServerInfoData.getEdition()).thenReturn("PRO"); + when(mServerInfoData.getEditionName()).thenReturn("Enterprise for AWS"); + when(mServerInfoData.getFeatures()).thenReturn("Fusion"); } @Test public void shouldTransformBuildProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getBuild(), is("20150527_1447")); } @Test public void shouldTransformDateFormatProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getDateFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd"))); } @Test public void shouldTransformDateTimeFormatProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getDatetimeFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"))); } @Test public void shouldTransformServerVersionProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getVersion(), is(ServerVersion.AMBER_MR2)); } @Test public void shouldTransformServerEditionProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getEdition(), is(ServerEdition.PRO)); } @Test public void shouldTransformServerEditionNameProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getEditionName(), is("Enterprise for AWS")); } @Test public void shouldTransformFeaturesProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoResponse); + ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getFeatures().asSet(), contains("Fusion")); } From 1532e183f20672ef1fcaefbe1b17607a01d67aa3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 12:57:10 +0300 Subject: [PATCH 215/457] Refactoring DTO/API for repository api --- .../sdk/network/api/RepositoryRestApi.java | 20 ++++---- .../network/api/RepositoryRestApiImpl.java | 46 +++++++++---------- ...okupResponse.java => DashboardLookup.java} | 4 +- ...rLookupResponse.java => FolderLookup.java} | 4 +- ...sponse.java => LegacyDashboardLookup.java} | 2 +- ...tLookupResponse.java => ReportLookup.java} | 6 +-- ...ookupResponse.java => ResourceLookup.java} | 4 +- ...esponse.java => ResourceSearchResult.java} | 14 +++--- .../sdk/network/entity/type/GsonFactory.java | 4 +- ...va => InputControlTypeAdapterFactory.java} | 4 +- ...va => ReportLookupTypeAdapterFactory.java} | 8 ++-- .../network/api/RepositoryRestApiTest.java | 12 ++--- .../resource/DashboardLookupResponseTest.java | 4 +- .../resource/FolderLookupResponseTest.java | 2 +- .../LegacyDashboardLookupResponseTest.java | 2 +- ...esponseTest.java => ReportLookupTest.java} | 6 +-- ...ava => ResourceLookupJsonConvertTest.java} | 4 +- .../api/RepositoryRestApiTest.java | 20 ++++---- .../repository/EmeraldMR2SearchStrategy.java | 18 ++++---- .../repository/EmeraldMR3SearchStrategy.java | 18 ++++---- .../service/repository/SearchStrategy.java | 4 +- .../sdk/service/repository/SearchTask.java | 4 +- .../service/repository/SearchTaskImpl.java | 4 +- .../EmeraldMR2SearchStrategyTest.java | 30 ++++++------ .../EmeraldMR3SearchStrategyTest.java | 14 +++--- .../repository/RepositoryServiceTest.java | 8 ++-- 26 files changed, 133 insertions(+), 133 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/{DashboardLookupResponse.java => DashboardLookup.java} (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/{FolderLookupResponse.java => FolderLookup.java} (92%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/{LegacyDashboardLookupResponse.java => LegacyDashboardLookup.java} (93%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/{ReportLookupResponse.java => ReportLookup.java} (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/{ResourceLookupResponse.java => ResourceLookup.java} (96%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/{ResourceSearchResponse.java => ResourceSearchResult.java} (85%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/{InputControlResponseTypeAdapterFactory.java => InputControlTypeAdapterFactory.java} (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/{ReportLookupResponseTypeAdapterFactory.java => ReportLookupTypeAdapterFactory.java} (88%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/{ReportLookupResponseTest.java => ReportLookupTest.java} (91%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/{ResourceLookupResponseJsonConvertTest.java => ResourceLookupJsonConvertTest.java} (93%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 82a96aff..83dba69e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -28,11 +28,11 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; -import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookup; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; +import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import java.util.Map; @@ -43,23 +43,23 @@ public interface RepositoryRestApi { @NonNull @WorkerThread - ResourceSearchResponse searchResources(@Nullable Map searchParams); + ResourceSearchResult searchResources(@Nullable Map searchParams); @NonNull @WorkerThread - ReportLookupResponse requestReportResource(@NonNull String resourceUri); + ReportLookup requestReportResource(@NonNull String resourceUri); @NonNull @WorkerThread - DashboardLookupResponse requestDashboardResource(@NonNull String resourceUri); + DashboardLookup requestDashboardResource(@NonNull String resourceUri); @NonNull @WorkerThread - LegacyDashboardLookupResponse requestLegacyDashboardResource(@NonNull String resourceUri); + LegacyDashboardLookup requestLegacyDashboardResource(@NonNull String resourceUri); @NonNull @WorkerThread - FolderLookupResponse requestFolderResource(@NonNull String resourceUri); + FolderLookup requestFolderResource(@NonNull String resourceUri); interface Factory { RepositoryRestApi get(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 0e2a63d9..1714e4dc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -27,11 +27,11 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookup; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; +import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import java.util.HashMap; import java.util.Map; @@ -61,9 +61,9 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NonNull @Override - public ResourceSearchResponse searchResources(@Nullable Map searchParams) { + public ResourceSearchResult searchResources(@Nullable Map searchParams) { Iterable types = null; - Call call; + Call call; if (searchParams == null) { call = mRestApi.searchResources(null, null); @@ -82,12 +82,12 @@ public ResourceSearchResponse searchResources(@Nullable Map sear call = mRestApi.searchResources(copy, types); } - Response rawResponse = CallWrapper.wrap(call).response(); + Response rawResponse = CallWrapper.wrap(call).response(); int status = rawResponse.code(); - ResourceSearchResponse entity; + ResourceSearchResult entity; if (status == 204) { - entity = ResourceSearchResponse.empty(); + entity = ResourceSearchResult.empty(); } else { entity = rawResponse.body(); com.squareup.okhttp.Headers headers = rawResponse.headers(); @@ -107,37 +107,37 @@ public ResourceSearchResponse searchResources(@Nullable Map sear @NonNull @Override - public ReportLookupResponse requestReportResource(@Nullable String resourceUri) { + public ReportLookup requestReportResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Report uri should not be null"); - Call call = mRestApi.requestReportResource(resourceUri); + Call call = mRestApi.requestReportResource(resourceUri); return CallWrapper.wrap(call).body(); } @NonNull @Override - public DashboardLookupResponse requestDashboardResource(@Nullable String resourceUri) { + public DashboardLookup requestDashboardResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Dashboard uri should not be null"); - Call call = mRestApi.requestDashboardResource(resourceUri); + Call call = mRestApi.requestDashboardResource(resourceUri); return CallWrapper.wrap(call).body(); } @NonNull @Override - public LegacyDashboardLookupResponse requestLegacyDashboardResource(@Nullable String resourceUri) { + public LegacyDashboardLookup requestLegacyDashboardResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Legacy dashboard uri should not be null"); - Call call = mRestApi.requestLegacyDashboardResource(resourceUri); + Call call = mRestApi.requestLegacyDashboardResource(resourceUri); return CallWrapper.wrap(call).body(); } @NonNull @Override - public FolderLookupResponse requestFolderResource(@Nullable String resourceUri) { + public FolderLookup requestFolderResource(@Nullable String resourceUri) { checkNotNull(resourceUri, "Folder uri should not be null"); - Call call = mRestApi.requestFolderResource(resourceUri); + Call call = mRestApi.requestFolderResource(resourceUri); return CallWrapper.wrap(call).body(); } @@ -145,32 +145,32 @@ private interface RestApi { @NonNull @Headers("Accept: application/json") @GET("rest_v2/resources") - Call searchResources( + Call searchResources( @Nullable @QueryMap Map searchParams, @Nullable @Query("type") Iterable types); @NonNull @Headers("Accept: application/repository.reportUnit+json") @GET("rest_v2/resources{resourceUri}") - Call requestReportResource( + Call requestReportResource( @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.dashboard+json") @GET("rest_v2/resources{resourceUri}") - Call requestDashboardResource( + Call requestDashboardResource( @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.legacyDashboard+json") @GET("rest_v2/resources{resourceUri}") - Call requestLegacyDashboardResource( + Call requestLegacyDashboardResource( @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NonNull @Headers("Accept: application/repository.folder+json") @GET("rest_v2/resources{resourceUri}") - Call requestFolderResource( + Call requestFolderResource( @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookup.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookup.java index d71f7ab8..833af3fa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookup.java @@ -33,7 +33,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class DashboardLookupResponse extends ResourceLookupResponse { +public final class DashboardLookup extends ResourceLookup { @Expose private List foundations; @@ -61,7 +61,7 @@ public List getResources() { @Override public String toString() { - return "DashboardLookupResponse{" + + return "DashboardLookup{" + "creationDate='" + creationDate + '\'' + ", label='" + label + '\'' + ", description='" + description + '\'' + diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java similarity index 92% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java index 83edd3f5..11c2233c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java @@ -28,9 +28,9 @@ * @author Tom Koptel * @since 2.0 */ -public class FolderLookupResponse extends ResourceLookupResponse { +public class FolderLookup extends ResourceLookup { - public FolderLookupResponse() {} + public FolderLookup() {} @Override public String getResourceType() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookup.java similarity index 93% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookup.java index 7c6ec809..cdd19c78 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookup.java @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class LegacyDashboardLookupResponse extends ResourceLookupResponse { +public final class LegacyDashboardLookup extends ResourceLookup { @Override public String getResourceType() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java index dc935833..71b123e2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java @@ -33,7 +33,7 @@ * @author Tom Koptel * @since 2.0 */ -public class ReportLookupResponse extends ResourceLookupResponse { +public class ReportLookup extends ResourceLookup { @Expose private DataSource dataSource; @@ -50,7 +50,7 @@ public class ReportLookupResponse extends ResourceLookupResponse { @Expose private List resources; - public ReportLookupResponse() {} + public ReportLookup() {} @Override public String getResourceType() { @@ -87,7 +87,7 @@ public List getResources() { @Override public String toString() { - return "ReportLookupResponse{" + + return "ReportLookup{" + "alwaysPromptControls=" + alwaysPromptControls + ", dataSource=" + dataSource + ", jrxml=" + jrxml + diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java index 898c95a7..98bbe2b6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java @@ -30,7 +30,7 @@ * @author Tom Koptel * @since 2.0 */ -public class ResourceLookupResponse { +public class ResourceLookup { @Expose protected String label; @@ -84,7 +84,7 @@ public int getVersion() { @Override public String toString() { - return "ResourceLookupResponse{" + + return "ResourceLookup{" + "creationDate='" + creationDate + '\'' + ", label='" + label + '\'' + ", description='" + description + '\'' + diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java similarity index 85% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResponse.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java index b2575981..da440f2e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResponse.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java @@ -34,29 +34,29 @@ * @author Tom Koptel * @since 2.0 */ -public final class ResourceSearchResponse { +public final class ResourceSearchResult { @Expose @SerializedName("resourceLookup") - private List mResources; + private List mResources; private int mResultCount; private int mTotalCount; private int mStartIndex; private int mNextOffset; - private ResourceSearchResponse(List resources) { + private ResourceSearchResult(List resources) { mResources = resources; } - public static ResourceSearchResponse empty() { - return new ResourceSearchResponse(Collections.emptyList()); + public static ResourceSearchResult empty() { + return new ResourceSearchResult(Collections.emptyList()); } public int getNextOffset() { return mNextOffset; } - public List getResources() { + public List getResources() { return mResources; } @@ -74,7 +74,7 @@ public int getTotalCount() { @Override public String toString() { - return "ResourceSearchResponse{" + + return "ResourceSearchResult{" + "mNextOffset=" + mNextOffset + ", mResourcesCount=" + mResources.size() + ", mResultCount=" + mResultCount + diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java index 50c313d3..4bf1cdf9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java @@ -36,8 +36,8 @@ public static Gson create() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.excludeFieldsWithoutExposeAnnotation(); gsonBuilder.disableHtmlEscaping(); - gsonBuilder.registerTypeAdapterFactory(new ReportLookupResponseTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new InputControlResponseTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ReportLookupTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new InputControlTypeAdapterFactory()); return gsonBuilder.create(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java index 74249fce..e580c6b9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlResponseTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java @@ -33,10 +33,10 @@ * @author Tom Koptel * @since 2.0 */ -final class InputControlResponseTypeAdapterFactory extends CustomizedTypeAdapterFactory { +final class InputControlTypeAdapterFactory extends CustomizedTypeAdapterFactory { private static final String[] RULE_TYPES = {"dateTimeFormatValidationRule", "mandatoryValidationRule"}; - public InputControlResponseTypeAdapterFactory() { + public InputControlTypeAdapterFactory() { super(InputControlCollection.class); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupResponseTypeAdapterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java similarity index 88% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupResponseTypeAdapterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java index 02ac682e..4e3c4a5d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupResponseTypeAdapterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java @@ -27,16 +27,16 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; /** * @author Tom Koptel * @since 2.0 */ -final class ReportLookupResponseTypeAdapterFactory extends CustomizedTypeAdapterFactory { - public ReportLookupResponseTypeAdapterFactory() { - super(ReportLookupResponse.class); +final class ReportLookupTypeAdapterFactory extends CustomizedTypeAdapterFactory { + public ReportLookupTypeAdapterFactory() { + super(ReportLookup.class); } @Override diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index d1aa175e..e62f0ea7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.network.api; import com.jaspersoft.android.sdk.network.api.auth.Token; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -83,7 +83,7 @@ public void setup() { public void shouldReturnEmptyResponseForNoContentResponse() { mWebMockRule.enqueue(MockResponseFactory.create204()); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getResources(), is(empty())); } @@ -94,7 +94,7 @@ public void requestForSearchShouldParseHeaderResultCount() { .addHeader("Result-Count", "100"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getResultCount(), is(100)); } @@ -105,7 +105,7 @@ public void requestForSearchShouldParseHeaderTotalCount() { .addHeader("Total-Count", "1000"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getTotalCount(), is(1000)); } @@ -116,7 +116,7 @@ public void requestForSearchShouldParseHeaderStartIndex() { .addHeader("Start-Index", "5"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getStartIndex(), is(5)); } @@ -127,7 +127,7 @@ public void requestForSearchShouldParseHeaderNextOffset() { .addHeader("Next-Offset", "10"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResponse response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getNextOffset(), is(10)); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java index 45e8238b..f57b1855 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java @@ -51,13 +51,13 @@ public class DashboardLookupResponseTest { "defaultFoundation", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = DashboardLookupResponse.class.getDeclaredField(fieldName); + Field field = DashboardLookup.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } @Test public void shouldAlwaysReturnReportUnitUriAsType() { - DashboardLookupResponse response = new DashboardLookupResponse(); + DashboardLookup response = new DashboardLookup(); assertThat(response.getResourceType(), is("dashboard")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java index b62cf2ef..2548322e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java @@ -37,7 +37,7 @@ public class FolderLookupResponseTest { @Test public void shouldAlwaysReturnReportUnitUriAsType() { - FolderLookupResponse response = new FolderLookupResponse(); + FolderLookup response = new FolderLookup(); assertThat(response.getResourceType(), is("folder")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java index 19bc463b..6a71d5f7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java @@ -36,7 +36,7 @@ public class LegacyDashboardLookupResponseTest { @Test public void shouldAlwaysReturnReportUnitUriAsType() { - LegacyDashboardLookupResponse response = new LegacyDashboardLookupResponse(); + LegacyDashboardLookup response = new LegacyDashboardLookup(); assertThat(response.getResourceType(), is("legacyDashboard")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java similarity index 91% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponseTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java index 05dc2b42..e6e53d9c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupResponseTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java @@ -43,7 +43,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ReportLookupResponseTest { +public class ReportLookupTest { @Test @Parameters({ "dataSource", @@ -55,13 +55,13 @@ public class ReportLookupResponseTest { "resources", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ReportLookupResponse.class.getDeclaredField(fieldName); + Field field = ReportLookup.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } @Test public void shouldAlwaysReturnReportUnitUriAsType() { - ReportLookupResponse response = new ReportLookupResponse(); + ReportLookup response = new ReportLookup(); assertThat(response.getResourceType(), is("reportUnit")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponseJsonConvertTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java similarity index 93% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponseJsonConvertTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java index 36fc95b4..cb5f839a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupResponseJsonConvertTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java @@ -42,7 +42,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ResourceLookupResponseJsonConvertTest { +public class ResourceLookupJsonConvertTest { @Test @Parameters({ "label", @@ -54,7 +54,7 @@ public class ResourceLookupResponseJsonConvertTest { "updateDate", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ResourceLookupResponse.class.getDeclaredField(fieldName); + Field field = ResourceLookup.class.getDeclaredField(fieldName); assertThat(field, hasAnnotation(Expose.class)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index d0b2b347..cbfbe495 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -26,10 +26,10 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; -import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookup; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -69,28 +69,28 @@ public void setup() { @Test public void shouldRequestListOfResources() { - ResourceSearchResponse resourceSearchResponse = api.searchResources(null); - assertThat(resourceSearchResponse, is(notNullValue())); - assertThat(resourceSearchResponse.getResources(), is(not(empty()))); + ResourceSearchResult resourceSearchResult = api.searchResources(null); + assertThat(resourceSearchResult, is(notNullValue())); + assertThat(resourceSearchResult.getResources(), is(not(empty()))); } @Test public void shouldRequestReport() { - ReportLookupResponse report = api.requestReportResource("/public/Samples/Reports/AllAccounts"); + ReportLookup report = api.requestReportResource("/public/Samples/Reports/AllAccounts"); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @Test public void shouldRequestDashboard() { - DashboardLookupResponse dashboard = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); + DashboardLookup dashboard = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); assertThat(dashboard, is(notNullValue())); assertThat(dashboard.getFoundations(), is(not(empty()))); } @Test public void shouldRequestRootFolder() { - FolderLookupResponse folder = api.requestFolderResource("/"); + FolderLookup folder = api.requestFolderResource("/"); assertThat(folder, is(notNullValue())); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index b2c5cfb9..08f405ab 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -27,8 +27,8 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import java.util.Collection; import java.util.Collections; @@ -40,14 +40,14 @@ * @since 2.0 */ final class EmeraldMR2SearchStrategy implements SearchStrategy { - private static final Collection EMPTY_RESPONSE = Collections.emptyList(); + private static final Collection EMPTY_RESPONSE = Collections.emptyList(); private static final int MAX_RETRY_COUNT = 5; private final RepositoryRestApi.Factory mRepoFactory; private final InternalCriteria mInitialCriteria; private int mServerDisposition; - private List mBuffer = new LinkedList<>(); + private List mBuffer = new LinkedList<>(); private boolean mEndReached; public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, InternalCriteria criteria) { @@ -57,7 +57,7 @@ public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, } @Override - public Collection searchNext() { + public Collection searchNext() { int limit = mInitialCriteria.getLimit(); int offset = mInitialCriteria.getOffset(); @@ -81,10 +81,10 @@ private void calculateDisposition(int offset) { } @NonNull - private Collection internalSearch(int limit) { + private Collection internalSearch(int limit) { int count = 0; while (mBuffer.size() < limit && hasNext()) { - ResourceSearchResponse response = performSearch(limit); + ResourceSearchResult response = performSearch(limit); mBuffer.addAll(response.getResources()); mServerDisposition += limit; @@ -103,13 +103,13 @@ private Collection internalSearch(int limit) { } int median = Math.min(limit, mBuffer.size()); - Collection result = mBuffer.subList(0, median); + Collection result = mBuffer.subList(0, median); mBuffer = mBuffer.subList(median, mBuffer.size()); return result; } @NonNull - private ResourceSearchResponse performSearch(int limit) { + private ResourceSearchResult performSearch(int limit) { InternalCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) .limit(limit) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index a874cf8a..f7ba265b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -27,8 +27,8 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import java.util.Collection; import java.util.Collections; @@ -38,7 +38,7 @@ * @since 2.0 */ final class EmeraldMR3SearchStrategy implements SearchStrategy { - public static final Collection EMPTY_RESPONSE = Collections.emptyList(); + public static final Collection EMPTY_RESPONSE = Collections.emptyList(); private final static int UNDEFINED = -1; private final RepositoryRestApi.Factory mRepoFactory; @@ -58,7 +58,7 @@ public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, } @Override - public Collection searchNext() { + public Collection searchNext() { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } @@ -75,15 +75,15 @@ public boolean hasNext() { } @NonNull - private Collection performLookup() { + private Collection performLookup() { InternalCriteria newSearchCriteria = createNextCriteria(); - ResourceSearchResponse result = performApiCall(newSearchCriteria); + ResourceSearchResult result = performApiCall(newSearchCriteria); updateInternalOffset(result); return result.getResources(); } @NonNull - private ResourceSearchResponse performApiCall(InternalCriteria newSearchCriteria) { + private ResourceSearchResult performApiCall(InternalCriteria newSearchCriteria) { RepositoryRestApi api = mRepoFactory.get(); return api.searchResources(newSearchCriteria.toMap()); } @@ -96,12 +96,12 @@ private void defineInternalOffset() { .limit(mUserOffset) .offset(0) .create(); - ResourceSearchResponse result = performApiCall(newCriteria); + ResourceSearchResult result = performApiCall(newCriteria); mInternalOffset = result.getNextOffset(); } } - private void updateInternalOffset(ResourceSearchResponse result) { + private void updateInternalOffset(ResourceSearchResult result) { int nextOffset = result.getNextOffset(); mEndReached = (nextOffset == 0); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index a48b397b..e84628a1 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.util.Collection; @@ -35,7 +35,7 @@ * @since 2.0 */ interface SearchStrategy { - Collection searchNext(); + Collection searchNext(); boolean hasNext(); class Factory { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 25bdb31b..02c5092c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -25,7 +25,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import java.util.Collection; @@ -35,6 +35,6 @@ */ public interface SearchTask { @NonNull - Collection nextLookup(); + Collection nextLookup(); boolean hasNext(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index b7e0604d..5ef271b4 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -29,7 +29,7 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import java.util.Collection; @@ -55,7 +55,7 @@ final class SearchTaskImpl implements SearchTask { @NonNull @Override - public Collection nextLookup() { + public Collection nextLookup() { return defineSearchStrategy().searchNext(); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index 69ee55da..8fddb0a9 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -1,8 +1,8 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import org.junit.Before; import org.junit.Test; @@ -36,7 +36,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ResourceSearchResponse.class}) +@PrepareForTest({ResourceSearchResult.class}) public class EmeraldMR2SearchStrategyTest { @Mock @@ -44,14 +44,14 @@ public class EmeraldMR2SearchStrategyTest { @Mock RepositoryRestApi mApi; @Mock - ResourceSearchResponse mResponse; + ResourceSearchResult mResponse; /** * Objects under test */ private EmeraldMR2SearchStrategy search10itemsStrategy; private EmeraldMR2SearchStrategy search10itemsStrategyWithUserOffset5; - public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); + public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); @Before public void setupMocks() { @@ -60,7 +60,7 @@ public void setupMocks() { when(mApi.searchResources(anyMap())).thenReturn(mResponse); when(mApiFactory.get()).thenReturn(mApi); - List stubLookup = Collections.singletonList(new ResourceLookupResponse()); + List stubLookup = Collections.singletonList(new ResourceLookup()); when(mResponse.getResources()).thenReturn(stubLookup); InternalCriteria criteria = InternalCriteria.builder().limit(10).create(); @@ -74,7 +74,7 @@ public void setupMocks() { public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(10)); Map params = new HashMap<>(); @@ -91,9 +91,9 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce @Test public void willRetry5timesIfApiReturnsNoElements()throws Exception { - when(mResponse.getResources()).thenReturn(Collections.emptyList()); + when(mResponse.getResources()).thenReturn(Collections.emptyList()); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); @@ -105,7 +105,7 @@ public void willRetry5timesIfApiReturnsNoElements()throws Exception { public void willReturnAsMuchElementsAsLeftIfEndReached()throws Exception { when(mResponse.getResources()).then(OnlyTwoItems.INSTANCE); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(2)); verify(mApiFactory, times(6)).get(); @@ -141,21 +141,21 @@ public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); - Collection result = strategy.searchNext(); + Collection result = strategy.searchNext(); assertThat(result, is(empty())); verifyZeroInteractions(mApi); } - private static class OnlyTwoItems implements Answer> { + private static class OnlyTwoItems implements Answer> { public static final OnlyTwoItems INSTANCE = new OnlyTwoItems(); - private final List twoItems = Arrays.asList(null, null); - private final List zeroItems = Collections.emptyList(); + private final List twoItems = Arrays.asList(null, null); + private final List zeroItems = Collections.emptyList(); private int count = 0; @Override - public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { + public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { if (count == 0) { count++; return twoItems; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index 56a2f2d1..bc0ab468 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -1,8 +1,8 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import org.hamcrest.Matchers; import org.junit.Before; @@ -33,7 +33,7 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest(ResourceSearchResponse.class) +@PrepareForTest(ResourceSearchResult.class) public class EmeraldMR3SearchStrategyTest { private static final InternalCriteria NO_CRITERIA = InternalCriteria.from(SearchCriteria.none()); @@ -42,7 +42,7 @@ public class EmeraldMR3SearchStrategyTest { @Mock RepositoryRestApi mApi; @Mock - ResourceSearchResponse mResponse; + ResourceSearchResult mResponse; @Before public void setupMocks() { @@ -51,7 +51,7 @@ public void setupMocks() { when(mApi.searchResources(anyMap())).thenReturn(mResponse); when(mApiFactory.get()).thenReturn(mApi); - List stubLookup = Collections.singletonList(new ResourceLookupResponse()); + List stubLookup = Collections.singletonList(new ResourceLookup()); when(mResponse.getResources()).thenReturn(stubLookup); } @@ -115,7 +115,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { when(mResponse.getNextOffset()).thenReturn(0); strategy.searchNext(); - Collection response = strategy.searchNext(); + Collection response = strategy.searchNext(); assertThat(response, is(empty())); assertThat(strategy.hasNext(), is(false)); @@ -129,7 +129,7 @@ public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, userCriteria); - Collection result = strategy.searchNext(); + Collection result = strategy.searchNext(); assertThat(result, Matchers.is(Matchers.empty())); verifyZeroInteractions(mApi); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 562730c8..9948c53b 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -26,8 +26,8 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.FolderLookupResponse; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookupResponse; +import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import org.junit.Before; import org.junit.Rule; @@ -54,9 +54,9 @@ public class RepositoryServiceTest { ServerRestApi.Factory infoApi; @Mock - FolderLookupResponse mFolderResponse; + FolderLookup mFolderResponse; @Mock - ReportLookupResponse mReportResponse; + ReportLookup mReportResponse; private RepositoryService objectUnderTest; From f4abae100d641c842d4cdfa27dcaccae58e3baab Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 13:11:50 +0300 Subject: [PATCH 216/457] Generifying Token interface. Remove redundant wrapper --- .../android/sdk/network/api/AuthBuilder.java | 4 ++-- .../sdk/network/api/AuthenticationRestApi.java | 3 ++- .../network/api/AuthenticationRestApiImpl.java | 12 ++++++------ .../sdk/network/api/GenericAuthBuilder.java | 2 +- ...uthResponseFactory.java => TokenFactory.java} | 16 +++++++++------- .../sdk/network/api/auth/CookieToken.java | 8 ++++++-- .../android/sdk/network/api/auth/Token.java | 6 +++--- .../network/api/AuthenticationRestApiTest.java | 5 +++-- .../api/InputControlRestApiBuilderTest.java | 2 +- .../sdk/network/api/InputControlRestApiTest.java | 2 +- .../api/ReportExecutionRestApiBuilderTest.java | 2 +- .../network/api/ReportExecutionRestApiTest.java | 2 +- .../api/ReportExportRestApiBuilderTest.java | 2 +- .../sdk/network/api/ReportExportRestApiTest.java | 2 +- .../api/ReportOptionRestApiBuilderTest.java | 2 +- .../sdk/network/api/ReportOptionRestApiTest.java | 2 +- .../api/RepositoryRestApiBuilderTest.java | 2 +- .../sdk/network/api/RepositoryRestApiTest.java | 2 +- ...nseFactoryTest.java => TokenFactoryTest.java} | 9 +++++---- .../api/AuthenticationRestApiTest.java | 9 +++++---- .../integration/api/utils/TestAuthenticator.java | 10 +++++----- .../android/sdk/service/TokenProvider.java | 4 ++-- .../android/sdk/service/auth/AuthService.java | 4 ++-- .../sdk/service/auth/SpringAuthService.java | 10 +++++----- .../sdk/service/auth/SpringAuthServiceTest.java | 6 +++--- 25 files changed, 69 insertions(+), 59 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{AuthResponseFactory.java => TokenFactory.java} (81%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/api/{AuthResponseFactoryTest.java => TokenFactoryTest.java} (87%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java index 118f136a..b8eae61b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java @@ -37,13 +37,13 @@ */ final class AuthBuilder { private final AdapterBuilder mAdapterBuilder; - private Token mToken; + private Token mToken; public AuthBuilder(AdapterBuilder adapterBuilder) { mAdapterBuilder = adapterBuilder; } - public AuthBuilder setToken(Token token) { + public AuthBuilder setToken(Token token) { checkNotNull(token, "token == null"); mToken = token; return this; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index cacf1e88..5686d4da 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -28,6 +28,7 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.HttpUrl; @@ -42,7 +43,7 @@ public interface AuthenticationRestApi { @NonNull @WorkerThread - AuthResponse authenticate(@NonNull String username, + Token authenticate(@NonNull String username, @NonNull String password, @Nullable String organization, @Nullable Map params); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 26a56dbd..45218913 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import com.google.gson.JsonSyntaxException; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.Call; @@ -63,7 +64,7 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { @NonNull @Override - public AuthResponse authenticate(@NonNull final String username, + public Token authenticate(@NonNull final String username, @NonNull final String password, final String organization, final Map params) { @@ -73,7 +74,7 @@ public AuthResponse authenticate(@NonNull final String username, com.squareup.okhttp.Response response = call.execute(); int statusCode = response.code(); if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request - return AuthResponseFactory.create(response); + return TokenFactory.create(response); } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request String location = response.headers().get("Location"); if (location == null) { @@ -82,7 +83,7 @@ public AuthResponse authenticate(@NonNull final String username, HttpUrl url = HttpUrl.parse(location); String errorQueryParameter = url.queryParameter("error"); if (errorQueryParameter == null) { - return AuthResponseFactory.create(response); + return TokenFactory.create(response); } else { com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() .protocol(response.protocol()) @@ -106,10 +107,9 @@ public AuthResponse authenticate(@NonNull final String username, public EncryptionKey requestEncryptionMetadata() { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); - AuthResponse anonymousResponse = AuthResponseFactory.create(response.raw()); - String anonymousCookie = anonymousResponse.getToken(); + Token anonymousToken = TokenFactory.create(response.raw()); - mClient.interceptors().add(CookieAuthInterceptor.create(anonymousCookie)); + mClient.interceptors().add(CookieAuthInterceptor.create(anonymousToken.get())); mRestAdapterBuilder.client(mClient); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java index 0086ff67..3fdd1223 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java @@ -56,7 +56,7 @@ public TargetBuilder logger(RestApiLog log) { } @SuppressWarnings("unchecked") - public TargetBuilder token(Token token) { + public TargetBuilder token(Token token) { mAuthBuilder.setToken(token); return (TargetBuilder) this; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java similarity index 81% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java index 2bd4fbec..275d924a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.squareup.okhttp.Response; @@ -35,22 +37,22 @@ * @author Tom Koptel * @since 2.0 */ -final class AuthResponseFactory { +final class TokenFactory { private final List mCookieParts; - AuthResponseFactory(List parts) { + TokenFactory(List parts) { mCookieParts = parts; } - public static AuthResponse create(Response response) { + public static Token create(Response response) { List parts = response.headers().values("Set-Cookie"); - AuthResponseFactory responseFactory = new AuthResponseFactory(parts); + TokenFactory responseFactory = new TokenFactory(parts); return responseFactory.create(); } - private AuthResponse create() { + private Token create() { String cookie = joinCookieParts().toString(); - return AuthResponse.createSuccessResponse(cookie); + return CookieToken.create(cookie); } private StringBuilder joinCookieParts() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java index 939fcb4c..484bcb99 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class CookieToken implements Token { +public final class CookieToken implements Token { private final String mCookie; private CookieToken(String cookie) { @@ -39,6 +39,10 @@ public static CookieToken create(String cookie) { return new CookieToken(cookie); } + public static CookieToken create(Token token) { + return new CookieToken(token.get()); + } + @Override public String get() { return mCookie; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java index 77c681d0..f2f6958a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public interface Token { - RawToken get(); +public interface Token { + String get(); void acceptPolicy(AuthPolicy policy); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index f21ef1bc..b2accbc3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.MockResponseFactory; @@ -75,8 +76,8 @@ public void shouldReturnResponseForSuccessRedirect() { .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", null, null); - assertThat(response.getToken(), is(notNullValue())); + Token response = mRestApi.authenticate("joeuser", "joeuser", null, null); + assertThat(response.get(), is(notNullValue())); } @Test diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java index 8e55bfe4..4267a5b6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java @@ -41,7 +41,7 @@ public class InputControlRestApiBuilderTest { private InputControlRestApi.Builder builderUnderTest; @Mock - Token mToken; + Token mToken; @Rule public ExpectedException expectedException = ExpectedException.none(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index 0aa200d5..139a2cbc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -26,7 +26,7 @@ public class InputControlRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); @Mock - Token mToken; + Token mToken; private InputControlRestApi restApiUnderTest; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java index 64fb5bdb..13cd1f91 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java @@ -41,7 +41,7 @@ public class ReportExecutionRestApiBuilderTest { private ReportExecutionRestApi.Builder builderUnderTest; @Mock - Token mToken; + Token mToken; @Rule public ExpectedException expectedException = ExpectedException.none(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index 4537bca3..c8a911b5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -73,7 +73,7 @@ public class ReportExecutionRestApiTest { private ReportExecutionRestApi restApiUnderTest; @Mock - Token mToken; + Token mToken; @Before public void setup() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java index ff75f470..6ba79b62 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java @@ -41,7 +41,7 @@ public class ReportExportRestApiBuilderTest { private ReportExportRestApi.Builder builderUnderTest; @Mock - Token mToken; + Token mToken; @Rule public ExpectedException expectedException = ExpectedException.none(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index 6a063155..5793c45d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -66,7 +66,7 @@ public class ReportExportRestApiTest { TestResource mResource; @Mock - Token mToken; + Token mToken; @Before public void setup() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java index a8f4bfd9..42da84a5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java @@ -41,7 +41,7 @@ public class ReportOptionRestApiBuilderTest { private ReportOptionRestApi.Builder builderUnderTest; @Mock - Token mToken; + Token mToken; @Rule public ExpectedException expectedException = ExpectedException.none(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index db16cece..f1889e54 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -59,7 +59,7 @@ public class ReportOptionRestApiTest { private ReportOptionRestApi restApiUnderTest; @Mock - Token mToken; + Token mToken; @Before public void setup() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java index a7de7cc9..8c5146fc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java @@ -41,7 +41,7 @@ public class RepositoryRestApiBuilderTest { private RepositoryRestApi.Builder builderUnderTest; @Mock - Token mToken; + Token mToken; @Rule public ExpectedException expectedException = ExpectedException.none(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index e62f0ea7..88671309 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -67,7 +67,7 @@ public class RepositoryRestApiTest { private RepositoryRestApi restApiUnderTest; @Mock - Token mToken; + Token mToken; @Before public void setup() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java similarity index 87% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java index 41634413..15f4385e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.squareup.okhttp.Protocol; import com.squareup.okhttp.Request; @@ -39,7 +40,7 @@ * @author Tom Koptel * @since 2.0 */ -public class AuthResponseFactoryTest { +public class TokenFactoryTest { private Request mRequest; @@ -60,7 +61,7 @@ public void shouldExtractTokenFromNetworkResponse() { .request(mRequest) .build(); - AuthResponse response = AuthResponseFactory.create(mockResponse); - assertThat(response.getToken(), is("cookie1;cookie2")); + Token response = TokenFactory.create(mockResponse); + assertThat(response.get(), is("cookie1;cookie2")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 453e27d9..82abcf4f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.TestLogger; @@ -65,8 +66,8 @@ public void shouldEncryptWithPassword() throws Exception { JSEncryptionAlgorithm generator = JSEncryptionAlgorithm.create(new BouncyCastleProvider()); String cipher = generator.encrypt(key.getModulus(), key.getExponent(), "superuser"); - AuthResponse authResponse = restApi.authenticate("superuser", cipher, null, null); - assertThat(authResponse, is(notNullValue())); + Token token = restApi.authenticate("superuser", cipher, null, null); + assertThat(token, is(notNullValue())); } @Test @@ -75,7 +76,7 @@ public void shouldReturnResponseForSpringRequest() throws IOException { .baseUrl(mobileDemo2) .logger(TestLogger.get(this)) .build(); - AuthResponse response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); - assertThat(response.getToken(), is(notNullValue())); + Token token = authApi.authenticate("joeuser", "joeuser", "organization_1", null); + assertThat(token.get(), is(notNullValue())); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java index 2994cfc3..4182e813 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api.utils; import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.Token; /** * @author Tom Koptel @@ -34,7 +34,7 @@ public final class TestAuthenticator { private final JrsMetadata mJrsMetadata; - private AuthResponse mAuthResponse; + private Token mToken; public TestAuthenticator(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; @@ -45,16 +45,16 @@ public static TestAuthenticator create(JrsMetadata metadata) { } public void authorize() { - if (mAuthResponse == null) { + if (mToken == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() .baseUrl(mJrsMetadata.getServerUrl()) .build(); - mAuthResponse = restApi + mToken = restApi .authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null); } } public String getCookie() { - return mAuthResponse.getToken(); + return mToken.get(); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java index 718c7de0..f7d50100 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -34,5 +34,5 @@ */ public interface TokenProvider { @NonNull - Token provideToken(); + Token provideToken(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 993d2252..7f84a729 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -35,5 +35,5 @@ */ public interface AuthService { @NonNull - Token authenticate(); + Token authenticate(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 4dea3583..32e8f3ab 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -76,13 +76,13 @@ public final class SpringAuthService implements AuthService { @NonNull @Override - public Token authenticate() { - AuthResponse authResponse = invokeAuthentication(); - return CookieToken.create(authResponse.getToken()); + public Token authenticate() { + Token authToken = invokeAuthentication(); + return CookieToken.create(authToken); } @NonNull - private AuthResponse invokeAuthentication() { + private Token invokeAuthentication() { String password = mPassword; EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index e527bafd..a97de39e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -2,6 +2,7 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; +import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; @@ -32,7 +33,6 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({ Locale.class, - AuthResponse.class, EncryptionKey.class, JSEncryptionAlgorithm.class, }) @@ -40,7 +40,7 @@ public class SpringAuthServiceTest { @Mock AuthenticationRestApi mRestApi; @Mock - AuthResponse mAuthResponse; + Token mToken; @Mock JSEncryptionAlgorithm mAlgorithm; @Mock @@ -72,7 +72,7 @@ public void setup() { when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); - when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(mAuthResponse); + when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(mToken); } @Test From a34fe44baa3ec5c27987a92642017ac85911a0b8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 13:35:57 +0300 Subject: [PATCH 217/457] Remove redundant DTO fields for Report metadata --- .../network/entity/resource/DataSource.java | 47 ---------------- .../entity/resource/DataSourceReference.java | 47 ---------------- .../sdk/network/entity/resource/JRXml.java | 48 ---------------- .../entity/resource/JRXmlFileReference.java | 48 ---------------- .../network/entity/resource/ReportLookup.java | 45 --------------- .../entity/resource/ReportResource.java | 55 ------------------- .../network/entity/resource/ResourceFile.java | 48 ---------------- 7 files changed, 338 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSource.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSourceReference.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXml.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXmlFileReference.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportResource.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceFile.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSource.java deleted file mode 100644 index 87a63bb6..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSource.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class DataSource { - @Expose - private DataSourceReference dataSourceReference; - - public DataSourceReference getDataSourceReference() { - return dataSourceReference; - } - - @Override - public String toString() { - return "DataSource{" + - "dataSourceReference=" + dataSourceReference + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSourceReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSourceReference.java deleted file mode 100644 index e8fdcd4e..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DataSourceReference.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class DataSourceReference { - @Expose - private String uri; - - public String getUri() { - return uri; - } - - @Override - public String toString() { - return "DataSourceReference{" + - "uri='" + uri + '\'' + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXml.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXml.java deleted file mode 100644 index f8844384..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXml.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class JRXml { - - @Expose - private JRXmlFileReference jrxmlFileReference; - - public JRXmlFileReference getJrxmlFileReference() { - return jrxmlFileReference; - } - - @Override - public String toString() { - return "JRXml{" + - "jrxmlFileReference=" + jrxmlFileReference + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXmlFileReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXmlFileReference.java deleted file mode 100644 index b61bda31..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/JRXmlFileReference.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class JRXmlFileReference { - - @Expose - private String uri; - - public String getUri() { - return uri; - } - - @Override - public String toString() { - return "JRXmlFileReference{" + - "uri='" + uri + '\'' + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java index 71b123e2..b2320ad5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java @@ -26,29 +26,14 @@ import com.google.gson.annotations.Expose; -import java.util.Arrays; -import java.util.List; - /** * @author Tom Koptel * @since 2.0 */ public class ReportLookup extends ResourceLookup { - @Expose - private DataSource dataSource; - @Expose - private JRXml jrxml; - @Expose - private String inputControlRenderingView; - @Expose - private String reportRenderingView; @Expose private boolean alwaysPromptControls; - @Expose - private String controlsLayout; - @Expose - private List resources; public ReportLookup() {} @@ -61,40 +46,10 @@ public boolean isAlwaysPromptControls() { return alwaysPromptControls; } - public String getControlsLayout() { - return controlsLayout; - } - - public DataSource getDataSource() { - return dataSource; - } - - public String getInputControlRenderingView() { - return inputControlRenderingView; - } - - public JRXml getJrxml() { - return jrxml; - } - - public String getReportRenderingView() { - return reportRenderingView; - } - - public List getResources() { - return resources; - } - @Override public String toString() { return "ReportLookup{" + "alwaysPromptControls=" + alwaysPromptControls + - ", dataSource=" + dataSource + - ", jrxml=" + jrxml + - ", inputControlRenderingView='" + inputControlRenderingView + '\'' + - ", reportRenderingView='" + reportRenderingView + '\'' + - ", controlsLayout='" + controlsLayout + '\'' + - ", resources=" + Arrays.toString(resources.toArray()) + '}'; } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportResource.java deleted file mode 100644 index c1f19ffe..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportResource.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ReportResource { - - @Expose - private String name; - @Expose - private ResourceFile file; - - public ResourceFile getFile() { - return file; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "ReportResource{" + - "file=" + file + - ", name='" + name + '\'' + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceFile.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceFile.java deleted file mode 100644 index 07feb946..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceFile.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ResourceFile { - - @Expose - private ResourceReference fileReference; - - public ResourceReference getFileReference() { - return fileReference; - } - - @Override - public String toString() { - return "ResourceFile{" + - "fileReference=" + fileReference + - '}'; - } -} From eeca1391db8d8619a70f1057b09eeeb0708179b3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 13:36:26 +0300 Subject: [PATCH 218/457] Optimizing imports --- .../android/sdk/network/api/InputControlRestApi.java | 1 - .../android/sdk/network/api/ReportExportRestApi.java | 4 ++-- .../android/sdk/network/api/ReportExportRestApiImpl.java | 4 ++-- .../android/sdk/network/api/ReportOptionRestApi.java | 1 - .../sdk/network/entity/execution/ExecutionRequestOptions.java | 1 - .../sdk/network/entity/export/ExportExecutionDescriptor.java | 1 - .../android/sdk/network/api/ReportExportRestApiTest.java | 2 +- .../network/entity/control/InputControlCollectionTest.java | 1 - .../sdk/test/integration/api/AuthenticationRestApiTest.java | 1 - .../sdk/test/integration/api/InputControlRestApiTest.java | 3 --- .../sdk/test/integration/api/ReportExportRestApiTest.java | 2 +- .../sdk/test/integration/api/ReportOptionRestApiTest.java | 1 - 12 files changed, 6 insertions(+), 16 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 0bfc713f..17a9bd17 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -28,7 +28,6 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import java.util.Collection; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 8ed24d36..27f241b2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -29,9 +29,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index b3e293b8..092a9d7e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -29,9 +29,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.squareup.okhttp.ResponseBody; import retrofit.Call; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 6ccfd4ed..9a4f0697 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -28,7 +28,6 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import java.util.Map; import java.util.Set; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 956b0d8b..1738730c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -28,7 +28,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.Arrays; import java.util.Map; import java.util.Set; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java index 0a302241..aaa08a87 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java @@ -27,7 +27,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.OutputResourceDescriptor; /** diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index 6a063155..6af60b40 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -26,8 +26,8 @@ import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java index 1fb86c0b..8fa1de9d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java @@ -11,7 +11,6 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Set; import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 453e27d9..382f991f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -36,7 +36,6 @@ import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; -import java.net.URLEncoder; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index ead0d954..37ccee83 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -27,9 +27,7 @@ import com.jaspersoft.android.sdk.network.api.InputControlRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; @@ -41,7 +39,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index cb921d3b..c7bf2c70 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -33,8 +33,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 47efba97..50c9d349 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -27,7 +27,6 @@ import com.jaspersoft.android.sdk.network.api.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; From 0ad2d03e866cbb92197ba1d7132bea676d86c7c3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 13:39:06 +0300 Subject: [PATCH 219/457] Remove dashboard metadata request API --- .../sdk/network/api/RepositoryRestApi.java | 5 -- .../network/api/RepositoryRestApiImpl.java | 16 ---- .../entity/resource/DashboardFoundation.java | 69 ---------------- .../entity/resource/DashboardLookup.java | 78 ------------------- .../entity/resource/DashboardResource.java | 62 --------------- .../resource/DashboardResourceInfo.java | 48 ------------ .../entity/resource/ResourceReference.java | 48 ------------ .../network/api/RepositoryRestApiTest.java | 17 ---- .../resource/DashboardLookupResponseTest.java | 63 --------------- .../api/RepositoryRestApiTest.java | 9 --- 10 files changed, 415 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardFoundation.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookup.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResource.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResourceInfo.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceReference.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 83dba69e..18d90b35 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -28,7 +28,6 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; -import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookup; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; @@ -49,10 +48,6 @@ public interface RepositoryRestApi { @WorkerThread ReportLookup requestReportResource(@NonNull String resourceUri); - @NonNull - @WorkerThread - DashboardLookup requestDashboardResource(@NonNull String resourceUri); - @NonNull @WorkerThread LegacyDashboardLookup requestLegacyDashboardResource(@NonNull String resourceUri); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 1714e4dc..15420809 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -27,7 +27,6 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookup; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; @@ -114,15 +113,6 @@ public ReportLookup requestReportResource(@Nullable String resourceUri) { return CallWrapper.wrap(call).body(); } - @NonNull - @Override - public DashboardLookup requestDashboardResource(@Nullable String resourceUri) { - checkNotNull(resourceUri, "Dashboard uri should not be null"); - - Call call = mRestApi.requestDashboardResource(resourceUri); - return CallWrapper.wrap(call).body(); - } - @NonNull @Override public LegacyDashboardLookup requestLegacyDashboardResource(@Nullable String resourceUri) { @@ -155,12 +145,6 @@ Call searchResources( Call requestReportResource( @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); - @NonNull - @Headers("Accept: application/repository.dashboard+json") - @GET("rest_v2/resources{resourceUri}") - Call requestDashboardResource( - @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); - @NonNull @Headers("Accept: application/repository.legacyDashboard+json") @GET("rest_v2/resources{resourceUri}") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardFoundation.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardFoundation.java deleted file mode 100644 index c6d2974d..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardFoundation.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class DashboardFoundation { - - @Expose - private String id; - @Expose - private String layout; - @Expose - private String wiring; - @Expose - private String components; - - public String getComponents() { - return components; - } - - public String getId() { - return id; - } - - public String getLayout() { - return layout; - } - - public String getWiring() { - return wiring; - } - - @Override - public String toString() { - return "DashboardFoundation{" + - "components='" + components + '\'' + - ", id='" + id + '\'' + - ", layout='" + layout + '\'' + - ", wiring='" + wiring + '\'' + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookup.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookup.java deleted file mode 100644 index 833af3fa..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookup.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -import java.util.Arrays; -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class DashboardLookup extends ResourceLookup { - - @Expose - private List foundations; - @Expose - private List resources; - @Expose - private String defaultFoundation; - - @Override - public String getResourceType() { - return "dashboard"; - } - - public String getDefaultFoundation() { - return defaultFoundation; - } - - public List getFoundations() { - return foundations; - } - - public List getResources() { - return resources; - } - - @Override - public String toString() { - return "DashboardLookup{" + - "creationDate='" + creationDate + '\'' + - ", label='" + label + '\'' + - ", description='" + description + '\'' + - ", uri='" + uri + '\'' + - ", resourceType='dashboard'" + - ", version=" + version + - ", permissionMask=" + permissionMask + - ", updateDate='" + updateDate + '\'' + - ", defaultFoundation='" + defaultFoundation + '\'' + - ", foundations=" + Arrays.toString(foundations.toArray()) + - ", resources=" + Arrays.toString(resources.toArray()) + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResource.java deleted file mode 100644 index eff4cbea..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResource.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class DashboardResource { - - @Expose - private String name; - @Expose - private String type; - @Expose - private DashboardResourceInfo resource; - - public DashboardResourceInfo getResource() { - return resource; - } - - public String getName() { - return name; - } - - public String getType() { - return type; - } - - @Override - public String toString() { - return "DashboardResource{" + - "name='" + name + '\'' + - ", type='" + type + '\'' + - ", resource=" + resource + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResourceInfo.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResourceInfo.java deleted file mode 100644 index 3a2f19aa..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardResourceInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class DashboardResourceInfo { - - @Expose - private ResourceReference resourceReference; - - public ResourceReference getResourceReference() { - return resourceReference; - } - - @Override - public String toString() { - return "DashboardResourceInfo{" + - "resourceReference=" + resourceReference + - '}'; - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceReference.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceReference.java deleted file mode 100644 index 86ed1878..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceReference.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ResourceReference { - - @Expose - private String uri; - - public String getUri() { - return uri; - } - - @Override - public String toString() { - return "ResourceReference{" + - "uri='" + uri + '\'' + - '}'; - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index e62f0ea7..38c29e07 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -139,14 +139,6 @@ public void requestForReportResourceShouldNotAcceptNullUri() { restApiUnderTest.requestReportResource(null); } - @Test - public void requestForDashboardResourceShouldNotAcceptNullUri() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Dashboard uri should not be null"); - - restApiUnderTest.requestDashboardResource(null); - } - @Test public void requestForLegacyDashboardResourceShouldNotAcceptNullUri() { mExpectedException.expect(NullPointerException.class); @@ -181,15 +173,6 @@ public void requestReportResourceShouldThrowRestErrorOn500() { restApiUnderTest.requestReportResource("any_id"); } - @Test - public void requestDashboardResourceShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); - - mWebMockRule.enqueue(MockResponseFactory.create500()); - - restApiUnderTest.requestDashboardResource("any_id"); - } - @Test public void requestLegacyDashboardResourceShouldThrowRestErrorOn500() { mExpectedException.expect(RestError.class); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java deleted file mode 100644 index f57b1855..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/DashboardLookupResponseTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class DashboardLookupResponseTest { - @Test - @Parameters({ - "foundations", - "resources", - "defaultFoundation", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = DashboardLookup.class.getDeclaredField(fieldName); - assertThat(field, hasAnnotation(Expose.class)); - } - - @Test - public void shouldAlwaysReturnReportUnitUriAsType() { - DashboardLookup response = new DashboardLookup(); - assertThat(response.getResourceType(), is("dashboard")); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index cbfbe495..66895eb6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; -import com.jaspersoft.android.sdk.network.entity.resource.DashboardLookup; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; @@ -81,17 +80,9 @@ public void shouldRequestReport() { assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } - @Test - public void shouldRequestDashboard() { - DashboardLookup dashboard = api.requestDashboardResource("/public/Samples/Dashboards/1._Supermart_Dashboard"); - assertThat(dashboard, is(notNullValue())); - assertThat(dashboard.getFoundations(), is(not(empty()))); - } - @Test public void shouldRequestRootFolder() { FolderLookup folder = api.requestFolderResource("/"); assertThat(folder, is(notNullValue())); } - } \ No newline at end of file From 8476f97518ea6765a56fd0845e7bc0aac36e44c8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 13 Oct 2015 13:43:29 +0300 Subject: [PATCH 220/457] Remove legacy dashboard metadata request API --- .../sdk/network/api/RepositoryRestApi.java | 5 --- .../network/api/RepositoryRestApiImpl.java | 16 ------- .../resource/LegacyDashboardLookup.java | 37 ---------------- .../network/api/RepositoryRestApiTest.java | 17 -------- .../LegacyDashboardLookupResponseTest.java | 42 ------------------- 5 files changed, 117 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookup.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 18d90b35..c38974fe 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -29,7 +29,6 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; -import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; @@ -48,10 +47,6 @@ public interface RepositoryRestApi { @WorkerThread ReportLookup requestReportResource(@NonNull String resourceUri); - @NonNull - @WorkerThread - LegacyDashboardLookup requestLegacyDashboardResource(@NonNull String resourceUri); - @NonNull @WorkerThread FolderLookup requestFolderResource(@NonNull String resourceUri); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 15420809..f9d73466 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -28,7 +28,6 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; -import com.jaspersoft.android.sdk.network.entity.resource.LegacyDashboardLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; @@ -113,15 +112,6 @@ public ReportLookup requestReportResource(@Nullable String resourceUri) { return CallWrapper.wrap(call).body(); } - @NonNull - @Override - public LegacyDashboardLookup requestLegacyDashboardResource(@Nullable String resourceUri) { - checkNotNull(resourceUri, "Legacy dashboard uri should not be null"); - - Call call = mRestApi.requestLegacyDashboardResource(resourceUri); - return CallWrapper.wrap(call).body(); - } - @NonNull @Override public FolderLookup requestFolderResource(@Nullable String resourceUri) { @@ -145,12 +135,6 @@ Call searchResources( Call requestReportResource( @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); - @NonNull - @Headers("Accept: application/repository.legacyDashboard+json") - @GET("rest_v2/resources{resourceUri}") - Call requestLegacyDashboardResource( - @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); - @NonNull @Headers("Accept: application/repository.folder+json") @GET("rest_v2/resources{resourceUri}") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookup.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookup.java deleted file mode 100644 index cdd19c78..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookup.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class LegacyDashboardLookup extends ResourceLookup { - - @Override - public String getResourceType() { - return "legacyDashboard"; - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index 38c29e07..ea4151e9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -139,14 +139,6 @@ public void requestForReportResourceShouldNotAcceptNullUri() { restApiUnderTest.requestReportResource(null); } - @Test - public void requestForLegacyDashboardResourceShouldNotAcceptNullUri() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Legacy dashboard uri should not be null"); - - restApiUnderTest.requestLegacyDashboardResource(null); - } - @Test public void requestForFolderResourceShouldNotAcceptNullUri() { mExpectedException.expect(NullPointerException.class); @@ -173,15 +165,6 @@ public void requestReportResourceShouldThrowRestErrorOn500() { restApiUnderTest.requestReportResource("any_id"); } - @Test - public void requestLegacyDashboardResourceShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); - - mWebMockRule.enqueue(MockResponseFactory.create500()); - - restApiUnderTest.requestLegacyDashboardResource("any_id"); - } - @Test public void requestFolderResourceShouldThrowRestErrorOn500() { mExpectedException.expect(RestError.class); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java deleted file mode 100644 index 6a71d5f7..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/LegacyDashboardLookupResponseTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.resource; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class LegacyDashboardLookupResponseTest { - @Test - public void shouldAlwaysReturnReportUnitUriAsType() { - LegacyDashboardLookup response = new LegacyDashboardLookup(); - assertThat(response.getResourceType(), is("legacyDashboard")); - } -} From 68d6e13173124e07f7f9f489033609b79393b983 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 14 Oct 2015 21:19:34 +0300 Subject: [PATCH 221/457] Implementing SearchUseCase --- .../entity/resource/ResourceSearchResult.java | 2 +- .../DefaultTypeParser.java} | 86 +++++++++--------- .../data/repository/GenericResource.java | 89 +++++++++++++++++++ .../ResourceType.java | 17 ++-- .../service/data/repository/SearchResult.java | 51 +++++++++++ .../sdk/service/data/server/ServerInfo.java | 2 +- .../repository/GenericResourceMapper.java | 80 +++++++++++++++++ .../service/repository/InternalCriteria.java | 2 +- .../repository/SearchResultMapper.java | 53 +++++++++++ .../sdk/service/repository/SearchUseCase.java | 53 +++++++++++ .../DefaultTypeParserTest.java} | 8 +- .../data/resource/ResourceLookupTest.java | 9 -- .../repository/GenericResourceMapperTest.java | 80 +++++++++++++++++ .../repository/SearchResultMapperTest.java | 71 +++++++++++++++ .../service/repository/SearchUseCaseTest.java | 67 ++++++++++++++ 15 files changed, 601 insertions(+), 69 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/data/{resource/ResourceLookup.java => repository/DefaultTypeParser.java} (64%) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/GenericResource.java rename client-service/src/main/java/com/jaspersoft/android/sdk/service/data/{resource => repository}/ResourceType.java (81%) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapper.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java rename client-service/src/test/java/com/jaspersoft/android/sdk/service/data/{resource/ResourceTypeTest.java => repository/DefaultTypeParserTest.java} (87%) delete mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapperTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java index da440f2e..42de94d4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java @@ -34,7 +34,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ResourceSearchResult { +public class ResourceSearchResult { @Expose @SerializedName("resourceLookup") diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookup.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java similarity index 64% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookup.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java index d62d5fef..ec0772b2 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookup.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java @@ -1,43 +1,43 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.resource; - -import java.net.URI; -import java.util.Date; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ResourceLookup { - private String label; - private String description; - private URI uri; - private ResourceType resourceType; - private int version; - private int permissionMask; - private Date creationDate; - private Date updateDate; -} +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.data.repository; + +/** + * @author Tom Koptel + * @since 2.0 + */ +enum DefaultTypeParser implements ResourceType.Parser { + INSTANCE; + + public ResourceType parse(String rawValue) { + ResourceType type; + try { + type = ResourceType.valueOf(rawValue); + } catch (IllegalArgumentException ex) { + type = ResourceType.unknown; + type.setRawValue(rawValue); + } + return type; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/GenericResource.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/GenericResource.java new file mode 100644 index 00000000..ce22a2ce --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/GenericResource.java @@ -0,0 +1,89 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.data.repository; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.Date; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class GenericResource { + @Nullable + private Date mCreationDate; + @Nullable + private Date mUpdateDate; + + private ResourceType mResourceType; + private String mLabel; + private String mDescription; + + @Nullable + public Date getCreationDate() { + return mCreationDate; + } + + public void setCreationDate(@Nullable Date creationDate) { + mCreationDate = creationDate; + } + + @Nullable + public Date getUpdateDate() { + return mUpdateDate; + } + + public void setUpdateDate(@Nullable Date updateDate) { + mUpdateDate = updateDate; + } + + @NonNull + public ResourceType getResourceType() { + return mResourceType; + } + + public void setResourceType(@NonNull ResourceType resourceType) { + mResourceType = resourceType; + } + + @NonNull + public String getLabel() { + return mLabel; + } + + public void setLabel(@NonNull String label) { + mLabel = label; + } + + @NonNull + public String getDescription() { + return mDescription; + } + + public void setDescription(@NonNull String description) { + mDescription = description; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceType.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java similarity index 81% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceType.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java index 74b6073a..7b81df99 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/resource/ResourceType.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.data.resource; +package com.jaspersoft.android.sdk.service.data.repository; /** * @author Tom Koptel @@ -50,15 +50,8 @@ public String getRawValue() { } }; - static ResourceType parseRawValue(String rawValue) { - ResourceType type; - try { - type = ResourceType.valueOf(rawValue); - } catch (IllegalArgumentException ex) { - type = ResourceType.unknown; - type.setRawValue(rawValue); - } - return type; + public static Parser defaultParser() { + return DefaultTypeParser.INSTANCE; } void setRawValue(String value) { @@ -68,4 +61,8 @@ void setRawValue(String value) { public String getRawValue() { return String.valueOf(this); } + + public interface Parser { + ResourceType parse(String rawVersion); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java new file mode 100644 index 00000000..b337b4d2 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.data.repository; + +import java.util.Collection; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class SearchResult { + private Collection mResources; + private int mNextOffset; + + public Collection getResources() { + return mResources; + } + + public void setResources(Collection resources) { + mResources = resources; + } + + public int getNextOffset() { + return mNextOffset; + } + + public void setNextOffset(int nextOffset) { + mNextOffset = nextOffset; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index 97ec261a..740fb010 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -30,7 +30,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ServerInfo { +public class ServerInfo { private SimpleDateFormat dateFormatPattern; private SimpleDateFormat datetimeFormatPattern; private ServerVersion version; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapper.java new file mode 100644 index 00000000..f740a3ab --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapper.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.repository; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.ResourceType; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedList; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class GenericResourceMapper { + + @NonNull + public Collection transform(Collection resources, SimpleDateFormat dateTimeFormat) { + Collection result = new LinkedList<>(); + for (ResourceLookup lookup : resources) { + if (lookup != null) { + result.add(transform(lookup, dateTimeFormat)); + } + } + return result; + } + + @NonNull + public GenericResource transform(ResourceLookup lookup, SimpleDateFormat dateTimeFormat) { + GenericResource resource = new GenericResource(); + resource.setCreationDate(toDate(lookup.getCreationDate(), dateTimeFormat)); + resource.setUpdateDate(toDate(lookup.getUpdateDate(), dateTimeFormat)); + resource.setDescription(lookup.getDescription()); + resource.setLabel(lookup.getLabel()); + resource.setResourceType(toType(lookup.getResourceType())); + return resource; + } + + @Nullable + private Date toDate(String creationDate, SimpleDateFormat dateTimeFormat) { + try { + return dateTimeFormat.parse(String.valueOf(creationDate)); + } catch (ParseException e) { + return null; + } + } + + @NonNull + private ResourceType toType(String resourceType) { + return ResourceType.defaultParser().parse(String.valueOf(resourceType)); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index 121859c8..64b22a46 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -42,7 +42,7 @@ * @author Tom Koptel * @since 2.0 */ -final class InternalCriteria { +class InternalCriteria { private final int mLimit; private final int mOffset; private final int mResourceMask; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java new file mode 100644 index 00000000..2f6ead29 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; + +import java.text.SimpleDateFormat; +import java.util.Collection; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class SearchResultMapper { + + private final GenericResourceMapper mGenericResourceMapper; + + SearchResultMapper(GenericResourceMapper genericResourceMapper) { + mGenericResourceMapper = genericResourceMapper; + } + + public SearchResult transform(ResourceSearchResult result, SimpleDateFormat dateTimeFormat) { + SearchResult searchResult = new SearchResult(); + searchResult.setNextOffset(result.getNextOffset()); + + Collection resources = mGenericResourceMapper.transform(result.getResources(), dateTimeFormat); + searchResult.setResources(resources); + return searchResult; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java new file mode 100644 index 00000000..5dc35ad1 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.repository; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; + +import java.text.SimpleDateFormat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class SearchUseCase { + private final RepositoryRestApi mRestApi; + private final SearchResultMapper mDataMapper; + + public SearchUseCase(RepositoryRestApi restApi, SearchResultMapper dataMapper) { + mRestApi = restApi; + mDataMapper = dataMapper; + } + + @NonNull + public SearchResult performSearch(@NonNull InternalCriteria criteria, + @NonNull SimpleDateFormat dateTimeFormat) { + ResourceSearchResult response = mRestApi.searchResources(criteria.toMap()); + return mDataMapper.transform(response, dateTimeFormat); + } +} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceTypeTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java similarity index 87% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceTypeTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java index fe173054..1e3c0cdb 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceTypeTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.data.resource; +package com.jaspersoft.android.sdk.service.data.repository; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,17 +39,17 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ResourceTypeTest { +public class DefaultTypeParserTest { @Test @Parameters({"folder", "reportUnit", "dashboard", "legacyDashboard", "file", "semanticLayerDataSource", "jndiJdbcDataSource"}) public void shouldProvideTypeForKnownResourceTypes(String type) { ResourceType resourceType = ResourceType.valueOf(type); - assertThat(ResourceType.parseRawValue(type), is(resourceType)); + assertThat(DefaultTypeParser.INSTANCE.parse(type), is(resourceType)); } @Test public void shouldReturnUnkownTypeForMissingMapping() { - ResourceType resourceType = ResourceType.parseRawValue("someStrangeType"); + ResourceType resourceType = DefaultTypeParser.INSTANCE.parse("someStrangeType"); assertThat(resourceType, is(notNullValue())); assertThat(resourceType.getRawValue(), is("someStrangeType")); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java deleted file mode 100644 index a35056ed..00000000 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/resource/ResourceLookupTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jaspersoft.android.sdk.service.data.resource; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ResourceLookupTest { - -} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapperTest.java new file mode 100644 index 00000000..22cb18ac --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapperTest.java @@ -0,0 +1,80 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.ResourceType; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; + +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class GenericResourceMapperTest { + public static final String FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss"; + public static final SimpleDateFormat DATE_FORMAT = + new SimpleDateFormat(FORMAT_PATTERN, Locale.getDefault()); + @Mock + ServerInfo mServerInfo; + @Mock + ResourceLookup mResourceLookup; + + private GenericResourceMapper objectUnderTest; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + objectUnderTest = new GenericResourceMapper(); + + when(mResourceLookup.getCreationDate()).thenReturn("2013-10-03 16:32:05"); + when(mResourceLookup.getUpdateDate()).thenReturn("2013-11-03 16:32:05"); + when(mResourceLookup.getResourceType()).thenReturn("reportUnit"); + when(mResourceLookup.getDescription()).thenReturn("description"); + when(mResourceLookup.getLabel()).thenReturn("label"); + } + + @Test + public void testTransform() throws Exception { + long creationTime = DATE_FORMAT.parse("2013-10-03 16:32:05").getTime(); + long updateTime = DATE_FORMAT.parse("2013-11-03 16:32:05").getTime(); + + GenericResource resource = objectUnderTest.transform(mResourceLookup, DATE_FORMAT); + assertThat(resource.getCreationDate().getTime(), is(creationTime)); + assertThat(resource.getUpdateDate().getTime(), is(updateTime)); + assertThat(resource.getDescription(), is("description")); + assertThat(resource.getLabel(), is("label")); + assertThat(resource.getResourceType(), is(ResourceType.reportUnit)); + } + + @Test + public void testTransformResourceLookupCollection() { + ResourceLookup mockResourceLookupOne = mock(ResourceLookup.class); + ResourceLookup mockResourceLookupTwo = mock(ResourceLookup.class); + + List lookups = new ArrayList(5); + lookups.add(mockResourceLookupOne); + lookups.add(mockResourceLookupTwo); + + Collection resourcesCollection = objectUnderTest.transform(lookups, DATE_FORMAT); + + assertThat(resourcesCollection.toArray()[0], is(instanceOf(GenericResource.class))); + assertThat(resourcesCollection.toArray()[1], is(instanceOf(GenericResource.class))); + assertThat(resourcesCollection.size(), is(2)); + } +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java new file mode 100644 index 00000000..882369d3 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java @@ -0,0 +1,71 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyList; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class SearchResultMapperTest { + + public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat(); + @Mock + GenericResourceMapper mGenericResourceMapper; + @Mock + GenericResource mGenericResource; + + @Mock + ResourceSearchResult mSearchResult; + @Mock + ServerInfo mServerInfo; + @Mock + ResourceLookup mLookup; + + private SearchResultMapper objectUnderTest; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + objectUnderTest = new SearchResultMapper(mGenericResourceMapper); + } + + @Test + public void testTransform() throws Exception { + List resources = Collections.singletonList(mLookup); + when(mSearchResult.getNextOffset()).thenReturn(100); + when(mSearchResult.getResources()).thenReturn(resources); + + Collection genericResources = Collections.singletonList(mGenericResource); + when(mGenericResourceMapper.transform(anyList(), any(SimpleDateFormat.class))).thenReturn(genericResources); + SearchResult searchResult = objectUnderTest.transform(mSearchResult, DATE_TIME_FORMAT); + + assertThat(searchResult.getNextOffset(), is(100)); + assertThat(searchResult.getResources(), contains(mGenericResource)); + + verify(mGenericResourceMapper).transform(resources, DATE_TIME_FORMAT); + verify(mSearchResult).getNextOffset(); + verify(mSearchResult).getResources(); + } +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java new file mode 100644 index 00000000..7ef949de --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -0,0 +1,67 @@ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.text.SimpleDateFormat; +import java.util.Map; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class SearchUseCaseTest { + + public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat(); + @Mock + RepositoryRestApi mRepositoryRestApi; + @Mock + SearchResultMapper mDataMapper; + + @Mock + ResourceLookup mResourceLookup; + @Mock + SearchResult mAdaptedSearchResult; + + @Mock + InternalCriteria mCriteria; + @Mock + ServerInfo mServerInfo; + + @Mock + ResourceSearchResult mResult; + + private SearchUseCase objectUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new SearchUseCase(mRepositoryRestApi, mDataMapper); + } + + @Test + public void shouldProvideAndAdaptSearchResult() { + when(mRepositoryRestApi.searchResources(any(Map.class))).thenReturn(mResult); + when(mDataMapper.transform(any(ResourceSearchResult.class), any(SimpleDateFormat.class))).thenReturn(mAdaptedSearchResult); + + SearchResult result = objectUnderTest.performSearch(mCriteria, DATE_TIME_FORMAT); + assertThat(result, is(mAdaptedSearchResult)); + + verify(mRepositoryRestApi).searchResources(any(Map.class)); + verify(mDataMapper).transform(mResult, DATE_TIME_FORMAT); + } +} \ No newline at end of file From 1071fcc19841b23a6d0bc8b8c13cc729db6b6187 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 19 Oct 2015 11:53:08 +0300 Subject: [PATCH 222/457] Replacing generic Token witb TokeProvider --- .../android/sdk/network/api/AuthBuilder.java | 48 +++++++++++---- .../network/api/AuthenticationRestApi.java | 4 +- .../api/AuthenticationRestApiImpl.java | 31 +++++++--- .../network/api/CookieAuthInterceptor.java | 59 ------------------- .../sdk/network/api/GenericAuthBuilder.java | 6 +- ...ResponseFactory.java => TokenFactory.java} | 17 +++--- .../{AuthPolicy.java => AbstractToken.java} | 6 +- .../sdk/network/api/auth/CookieToken.java | 8 +-- .../android/sdk/network/api/auth/Token.java | 34 ----------- .../sdk/network/api/auth}/TokenProvider.java | 8 +-- .../network/entity/server/AuthResponse.java | 53 ----------------- .../api/AuthenticationRestApiTest.java | 6 +- .../sdk/network/api/FakeTokenProvider.java} | 22 +++---- .../api/InputControlRestApiBuilderTest.java | 15 ++--- .../network/api/InputControlRestApiTest.java | 8 +-- .../ReportExecutionRestApiBuilderTest.java | 16 ++--- .../api/ReportExecutionRestApiTest.java | 9 +-- .../api/ReportExportRestApiBuilderTest.java | 16 ++--- .../network/api/ReportExportRestApiTest.java | 9 +-- .../api/ReportOptionRestApiBuilderTest.java | 14 ++--- .../network/api/ReportOptionRestApiTest.java | 7 +-- .../api/RepositoryRestApiBuilderTest.java | 16 ++--- .../network/api/RepositoryRestApiTest.java | 7 +-- ...FactoryTest.java => TokenFactoryTest.java} | 10 ++-- .../api/AuthenticationRestApiTest.java | 9 ++- .../api/InputControlRestApiTest.java | 9 +-- .../api/ReportExecutionRestApiTest.java | 10 +--- .../api/ReportExportRestApiTest.java | 11 ++-- .../api/ReportOptionRestApiTest.java | 12 ++-- .../api/RepositoryRestApiTest.java | 9 +-- ...enticator.java => DummyTokenProvider.java} | 28 +++++---- .../android/sdk/service/auth/AuthService.java | 6 +- .../sdk/service/auth/SpringAuthService.java | 14 +---- .../repository/RepositoryRestApiFactory.java | 53 ----------------- .../service/auth/SpringAuthServiceTest.java | 7 +-- 35 files changed, 173 insertions(+), 424 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{AuthResponseFactory.java => TokenFactory.java} (79%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/{AuthPolicy.java => AbstractToken.java} (88%) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java rename {client-service/src/main/java/com/jaspersoft/android/sdk/service => client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth}/TokenProvider.java (84%) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java rename client-network/src/{main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java => test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java} (70%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/api/{AuthResponseFactoryTest.java => TokenFactoryTest.java} (85%) rename client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/{TestAuthenticator.java => DummyTokenProvider.java} (72%) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java index 118f136a..1461cd03 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java @@ -24,8 +24,14 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; +import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; +import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + +import java.io.IOException; import retrofit.Retrofit; @@ -37,30 +43,52 @@ */ final class AuthBuilder { private final AdapterBuilder mAdapterBuilder; - private Token mToken; + private TokenProvider mTokenProvider; public AuthBuilder(AdapterBuilder adapterBuilder) { mAdapterBuilder = adapterBuilder; } - public AuthBuilder setToken(Token token) { - checkNotNull(token, "token == null"); - mToken = token; + public AuthBuilder setTokenProvider(TokenProvider tokenProvider) { + checkNotNull(tokenProvider, "tokenProvider == null"); + mTokenProvider = tokenProvider; return this; } void ensureDefaults() { - if (mToken == null) { - throw new IllegalStateException("This API requires authentication token"); + if (mTokenProvider == null) { + throw new IllegalStateException("This API requires authentication tokenProvider"); } } Retrofit.Builder getAdapter() { - OkHttpClient client = mAdapterBuilder.clientBuilder.getClient(); - DefaultAuthPolicy authPolicy = new DefaultAuthPolicy(client); - mToken.acceptPolicy(authPolicy); + OkHttpClient client = mAdapterBuilder.clientBuilder.getClient(); + client.interceptors().add(CookieAuthInterceptor.create(mTokenProvider)); return mAdapterBuilder.getAdapter(); } + + private static final class CookieAuthInterceptor implements Interceptor { + private final TokenProvider mTokenProvider; + + CookieAuthInterceptor(TokenProvider tokenProvider) { + mTokenProvider = tokenProvider; + } + + public static CookieAuthInterceptor create(TokenProvider tokenProvider) { + checkNotNull(tokenProvider, "Token should not be null"); + return new CookieAuthInterceptor(tokenProvider); + } + + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + AbstractToken token = mTokenProvider.provideToken(); + Request compressedRequest = originalRequest.newBuilder() + .header("Cookie", token.get()) + .build(); + return chain.proceed(compressedRequest); + } + } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index cacf1e88..aac68c8e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -28,7 +28,7 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; @@ -42,7 +42,7 @@ public interface AuthenticationRestApi { @NonNull @WorkerThread - AuthResponse authenticate(@NonNull String username, + AbstractToken authenticate(@NonNull String username, @NonNull String password, @Nullable String organization, @Nullable Map params); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 26a56dbd..48a5f4ef 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,11 +27,12 @@ import android.support.annotation.NonNull; import com.google.gson.JsonSyntaxException; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.Call; import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; @@ -63,7 +64,7 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { @NonNull @Override - public AuthResponse authenticate(@NonNull final String username, + public AbstractToken authenticate(@NonNull final String username, @NonNull final String password, final String organization, final Map params) { @@ -73,7 +74,7 @@ public AuthResponse authenticate(@NonNull final String username, com.squareup.okhttp.Response response = call.execute(); int statusCode = response.code(); if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request - return AuthResponseFactory.create(response); + return TokenFactory.create(response); } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request String location = response.headers().get("Location"); if (location == null) { @@ -82,7 +83,7 @@ public AuthResponse authenticate(@NonNull final String username, HttpUrl url = HttpUrl.parse(location); String errorQueryParameter = url.queryParameter("error"); if (errorQueryParameter == null) { - return AuthResponseFactory.create(response); + return TokenFactory.create(response); } else { com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() .protocol(response.protocol()) @@ -106,10 +107,9 @@ public AuthResponse authenticate(@NonNull final String username, public EncryptionKey requestEncryptionMetadata() { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); - AuthResponse anonymousResponse = AuthResponseFactory.create(response.raw()); - String anonymousCookie = anonymousResponse.getToken(); + AbstractToken anonymousToken = TokenFactory.create(response.raw()); - mClient.interceptors().add(CookieAuthInterceptor.create(anonymousCookie)); + mClient.interceptors().add(new CookieAuthInterceptor(anonymousToken)); mRestAdapterBuilder.client(mClient); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); @@ -157,6 +157,23 @@ private Request createAuthRequest( .build(); } + private static final class CookieAuthInterceptor implements Interceptor { + private final AbstractToken mToken; + + CookieAuthInterceptor(AbstractToken token) { + mToken = token; + } + + @Override + public com.squareup.okhttp.Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + Request compressedRequest = originalRequest.newBuilder() + .header("Cookie", mToken.get()) + .build(); + return chain.proceed(compressedRequest); + } + } + private interface RestApi { @NonNull @Headers("Accept: text/plain") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java deleted file mode 100644 index 58fe4d63..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieAuthInterceptor.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import com.squareup.okhttp.Interceptor; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; - -import java.io.IOException; - -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class CookieAuthInterceptor implements Interceptor { - private final String mCookie; - - CookieAuthInterceptor(String cookie) { - mCookie = cookie; - } - - public static CookieAuthInterceptor create(String token) { - checkNotNull(token, "Token should not be null"); - return new CookieAuthInterceptor(token); - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request originalRequest = chain.request(); - Request compressedRequest = originalRequest.newBuilder() - .header("Cookie", mCookie) - .build(); - return chain.proceed(compressedRequest); - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java index 0086ff67..5d4a4ad3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; +import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; import retrofit.Retrofit; @@ -56,8 +56,8 @@ public TargetBuilder logger(RestApiLog log) { } @SuppressWarnings("unchecked") - public TargetBuilder token(Token token) { - mAuthBuilder.setToken(token); + public TargetBuilder tokenProvider(TokenProvider tokenProvider) { + mAuthBuilder.setTokenProvider(tokenProvider); return (TargetBuilder) this; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java similarity index 79% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java index 2bd4fbec..411ba4fb 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,7 +24,8 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; +import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.squareup.okhttp.Response; import java.util.Iterator; @@ -35,22 +36,22 @@ * @author Tom Koptel * @since 2.0 */ -final class AuthResponseFactory { +final class TokenFactory { private final List mCookieParts; - AuthResponseFactory(List parts) { + TokenFactory(List parts) { mCookieParts = parts; } - public static AuthResponse create(Response response) { + public static AbstractToken create(Response response) { List parts = response.headers().values("Set-Cookie"); - AuthResponseFactory responseFactory = new AuthResponseFactory(parts); + TokenFactory responseFactory = new TokenFactory(parts); return responseFactory.create(); } - private AuthResponse create() { + private AbstractToken create() { String cookie = joinCookieParts().toString(); - return AuthResponse.createSuccessResponse(cookie); + return CookieToken.create(cookie); } private StringBuilder joinCookieParts() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AuthPolicy.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AbstractToken.java similarity index 88% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AuthPolicy.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AbstractToken.java index c1e7cca7..3e6e0fa8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AuthPolicy.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AbstractToken.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -28,6 +28,6 @@ * @author Tom Koptel * @since 2.0 */ -public interface AuthPolicy { - void applyCookieToken(CookieToken token); +public abstract class AbstractToken { + public abstract String get(); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java index 939fcb4c..d8a7df3c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class CookieToken implements Token { +public final class CookieToken extends AbstractToken { private final String mCookie; private CookieToken(String cookie) { @@ -44,8 +44,4 @@ public String get() { return mCookie; } - @Override - public void acceptPolicy(AuthPolicy policy) { - policy.applyCookieToken(this); - } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java deleted file mode 100644 index 77c681d0..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/Token.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api.auth; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface Token { - RawToken get(); - void acceptPolicy(AuthPolicy policy); -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/TokenProvider.java similarity index 84% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/TokenProvider.java index 718c7de0..1bc1b1a1 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/TokenProvider.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/TokenProvider.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,17 +22,15 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.network.api.auth; import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.auth.Token; - /** * @author Tom Koptel * @since 2.0 */ public interface TokenProvider { @NonNull - Token provideToken(); + AbstractToken provideToken(); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java deleted file mode 100644 index 28003469..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/AuthResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.entity.server; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class AuthResponse { - private final String mToken; - - - private AuthResponse(String token) { - mToken = token; - } - - public static AuthResponse createSuccessResponse(String token) { - return new AuthResponse(token); - } - - public String getToken() { - return mToken; - } - - @Override - public String toString() { - return "AuthResponse{" + - "mToken='" + mToken + '\'' + - '}'; - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index f21ef1bc..e7477049 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -75,8 +75,8 @@ public void shouldReturnResponseForSuccessRedirect() { .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - AuthResponse response = mRestApi.authenticate("joeuser", "joeuser", null, null); - assertThat(response.getToken(), is(notNullValue())); + AbstractToken response = mRestApi.authenticate("joeuser", "joeuser", null, null); + assertThat(response, is(notNullValue())); } @Test diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java similarity index 70% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java index 59e3fc9b..5fa1398d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/DefaultAuthPolicy.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -21,27 +21,27 @@ * along with Jaspersoft Mobile for Android. If not, see * . */ - package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.AuthPolicy; +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.api.auth.CookieToken; -import com.squareup.okhttp.OkHttpClient; +import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; /** * @author Tom Koptel * @since 2.0 */ -final class DefaultAuthPolicy implements AuthPolicy { - - private final OkHttpClient mHttpClient; +final class FakeTokenProvider implements TokenProvider { - DefaultAuthPolicy(OkHttpClient httpClient) { - mHttpClient = httpClient; + public static TokenProvider get() { + return new FakeTokenProvider(); } + @NonNull @Override - public void applyCookieToken(CookieToken token) { - mHttpClient.interceptors().add(CookieAuthInterceptor.create(token.get())); + public AbstractToken provideToken() { + return CookieToken.create("cookie"); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java index 8e55bfe4..61279b54 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java @@ -24,13 +24,10 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** @@ -40,15 +37,11 @@ public class InputControlRestApiBuilderTest { private InputControlRestApi.Builder builderUnderTest; - @Mock - Token mToken; - @Rule public ExpectedException expectedException = ExpectedException.none(); @Before public void setup() { - MockitoAnnotations.initMocks(this); builderUnderTest = new InputControlRestApi.Builder(); } @@ -76,14 +69,14 @@ public void builderShouldEnsureBaseUrlNotNull() { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Base url should be supplied to work with JRS API"); - builderUnderTest.token(mToken); + builderUnderTest.tokenProvider(FakeTokenProvider.get()); builderUnderTest.build(); } @Test public void builderShouldEnsureTokenNotNull() { expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication token"); + expectedException.expectMessage("This API requires authentication tokenProvider"); builderUnderTest.baseUrl("http://localhost"); builderUnderTest.build(); @@ -92,8 +85,8 @@ public void builderShouldEnsureTokenNotNull() { @Test public void builderShouldAllowNullToken() { expectedException.expect(NullPointerException.class); - expectedException.expectMessage("token == null"); + expectedException.expectMessage("tokenProvider == null"); - builderUnderTest.token(null); + builderUnderTest.tokenProvider(null); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index 0aa200d5..9bede823 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -1,6 +1,5 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -8,7 +7,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.Collections; @@ -25,16 +23,12 @@ public class InputControlRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); - @Mock - Token mToken; - private InputControlRestApi restApiUnderTest; @Before public void setup() { - MockitoAnnotations.initMocks(this); restApiUnderTest = new InputControlRestApi.Builder() - .token(mToken) + .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java index 64fb5bdb..8d0ce0c2 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java @@ -24,14 +24,10 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; /** * @author Tom Koptel @@ -40,15 +36,11 @@ public class ReportExecutionRestApiBuilderTest { private ReportExecutionRestApi.Builder builderUnderTest; - @Mock - Token mToken; - @Rule public ExpectedException expectedException = ExpectedException.none(); @Before public void setup() { - MockitoAnnotations.initMocks(this); builderUnderTest = new ReportExecutionRestApi.Builder(); } @@ -76,14 +68,14 @@ public void builderShouldEnsureBaseUrlNotNull() { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Base url should be supplied to work with JRS API"); - builderUnderTest.token(mToken); + builderUnderTest.tokenProvider(FakeTokenProvider.get()); builderUnderTest.build(); } @Test public void builderShouldEnsureTokenNotNull() { expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication token"); + expectedException.expectMessage("This API requires authentication tokenProvider"); builderUnderTest.baseUrl("http://localhost"); builderUnderTest.build(); @@ -92,8 +84,8 @@ public void builderShouldEnsureTokenNotNull() { @Test public void builderShouldAllowNullToken() { expectedException.expect(NullPointerException.class); - expectedException.expectMessage("token == null"); + expectedException.expectMessage("tokenProvider == null"); - builderUnderTest.token(null); + builderUnderTest.tokenProvider(null); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index 733f7385..ce93bc70 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -37,8 +36,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import java.io.IOException; import java.util.Collections; @@ -72,15 +69,11 @@ public class ReportExecutionRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private ReportExecutionRestApi restApiUnderTest; - @Mock - Token mToken; - @Before public void setup() { - MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); restApiUnderTest = new ReportExecutionRestApi.Builder() - .token(mToken) + .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java index ff75f470..f699b2eb 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java @@ -24,14 +24,10 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; /** * @author Tom Koptel @@ -40,15 +36,11 @@ public class ReportExportRestApiBuilderTest { private ReportExportRestApi.Builder builderUnderTest; - @Mock - Token mToken; - @Rule public ExpectedException expectedException = ExpectedException.none(); @Before public void setup() { - MockitoAnnotations.initMocks(this); builderUnderTest = new ReportExportRestApi.Builder(); } @@ -76,14 +68,14 @@ public void builderShouldEnsureBaseUrlNotNull() { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Base url should be supplied to work with JRS API"); - builderUnderTest.token(mToken); + builderUnderTest.tokenProvider(FakeTokenProvider.get()); builderUnderTest.build(); } @Test public void builderShouldEnsureTokenNotNull() { expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication token"); + expectedException.expectMessage("This API requires authentication tokenProvider"); builderUnderTest.baseUrl("http://localhost"); builderUnderTest.build(); @@ -92,8 +84,8 @@ public void builderShouldEnsureTokenNotNull() { @Test public void builderShouldAllowNullToken() { expectedException.expect(NullPointerException.class); - expectedException.expectMessage("token == null"); + expectedException.expectMessage("tokenProvider == null"); - builderUnderTest.token(null); + builderUnderTest.tokenProvider(null); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index dff0c5d3..45a2a84f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportInput; import com.jaspersoft.android.sdk.network.entity.export.ExportResourceResponse; @@ -39,8 +38,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import java.io.IOException; import java.io.InputStream; @@ -65,15 +62,11 @@ public class ReportExportRestApiTest { @ResourceFile("json/root_folder.json") TestResource mResource; - @Mock - Token mToken; - @Before public void setup() { - MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); restApiUnderTest = new ReportExportRestApi.Builder() - .token(mToken) + .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java index a8f4bfd9..d1e4571a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java @@ -24,13 +24,10 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** @@ -40,9 +37,6 @@ public class ReportOptionRestApiBuilderTest { private ReportOptionRestApi.Builder builderUnderTest; - @Mock - Token mToken; - @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -76,14 +70,14 @@ public void builderShouldEnsureBaseUrlNotNull() { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Base url should be supplied to work with JRS API"); - builderUnderTest.token(mToken); + builderUnderTest.tokenProvider(FakeTokenProvider.get()); builderUnderTest.build(); } @Test public void builderShouldEnsureTokenNotNull() { expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication token"); + expectedException.expectMessage("This API requires authentication tokenProvider"); builderUnderTest.baseUrl("http://localhost"); builderUnderTest.build(); @@ -92,8 +86,8 @@ public void builderShouldEnsureTokenNotNull() { @Test public void builderShouldAllowNullToken() { expectedException.expect(NullPointerException.class); - expectedException.expectMessage("token == null"); + expectedException.expectMessage("tokenProvider == null"); - builderUnderTest.token(null); + builderUnderTest.tokenProvider(null); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index db16cece..4da9e8aa 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.squareup.okhttp.mockwebserver.MockResponse; @@ -34,7 +33,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.Collections; @@ -58,14 +56,11 @@ public class ReportOptionRestApiTest { private ReportOptionRestApi restApiUnderTest; - @Mock - Token mToken; - @Before public void setup() { MockitoAnnotations.initMocks(this); restApiUnderTest = new ReportOptionRestApi.Builder() - .token(mToken) + .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java index a7de7cc9..0200ea99 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java @@ -24,14 +24,10 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; /** * @author Tom Koptel @@ -40,15 +36,11 @@ public class RepositoryRestApiBuilderTest { private RepositoryRestApi.Builder builderUnderTest; - @Mock - Token mToken; - @Rule public ExpectedException expectedException = ExpectedException.none(); @Before public void setup() { - MockitoAnnotations.initMocks(this); builderUnderTest = new RepositoryRestApi.Builder(); } @@ -76,14 +68,14 @@ public void builderShouldEnsureBaseUrlNotNull() { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Base url should be supplied to work with JRS API"); - builderUnderTest.token(mToken); + builderUnderTest.tokenProvider(FakeTokenProvider.get()); builderUnderTest.build(); } @Test public void builderShouldEnsureTokenNotNull() { expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication token"); + expectedException.expectMessage("This API requires authentication tokenProvider"); builderUnderTest.baseUrl("http://localhost"); builderUnderTest.build(); @@ -92,8 +84,8 @@ public void builderShouldEnsureTokenNotNull() { @Test public void builderShouldAllowNullToken() { expectedException.expect(NullPointerException.class); - expectedException.expectMessage("token == null"); + expectedException.expectMessage("tokenProvider == null"); - builderUnderTest.token(null); + builderUnderTest.tokenProvider(null); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index d1aa175e..5fff23bc 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.Token; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -38,7 +37,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.HashMap; @@ -66,15 +64,12 @@ public class RepositoryRestApiTest { private RepositoryRestApi restApiUnderTest; - @Mock - Token mToken; - @Before public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); restApiUnderTest = new RepositoryRestApi.Builder() - .token(mToken) + .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java similarity index 85% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java index 41634413..8378b35a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthResponseFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.squareup.okhttp.Protocol; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; @@ -39,7 +39,7 @@ * @author Tom Koptel * @since 2.0 */ -public class AuthResponseFactoryTest { +public class TokenFactoryTest { private Request mRequest; @@ -60,7 +60,7 @@ public void shouldExtractTokenFromNetworkResponse() { .request(mRequest) .build(); - AuthResponse response = AuthResponseFactory.create(mockResponse); - assertThat(response.getToken(), is("cookie1;cookie2")); + AbstractToken token = TokenFactory.create(mockResponse); + assertThat(token.get(), is("cookie1;cookie2")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 453e27d9..cc5d64ff 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.TestLogger; @@ -36,7 +36,6 @@ import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; -import java.net.URLEncoder; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -65,7 +64,7 @@ public void shouldEncryptWithPassword() throws Exception { JSEncryptionAlgorithm generator = JSEncryptionAlgorithm.create(new BouncyCastleProvider()); String cipher = generator.encrypt(key.getModulus(), key.getExponent(), "superuser"); - AuthResponse authResponse = restApi.authenticate("superuser", cipher, null, null); + AbstractToken authResponse = restApi.authenticate("superuser", cipher, null, null); assertThat(authResponse, is(notNullValue())); } @@ -75,7 +74,7 @@ public void shouldReturnResponseForSpringRequest() throws IOException { .baseUrl(mobileDemo2) .logger(TestLogger.get(this)) .build(); - AuthResponse response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); - assertThat(response.getToken(), is(notNullValue())); + AbstractToken response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); + assertThat(response, is(notNullValue())); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index b540f3d9..45d52cce 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -25,13 +25,12 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.InputControlRestApi; -import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlResponse; import com.jaspersoft.android.sdk.network.entity.control.InputControlValueResponse; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; -import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; +import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import org.junit.Before; import org.junit.Test; @@ -56,7 +55,7 @@ public class InputControlRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); + private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); private InputControlRestApi mRestApi; public static final Map> CONTROL_PARAMETERS = new HashMap<>(); @@ -68,10 +67,8 @@ public class InputControlRestApiTest { @Before public void setup() { - mAuthenticator.authorize(); - String cookie = mAuthenticator.getCookie(); mRestApi = new InputControlRestApi.Builder() - .token(CookieToken.create(cookie)) + .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 5ba33ed5..55a6167c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -27,14 +27,13 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatusResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDetailsResponse; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; -import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; import org.junit.Before; import org.junit.Ignore; @@ -63,16 +62,13 @@ public class ReportExecutionRestApiTest { ReportExecutionRestApi apiUnderTest; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); + private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); @Before public void setup() { - mAuthenticator.authorize(); - String cookie = mAuthenticator.getCookie(); - if (apiUnderTest == null) { apiUnderTest = new ReportExecutionRestApi.Builder() - .token(CookieToken.create(cookie)) + .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index b97763e8..cf425ce3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -37,7 +37,7 @@ import com.jaspersoft.android.sdk.network.entity.export.ReportExportExecutionResponse; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; -import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; +import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import org.junit.Before; import org.junit.Test; @@ -59,16 +59,13 @@ public class ReportExportRestApiTest { ReportExportRestApi apiUnderTest; private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); + private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); @Before public void setup() { - mAuthenticator.authorize(); - String cookie = mAuthenticator.getCookie(); - if (mExecApi == null) { mExecApi = new ReportExecutionRestApi.Builder() - .token(CookieToken.create(cookie)) + .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -76,7 +73,7 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportExportRestApi.Builder() - .token(CookieToken.create(cookie)) + .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index a200e711..1fc27a3f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -25,12 +25,11 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.api.ReportOptionRestApi; -import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionResponse; import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; -import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; import org.junit.Before; import org.junit.Test; @@ -52,12 +51,12 @@ public class ReportOptionRestApiTest { private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); + private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); private ReportOptionRestApi apiUnderTest; - private static final String REPORT_URI = "/public/Samples/Reports/1._Geographic_Results_by_Segment_Report"; public static final Map> CONTROL_PARAMETERS = new HashMap<>(); + static { Set values = new HashSet<>(); values.add("19"); @@ -66,13 +65,10 @@ public class ReportOptionRestApiTest { @Before public void setup() { - mAuthenticator.authorize(); - String cookie = mAuthenticator.getCookie(); - if (apiUnderTest == null) { apiUnderTest = new ReportOptionRestApi.Builder() .logger(TestLogger.get(this)) - .token(CookieToken.create(cookie)) + .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .build(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index d0b2b347..df9eae62 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -32,7 +32,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResponse; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; -import com.jaspersoft.android.sdk.test.integration.api.utils.TestAuthenticator; +import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import org.junit.Before; import org.junit.Test; @@ -50,17 +50,14 @@ public class RepositoryRestApiTest { private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final TestAuthenticator mAuthenticator = TestAuthenticator.create(mMetadata); + private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); private RepositoryRestApi api; @Before public void setup() { - mAuthenticator.authorize(); - String cookie = mAuthenticator.getCookie(); - if (api == null) { api = new RepositoryRestApi.Builder() - .token(CookieToken.create(cookie)) + .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java similarity index 72% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index 2994cfc3..8d62120e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/TestAuthenticator.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -24,37 +24,39 @@ package com.jaspersoft.android.sdk.test.integration.api.utils; +import android.support.annotation.NonNull; + import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; +import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; /** * @author Tom Koptel * @since 2.0 */ -public final class TestAuthenticator { +public final class DummyTokenProvider implements TokenProvider { private final JrsMetadata mJrsMetadata; - private AuthResponse mAuthResponse; + private AbstractToken mToken; - public TestAuthenticator(JrsMetadata jrsMetadata) { + public DummyTokenProvider(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; } - public static TestAuthenticator create(JrsMetadata metadata) { - return new TestAuthenticator(metadata); + public static DummyTokenProvider create(JrsMetadata metadata) { + return new DummyTokenProvider(metadata); } - public void authorize() { - if (mAuthResponse == null) { + @NonNull + @Override + public AbstractToken provideToken() { + if (mToken == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() .baseUrl(mJrsMetadata.getServerUrl()) .build(); - mAuthResponse = restApi + mToken = restApi .authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null); } - } - - public String getCookie() { - return mAuthResponse.getToken(); + return mToken; } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 993d2252..2bab2a23 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.auth.Token; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; /** @@ -35,5 +35,5 @@ */ public interface AuthService { @NonNull - Token authenticate(); + AbstractToken authenticate(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 4dea3583..79bc8978 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -30,9 +30,7 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; -import com.jaspersoft.android.sdk.network.api.auth.CookieToken; -import com.jaspersoft.android.sdk.network.api.auth.Token; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import java.util.HashMap; @@ -76,13 +74,7 @@ public final class SpringAuthService implements AuthService { @NonNull @Override - public Token authenticate() { - AuthResponse authResponse = invokeAuthentication(); - return CookieToken.create(authResponse.getToken()); - } - - @NonNull - private AuthResponse invokeAuthentication() { + public AbstractToken authenticate() { String password = mPassword; EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java deleted file mode 100644 index a5e9f7f1..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryRestApiFactory.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.repository; - -import android.support.annotation.WorkerThread; - -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.TokenProvider; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class RepositoryRestApiFactory implements RepositoryRestApi.Factory { - private final String mServerUrl; - private final TokenProvider mTokenProvider; - - public RepositoryRestApiFactory(String serverUrl, TokenProvider tokenProvider) { - mServerUrl = serverUrl; - mTokenProvider = tokenProvider; - } - - @Override - @WorkerThread - public RepositoryRestApi get() { - return new RepositoryRestApi.Builder() - .baseUrl(mServerUrl) - .token(mTokenProvider.provideToken()) - .build(); - } -} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index e527bafd..99c19c0c 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -2,7 +2,7 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; -import com.jaspersoft.android.sdk.network.entity.server.AuthResponse; +import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import org.junit.Before; @@ -32,7 +32,6 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({ Locale.class, - AuthResponse.class, EncryptionKey.class, JSEncryptionAlgorithm.class, }) @@ -40,7 +39,7 @@ public class SpringAuthServiceTest { @Mock AuthenticationRestApi mRestApi; @Mock - AuthResponse mAuthResponse; + AbstractToken mToken; @Mock JSEncryptionAlgorithm mAlgorithm; @Mock @@ -72,7 +71,7 @@ public void setup() { when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); - when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(mAuthResponse); + when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(mToken); } @Test From 1240d3b95d22586d6c80b581155a2843f5cfff5d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 19 Oct 2015 12:00:46 +0300 Subject: [PATCH 223/457] Removing excessive rest API Factory abstractions --- .../sdk/network/api/RepositoryRestApi.java | 4 -- .../sdk/network/api/ServerRestApi.java | 4 -- .../repository/EmeraldMR2SearchStrategy.java | 9 ++-- .../repository/EmeraldMR3SearchStrategy.java | 9 ++-- .../service/repository/RepositoryService.java | 14 +++--- .../service/repository/SearchStrategy.java | 6 +-- .../service/repository/SearchTaskImpl.java | 18 ++++---- .../service/server/ServerRestApiFactory.java | 46 ------------------- .../EmeraldMR2SearchStrategyTest.java | 13 ++---- .../EmeraldMR3SearchStrategyTest.java | 15 ++---- .../repository/RepositoryServiceTest.java | 8 +--- .../repository/SearchStrategyTest.java | 6 +-- .../repository/SearchTaskImplTest.java | 16 ++----- 13 files changed, 43 insertions(+), 125 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 82a96aff..ed862964 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -61,10 +61,6 @@ public interface RepositoryRestApi { @WorkerThread FolderLookupResponse requestFolderResource(@NonNull String resourceUri); - interface Factory { - RepositoryRestApi get(); - } - final class Builder extends GenericAuthBuilder { @Override RepositoryRestApi createApi() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 52765a2e..52084f4f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -66,10 +66,6 @@ public interface ServerRestApi { @WorkerThread String requestExpiration(); - interface Factory { - ServerRestApi get(); - } - final class Builder extends GenericBuilder { @Override ServerRestApi createApi() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index b2c5cfb9..8c588725 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -43,15 +43,15 @@ final class EmeraldMR2SearchStrategy implements SearchStrategy { private static final Collection EMPTY_RESPONSE = Collections.emptyList(); private static final int MAX_RETRY_COUNT = 5; - private final RepositoryRestApi.Factory mRepoFactory; + private final RepositoryRestApi mRepoFactoryRestApi; private final InternalCriteria mInitialCriteria; private int mServerDisposition; private List mBuffer = new LinkedList<>(); private boolean mEndReached; - public EmeraldMR2SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, InternalCriteria criteria) { - mRepoFactory = repositoryApiFactory; + public EmeraldMR2SearchStrategy(RepositoryRestApi repositoryApiFactory, InternalCriteria criteria) { + mRepoFactoryRestApi = repositoryApiFactory; mInitialCriteria = criteria; mEndReached = false; } @@ -114,7 +114,6 @@ private ResourceSearchResponse performSearch(int limit) { .offset(mServerDisposition) .limit(limit) .create(); - RepositoryRestApi api = mRepoFactory.get(); - return api.searchResources(nextCriteria.toMap()); + return mRepoFactoryRestApi.searchResources(nextCriteria.toMap()); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index a874cf8a..18cf3dd9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -41,15 +41,15 @@ final class EmeraldMR3SearchStrategy implements SearchStrategy { public static final Collection EMPTY_RESPONSE = Collections.emptyList(); private final static int UNDEFINED = -1; - private final RepositoryRestApi.Factory mRepoFactory; + private final RepositoryRestApi mRepositoryRestApi; private final InternalCriteria mInitialCriteria; private int mUserOffset; private int mInternalOffset = UNDEFINED; private boolean mEndReached; - public EmeraldMR3SearchStrategy(RepositoryRestApi.Factory repositoryApiFactory, InternalCriteria criteria) { - mRepoFactory = repositoryApiFactory; + public EmeraldMR3SearchStrategy(RepositoryRestApi repositoryApiFactory, InternalCriteria criteria) { + mRepositoryRestApi = repositoryApiFactory; // Internally enabling 'forceFullPageFlag' mInitialCriteria = criteria.newBuilder() .forceFullPage(true) @@ -84,8 +84,7 @@ private Collection performLookup() { @NonNull private ResourceSearchResponse performApiCall(InternalCriteria newSearchCriteria) { - RepositoryRestApi api = mRepoFactory.get(); - return api.searchResources(newSearchCriteria.toMap()); + return mRepositoryRestApi.searchResources(newSearchCriteria.toMap()); } private void defineInternalOffset() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index b7576aa9..ff5acf2c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -32,16 +32,16 @@ * @since 2.0 */ public class RepositoryService { - private final RepositoryRestApi.Factory mRepositoryApiFactory; - private final ServerRestApi.Factory mInfoApiFactory; + private final RepositoryRestApi mRepositoryRestApi; + private final ServerRestApi mServerRestApi; - public RepositoryService(RepositoryRestApi.Factory repositoryApiFactory, - ServerRestApi.Factory infoApiFactory) { - mRepositoryApiFactory = repositoryApiFactory; - mInfoApiFactory = infoApiFactory; + public RepositoryService(RepositoryRestApi repositoryRestApi, + ServerRestApi infoApiFactory) { + mRepositoryRestApi = repositoryRestApi; + mServerRestApi = infoApiFactory; } public SearchTask search(SearchCriteria criteria) { - return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryApiFactory, mInfoApiFactory); + return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryRestApi, mServerRestApi); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index a48b397b..4fc1ed08 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -40,14 +40,14 @@ interface SearchStrategy { class Factory { public static SearchStrategy get(String serverVersion, - RepositoryRestApi.Factory repositoryApiFactory, + RepositoryRestApi repositoryRestApi, InternalCriteria criteria) { ServerVersion version = ServerVersion.defaultParser().parse(serverVersion); if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { - return new EmeraldMR2SearchStrategy(repositoryApiFactory, criteria); + return new EmeraldMR2SearchStrategy(repositoryRestApi, criteria); } if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { - return new EmeraldMR3SearchStrategy(repositoryApiFactory, criteria); + return new EmeraldMR3SearchStrategy(repositoryRestApi, criteria); } throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + serverVersion); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index b7e0604d..0d664eb4 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -39,18 +39,18 @@ */ final class SearchTaskImpl implements SearchTask { private final InternalCriteria mCriteria; - private final RepositoryRestApi.Factory mRepositoryApiFactory; - private final ServerRestApi.Factory mInfoApiFactory; + private final RepositoryRestApi mRepositoryRestApi; + private final ServerRestApi mServerRestApi; @Nullable private SearchStrategy strategy; SearchTaskImpl(InternalCriteria criteria, - RepositoryRestApi.Factory repositoryApiFactory, - ServerRestApi.Factory infoApiFactory) { + RepositoryRestApi repositoryRestApi, + ServerRestApi serverRestApi) { mCriteria = criteria; - mRepositoryApiFactory = repositoryApiFactory; - mInfoApiFactory = infoApiFactory; + mRepositoryRestApi = repositoryRestApi; + mServerRestApi = serverRestApi; } @NonNull @@ -73,10 +73,8 @@ public boolean hasNext() { private SearchStrategy defineSearchStrategy() { if (strategy == null) { - String version = mInfoApiFactory.get().requestVersion(); - strategy = SearchStrategy.Factory.get(version, mRepositoryApiFactory, mCriteria); - - + String version = mServerRestApi.requestVersion(); + strategy = SearchStrategy.Factory.get(version, mRepositoryRestApi, mCriteria); } return strategy; } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java deleted file mode 100644 index 6358e356..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/server/ServerRestApiFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.server; - -import com.jaspersoft.android.sdk.network.api.ServerRestApi; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ServerRestApiFactory implements ServerRestApi.Factory { - private final String mServerUrl; - - public ServerRestApiFactory(String serverUrl) { - mServerUrl = serverUrl; - } - - @Override - public ServerRestApi get() { - return new ServerRestApi.Builder() - .baseUrl(mServerUrl) - .build(); - } -} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index 69ee55da..7007622e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -39,8 +39,6 @@ @PrepareForTest({ResourceSearchResponse.class}) public class EmeraldMR2SearchStrategyTest { - @Mock - RepositoryRestApi.Factory mApiFactory; @Mock RepositoryRestApi mApi; @Mock @@ -58,16 +56,15 @@ public void setupMocks() { MockitoAnnotations.initMocks(this); when(mApi.searchResources(anyMap())).thenReturn(mResponse); - when(mApiFactory.get()).thenReturn(mApi); List stubLookup = Collections.singletonList(new ResourceLookupResponse()); when(mResponse.getResources()).thenReturn(stubLookup); InternalCriteria criteria = InternalCriteria.builder().limit(10).create(); - search10itemsStrategy = new EmeraldMR2SearchStrategy(mApiFactory, criteria); + search10itemsStrategy = new EmeraldMR2SearchStrategy(mApi, criteria); InternalCriteria userCriteria = criteria.newBuilder().offset(5).create(); - search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); + search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(mApi, userCriteria); } @Test @@ -85,8 +82,6 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce params.put("limit", "10"); params.put("offset", "10"); verify(mApi).searchResources(params); - - verify(mApiFactory, times(2)).get(); } @Test @@ -97,7 +92,6 @@ public void willRetry5timesIfApiReturnsNoElements()throws Exception { assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); - verify(mApiFactory, times(6)).get(); verify(mApi, times(6)).searchResources(anyMap()); } @@ -108,7 +102,6 @@ public void willReturnAsMuchElementsAsLeftIfEndReached()throws Exception { Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(2)); - verify(mApiFactory, times(6)).get(); verify(mApi, times(6)).searchResources(anyMap()); } @@ -139,7 +132,7 @@ public void forCustomOffsetShouldCalculateServerDisposition()throws Exception { @Test public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(mApiFactory, userCriteria); + EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(mApi, userCriteria); Collection result = strategy.searchNext(); assertThat(result, is(empty())); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index 56a2f2d1..def9f815 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -37,8 +37,6 @@ public class EmeraldMR3SearchStrategyTest { private static final InternalCriteria NO_CRITERIA = InternalCriteria.from(SearchCriteria.none()); - @Mock - RepositoryRestApi.Factory mApiFactory; @Mock RepositoryRestApi mApi; @Mock @@ -49,7 +47,6 @@ public void setupMocks() { MockitoAnnotations.initMocks(this); when(mApi.searchResources(anyMap())).thenReturn(mResponse); - when(mApiFactory.get()).thenReturn(mApi); List stubLookup = Collections.singletonList(new ResourceLookupResponse()); when(mResponse.getResources()).thenReturn(stubLookup); @@ -58,7 +55,7 @@ public void setupMocks() { @Test public void shouldMakeImmediateCallOnApiForUserOffsetZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, searchCriteria); when(mApi.searchResources(anyMap())).thenReturn(mResponse); @@ -73,7 +70,7 @@ public void shouldMakeImmediateCallOnApiForUserOffsetZero() { @Test public void makesAdditionalCallOnApiIfUserOffsetNotZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, searchCriteria); strategy.searchNext(); @@ -87,7 +84,7 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() { @Test public void secondSearchLookupShouldUseNextOffset() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, searchCriteria); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, searchCriteria); when(mResponse.getNextOffset()).thenReturn(133); strategy.searchNext(); @@ -100,14 +97,13 @@ public void secondSearchLookupShouldUseNextOffset() { params.put("forceFullPage", "true"); params.put("offset", "133"); - verify(mApiFactory, times(2)).get(); verify(mResponse, times(2)).getNextOffset(); verify(mApi, times(1)).searchResources(params); } @Test public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, NO_CRITERIA); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, NO_CRITERIA); when(mResponse.getNextOffset()).thenReturn(133); strategy.searchNext(); @@ -119,7 +115,6 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { assertThat(response, is(empty())); assertThat(strategy.hasNext(), is(false)); - verify(mApiFactory, times(2)).get(); verify(mResponse, times(2)).getNextOffset(); verify(mApi, times(2)).searchResources(anyMap()); } @@ -127,7 +122,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { @Test public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApiFactory, userCriteria); + SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, userCriteria); Collection result = strategy.searchNext(); assertThat(result, Matchers.is(Matchers.empty())); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 562730c8..aa73ea9e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -46,13 +46,10 @@ * @since 2.0 */ public class RepositoryServiceTest { - @Mock - RepositoryRestApi.Factory repoApiFactory; @Mock RepositoryRestApi repoApi; @Mock - ServerRestApi.Factory infoApi; - + ServerRestApi infoApi; @Mock FolderLookupResponse mFolderResponse; @Mock @@ -66,8 +63,7 @@ public class RepositoryServiceTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - when(repoApiFactory.get()).thenReturn(repoApi); - objectUnderTest = new RepositoryService(repoApiFactory, infoApi); + objectUnderTest = new RepositoryService(repoApi, infoApi); } @Test diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index d44fb484..0ce14aa0 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -47,7 +47,7 @@ public class SearchStrategyTest { private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock - RepositoryRestApi.Factory mFactory; + RepositoryRestApi mRepoApi; @Before public void before() { @@ -60,7 +60,7 @@ public void before() { "5.5", }) public void factoryCreatesEmeraldMR2Strategy(String version) { - SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, CRITERIA); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mRepoApi, CRITERIA); assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); } @@ -70,7 +70,7 @@ public void factoryCreatesEmeraldMR2Strategy(String version) { "6.0.1", }) public void factoryCreatesEmeraldMR3Strategy(String version) { - SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mFactory, CRITERIA); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mRepoApi, CRITERIA); assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index ed716617..985b35ce 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -52,10 +52,6 @@ public class SearchTaskImplTest { private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); - @Mock - RepositoryRestApi.Factory mRepoApiFactory; - @Mock - ServerRestApi.Factory mInfoApiFactory; @Mock RepositoryRestApi mRepoApi; @Mock @@ -68,14 +64,12 @@ public class SearchTaskImplTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApiFactory, mInfoApiFactory); - when(mRepoApiFactory.get()).thenReturn(mRepoApi); - when(mInfoApiFactory.get()).thenReturn(mInfoApi); + objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApi, mInfoApi); when(mSearchStrategy.searchNext()).thenReturn(null); PowerMockito.mockStatic(SearchStrategy.Factory.class); - PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.Factory.class), any(InternalCriteria.class))).thenReturn(mSearchStrategy); + PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.class), any(InternalCriteria.class))).thenReturn(mSearchStrategy); } @Test @@ -84,10 +78,9 @@ public void nextLookupShouldDefineSearchStrategy() { objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(CRITERIA)); + SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApi), eq(CRITERIA)); verify(mInfoApi, times(1)).requestVersion(); - verify(mInfoApiFactory, times(1)).get(); verify(mSearchStrategy, times(1)).searchNext(); } @@ -99,10 +92,9 @@ public void secondLookupShouldUseCachedStrategy() { objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApiFactory), eq(CRITERIA)); + SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApi), eq(CRITERIA)); verify(mInfoApi, times(1)).requestVersion(); - verify(mInfoApiFactory, times(1)).get(); verify(mSearchStrategy, times(2)).searchNext(); } } \ No newline at end of file From 1bb5efa21d592534a86ec4c3b3a6e89cd52370ae Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 09:00:20 +0300 Subject: [PATCH 224/457] Add explicit token parameter for InputControlRestApi --- .../sdk/network/api/InputControlRestApi.java | 15 +- .../network/api/InputControlRestApiImpl.java | 33 +- .../api/InputControlRestApiBuilderTest.java | 18 - .../network/api/InputControlRestApiTest.java | 118 +- .../api/InputControlRestApiTest.java | 9 +- .../api/utils/DummyTokenProvider.java | 4 + .../json/input_controls_states_list.json | 7847 ++++++++++++++++ .../json/input_controls_with_states.json | 7891 +++++++++++++++++ .../json/input_controls_without_states.json | 48 + 9 files changed, 15935 insertions(+), 48 deletions(-) create mode 100644 client-network/src/test/resources/json/input_controls_states_list.json create mode 100644 client-network/src/test/resources/json/input_controls_with_states.json create mode 100644 client-network/src/test/resources/json/input_controls_without_states.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 17a9bd17..b0da0159 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -47,16 +47,20 @@ public interface InputControlRestApi { * * @param reportUri uri of report * @param excludeState exclude field state which incorporates options values for control + * @param token is a key API sends to authorize client * @return unmodifiable list of {@link InputControl} */ @NonNull @WorkerThread - Collection requestInputControls(@NonNull String reportUri, boolean excludeState); + Collection requestInputControls(@NonNull String reportUri, + boolean excludeState, + @NonNull String token); @NonNull @WorkerThread Collection requestInputControlsInitialStates(@NonNull String reportUri, - boolean freshData); + boolean freshData, + @NonNull String token); /** * Provides values for specified controls. This API helpful to @@ -70,10 +74,11 @@ Collection requestInputControlsInitialStates(@NonNull String @NonNull @WorkerThread Collection requestInputControlsStates(@NonNull String reportUri, - @NonNull Map> controlsValues, - boolean freshData); + @NonNull Map> controlsValues, + boolean freshData, + @NonNull String token); - final class Builder extends GenericAuthBuilder { + final class Builder extends GenericBuilder { @Override InputControlRestApi createApi() { return new InputControlRestApiImpl(getAdapter().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index d64c6ac2..88479488 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -40,6 +40,7 @@ import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; +import retrofit.http.Header; import retrofit.http.Headers; import retrofit.http.POST; import retrofit.http.Path; @@ -60,20 +61,27 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override - public Collection requestInputControls(@Nullable String reportUri, boolean excludeState) { + public Collection requestInputControls(@Nullable String reportUri, + boolean excludeState, + @Nullable String token) { checkNotNull(reportUri, "Report URI should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestInputControls(reportUri, excludeState ? "state" : null); + String state = (excludeState ? "state" : null); + Call call = mRestApi.requestInputControls(reportUri, state, token); InputControlCollection response = CallWrapper.wrap(call).body(); return response.get(); } @NonNull @Override - public Collection requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) { + public Collection requestInputControlsInitialStates(@Nullable String reportUri, + boolean freshData, + @Nullable String token) { checkNotNull(reportUri, "Report URI should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); + Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData, token); InputControlStateCollection response = CallWrapper.wrap(call).body(); return response.get(); } @@ -81,13 +89,15 @@ public Collection requestInputControlsInitialStates(@Nullable @NonNull @Override public Collection requestInputControlsStates(@Nullable String reportUri, - @Nullable Map> controlsValues, - boolean freshData) { + @Nullable Map> controlsValues, + boolean freshData, + @Nullable String token) { checkNotNull(reportUri, "Report URI should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); + checkNotNull(token, "Request token should not be null"); String ids = Utils.joinString(";", controlsValues.keySet()); - Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData, token); InputControlStateCollection response = CallWrapper.wrap(call).body(); return response.get(); } @@ -98,14 +108,16 @@ private interface RestApi { @GET("rest_v2/reports{reportUnitURI}/inputControls") Call requestInputControls( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @Query("exclude") String state); + @Query("exclude") String state, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls/values") Call requestInputControlsInitialValues( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @Query("freshData") boolean freshData); + @Query("freshData") boolean freshData, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @@ -114,6 +126,7 @@ Call requestInputControlsValues( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @NonNull @Path(value = "controlsId", encoded = true) String ids, @NonNull @Body Map> controlsValues, - @Query("freshData") boolean freshData); + @Query("freshData") boolean freshData, + @Header("Cookie") String cookie); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java index aaaa6698..1ae49354 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java @@ -68,24 +68,6 @@ public void builderShouldEnsureBaseUrlNotNull() { expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Base url should be supplied to work with JRS API"); - builderUnderTest.tokenProvider(FakeTokenProvider.get()); builderUnderTest.build(); } - - @Test - public void builderShouldEnsureTokenNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication tokenProvider"); - - builderUnderTest.baseUrl("http://localhost"); - builderUnderTest.build(); - } - - @Test - public void builderShouldAllowNullToken() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("tokenProvider == null"); - - builderUnderTest.tokenProvider(null); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index 84d19bf0..7efe5c34 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -1,14 +1,34 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.RecordedRequest; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; /** * @author Tom Koptel @@ -24,10 +44,17 @@ public class InputControlRestApiTest { private InputControlRestApi restApiUnderTest; + @ResourceFile("json/input_controls_states_list.json") + TestResource icsStates; + @ResourceFile("json/input_controls_without_states.json") + TestResource icsWithoutStates; + @ResourceFile("json/input_controls_with_states.json") + TestResource icsWithStates; + @Before public void setup() { + TestResourceInjector.inject(this); restApiUnderTest = new InputControlRestApi.Builder() - .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } @@ -36,47 +63,118 @@ public void setup() { public void requestInputControlsShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControls(null, false); + restApiUnderTest.requestInputControls(null, false, "cookie"); } @Test - public void requestInputControlsInitialStatesShouldNotAllowNullReportUri2() { + public void requestInputControlsInitialStatesShouldNotAllowNullToken() { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsInitialStates(null, false); + mExpectedException.expectMessage("Request token should not be null"); + restApiUnderTest.requestInputControlsInitialStates("/uri", false, null); } @Test public void requestInputControlsStatesShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP, true, "cookie"); } @Test public void requestInputControlsStatesShouldNotAllowNullControlParams() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.requestInputControlsStates("any_id", null, true); + restApiUnderTest.requestInputControlsStates("any_id", null, true, "cookie"); + } + + @Test + public void requestInputControlsStatesShouldNotAllowNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true, null); } @Test public void requestInputControlsShouldThrowRestErrorFor500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControls("any_id", true); + restApiUnderTest.requestInputControls("any_id", true, "cookie"); } + @Test public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsInitialStates("any_id", true); + restApiUnderTest.requestInputControlsInitialStates("any_id", true, "cookie"); } @Test public void requestInputControlsStatesShouldThrowRestErrorFor500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true, "cookie"); + } + + @Test + public void apiShouldProvideListOfInputControlsInitialStatesWithFreshData() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200() + .setBody(icsStates.asString()); + mWebMockRule.enqueue(mockResponse); + + Collection states = restApiUnderTest.requestInputControlsInitialStates("/my/uri", true, "cookie"); + assertThat(states, is(not(empty()))); + + RecordedRequest response = mWebMockRule.get().takeRequest(); + assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls/values?freshData=true")); + assertThat(response.getHeader("Cookie"), is("cookie")); + } + + @Test + public void apiShouldProvideFreshStatesForInputControls() throws Exception { + Map> parameters = new HashMap<>(); + Set values = new HashSet<>(); + values.add("19"); + parameters.put("sales_fact_ALL__store_sales_2013_1", values); + + MockResponse mockResponse = MockResponseFactory.create200() + .setBody(icsStates.asString()); + mWebMockRule.enqueue(mockResponse); + + Collection states = restApiUnderTest.requestInputControlsStates("/my/uri", parameters, true, "cookie"); + assertThat(states, Matchers.is(not(Matchers.empty()))); + + RecordedRequest response = mWebMockRule.get().takeRequest(); + assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls/sales_fact_ALL__store_sales_2013_1/values?freshData=true")); + assertThat(response.getHeader("Cookie"), is("cookie")); + } + + @Test + public void apiShouldProvideInputControlsListIfStateExcluded() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200() + .setBody(icsWithoutStates.asString()); + mWebMockRule.enqueue(mockResponse); + + Collection controls = restApiUnderTest.requestInputControls("/my/uri", true, "cookie"); + assertThat(controls, Matchers.is(not(Matchers.empty()))); + assertThat(new ArrayList<>(controls).get(0).getState(), is(nullValue())); + + RecordedRequest response = mWebMockRule.get().takeRequest(); + assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls?exclude=state")); + assertThat(response.getHeader("Cookie"), is("cookie")); + } + + @Test + public void apiShouldProvideInputControlsWithStates() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200() + .setBody(icsWithStates.asString()); + mWebMockRule.enqueue(mockResponse); + + Collection controls = restApiUnderTest.requestInputControls("/my/uri", false, "cookie"); + assertThat(controls, Matchers.is(not(Matchers.empty()))); + assertThat(new ArrayList<>(controls).get(0).getState(), is(not(nullValue()))); + + RecordedRequest response = mWebMockRule.get().takeRequest(); + assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls")); + assertThat(response.getHeader("Cookie"), is("cookie")); } } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 22a16ce8..2dc1a351 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -68,7 +68,6 @@ public class InputControlRestApiTest { @Before public void setup() { mRestApi = new InputControlRestApi.Builder() - .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -76,7 +75,7 @@ public void setup() { @Test public void shouldProvideInputControlsList() { - Collection controls = mRestApi.requestInputControls(REPORT_URI, false); + Collection controls = mRestApi.requestInputControls(REPORT_URI, false, mAuthenticator.token()); assertThat(controls, is(not(empty()))); InputControl control = new ArrayList<>(controls).get(0); @@ -88,7 +87,7 @@ public void shouldProvideInputControlsList() { */ @Test public void shouldProvideInputControlsListIfStateExcluded() { - Collection controls = mRestApi.requestInputControls(REPORT_URI, true); + Collection controls = mRestApi.requestInputControls(REPORT_URI, true, mAuthenticator.token()); assertThat(controls, is(not(empty()))); InputControl control = new ArrayList<>(controls).get(0); @@ -97,13 +96,13 @@ public void shouldProvideInputControlsListIfStateExcluded() { @Test public void shouldProvideFreshInitialInputControlsValues() { - Collection states = mRestApi.requestInputControlsInitialStates(REPORT_URI, true); + Collection states = mRestApi.requestInputControlsInitialStates(REPORT_URI, true, mAuthenticator.token()); assertThat(states, is(not(empty()))); } @Test public void shouldProvideFreshStatesForInputControls() { - Collection states = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); + Collection states = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true, mAuthenticator.token()); assertThat(states, is(not(empty()))); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index 8d62120e..7972e715 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -59,4 +59,8 @@ public AbstractToken provideToken() { } return mToken; } + + public String token() { + return provideToken().get(); + } } diff --git a/client-network/src/test/resources/json/input_controls_states_list.json b/client-network/src/test/resources/json/input_controls_states_list.json new file mode 100644 index 00000000..96ff0fa0 --- /dev/null +++ b/client-network/src/test/resources/json/input_controls_states_list.json @@ -0,0 +1,7847 @@ +{ + "inputControlState": [ + { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", + "id": "sales__product__product_name_1", + "options": [ + { + "selected": false, + "label": "ADJ Rosy Sunglasses", + "value": "ADJ Rosy Sunglasses" + }, + { + "selected": false, + "label": "Akron City Map", + "value": "Akron City Map" + }, + { + "selected": false, + "label": "Akron Eyeglass Screwdriver", + "value": "Akron Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "American Beef Bologna", + "value": "American Beef Bologna" + }, + { + "selected": false, + "label": "American Chicken Hot Dogs", + "value": "American Chicken Hot Dogs" + }, + { + "selected": false, + "label": "American Cole Slaw", + "value": "American Cole Slaw" + }, + { + "selected": false, + "label": "American Corned Beef", + "value": "American Corned Beef" + }, + { + "selected": false, + "label": "American Foot-Long Hot Dogs", + "value": "American Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "American Low Fat Bologna", + "value": "American Low Fat Bologna" + }, + { + "selected": false, + "label": "American Low Fat Cole Slaw", + "value": "American Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "American Pimento Loaf", + "value": "American Pimento Loaf" + }, + { + "selected": false, + "label": "American Potato Salad", + "value": "American Potato Salad" + }, + { + "selected": false, + "label": "American Roasted Chicken", + "value": "American Roasted Chicken" + }, + { + "selected": false, + "label": "American Sliced Chicken", + "value": "American Sliced Chicken" + }, + { + "selected": false, + "label": "American Sliced Ham", + "value": "American Sliced Ham" + }, + { + "selected": false, + "label": "American Sliced Turkey", + "value": "American Sliced Turkey" + }, + { + "selected": false, + "label": "American Turkey Hot Dogs", + "value": "American Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Amigo Lox", + "value": "Amigo Lox" + }, + { + "selected": false, + "label": "Amigo Scallops", + "value": "Amigo Scallops" + }, + { + "selected": false, + "label": "Applause Canned Mixed Fruit", + "value": "Applause Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Applause Canned Peaches", + "value": "Applause Canned Peaches" + }, + { + "selected": false, + "label": "Atomic Bubble Gum", + "value": "Atomic Bubble Gum" + }, + { + "selected": false, + "label": "Atomic Malted Milk Balls", + "value": "Atomic Malted Milk Balls" + }, + { + "selected": false, + "label": "Atomic Mint Chocolate Bar", + "value": "Atomic Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Atomic Mints", + "value": "Atomic Mints" + }, + { + "selected": false, + "label": "Atomic Semi-Sweet Chocolate Bar", + "value": "Atomic Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Atomic Spicy Mints", + "value": "Atomic Spicy Mints" + }, + { + "selected": false, + "label": "Atomic Tasty Candy Bar", + "value": "Atomic Tasty Candy Bar" + }, + { + "selected": false, + "label": "Atomic White Chocolate Bar", + "value": "Atomic White Chocolate Bar" + }, + { + "selected": false, + "label": "BBB Best Apple Butter", + "value": "BBB Best Apple Butter" + }, + { + "selected": false, + "label": "BBB Best Apple Jam", + "value": "BBB Best Apple Jam" + }, + { + "selected": false, + "label": "BBB Best Apple Jelly", + "value": "BBB Best Apple Jelly" + }, + { + "selected": false, + "label": "BBB Best Apple Preserves", + "value": "BBB Best Apple Preserves" + }, + { + "selected": false, + "label": "BBB Best Brown Sugar", + "value": "BBB Best Brown Sugar" + }, + { + "selected": false, + "label": "BBB Best Canola Oil", + "value": "BBB Best Canola Oil" + }, + { + "selected": false, + "label": "BBB Best Chunky Peanut Butter", + "value": "BBB Best Chunky Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best Columbian Coffee", + "value": "BBB Best Columbian Coffee" + }, + { + "selected": false, + "label": "BBB Best Corn Oil", + "value": "BBB Best Corn Oil" + }, + { + "selected": false, + "label": "BBB Best Creamy Peanut Butter", + "value": "BBB Best Creamy Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best Decaf Coffee", + "value": "BBB Best Decaf Coffee" + }, + { + "selected": false, + "label": "BBB Best Extra Chunky Peanut Butter", + "value": "BBB Best Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best French Roast Coffee", + "value": "BBB Best French Roast Coffee" + }, + { + "selected": false, + "label": "BBB Best Grape Jam", + "value": "BBB Best Grape Jam" + }, + { + "selected": false, + "label": "BBB Best Grape Jelly", + "value": "BBB Best Grape Jelly" + }, + { + "selected": false, + "label": "BBB Best Grape Preserves", + "value": "BBB Best Grape Preserves" + }, + { + "selected": false, + "label": "BBB Best Hot Chocolate", + "value": "BBB Best Hot Chocolate" + }, + { + "selected": false, + "label": "BBB Best Low Fat Apple Butter", + "value": "BBB Best Low Fat Apple Butter" + }, + { + "selected": false, + "label": "BBB Best Oregano", + "value": "BBB Best Oregano" + }, + { + "selected": false, + "label": "BBB Best Pepper", + "value": "BBB Best Pepper" + }, + { + "selected": false, + "label": "BBB Best Regular Coffee", + "value": "BBB Best Regular Coffee" + }, + { + "selected": false, + "label": "BBB Best Salt", + "value": "BBB Best Salt" + }, + { + "selected": false, + "label": "BBB Best Sesame Oil", + "value": "BBB Best Sesame Oil" + }, + { + "selected": false, + "label": "BBB Best Strawberry Jam", + "value": "BBB Best Strawberry Jam" + }, + { + "selected": false, + "label": "BBB Best Strawberry Jelly", + "value": "BBB Best Strawberry Jelly" + }, + { + "selected": false, + "label": "BBB Best Strawberry Preserves", + "value": "BBB Best Strawberry Preserves" + }, + { + "selected": false, + "label": "BBB Best Tomato Sauce", + "value": "BBB Best Tomato Sauce" + }, + { + "selected": false, + "label": "BBB Best Vegetable Oil", + "value": "BBB Best Vegetable Oil" + }, + { + "selected": false, + "label": "BBB Best White Sugar", + "value": "BBB Best White Sugar" + }, + { + "selected": false, + "label": "Best Choice Apple Fruit Roll", + "value": "Best Choice Apple Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Avocado Dip", + "value": "Best Choice Avocado Dip" + }, + { + "selected": false, + "label": "Best Choice BBQ Potato Chips", + "value": "Best Choice BBQ Potato Chips" + }, + { + "selected": false, + "label": "Best Choice Beef Jerky", + "value": "Best Choice Beef Jerky" + }, + { + "selected": false, + "label": "Best Choice Buttered Popcorn", + "value": "Best Choice Buttered Popcorn" + }, + { + "selected": false, + "label": "Best Choice Cheese Crackers", + "value": "Best Choice Cheese Crackers" + }, + { + "selected": false, + "label": "Best Choice Cheese Dip", + "value": "Best Choice Cheese Dip" + }, + { + "selected": false, + "label": "Best Choice Chocolate Chip Cookies", + "value": "Best Choice Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Best Choice Chocolate Donuts", + "value": "Best Choice Chocolate Donuts" + }, + { + "selected": false, + "label": "Best Choice Corn Chips", + "value": "Best Choice Corn Chips" + }, + { + "selected": false, + "label": "Best Choice Dried Apples", + "value": "Best Choice Dried Apples" + }, + { + "selected": false, + "label": "Best Choice Dried Apricots", + "value": "Best Choice Dried Apricots" + }, + { + "selected": false, + "label": "Best Choice Dried Dates", + "value": "Best Choice Dried Dates" + }, + { + "selected": false, + "label": "Best Choice Fondue Mix", + "value": "Best Choice Fondue Mix" + }, + { + "selected": false, + "label": "Best Choice Frosted Cookies", + "value": "Best Choice Frosted Cookies" + }, + { + "selected": false, + "label": "Best Choice Frosted Donuts", + "value": "Best Choice Frosted Donuts" + }, + { + "selected": false, + "label": "Best Choice Fudge Brownies", + "value": "Best Choice Fudge Brownies" + }, + { + "selected": false, + "label": "Best Choice Fudge Cookies", + "value": "Best Choice Fudge Cookies" + }, + { + "selected": false, + "label": "Best Choice Golden Raisins", + "value": "Best Choice Golden Raisins" + }, + { + "selected": false, + "label": "Best Choice Graham Crackers", + "value": "Best Choice Graham Crackers" + }, + { + "selected": false, + "label": "Best Choice Grape Fruit Roll", + "value": "Best Choice Grape Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Lemon Cookies", + "value": "Best Choice Lemon Cookies" + }, + { + "selected": false, + "label": "Best Choice Low Fat BBQ Chips", + "value": "Best Choice Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Best Choice Low Fat Chips", + "value": "Best Choice Low Fat Chips" + }, + { + "selected": false, + "label": "Best Choice Low Fat Cookies", + "value": "Best Choice Low Fat Cookies" + }, + { + "selected": false, + "label": "Best Choice Low Fat Popcorn", + "value": "Best Choice Low Fat Popcorn" + }, + { + "selected": false, + "label": "Best Choice Mini Donuts", + "value": "Best Choice Mini Donuts" + }, + { + "selected": false, + "label": "Best Choice No Salt Popcorn", + "value": "Best Choice No Salt Popcorn" + }, + { + "selected": false, + "label": "Best Choice Potato Chips", + "value": "Best Choice Potato Chips" + }, + { + "selected": false, + "label": "Best Choice Raisins", + "value": "Best Choice Raisins" + }, + { + "selected": false, + "label": "Best Choice Raspberry Fruit Roll", + "value": "Best Choice Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Salsa Dip", + "value": "Best Choice Salsa Dip" + }, + { + "selected": false, + "label": "Best Choice Salted Pretzels", + "value": "Best Choice Salted Pretzels" + }, + { + "selected": false, + "label": "Best Choice Sesame Crackers", + "value": "Best Choice Sesame Crackers" + }, + { + "selected": false, + "label": "Best Choice Strawberry Fruit Roll", + "value": "Best Choice Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Sugar Cookies", + "value": "Best Choice Sugar Cookies" + }, + { + "selected": false, + "label": "Best Corn Puffs", + "value": "Best Corn Puffs" + }, + { + "selected": false, + "label": "Best Grits", + "value": "Best Grits" + }, + { + "selected": false, + "label": "Best Oatmeal", + "value": "Best Oatmeal" + }, + { + "selected": false, + "label": "Best Wheat Puffs", + "value": "Best Wheat Puffs" + }, + { + "selected": false, + "label": "Better Beef Soup", + "value": "Better Beef Soup" + }, + { + "selected": false, + "label": "Better Canned Beets", + "value": "Better Canned Beets" + }, + { + "selected": false, + "label": "Better Canned Peas", + "value": "Better Canned Peas" + }, + { + "selected": false, + "label": "Better Canned String Beans", + "value": "Better Canned String Beans" + }, + { + "selected": false, + "label": "Better Canned Tomatos", + "value": "Better Canned Tomatos" + }, + { + "selected": false, + "label": "Better Canned Tuna in Oil", + "value": "Better Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Better Canned Tuna in Water", + "value": "Better Canned Tuna in Water" + }, + { + "selected": false, + "label": "Better Canned Yams", + "value": "Better Canned Yams" + }, + { + "selected": false, + "label": "Better Chicken Noodle Soup", + "value": "Better Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Better Chicken Ramen Soup", + "value": "Better Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Better Chicken Soup", + "value": "Better Chicken Soup" + }, + { + "selected": false, + "label": "Better Creamed Corn", + "value": "Better Creamed Corn" + }, + { + "selected": false, + "label": "Better Fancy Canned Anchovies", + "value": "Better Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Better Fancy Canned Clams", + "value": "Better Fancy Canned Clams" + }, + { + "selected": false, + "label": "Better Fancy Canned Oysters", + "value": "Better Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Better Fancy Canned Sardines", + "value": "Better Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Better Large Canned Shrimp", + "value": "Better Large Canned Shrimp" + }, + { + "selected": false, + "label": "Better Noodle Soup", + "value": "Better Noodle Soup" + }, + { + "selected": false, + "label": "Better Regular Ramen Soup", + "value": "Better Regular Ramen Soup" + }, + { + "selected": false, + "label": "Better Rice Soup", + "value": "Better Rice Soup" + }, + { + "selected": false, + "label": "Better Turkey Noodle Soup", + "value": "Better Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Better Vegetable Soup", + "value": "Better Vegetable Soup" + }, + { + "selected": false, + "label": "Big City Canned Mixed Fruit", + "value": "Big City Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Big City Canned Peaches", + "value": "Big City Canned Peaches" + }, + { + "selected": false, + "label": "Big Time Apple Cinnamon Waffles", + "value": "Big Time Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Big Time Beef TV Dinner", + "value": "Big Time Beef TV Dinner" + }, + { + "selected": false, + "label": "Big Time Blueberry Waffles", + "value": "Big Time Blueberry Waffles" + }, + { + "selected": false, + "label": "Big Time Chicken TV Dinner", + "value": "Big Time Chicken TV Dinner" + }, + { + "selected": false, + "label": "Big Time Fajita French Fries", + "value": "Big Time Fajita French Fries" + }, + { + "selected": false, + "label": "Big Time Frozen Broccoli", + "value": "Big Time Frozen Broccoli" + }, + { + "selected": false, + "label": "Big Time Frozen Carrots", + "value": "Big Time Frozen Carrots" + }, + { + "selected": false, + "label": "Big Time Frozen Cauliflower", + "value": "Big Time Frozen Cauliflower" + }, + { + "selected": false, + "label": "Big Time Frozen Cheese Pizza", + "value": "Big Time Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Breast", + "value": "Big Time Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Thighs", + "value": "Big Time Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Wings", + "value": "Big Time Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Big Time Frozen Corn", + "value": "Big Time Frozen Corn" + }, + { + "selected": false, + "label": "Big Time Frozen Mushroom Pizza", + "value": "Big Time Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Pancakes", + "value": "Big Time Frozen Pancakes" + }, + { + "selected": false, + "label": "Big Time Frozen Peas", + "value": "Big Time Frozen Peas" + }, + { + "selected": false, + "label": "Big Time Frozen Pepperoni Pizza", + "value": "Big Time Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Sausage Pizza", + "value": "Big Time Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Big Time Grape Popsicles", + "value": "Big Time Grape Popsicles" + }, + { + "selected": false, + "label": "Big Time Home Style French Fries", + "value": "Big Time Home Style French Fries" + }, + { + "selected": false, + "label": "Big Time Ice Cream", + "value": "Big Time Ice Cream" + }, + { + "selected": false, + "label": "Big Time Ice Cream Sandwich", + "value": "Big Time Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Big Time Lemon Popsicles", + "value": "Big Time Lemon Popsicles" + }, + { + "selected": false, + "label": "Big Time Lime Popsicles", + "value": "Big Time Lime Popsicles" + }, + { + "selected": false, + "label": "Big Time Low Fat French Fries", + "value": "Big Time Low Fat French Fries" + }, + { + "selected": false, + "label": "Big Time Low Fat Waffles", + "value": "Big Time Low Fat Waffles" + }, + { + "selected": false, + "label": "Big Time Orange Popsicles", + "value": "Big Time Orange Popsicles" + }, + { + "selected": false, + "label": "Big Time Pancake Mix", + "value": "Big Time Pancake Mix" + }, + { + "selected": false, + "label": "Big Time Popsicles", + "value": "Big Time Popsicles" + }, + { + "selected": false, + "label": "Big Time Turkey TV Dinner", + "value": "Big Time Turkey TV Dinner" + }, + { + "selected": false, + "label": "Big Time Waffles", + "value": "Big Time Waffles" + }, + { + "selected": false, + "label": "Bird Call 200 MG Acetominifen", + "value": "Bird Call 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Bird Call 200 MG Ibuprofen", + "value": "Bird Call 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Bird Call Angled Toothbrush", + "value": "Bird Call Angled Toothbrush" + }, + { + "selected": false, + "label": "Bird Call Apricot Shampoo", + "value": "Bird Call Apricot Shampoo" + }, + { + "selected": false, + "label": "Bird Call Buffered Aspirin", + "value": "Bird Call Buffered Aspirin" + }, + { + "selected": false, + "label": "Bird Call Childrens Aspirin", + "value": "Bird Call Childrens Aspirin" + }, + { + "selected": false, + "label": "Bird Call Childrens Cold Remedy", + "value": "Bird Call Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Bird Call Conditioning Shampoo", + "value": "Bird Call Conditioning Shampoo" + }, + { + "selected": false, + "label": "Bird Call Deodorant", + "value": "Bird Call Deodorant" + }, + { + "selected": false, + "label": "Bird Call Dishwasher Detergent", + "value": "Bird Call Dishwasher Detergent" + }, + { + "selected": false, + "label": "Bird Call Extra Moisture Shampoo", + "value": "Bird Call Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Bird Call HCL Nasal Spray", + "value": "Bird Call HCL Nasal Spray" + }, + { + "selected": false, + "label": "Bird Call Laundry Detergent", + "value": "Bird Call Laundry Detergent" + }, + { + "selected": false, + "label": "Bird Call Mint Mouthwash", + "value": "Bird Call Mint Mouthwash" + }, + { + "selected": false, + "label": "Bird Call Multi-Symptom Cold Remedy", + "value": "Bird Call Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Bird Call Silky Smooth Hair Conditioner", + "value": "Bird Call Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Bird Call Tartar Control Toothpaste", + "value": "Bird Call Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Bird Call Toothpaste", + "value": "Bird Call Toothpaste" + }, + { + "selected": false, + "label": "Bird Call Whitening Toothpast", + "value": "Bird Call Whitening Toothpast" + }, + { + "selected": false, + "label": "Black Tie City Map", + "value": "Black Tie City Map" + }, + { + "selected": false, + "label": "Black Tie Eyeglass Screwdriver", + "value": "Black Tie Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Blue Label Beef Soup", + "value": "Blue Label Beef Soup" + }, + { + "selected": false, + "label": "Blue Label Canned Beets", + "value": "Blue Label Canned Beets" + }, + { + "selected": false, + "label": "Blue Label Canned Peas", + "value": "Blue Label Canned Peas" + }, + { + "selected": false, + "label": "Blue Label Canned String Beans", + "value": "Blue Label Canned String Beans" + }, + { + "selected": false, + "label": "Blue Label Canned Tomatos", + "value": "Blue Label Canned Tomatos" + }, + { + "selected": false, + "label": "Blue Label Canned Tuna in Oil", + "value": "Blue Label Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Blue Label Canned Tuna in Water", + "value": "Blue Label Canned Tuna in Water" + }, + { + "selected": false, + "label": "Blue Label Canned Yams", + "value": "Blue Label Canned Yams" + }, + { + "selected": false, + "label": "Blue Label Chicken Noodle Soup", + "value": "Blue Label Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Chicken Ramen Soup", + "value": "Blue Label Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Blue Label Chicken Soup", + "value": "Blue Label Chicken Soup" + }, + { + "selected": false, + "label": "Blue Label Creamed Corn", + "value": "Blue Label Creamed Corn" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Anchovies", + "value": "Blue Label Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Clams", + "value": "Blue Label Fancy Canned Clams" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Oysters", + "value": "Blue Label Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Sardines", + "value": "Blue Label Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Blue Label Large Canned Shrimp", + "value": "Blue Label Large Canned Shrimp" + }, + { + "selected": false, + "label": "Blue Label Noodle Soup", + "value": "Blue Label Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Regular Ramen Soup", + "value": "Blue Label Regular Ramen Soup" + }, + { + "selected": false, + "label": "Blue Label Rice Soup", + "value": "Blue Label Rice Soup" + }, + { + "selected": false, + "label": "Blue Label Turkey Noodle Soup", + "value": "Blue Label Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Vegetable Soup", + "value": "Blue Label Vegetable Soup" + }, + { + "selected": false, + "label": "Blue Medal Egg Substitute", + "value": "Blue Medal Egg Substitute" + }, + { + "selected": false, + "label": "Blue Medal Large Brown Eggs", + "value": "Blue Medal Large Brown Eggs" + }, + { + "selected": false, + "label": "Blue Medal Large Eggs", + "value": "Blue Medal Large Eggs" + }, + { + "selected": false, + "label": "Blue Medal Small Brown Eggs", + "value": "Blue Medal Small Brown Eggs" + }, + { + "selected": false, + "label": "Blue Medal Small Eggs", + "value": "Blue Medal Small Eggs" + }, + { + "selected": false, + "label": "Booker 1% Milk", + "value": "Booker 1% Milk" + }, + { + "selected": false, + "label": "Booker 2% Milk", + "value": "Booker 2% Milk" + }, + { + "selected": false, + "label": "Booker Blueberry Yogurt", + "value": "Booker Blueberry Yogurt" + }, + { + "selected": false, + "label": "Booker Buttermilk", + "value": "Booker Buttermilk" + }, + { + "selected": false, + "label": "Booker Cheese Spread", + "value": "Booker Cheese Spread" + }, + { + "selected": false, + "label": "Booker Chocolate Milk", + "value": "Booker Chocolate Milk" + }, + { + "selected": false, + "label": "Booker Havarti Cheese", + "value": "Booker Havarti Cheese" + }, + { + "selected": false, + "label": "Booker Head Cheese", + "value": "Booker Head Cheese" + }, + { + "selected": false, + "label": "Booker Jack Cheese", + "value": "Booker Jack Cheese" + }, + { + "selected": false, + "label": "Booker Large Curd Cottage Cheese", + "value": "Booker Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Booker Low Fat Cottage Cheese", + "value": "Booker Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Booker Low Fat Sour Cream", + "value": "Booker Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Booker Low Fat String Cheese", + "value": "Booker Low Fat String Cheese" + }, + { + "selected": false, + "label": "Booker Mild Cheddar Cheese", + "value": "Booker Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Booker Muenster Cheese", + "value": "Booker Muenster Cheese" + }, + { + "selected": false, + "label": "Booker Sharp Cheddar Cheese", + "value": "Booker Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Booker Sour Cream", + "value": "Booker Sour Cream" + }, + { + "selected": false, + "label": "Booker Strawberry Yogurt", + "value": "Booker Strawberry Yogurt" + }, + { + "selected": false, + "label": "Booker String Cheese", + "value": "Booker String Cheese" + }, + { + "selected": false, + "label": "Booker Whole Milk", + "value": "Booker Whole Milk" + }, + { + "selected": false, + "label": "Bravo Beef Soup", + "value": "Bravo Beef Soup" + }, + { + "selected": false, + "label": "Bravo Canned Beets", + "value": "Bravo Canned Beets" + }, + { + "selected": false, + "label": "Bravo Canned Peas", + "value": "Bravo Canned Peas" + }, + { + "selected": false, + "label": "Bravo Canned String Beans", + "value": "Bravo Canned String Beans" + }, + { + "selected": false, + "label": "Bravo Canned Tomatos", + "value": "Bravo Canned Tomatos" + }, + { + "selected": false, + "label": "Bravo Canned Tuna in Oil", + "value": "Bravo Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Bravo Canned Tuna in Water", + "value": "Bravo Canned Tuna in Water" + }, + { + "selected": false, + "label": "Bravo Canned Yams", + "value": "Bravo Canned Yams" + }, + { + "selected": false, + "label": "Bravo Chicken Noodle Soup", + "value": "Bravo Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Chicken Ramen Soup", + "value": "Bravo Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Bravo Chicken Soup", + "value": "Bravo Chicken Soup" + }, + { + "selected": false, + "label": "Bravo Creamed Corn", + "value": "Bravo Creamed Corn" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Anchovies", + "value": "Bravo Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Clams", + "value": "Bravo Fancy Canned Clams" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Oysters", + "value": "Bravo Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Sardines", + "value": "Bravo Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Bravo Large Canned Shrimp", + "value": "Bravo Large Canned Shrimp" + }, + { + "selected": false, + "label": "Bravo Noodle Soup", + "value": "Bravo Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Regular Ramen Soup", + "value": "Bravo Regular Ramen Soup" + }, + { + "selected": false, + "label": "Bravo Rice Soup", + "value": "Bravo Rice Soup" + }, + { + "selected": false, + "label": "Bravo Turkey Noodle Soup", + "value": "Bravo Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Vegetable Soup", + "value": "Bravo Vegetable Soup" + }, + { + "selected": false, + "label": "Carlson 1% Milk", + "value": "Carlson 1% Milk" + }, + { + "selected": false, + "label": "Carlson 2% Milk", + "value": "Carlson 2% Milk" + }, + { + "selected": false, + "label": "Carlson Blueberry Yogurt", + "value": "Carlson Blueberry Yogurt" + }, + { + "selected": false, + "label": "Carlson Buttermilk", + "value": "Carlson Buttermilk" + }, + { + "selected": false, + "label": "Carlson Cheese Spread", + "value": "Carlson Cheese Spread" + }, + { + "selected": false, + "label": "Carlson Chocolate Milk", + "value": "Carlson Chocolate Milk" + }, + { + "selected": false, + "label": "Carlson Havarti Cheese", + "value": "Carlson Havarti Cheese" + }, + { + "selected": false, + "label": "Carlson Head Cheese", + "value": "Carlson Head Cheese" + }, + { + "selected": false, + "label": "Carlson Jack Cheese", + "value": "Carlson Jack Cheese" + }, + { + "selected": false, + "label": "Carlson Large Curd Cottage Cheese", + "value": "Carlson Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Carlson Low Fat Cottage Cheese", + "value": "Carlson Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Carlson Low Fat Sour Cream", + "value": "Carlson Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Carlson Low Fat String Cheese", + "value": "Carlson Low Fat String Cheese" + }, + { + "selected": false, + "label": "Carlson Mild Cheddar Cheese", + "value": "Carlson Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Carlson Muenster Cheese", + "value": "Carlson Muenster Cheese" + }, + { + "selected": false, + "label": "Carlson Sharp Cheddar Cheese", + "value": "Carlson Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Carlson Sour Cream", + "value": "Carlson Sour Cream" + }, + { + "selected": false, + "label": "Carlson Strawberry Yogurt", + "value": "Carlson Strawberry Yogurt" + }, + { + "selected": false, + "label": "Carlson String Cheese", + "value": "Carlson String Cheese" + }, + { + "selected": false, + "label": "Carlson Whole Milk", + "value": "Carlson Whole Milk" + }, + { + "selected": false, + "label": "Carrington Apple Cinnamon Waffles", + "value": "Carrington Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Carrington Beef TV Dinner", + "value": "Carrington Beef TV Dinner" + }, + { + "selected": false, + "label": "Carrington Blueberry Waffles", + "value": "Carrington Blueberry Waffles" + }, + { + "selected": false, + "label": "Carrington Chicken TV Dinner", + "value": "Carrington Chicken TV Dinner" + }, + { + "selected": false, + "label": "Carrington Fajita French Fries", + "value": "Carrington Fajita French Fries" + }, + { + "selected": false, + "label": "Carrington Frozen Broccoli", + "value": "Carrington Frozen Broccoli" + }, + { + "selected": false, + "label": "Carrington Frozen Carrots", + "value": "Carrington Frozen Carrots" + }, + { + "selected": false, + "label": "Carrington Frozen Cauliflower", + "value": "Carrington Frozen Cauliflower" + }, + { + "selected": false, + "label": "Carrington Frozen Cheese Pizza", + "value": "Carrington Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Breast", + "value": "Carrington Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Thighs", + "value": "Carrington Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Wings", + "value": "Carrington Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Carrington Frozen Corn", + "value": "Carrington Frozen Corn" + }, + { + "selected": false, + "label": "Carrington Frozen Mushroom Pizza", + "value": "Carrington Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Pancakes", + "value": "Carrington Frozen Pancakes" + }, + { + "selected": false, + "label": "Carrington Frozen Peas", + "value": "Carrington Frozen Peas" + }, + { + "selected": false, + "label": "Carrington Frozen Pepperoni Pizza", + "value": "Carrington Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Sausage Pizza", + "value": "Carrington Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Carrington Grape Popsicles", + "value": "Carrington Grape Popsicles" + }, + { + "selected": false, + "label": "Carrington Home Style French Fries", + "value": "Carrington Home Style French Fries" + }, + { + "selected": false, + "label": "Carrington Ice Cream", + "value": "Carrington Ice Cream" + }, + { + "selected": false, + "label": "Carrington Ice Cream Sandwich", + "value": "Carrington Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Carrington Lemon Popsicles", + "value": "Carrington Lemon Popsicles" + }, + { + "selected": false, + "label": "Carrington Lime Popsicles", + "value": "Carrington Lime Popsicles" + }, + { + "selected": false, + "label": "Carrington Low Fat French Fries", + "value": "Carrington Low Fat French Fries" + }, + { + "selected": false, + "label": "Carrington Low Fat Waffles", + "value": "Carrington Low Fat Waffles" + }, + { + "selected": false, + "label": "Carrington Orange Popsicles", + "value": "Carrington Orange Popsicles" + }, + { + "selected": false, + "label": "Carrington Pancake Mix", + "value": "Carrington Pancake Mix" + }, + { + "selected": false, + "label": "Carrington Popsicles", + "value": "Carrington Popsicles" + }, + { + "selected": false, + "label": "Carrington Turkey TV Dinner", + "value": "Carrington Turkey TV Dinner" + }, + { + "selected": false, + "label": "Carrington Waffles", + "value": "Carrington Waffles" + }, + { + "selected": false, + "label": "CDR Apple Butter", + "value": "CDR Apple Butter" + }, + { + "selected": false, + "label": "CDR Apple Jam", + "value": "CDR Apple Jam" + }, + { + "selected": false, + "label": "CDR Apple Jelly", + "value": "CDR Apple Jelly" + }, + { + "selected": false, + "label": "CDR Apple Preserves", + "value": "CDR Apple Preserves" + }, + { + "selected": false, + "label": "CDR Brown Sugar", + "value": "CDR Brown Sugar" + }, + { + "selected": false, + "label": "CDR Canola Oil", + "value": "CDR Canola Oil" + }, + { + "selected": false, + "label": "CDR Chunky Peanut Butter", + "value": "CDR Chunky Peanut Butter" + }, + { + "selected": false, + "label": "CDR Columbian Coffee", + "value": "CDR Columbian Coffee" + }, + { + "selected": false, + "label": "CDR Corn Oil", + "value": "CDR Corn Oil" + }, + { + "selected": false, + "label": "CDR Creamy Peanut Butter", + "value": "CDR Creamy Peanut Butter" + }, + { + "selected": false, + "label": "CDR Decaf Coffee", + "value": "CDR Decaf Coffee" + }, + { + "selected": false, + "label": "CDR Extra Chunky Peanut Butter", + "value": "CDR Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "CDR French Roast Coffee", + "value": "CDR French Roast Coffee" + }, + { + "selected": false, + "label": "CDR Grape Jam", + "value": "CDR Grape Jam" + }, + { + "selected": false, + "label": "CDR Grape Jelly", + "value": "CDR Grape Jelly" + }, + { + "selected": false, + "label": "CDR Grape Preserves", + "value": "CDR Grape Preserves" + }, + { + "selected": false, + "label": "CDR Hot Chocolate", + "value": "CDR Hot Chocolate" + }, + { + "selected": false, + "label": "CDR Low Fat Apple Butter", + "value": "CDR Low Fat Apple Butter" + }, + { + "selected": false, + "label": "CDR Oregano", + "value": "CDR Oregano" + }, + { + "selected": false, + "label": "CDR Pepper", + "value": "CDR Pepper" + }, + { + "selected": false, + "label": "CDR Regular Coffee", + "value": "CDR Regular Coffee" + }, + { + "selected": false, + "label": "CDR Salt", + "value": "CDR Salt" + }, + { + "selected": false, + "label": "CDR Sesame Oil", + "value": "CDR Sesame Oil" + }, + { + "selected": false, + "label": "CDR Strawberry Jam", + "value": "CDR Strawberry Jam" + }, + { + "selected": false, + "label": "CDR Strawberry Jelly", + "value": "CDR Strawberry Jelly" + }, + { + "selected": false, + "label": "CDR Strawberry Preserves", + "value": "CDR Strawberry Preserves" + }, + { + "selected": false, + "label": "CDR Tomato Sauce", + "value": "CDR Tomato Sauce" + }, + { + "selected": false, + "label": "CDR Vegetable Oil", + "value": "CDR Vegetable Oil" + }, + { + "selected": false, + "label": "CDR White Sugar", + "value": "CDR White Sugar" + }, + { + "selected": false, + "label": "Choice Bubble Gum", + "value": "Choice Bubble Gum" + }, + { + "selected": false, + "label": "Choice Malted Milk Balls", + "value": "Choice Malted Milk Balls" + }, + { + "selected": false, + "label": "Choice Mint Chocolate Bar", + "value": "Choice Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Choice Mints", + "value": "Choice Mints" + }, + { + "selected": false, + "label": "Choice Semi-Sweet Chocolate Bar", + "value": "Choice Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Choice Spicy Mints", + "value": "Choice Spicy Mints" + }, + { + "selected": false, + "label": "Choice Tasty Candy Bar", + "value": "Choice Tasty Candy Bar" + }, + { + "selected": false, + "label": "Choice White Chocolate Bar", + "value": "Choice White Chocolate Bar" + }, + { + "selected": false, + "label": "Club 1% Milk", + "value": "Club 1% Milk" + }, + { + "selected": false, + "label": "Club 2% Milk", + "value": "Club 2% Milk" + }, + { + "selected": false, + "label": "Club Blueberry Yogurt", + "value": "Club Blueberry Yogurt" + }, + { + "selected": false, + "label": "Club Buttermilk", + "value": "Club Buttermilk" + }, + { + "selected": false, + "label": "Club Cheese Spread", + "value": "Club Cheese Spread" + }, + { + "selected": false, + "label": "Club Chocolate Milk", + "value": "Club Chocolate Milk" + }, + { + "selected": false, + "label": "Club Havarti Cheese", + "value": "Club Havarti Cheese" + }, + { + "selected": false, + "label": "Club Head Cheese", + "value": "Club Head Cheese" + }, + { + "selected": false, + "label": "Club Jack Cheese", + "value": "Club Jack Cheese" + }, + { + "selected": false, + "label": "Club Large Curd Cottage Cheese", + "value": "Club Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Club Low Fat Cottage Cheese", + "value": "Club Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Club Low Fat Sour Cream", + "value": "Club Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Club Low Fat String Cheese", + "value": "Club Low Fat String Cheese" + }, + { + "selected": false, + "label": "Club Mild Cheddar Cheese", + "value": "Club Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Club Muenster Cheese", + "value": "Club Muenster Cheese" + }, + { + "selected": false, + "label": "Club Sharp Cheddar Cheese", + "value": "Club Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Club Sour Cream", + "value": "Club Sour Cream" + }, + { + "selected": false, + "label": "Club Strawberry Yogurt", + "value": "Club Strawberry Yogurt" + }, + { + "selected": false, + "label": "Club String Cheese", + "value": "Club String Cheese" + }, + { + "selected": false, + "label": "Club Whole Milk", + "value": "Club Whole Milk" + }, + { + "selected": false, + "label": "Colony Bagels", + "value": "Colony Bagels" + }, + { + "selected": false, + "label": "Colony Blueberry Muffins", + "value": "Colony Blueberry Muffins" + }, + { + "selected": false, + "label": "Colony Cranberry Muffins", + "value": "Colony Cranberry Muffins" + }, + { + "selected": false, + "label": "Colony English Muffins", + "value": "Colony English Muffins" + }, + { + "selected": false, + "label": "Colony Muffins", + "value": "Colony Muffins" + }, + { + "selected": false, + "label": "Colony Pumpernickel Bread", + "value": "Colony Pumpernickel Bread" + }, + { + "selected": false, + "label": "Colony Rye Bread", + "value": "Colony Rye Bread" + }, + { + "selected": false, + "label": "Colony Wheat Bread", + "value": "Colony Wheat Bread" + }, + { + "selected": false, + "label": "Colony White Bread", + "value": "Colony White Bread" + }, + { + "selected": false, + "label": "Colossal Manicotti", + "value": "Colossal Manicotti" + }, + { + "selected": false, + "label": "Colossal Ravioli", + "value": "Colossal Ravioli" + }, + { + "selected": false, + "label": "Colossal Rice Medly", + "value": "Colossal Rice Medly" + }, + { + "selected": false, + "label": "Colossal Spaghetti", + "value": "Colossal Spaghetti" + }, + { + "selected": false, + "label": "Colossal Thai Rice", + "value": "Colossal Thai Rice" + }, + { + "selected": false, + "label": "Consolidated 200 MG Acetominifen", + "value": "Consolidated 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Consolidated 200 MG Ibuprofen", + "value": "Consolidated 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Consolidated Angled Toothbrush", + "value": "Consolidated Angled Toothbrush" + }, + { + "selected": false, + "label": "Consolidated Apricot Shampoo", + "value": "Consolidated Apricot Shampoo" + }, + { + "selected": false, + "label": "Consolidated Buffered Aspirin", + "value": "Consolidated Buffered Aspirin" + }, + { + "selected": false, + "label": "Consolidated Childrens Aspirin", + "value": "Consolidated Childrens Aspirin" + }, + { + "selected": false, + "label": "Consolidated Childrens Cold Remedy", + "value": "Consolidated Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Consolidated Conditioning Shampoo", + "value": "Consolidated Conditioning Shampoo" + }, + { + "selected": false, + "label": "Consolidated Deodorant", + "value": "Consolidated Deodorant" + }, + { + "selected": false, + "label": "Consolidated Dishwasher Detergent", + "value": "Consolidated Dishwasher Detergent" + }, + { + "selected": false, + "label": "Consolidated Extra Moisture Shampoo", + "value": "Consolidated Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Consolidated HCL Nasal Spray", + "value": "Consolidated HCL Nasal Spray" + }, + { + "selected": false, + "label": "Consolidated Laundry Detergent", + "value": "Consolidated Laundry Detergent" + }, + { + "selected": false, + "label": "Consolidated Mint Mouthwash", + "value": "Consolidated Mint Mouthwash" + }, + { + "selected": false, + "label": "Consolidated Multi-Symptom Cold Remedy", + "value": "Consolidated Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Consolidated Silky Smooth Hair Conditioner", + "value": "Consolidated Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Consolidated Tartar Control Toothpaste", + "value": "Consolidated Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Consolidated Toothpaste", + "value": "Consolidated Toothpaste" + }, + { + "selected": false, + "label": "Consolidated Whitening Toothpast", + "value": "Consolidated Whitening Toothpast" + }, + { + "selected": false, + "label": "Cormorant 100 Watt Lightbulb", + "value": "Cormorant 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 25 Watt Lightbulb", + "value": "Cormorant 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 60 Watt Lightbulb", + "value": "Cormorant 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 75 Watt Lightbulb", + "value": "Cormorant 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant AAA-Size Batteries", + "value": "Cormorant AAA-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant AA-Size Batteries", + "value": "Cormorant AA-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant Bees Wax Candles", + "value": "Cormorant Bees Wax Candles" + }, + { + "selected": false, + "label": "Cormorant Copper Cleaner", + "value": "Cormorant Copper Cleaner" + }, + { + "selected": false, + "label": "Cormorant Copper Pot Scrubber", + "value": "Cormorant Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Cormorant Counter Cleaner", + "value": "Cormorant Counter Cleaner" + }, + { + "selected": false, + "label": "Cormorant C-Size Batteries", + "value": "Cormorant C-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant D-Size Batteries", + "value": "Cormorant D-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant Economy Toilet Brush", + "value": "Cormorant Economy Toilet Brush" + }, + { + "selected": false, + "label": "Cormorant Frying Pan", + "value": "Cormorant Frying Pan" + }, + { + "selected": false, + "label": "Cormorant Glass Cleaner", + "value": "Cormorant Glass Cleaner" + }, + { + "selected": false, + "label": "Cormorant Large Sponge", + "value": "Cormorant Large Sponge" + }, + { + "selected": false, + "label": "Cormorant Paper Cups", + "value": "Cormorant Paper Cups" + }, + { + "selected": false, + "label": "Cormorant Paper Plates", + "value": "Cormorant Paper Plates" + }, + { + "selected": false, + "label": "Cormorant Paper Towels", + "value": "Cormorant Paper Towels" + }, + { + "selected": false, + "label": "Cormorant Plastic Forks", + "value": "Cormorant Plastic Forks" + }, + { + "selected": false, + "label": "Cormorant Plastic Knives", + "value": "Cormorant Plastic Knives" + }, + { + "selected": false, + "label": "Cormorant Plastic Spoons", + "value": "Cormorant Plastic Spoons" + }, + { + "selected": false, + "label": "Cormorant Room Freshener", + "value": "Cormorant Room Freshener" + }, + { + "selected": false, + "label": "Cormorant Scented Tissue", + "value": "Cormorant Scented Tissue" + }, + { + "selected": false, + "label": "Cormorant Scented Toilet Tissue", + "value": "Cormorant Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Cormorant Scissors", + "value": "Cormorant Scissors" + }, + { + "selected": false, + "label": "Cormorant Screw Driver", + "value": "Cormorant Screw Driver" + }, + { + "selected": false, + "label": "Cormorant Silver Cleaner", + "value": "Cormorant Silver Cleaner" + }, + { + "selected": false, + "label": "Cormorant Soft Napkins", + "value": "Cormorant Soft Napkins" + }, + { + "selected": false, + "label": "Cormorant Tissues", + "value": "Cormorant Tissues" + }, + { + "selected": false, + "label": "Cormorant Toilet Bowl Cleaner", + "value": "Cormorant Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Cormorant Toilet Paper", + "value": "Cormorant Toilet Paper" + }, + { + "selected": false, + "label": "Curlew Lox", + "value": "Curlew Lox" + }, + { + "selected": false, + "label": "Curlew Scallops", + "value": "Curlew Scallops" + }, + { + "selected": false, + "label": "Cutting Edge Beef Bologna", + "value": "Cutting Edge Beef Bologna" + }, + { + "selected": false, + "label": "Cutting Edge Chicken Hot Dogs", + "value": "Cutting Edge Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Cutting Edge Cole Slaw", + "value": "Cutting Edge Cole Slaw" + }, + { + "selected": false, + "label": "Cutting Edge Corned Beef", + "value": "Cutting Edge Corned Beef" + }, + { + "selected": false, + "label": "Cutting Edge Foot-Long Hot Dogs", + "value": "Cutting Edge Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Cutting Edge Low Fat Bologna", + "value": "Cutting Edge Low Fat Bologna" + }, + { + "selected": false, + "label": "Cutting Edge Low Fat Cole Slaw", + "value": "Cutting Edge Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Cutting Edge Pimento Loaf", + "value": "Cutting Edge Pimento Loaf" + }, + { + "selected": false, + "label": "Cutting Edge Potato Salad", + "value": "Cutting Edge Potato Salad" + }, + { + "selected": false, + "label": "Cutting Edge Roasted Chicken", + "value": "Cutting Edge Roasted Chicken" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Chicken", + "value": "Cutting Edge Sliced Chicken" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Ham", + "value": "Cutting Edge Sliced Ham" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Turkey", + "value": "Cutting Edge Sliced Turkey" + }, + { + "selected": false, + "label": "Cutting Edge Turkey Hot Dogs", + "value": "Cutting Edge Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Denny 100 Watt Lightbulb", + "value": "Denny 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 25 Watt Lightbulb", + "value": "Denny 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 60 Watt Lightbulb", + "value": "Denny 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 75 Watt Lightbulb", + "value": "Denny 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny AAA-Size Batteries", + "value": "Denny AAA-Size Batteries" + }, + { + "selected": false, + "label": "Denny AA-Size Batteries", + "value": "Denny AA-Size Batteries" + }, + { + "selected": false, + "label": "Denny Bees Wax Candles", + "value": "Denny Bees Wax Candles" + }, + { + "selected": false, + "label": "Denny Copper Cleaner", + "value": "Denny Copper Cleaner" + }, + { + "selected": false, + "label": "Denny Copper Pot Scrubber", + "value": "Denny Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Denny Counter Cleaner", + "value": "Denny Counter Cleaner" + }, + { + "selected": false, + "label": "Denny C-Size Batteries", + "value": "Denny C-Size Batteries" + }, + { + "selected": false, + "label": "Denny D-Size Batteries", + "value": "Denny D-Size Batteries" + }, + { + "selected": false, + "label": "Denny Economy Toilet Brush", + "value": "Denny Economy Toilet Brush" + }, + { + "selected": false, + "label": "Denny Frying Pan", + "value": "Denny Frying Pan" + }, + { + "selected": false, + "label": "Denny Glass Cleaner", + "value": "Denny Glass Cleaner" + }, + { + "selected": false, + "label": "Denny Large Sponge", + "value": "Denny Large Sponge" + }, + { + "selected": false, + "label": "Denny Paper Cups", + "value": "Denny Paper Cups" + }, + { + "selected": false, + "label": "Denny Paper Plates", + "value": "Denny Paper Plates" + }, + { + "selected": false, + "label": "Denny Paper Towels", + "value": "Denny Paper Towels" + }, + { + "selected": false, + "label": "Denny Plastic Forks", + "value": "Denny Plastic Forks" + }, + { + "selected": false, + "label": "Denny Plastic Knives", + "value": "Denny Plastic Knives" + }, + { + "selected": false, + "label": "Denny Plastic Spoons", + "value": "Denny Plastic Spoons" + }, + { + "selected": false, + "label": "Denny Room Freshener", + "value": "Denny Room Freshener" + }, + { + "selected": false, + "label": "Denny Scented Tissue", + "value": "Denny Scented Tissue" + }, + { + "selected": false, + "label": "Denny Scented Toilet Tissue", + "value": "Denny Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Denny Scissors", + "value": "Denny Scissors" + }, + { + "selected": false, + "label": "Denny Screw Driver", + "value": "Denny Screw Driver" + }, + { + "selected": false, + "label": "Denny Silver Cleaner", + "value": "Denny Silver Cleaner" + }, + { + "selected": false, + "label": "Denny Soft Napkins", + "value": "Denny Soft Napkins" + }, + { + "selected": false, + "label": "Denny Tissues", + "value": "Denny Tissues" + }, + { + "selected": false, + "label": "Denny Toilet Bowl Cleaner", + "value": "Denny Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Denny Toilet Paper", + "value": "Denny Toilet Paper" + }, + { + "selected": false, + "label": "Discover Manicotti", + "value": "Discover Manicotti" + }, + { + "selected": false, + "label": "Discover Ravioli", + "value": "Discover Ravioli" + }, + { + "selected": false, + "label": "Discover Rice Medly", + "value": "Discover Rice Medly" + }, + { + "selected": false, + "label": "Discover Spaghetti", + "value": "Discover Spaghetti" + }, + { + "selected": false, + "label": "Discover Thai Rice", + "value": "Discover Thai Rice" + }, + { + "selected": false, + "label": "Dollar Monthly Auto Magazine", + "value": "Dollar Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Computer Magazine", + "value": "Dollar Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Fashion Magazine", + "value": "Dollar Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Home Magazine", + "value": "Dollar Monthly Home Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Sports Magazine", + "value": "Dollar Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Dual City Lox", + "value": "Dual City Lox" + }, + { + "selected": false, + "label": "Dual City Scallops", + "value": "Dual City Scallops" + }, + { + "selected": false, + "label": "Ebony Almonds", + "value": "Ebony Almonds" + }, + { + "selected": false, + "label": "Ebony Asparagus", + "value": "Ebony Asparagus" + }, + { + "selected": false, + "label": "Ebony Baby Onion", + "value": "Ebony Baby Onion" + }, + { + "selected": false, + "label": "Ebony Beets", + "value": "Ebony Beets" + }, + { + "selected": false, + "label": "Ebony Broccoli", + "value": "Ebony Broccoli" + }, + { + "selected": false, + "label": "Ebony Canned Peanuts", + "value": "Ebony Canned Peanuts" + }, + { + "selected": false, + "label": "Ebony Cantelope", + "value": "Ebony Cantelope" + }, + { + "selected": false, + "label": "Ebony Cauliflower", + "value": "Ebony Cauliflower" + }, + { + "selected": false, + "label": "Ebony Corn on the Cob", + "value": "Ebony Corn on the Cob" + }, + { + "selected": false, + "label": "Ebony Dried Mushrooms", + "value": "Ebony Dried Mushrooms" + }, + { + "selected": false, + "label": "Ebony Elephant Garlic", + "value": "Ebony Elephant Garlic" + }, + { + "selected": false, + "label": "Ebony Fancy Plums", + "value": "Ebony Fancy Plums" + }, + { + "selected": false, + "label": "Ebony Firm Tofu", + "value": "Ebony Firm Tofu" + }, + { + "selected": false, + "label": "Ebony Fresh Lima Beans", + "value": "Ebony Fresh Lima Beans" + }, + { + "selected": false, + "label": "Ebony Fuji Apples", + "value": "Ebony Fuji Apples" + }, + { + "selected": false, + "label": "Ebony Garlic", + "value": "Ebony Garlic" + }, + { + "selected": false, + "label": "Ebony Golden Delcious Apples", + "value": "Ebony Golden Delcious Apples" + }, + { + "selected": false, + "label": "Ebony Green Pepper", + "value": "Ebony Green Pepper" + }, + { + "selected": false, + "label": "Ebony Honey Dew", + "value": "Ebony Honey Dew" + }, + { + "selected": false, + "label": "Ebony Lemons", + "value": "Ebony Lemons" + }, + { + "selected": false, + "label": "Ebony Lettuce", + "value": "Ebony Lettuce" + }, + { + "selected": false, + "label": "Ebony Limes", + "value": "Ebony Limes" + }, + { + "selected": false, + "label": "Ebony Macintosh Apples", + "value": "Ebony Macintosh Apples" + }, + { + "selected": false, + "label": "Ebony Mandarin Oranges", + "value": "Ebony Mandarin Oranges" + }, + { + "selected": false, + "label": "Ebony Mixed Nuts", + "value": "Ebony Mixed Nuts" + }, + { + "selected": false, + "label": "Ebony Mushrooms", + "value": "Ebony Mushrooms" + }, + { + "selected": false, + "label": "Ebony New Potatos", + "value": "Ebony New Potatos" + }, + { + "selected": false, + "label": "Ebony Onions", + "value": "Ebony Onions" + }, + { + "selected": false, + "label": "Ebony Oranges", + "value": "Ebony Oranges" + }, + { + "selected": false, + "label": "Ebony Party Nuts", + "value": "Ebony Party Nuts" + }, + { + "selected": false, + "label": "Ebony Peaches", + "value": "Ebony Peaches" + }, + { + "selected": false, + "label": "Ebony Plums", + "value": "Ebony Plums" + }, + { + "selected": false, + "label": "Ebony Potatos", + "value": "Ebony Potatos" + }, + { + "selected": false, + "label": "Ebony Prepared Salad", + "value": "Ebony Prepared Salad" + }, + { + "selected": false, + "label": "Ebony Red Delcious Apples", + "value": "Ebony Red Delcious Apples" + }, + { + "selected": false, + "label": "Ebony Red Pepper", + "value": "Ebony Red Pepper" + }, + { + "selected": false, + "label": "Ebony Shitake Mushrooms", + "value": "Ebony Shitake Mushrooms" + }, + { + "selected": false, + "label": "Ebony Squash", + "value": "Ebony Squash" + }, + { + "selected": false, + "label": "Ebony Summer Squash", + "value": "Ebony Summer Squash" + }, + { + "selected": false, + "label": "Ebony Sweet Onion", + "value": "Ebony Sweet Onion" + }, + { + "selected": false, + "label": "Ebony Sweet Peas", + "value": "Ebony Sweet Peas" + }, + { + "selected": false, + "label": "Ebony Tangerines", + "value": "Ebony Tangerines" + }, + { + "selected": false, + "label": "Ebony Tomatos", + "value": "Ebony Tomatos" + }, + { + "selected": false, + "label": "Ebony Walnuts", + "value": "Ebony Walnuts" + }, + { + "selected": false, + "label": "Even Better 1% Milk", + "value": "Even Better 1% Milk" + }, + { + "selected": false, + "label": "Even Better 2% Milk", + "value": "Even Better 2% Milk" + }, + { + "selected": false, + "label": "Even Better Blueberry Yogurt", + "value": "Even Better Blueberry Yogurt" + }, + { + "selected": false, + "label": "Even Better Buttermilk", + "value": "Even Better Buttermilk" + }, + { + "selected": false, + "label": "Even Better Cheese Spread", + "value": "Even Better Cheese Spread" + }, + { + "selected": false, + "label": "Even Better Chocolate Milk", + "value": "Even Better Chocolate Milk" + }, + { + "selected": false, + "label": "Even Better Havarti Cheese", + "value": "Even Better Havarti Cheese" + }, + { + "selected": false, + "label": "Even Better Head Cheese", + "value": "Even Better Head Cheese" + }, + { + "selected": false, + "label": "Even Better Jack Cheese", + "value": "Even Better Jack Cheese" + }, + { + "selected": false, + "label": "Even Better Large Curd Cottage Cheese", + "value": "Even Better Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Even Better Low Fat Cottage Cheese", + "value": "Even Better Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Even Better Low Fat Sour Cream", + "value": "Even Better Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Even Better Low Fat String Cheese", + "value": "Even Better Low Fat String Cheese" + }, + { + "selected": false, + "label": "Even Better Mild Cheddar Cheese", + "value": "Even Better Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Even Better Muenster Cheese", + "value": "Even Better Muenster Cheese" + }, + { + "selected": false, + "label": "Even Better Sharp Cheddar Cheese", + "value": "Even Better Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Even Better Sour Cream", + "value": "Even Better Sour Cream" + }, + { + "selected": false, + "label": "Even Better Strawberry Yogurt", + "value": "Even Better Strawberry Yogurt" + }, + { + "selected": false, + "label": "Even Better String Cheese", + "value": "Even Better String Cheese" + }, + { + "selected": false, + "label": "Even Better Whole Milk", + "value": "Even Better Whole Milk" + }, + { + "selected": false, + "label": "Excellent Apple Drink", + "value": "Excellent Apple Drink" + }, + { + "selected": false, + "label": "Excellent Apple Juice", + "value": "Excellent Apple Juice" + }, + { + "selected": false, + "label": "Excellent Berry Juice", + "value": "Excellent Berry Juice" + }, + { + "selected": false, + "label": "Excellent Cola", + "value": "Excellent Cola" + }, + { + "selected": false, + "label": "Excellent Cranberry Juice", + "value": "Excellent Cranberry Juice" + }, + { + "selected": false, + "label": "Excellent Cream Soda", + "value": "Excellent Cream Soda" + }, + { + "selected": false, + "label": "Excellent Diet Cola", + "value": "Excellent Diet Cola" + }, + { + "selected": false, + "label": "Excellent Diet Soda", + "value": "Excellent Diet Soda" + }, + { + "selected": false, + "label": "Excellent Mango Drink", + "value": "Excellent Mango Drink" + }, + { + "selected": false, + "label": "Excellent Orange Juice", + "value": "Excellent Orange Juice" + }, + { + "selected": false, + "label": "Excellent Strawberry Drink", + "value": "Excellent Strawberry Drink" + }, + { + "selected": false, + "label": "Excel Monthly Auto Magazine", + "value": "Excel Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Computer Magazine", + "value": "Excel Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Fashion Magazine", + "value": "Excel Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Home Magazine", + "value": "Excel Monthly Home Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Sports Magazine", + "value": "Excel Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Fabulous Apple Drink", + "value": "Fabulous Apple Drink" + }, + { + "selected": false, + "label": "Fabulous Apple Juice", + "value": "Fabulous Apple Juice" + }, + { + "selected": false, + "label": "Fabulous Berry Juice", + "value": "Fabulous Berry Juice" + }, + { + "selected": false, + "label": "Fabulous Cola", + "value": "Fabulous Cola" + }, + { + "selected": false, + "label": "Fabulous Cranberry Juice", + "value": "Fabulous Cranberry Juice" + }, + { + "selected": false, + "label": "Fabulous Cream Soda", + "value": "Fabulous Cream Soda" + }, + { + "selected": false, + "label": "Fabulous Diet Cola", + "value": "Fabulous Diet Cola" + }, + { + "selected": false, + "label": "Fabulous Diet Soda", + "value": "Fabulous Diet Soda" + }, + { + "selected": false, + "label": "Fabulous Mango Drink", + "value": "Fabulous Mango Drink" + }, + { + "selected": false, + "label": "Fabulous Orange Juice", + "value": "Fabulous Orange Juice" + }, + { + "selected": false, + "label": "Fabulous Strawberry Drink", + "value": "Fabulous Strawberry Drink" + }, + { + "selected": false, + "label": "Fantastic Bagels", + "value": "Fantastic Bagels" + }, + { + "selected": false, + "label": "Fantastic Blueberry Muffins", + "value": "Fantastic Blueberry Muffins" + }, + { + "selected": false, + "label": "Fantastic Cranberry Muffins", + "value": "Fantastic Cranberry Muffins" + }, + { + "selected": false, + "label": "Fantastic English Muffins", + "value": "Fantastic English Muffins" + }, + { + "selected": false, + "label": "Fantastic Muffins", + "value": "Fantastic Muffins" + }, + { + "selected": false, + "label": "Fantastic Pumpernickel Bread", + "value": "Fantastic Pumpernickel Bread" + }, + { + "selected": false, + "label": "Fantastic Rye Bread", + "value": "Fantastic Rye Bread" + }, + { + "selected": false, + "label": "Fantastic Wheat Bread", + "value": "Fantastic Wheat Bread" + }, + { + "selected": false, + "label": "Fantastic White Bread", + "value": "Fantastic White Bread" + }, + { + "selected": false, + "label": "Fast Apple Fruit Roll", + "value": "Fast Apple Fruit Roll" + }, + { + "selected": false, + "label": "Fast Avocado Dip", + "value": "Fast Avocado Dip" + }, + { + "selected": false, + "label": "Fast BBQ Potato Chips", + "value": "Fast BBQ Potato Chips" + }, + { + "selected": false, + "label": "Fast Beef Jerky", + "value": "Fast Beef Jerky" + }, + { + "selected": false, + "label": "Fast Buttered Popcorn", + "value": "Fast Buttered Popcorn" + }, + { + "selected": false, + "label": "Fast Cheese Crackers", + "value": "Fast Cheese Crackers" + }, + { + "selected": false, + "label": "Fast Cheese Dip", + "value": "Fast Cheese Dip" + }, + { + "selected": false, + "label": "Fast Chocolate Chip Cookies", + "value": "Fast Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Fast Chocolate Donuts", + "value": "Fast Chocolate Donuts" + }, + { + "selected": false, + "label": "Fast Corn Chips", + "value": "Fast Corn Chips" + }, + { + "selected": false, + "label": "Fast Dried Apples", + "value": "Fast Dried Apples" + }, + { + "selected": false, + "label": "Fast Dried Apricots", + "value": "Fast Dried Apricots" + }, + { + "selected": false, + "label": "Fast Dried Dates", + "value": "Fast Dried Dates" + }, + { + "selected": false, + "label": "Fast Fondue Mix", + "value": "Fast Fondue Mix" + }, + { + "selected": false, + "label": "Fast Frosted Cookies", + "value": "Fast Frosted Cookies" + }, + { + "selected": false, + "label": "Fast Frosted Donuts", + "value": "Fast Frosted Donuts" + }, + { + "selected": false, + "label": "Fast Fudge Brownies", + "value": "Fast Fudge Brownies" + }, + { + "selected": false, + "label": "Fast Fudge Cookies", + "value": "Fast Fudge Cookies" + }, + { + "selected": false, + "label": "Fast Golden Raisins", + "value": "Fast Golden Raisins" + }, + { + "selected": false, + "label": "Fast Graham Crackers", + "value": "Fast Graham Crackers" + }, + { + "selected": false, + "label": "Fast Grape Fruit Roll", + "value": "Fast Grape Fruit Roll" + }, + { + "selected": false, + "label": "Fast Lemon Cookies", + "value": "Fast Lemon Cookies" + }, + { + "selected": false, + "label": "Fast Low Fat BBQ Chips", + "value": "Fast Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Fast Low Fat Chips", + "value": "Fast Low Fat Chips" + }, + { + "selected": false, + "label": "Fast Low Fat Cookies", + "value": "Fast Low Fat Cookies" + }, + { + "selected": false, + "label": "Fast Low Fat Popcorn", + "value": "Fast Low Fat Popcorn" + }, + { + "selected": false, + "label": "Fast Mini Donuts", + "value": "Fast Mini Donuts" + }, + { + "selected": false, + "label": "Fast No Salt Popcorn", + "value": "Fast No Salt Popcorn" + }, + { + "selected": false, + "label": "Fast Potato Chips", + "value": "Fast Potato Chips" + }, + { + "selected": false, + "label": "Fast Raisins", + "value": "Fast Raisins" + }, + { + "selected": false, + "label": "Fast Raspberry Fruit Roll", + "value": "Fast Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Fast Salsa Dip", + "value": "Fast Salsa Dip" + }, + { + "selected": false, + "label": "Fast Salted Pretzels", + "value": "Fast Salted Pretzels" + }, + { + "selected": false, + "label": "Fast Sesame Crackers", + "value": "Fast Sesame Crackers" + }, + { + "selected": false, + "label": "Fast Strawberry Fruit Roll", + "value": "Fast Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Fast Sugar Cookies", + "value": "Fast Sugar Cookies" + }, + { + "selected": false, + "label": "Faux Products 200 MG Acetominifen", + "value": "Faux Products 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Faux Products 200 MG Ibuprofen", + "value": "Faux Products 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Faux Products Angled Toothbrush", + "value": "Faux Products Angled Toothbrush" + }, + { + "selected": false, + "label": "Faux Products Apricot Shampoo", + "value": "Faux Products Apricot Shampoo" + }, + { + "selected": false, + "label": "Faux Products Buffered Aspirin", + "value": "Faux Products Buffered Aspirin" + }, + { + "selected": false, + "label": "Faux Products Childrens Aspirin", + "value": "Faux Products Childrens Aspirin" + }, + { + "selected": false, + "label": "Faux Products Childrens Cold Remedy", + "value": "Faux Products Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Faux Products Conditioning Shampoo", + "value": "Faux Products Conditioning Shampoo" + }, + { + "selected": false, + "label": "Faux Products Deodorant", + "value": "Faux Products Deodorant" + }, + { + "selected": false, + "label": "Faux Products Dishwasher Detergent", + "value": "Faux Products Dishwasher Detergent" + }, + { + "selected": false, + "label": "Faux Products Extra Moisture Shampoo", + "value": "Faux Products Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Faux Products HCL Nasal Spray", + "value": "Faux Products HCL Nasal Spray" + }, + { + "selected": false, + "label": "Faux Products Laundry Detergent", + "value": "Faux Products Laundry Detergent" + }, + { + "selected": false, + "label": "Faux Products Mint Mouthwash", + "value": "Faux Products Mint Mouthwash" + }, + { + "selected": false, + "label": "Faux Products Multi-Symptom Cold Remedy", + "value": "Faux Products Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Faux Products Silky Smooth Hair Conditioner", + "value": "Faux Products Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Faux Products Tartar Control Toothpaste", + "value": "Faux Products Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Faux Products Toothpaste", + "value": "Faux Products Toothpaste" + }, + { + "selected": false, + "label": "Faux Products Whitening Toothpast", + "value": "Faux Products Whitening Toothpast" + }, + { + "selected": false, + "label": "Footnote Extra Lean Hamburger", + "value": "Footnote Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Footnote Seasoned Hamburger", + "value": "Footnote Seasoned Hamburger" + }, + { + "selected": false, + "label": "Fort West Apple Fruit Roll", + "value": "Fort West Apple Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Avocado Dip", + "value": "Fort West Avocado Dip" + }, + { + "selected": false, + "label": "Fort West BBQ Potato Chips", + "value": "Fort West BBQ Potato Chips" + }, + { + "selected": false, + "label": "Fort West Beef Jerky", + "value": "Fort West Beef Jerky" + }, + { + "selected": false, + "label": "Fort West Buttered Popcorn", + "value": "Fort West Buttered Popcorn" + }, + { + "selected": false, + "label": "Fort West Cheese Crackers", + "value": "Fort West Cheese Crackers" + }, + { + "selected": false, + "label": "Fort West Cheese Dip", + "value": "Fort West Cheese Dip" + }, + { + "selected": false, + "label": "Fort West Chocolate Chip Cookies", + "value": "Fort West Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Fort West Chocolate Donuts", + "value": "Fort West Chocolate Donuts" + }, + { + "selected": false, + "label": "Fort West Corn Chips", + "value": "Fort West Corn Chips" + }, + { + "selected": false, + "label": "Fort West Dried Apples", + "value": "Fort West Dried Apples" + }, + { + "selected": false, + "label": "Fort West Dried Apricots", + "value": "Fort West Dried Apricots" + }, + { + "selected": false, + "label": "Fort West Dried Dates", + "value": "Fort West Dried Dates" + }, + { + "selected": false, + "label": "Fort West Fondue Mix", + "value": "Fort West Fondue Mix" + }, + { + "selected": false, + "label": "Fort West Frosted Cookies", + "value": "Fort West Frosted Cookies" + }, + { + "selected": false, + "label": "Fort West Frosted Donuts", + "value": "Fort West Frosted Donuts" + }, + { + "selected": false, + "label": "Fort West Fudge Brownies", + "value": "Fort West Fudge Brownies" + }, + { + "selected": false, + "label": "Fort West Fudge Cookies", + "value": "Fort West Fudge Cookies" + }, + { + "selected": false, + "label": "Fort West Golden Raisins", + "value": "Fort West Golden Raisins" + }, + { + "selected": false, + "label": "Fort West Graham Crackers", + "value": "Fort West Graham Crackers" + }, + { + "selected": false, + "label": "Fort West Grape Fruit Roll", + "value": "Fort West Grape Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Lemon Cookies", + "value": "Fort West Lemon Cookies" + }, + { + "selected": false, + "label": "Fort West Low Fat BBQ Chips", + "value": "Fort West Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Fort West Low Fat Chips", + "value": "Fort West Low Fat Chips" + }, + { + "selected": false, + "label": "Fort West Low Fat Cookies", + "value": "Fort West Low Fat Cookies" + }, + { + "selected": false, + "label": "Fort West Low Fat Popcorn", + "value": "Fort West Low Fat Popcorn" + }, + { + "selected": false, + "label": "Fort West Mini Donuts", + "value": "Fort West Mini Donuts" + }, + { + "selected": false, + "label": "Fort West No Salt Popcorn", + "value": "Fort West No Salt Popcorn" + }, + { + "selected": false, + "label": "Fort West Potato Chips", + "value": "Fort West Potato Chips" + }, + { + "selected": false, + "label": "Fort West Raisins", + "value": "Fort West Raisins" + }, + { + "selected": false, + "label": "Fort West Raspberry Fruit Roll", + "value": "Fort West Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Salsa Dip", + "value": "Fort West Salsa Dip" + }, + { + "selected": false, + "label": "Fort West Salted Pretzels", + "value": "Fort West Salted Pretzels" + }, + { + "selected": false, + "label": "Fort West Sesame Crackers", + "value": "Fort West Sesame Crackers" + }, + { + "selected": false, + "label": "Fort West Strawberry Fruit Roll", + "value": "Fort West Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Sugar Cookies", + "value": "Fort West Sugar Cookies" + }, + { + "selected": false, + "label": "Framton City Map", + "value": "Framton City Map" + }, + { + "selected": false, + "label": "Framton Eyeglass Screwdriver", + "value": "Framton Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Gauss Monthly Auto Magazine", + "value": "Gauss Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Computer Magazine", + "value": "Gauss Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Fashion Magazine", + "value": "Gauss Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Home Magazine", + "value": "Gauss Monthly Home Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Sports Magazine", + "value": "Gauss Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Genteel Extra Lean Hamburger", + "value": "Genteel Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Genteel Seasoned Hamburger", + "value": "Genteel Seasoned Hamburger" + }, + { + "selected": false, + "label": "Gerolli Extra Lean Hamburger", + "value": "Gerolli Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Gerolli Seasoned Hamburger", + "value": "Gerolli Seasoned Hamburger" + }, + { + "selected": false, + "label": "Giant Egg Substitute", + "value": "Giant Egg Substitute" + }, + { + "selected": false, + "label": "Giant Large Brown Eggs", + "value": "Giant Large Brown Eggs" + }, + { + "selected": false, + "label": "Giant Large Eggs", + "value": "Giant Large Eggs" + }, + { + "selected": false, + "label": "Giant Small Brown Eggs", + "value": "Giant Small Brown Eggs" + }, + { + "selected": false, + "label": "Giant Small Eggs", + "value": "Giant Small Eggs" + }, + { + "selected": false, + "label": "Golden Apple Cinnamon Waffles", + "value": "Golden Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Golden Beef TV Dinner", + "value": "Golden Beef TV Dinner" + }, + { + "selected": false, + "label": "Golden Blueberry Waffles", + "value": "Golden Blueberry Waffles" + }, + { + "selected": false, + "label": "Golden Chicken TV Dinner", + "value": "Golden Chicken TV Dinner" + }, + { + "selected": false, + "label": "Golden Fajita French Fries", + "value": "Golden Fajita French Fries" + }, + { + "selected": false, + "label": "Golden Frozen Broccoli", + "value": "Golden Frozen Broccoli" + }, + { + "selected": false, + "label": "Golden Frozen Carrots", + "value": "Golden Frozen Carrots" + }, + { + "selected": false, + "label": "Golden Frozen Cauliflower", + "value": "Golden Frozen Cauliflower" + }, + { + "selected": false, + "label": "Golden Frozen Cheese Pizza", + "value": "Golden Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Breast", + "value": "Golden Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Thighs", + "value": "Golden Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Wings", + "value": "Golden Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Golden Frozen Corn", + "value": "Golden Frozen Corn" + }, + { + "selected": false, + "label": "Golden Frozen Mushroom Pizza", + "value": "Golden Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Pancakes", + "value": "Golden Frozen Pancakes" + }, + { + "selected": false, + "label": "Golden Frozen Peas", + "value": "Golden Frozen Peas" + }, + { + "selected": false, + "label": "Golden Frozen Pepperoni Pizza", + "value": "Golden Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Sausage Pizza", + "value": "Golden Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Golden Grape Popsicles", + "value": "Golden Grape Popsicles" + }, + { + "selected": false, + "label": "Golden Home Style French Fries", + "value": "Golden Home Style French Fries" + }, + { + "selected": false, + "label": "Golden Ice Cream", + "value": "Golden Ice Cream" + }, + { + "selected": false, + "label": "Golden Ice Cream Sandwich", + "value": "Golden Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Golden Lemon Popsicles", + "value": "Golden Lemon Popsicles" + }, + { + "selected": false, + "label": "Golden Lime Popsicles", + "value": "Golden Lime Popsicles" + }, + { + "selected": false, + "label": "Golden Low Fat French Fries", + "value": "Golden Low Fat French Fries" + }, + { + "selected": false, + "label": "Golden Low Fat Waffles", + "value": "Golden Low Fat Waffles" + }, + { + "selected": false, + "label": "Golden Orange Popsicles", + "value": "Golden Orange Popsicles" + }, + { + "selected": false, + "label": "Golden Pancake Mix", + "value": "Golden Pancake Mix" + }, + { + "selected": false, + "label": "Golden Popsicles", + "value": "Golden Popsicles" + }, + { + "selected": false, + "label": "Golden Turkey TV Dinner", + "value": "Golden Turkey TV Dinner" + }, + { + "selected": false, + "label": "Golden Waffles", + "value": "Golden Waffles" + }, + { + "selected": false, + "label": "Good Chablis Wine", + "value": "Good Chablis Wine" + }, + { + "selected": false, + "label": "Good Chardonnay", + "value": "Good Chardonnay" + }, + { + "selected": false, + "label": "Good Chardonnay Wine", + "value": "Good Chardonnay Wine" + }, + { + "selected": false, + "label": "Good Imported Beer", + "value": "Good Imported Beer" + }, + { + "selected": false, + "label": "Good Light Beer", + "value": "Good Light Beer" + }, + { + "selected": false, + "label": "Good Light Wine", + "value": "Good Light Wine" + }, + { + "selected": false, + "label": "Good Merlot Wine", + "value": "Good Merlot Wine" + }, + { + "selected": false, + "label": "Good White Zinfandel Wine", + "value": "Good White Zinfandel Wine" + }, + { + "selected": false, + "label": "Gorilla 1% Milk", + "value": "Gorilla 1% Milk" + }, + { + "selected": false, + "label": "Gorilla 2% Milk", + "value": "Gorilla 2% Milk" + }, + { + "selected": false, + "label": "Gorilla Blueberry Yogurt", + "value": "Gorilla Blueberry Yogurt" + }, + { + "selected": false, + "label": "Gorilla Buttermilk", + "value": "Gorilla Buttermilk" + }, + { + "selected": false, + "label": "Gorilla Cheese Spread", + "value": "Gorilla Cheese Spread" + }, + { + "selected": false, + "label": "Gorilla Chocolate Milk", + "value": "Gorilla Chocolate Milk" + }, + { + "selected": false, + "label": "Gorilla Havarti Cheese", + "value": "Gorilla Havarti Cheese" + }, + { + "selected": false, + "label": "Gorilla Head Cheese", + "value": "Gorilla Head Cheese" + }, + { + "selected": false, + "label": "Gorilla Jack Cheese", + "value": "Gorilla Jack Cheese" + }, + { + "selected": false, + "label": "Gorilla Large Curd Cottage Cheese", + "value": "Gorilla Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Gorilla Low Fat Cottage Cheese", + "value": "Gorilla Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Gorilla Low Fat Sour Cream", + "value": "Gorilla Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Gorilla Low Fat String Cheese", + "value": "Gorilla Low Fat String Cheese" + }, + { + "selected": false, + "label": "Gorilla Mild Cheddar Cheese", + "value": "Gorilla Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Gorilla Muenster Cheese", + "value": "Gorilla Muenster Cheese" + }, + { + "selected": false, + "label": "Gorilla Sharp Cheddar Cheese", + "value": "Gorilla Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Gorilla Sour Cream", + "value": "Gorilla Sour Cream" + }, + { + "selected": false, + "label": "Gorilla Strawberry Yogurt", + "value": "Gorilla Strawberry Yogurt" + }, + { + "selected": false, + "label": "Gorilla String Cheese", + "value": "Gorilla String Cheese" + }, + { + "selected": false, + "label": "Gorilla Whole Milk", + "value": "Gorilla Whole Milk" + }, + { + "selected": false, + "label": "Great Bagels", + "value": "Great Bagels" + }, + { + "selected": false, + "label": "Great Blueberry Muffins", + "value": "Great Blueberry Muffins" + }, + { + "selected": false, + "label": "Great Cranberry Muffins", + "value": "Great Cranberry Muffins" + }, + { + "selected": false, + "label": "Great English Muffins", + "value": "Great English Muffins" + }, + { + "selected": false, + "label": "Great Muffins", + "value": "Great Muffins" + }, + { + "selected": false, + "label": "Great Pumpernickel Bread", + "value": "Great Pumpernickel Bread" + }, + { + "selected": false, + "label": "Great Rye Bread", + "value": "Great Rye Bread" + }, + { + "selected": false, + "label": "Great Wheat Bread", + "value": "Great Wheat Bread" + }, + { + "selected": false, + "label": "Great White Bread", + "value": "Great White Bread" + }, + { + "selected": false, + "label": "Green Ribbon Canned Mixed Fruit", + "value": "Green Ribbon Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Green Ribbon Canned Peaches", + "value": "Green Ribbon Canned Peaches" + }, + { + "selected": false, + "label": "Gulf Coast Bubble Gum", + "value": "Gulf Coast Bubble Gum" + }, + { + "selected": false, + "label": "Gulf Coast Malted Milk Balls", + "value": "Gulf Coast Malted Milk Balls" + }, + { + "selected": false, + "label": "Gulf Coast Mint Chocolate Bar", + "value": "Gulf Coast Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Gulf Coast Mints", + "value": "Gulf Coast Mints" + }, + { + "selected": false, + "label": "Gulf Coast Semi-Sweet Chocolate Bar", + "value": "Gulf Coast Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Gulf Coast Spicy Mints", + "value": "Gulf Coast Spicy Mints" + }, + { + "selected": false, + "label": "Gulf Coast Tasty Candy Bar", + "value": "Gulf Coast Tasty Candy Bar" + }, + { + "selected": false, + "label": "Gulf Coast White Chocolate Bar", + "value": "Gulf Coast White Chocolate Bar" + }, + { + "selected": false, + "label": "Hermanos Almonds", + "value": "Hermanos Almonds" + }, + { + "selected": false, + "label": "Hermanos Asparagus", + "value": "Hermanos Asparagus" + }, + { + "selected": false, + "label": "Hermanos Baby Onion", + "value": "Hermanos Baby Onion" + }, + { + "selected": false, + "label": "Hermanos Beets", + "value": "Hermanos Beets" + }, + { + "selected": false, + "label": "Hermanos Broccoli", + "value": "Hermanos Broccoli" + }, + { + "selected": false, + "label": "Hermanos Canned Peanuts", + "value": "Hermanos Canned Peanuts" + }, + { + "selected": false, + "label": "Hermanos Cantelope", + "value": "Hermanos Cantelope" + }, + { + "selected": false, + "label": "Hermanos Cauliflower", + "value": "Hermanos Cauliflower" + }, + { + "selected": false, + "label": "Hermanos Corn on the Cob", + "value": "Hermanos Corn on the Cob" + }, + { + "selected": false, + "label": "Hermanos Dried Mushrooms", + "value": "Hermanos Dried Mushrooms" + }, + { + "selected": false, + "label": "Hermanos Elephant Garlic", + "value": "Hermanos Elephant Garlic" + }, + { + "selected": false, + "label": "Hermanos Fancy Plums", + "value": "Hermanos Fancy Plums" + }, + { + "selected": false, + "label": "Hermanos Firm Tofu", + "value": "Hermanos Firm Tofu" + }, + { + "selected": false, + "label": "Hermanos Fresh Lima Beans", + "value": "Hermanos Fresh Lima Beans" + }, + { + "selected": false, + "label": "Hermanos Fuji Apples", + "value": "Hermanos Fuji Apples" + }, + { + "selected": false, + "label": "Hermanos Garlic", + "value": "Hermanos Garlic" + }, + { + "selected": false, + "label": "Hermanos Golden Delcious Apples", + "value": "Hermanos Golden Delcious Apples" + }, + { + "selected": false, + "label": "Hermanos Green Pepper", + "value": "Hermanos Green Pepper" + }, + { + "selected": false, + "label": "Hermanos Honey Dew", + "value": "Hermanos Honey Dew" + }, + { + "selected": false, + "label": "Hermanos Lemons", + "value": "Hermanos Lemons" + }, + { + "selected": false, + "label": "Hermanos Lettuce", + "value": "Hermanos Lettuce" + }, + { + "selected": false, + "label": "Hermanos Limes", + "value": "Hermanos Limes" + }, + { + "selected": false, + "label": "Hermanos Macintosh Apples", + "value": "Hermanos Macintosh Apples" + }, + { + "selected": false, + "label": "Hermanos Mandarin Oranges", + "value": "Hermanos Mandarin Oranges" + }, + { + "selected": false, + "label": "Hermanos Mixed Nuts", + "value": "Hermanos Mixed Nuts" + }, + { + "selected": false, + "label": "Hermanos Mushrooms", + "value": "Hermanos Mushrooms" + }, + { + "selected": false, + "label": "Hermanos New Potatos", + "value": "Hermanos New Potatos" + }, + { + "selected": false, + "label": "Hermanos Onions", + "value": "Hermanos Onions" + }, + { + "selected": false, + "label": "Hermanos Oranges", + "value": "Hermanos Oranges" + }, + { + "selected": false, + "label": "Hermanos Party Nuts", + "value": "Hermanos Party Nuts" + }, + { + "selected": false, + "label": "Hermanos Peaches", + "value": "Hermanos Peaches" + }, + { + "selected": false, + "label": "Hermanos Plums", + "value": "Hermanos Plums" + }, + { + "selected": false, + "label": "Hermanos Potatos", + "value": "Hermanos Potatos" + }, + { + "selected": false, + "label": "Hermanos Prepared Salad", + "value": "Hermanos Prepared Salad" + }, + { + "selected": false, + "label": "Hermanos Red Delcious Apples", + "value": "Hermanos Red Delcious Apples" + }, + { + "selected": false, + "label": "Hermanos Red Pepper", + "value": "Hermanos Red Pepper" + }, + { + "selected": false, + "label": "Hermanos Shitake Mushrooms", + "value": "Hermanos Shitake Mushrooms" + }, + { + "selected": false, + "label": "Hermanos Squash", + "value": "Hermanos Squash" + }, + { + "selected": false, + "label": "Hermanos Summer Squash", + "value": "Hermanos Summer Squash" + }, + { + "selected": false, + "label": "Hermanos Sweet Onion", + "value": "Hermanos Sweet Onion" + }, + { + "selected": false, + "label": "Hermanos Sweet Peas", + "value": "Hermanos Sweet Peas" + }, + { + "selected": false, + "label": "Hermanos Tangerines", + "value": "Hermanos Tangerines" + }, + { + "selected": false, + "label": "Hermanos Tomatos", + "value": "Hermanos Tomatos" + }, + { + "selected": false, + "label": "Hermanos Walnuts", + "value": "Hermanos Walnuts" + }, + { + "selected": false, + "label": "High Quality 100 Watt Lightbulb", + "value": "High Quality 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 25 Watt Lightbulb", + "value": "High Quality 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 60 Watt Lightbulb", + "value": "High Quality 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 75 Watt Lightbulb", + "value": "High Quality 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality AAA-Size Batteries", + "value": "High Quality AAA-Size Batteries" + }, + { + "selected": false, + "label": "High Quality AA-Size Batteries", + "value": "High Quality AA-Size Batteries" + }, + { + "selected": false, + "label": "High Quality Bees Wax Candles", + "value": "High Quality Bees Wax Candles" + }, + { + "selected": false, + "label": "High Quality Copper Cleaner", + "value": "High Quality Copper Cleaner" + }, + { + "selected": false, + "label": "High Quality Copper Pot Scrubber", + "value": "High Quality Copper Pot Scrubber" + }, + { + "selected": false, + "label": "High Quality Counter Cleaner", + "value": "High Quality Counter Cleaner" + }, + { + "selected": false, + "label": "High Quality C-Size Batteries", + "value": "High Quality C-Size Batteries" + }, + { + "selected": false, + "label": "High Quality D-Size Batteries", + "value": "High Quality D-Size Batteries" + }, + { + "selected": false, + "label": "High Quality Economy Toilet Brush", + "value": "High Quality Economy Toilet Brush" + }, + { + "selected": false, + "label": "High Quality Frying Pan", + "value": "High Quality Frying Pan" + }, + { + "selected": false, + "label": "High Quality Glass Cleaner", + "value": "High Quality Glass Cleaner" + }, + { + "selected": false, + "label": "High Quality Large Sponge", + "value": "High Quality Large Sponge" + }, + { + "selected": false, + "label": "High Quality Paper Cups", + "value": "High Quality Paper Cups" + }, + { + "selected": false, + "label": "High Quality Paper Plates", + "value": "High Quality Paper Plates" + }, + { + "selected": false, + "label": "High Quality Paper Towels", + "value": "High Quality Paper Towels" + }, + { + "selected": false, + "label": "High Quality Plastic Forks", + "value": "High Quality Plastic Forks" + }, + { + "selected": false, + "label": "High Quality Plastic Knives", + "value": "High Quality Plastic Knives" + }, + { + "selected": false, + "label": "High Quality Plastic Spoons", + "value": "High Quality Plastic Spoons" + }, + { + "selected": false, + "label": "High Quality Room Freshener", + "value": "High Quality Room Freshener" + }, + { + "selected": false, + "label": "High Quality Scented Tissue", + "value": "High Quality Scented Tissue" + }, + { + "selected": false, + "label": "High Quality Scented Toilet Tissue", + "value": "High Quality Scented Toilet Tissue" + }, + { + "selected": false, + "label": "High Quality Scissors", + "value": "High Quality Scissors" + }, + { + "selected": false, + "label": "High Quality Screw Driver", + "value": "High Quality Screw Driver" + }, + { + "selected": false, + "label": "High Quality Silver Cleaner", + "value": "High Quality Silver Cleaner" + }, + { + "selected": false, + "label": "High Quality Soft Napkins", + "value": "High Quality Soft Napkins" + }, + { + "selected": false, + "label": "High Quality Tissues", + "value": "High Quality Tissues" + }, + { + "selected": false, + "label": "High Quality Toilet Bowl Cleaner", + "value": "High Quality Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "High Quality Toilet Paper", + "value": "High Quality Toilet Paper" + }, + { + "selected": false, + "label": "High Top Almonds", + "value": "High Top Almonds" + }, + { + "selected": false, + "label": "High Top Asparagus", + "value": "High Top Asparagus" + }, + { + "selected": false, + "label": "High Top Baby Onion", + "value": "High Top Baby Onion" + }, + { + "selected": false, + "label": "High Top Beets", + "value": "High Top Beets" + }, + { + "selected": false, + "label": "High Top Broccoli", + "value": "High Top Broccoli" + }, + { + "selected": false, + "label": "High Top Canned Peanuts", + "value": "High Top Canned Peanuts" + }, + { + "selected": false, + "label": "High Top Cantelope", + "value": "High Top Cantelope" + }, + { + "selected": false, + "label": "High Top Cauliflower", + "value": "High Top Cauliflower" + }, + { + "selected": false, + "label": "High Top Corn on the Cob", + "value": "High Top Corn on the Cob" + }, + { + "selected": false, + "label": "High Top Dried Mushrooms", + "value": "High Top Dried Mushrooms" + }, + { + "selected": false, + "label": "High Top Elephant Garlic", + "value": "High Top Elephant Garlic" + }, + { + "selected": false, + "label": "High Top Fancy Plums", + "value": "High Top Fancy Plums" + }, + { + "selected": false, + "label": "High Top Firm Tofu", + "value": "High Top Firm Tofu" + }, + { + "selected": false, + "label": "High Top Fresh Lima Beans", + "value": "High Top Fresh Lima Beans" + }, + { + "selected": false, + "label": "High Top Fuji Apples", + "value": "High Top Fuji Apples" + }, + { + "selected": false, + "label": "High Top Garlic", + "value": "High Top Garlic" + }, + { + "selected": false, + "label": "High Top Golden Delcious Apples", + "value": "High Top Golden Delcious Apples" + }, + { + "selected": false, + "label": "High Top Green Pepper", + "value": "High Top Green Pepper" + }, + { + "selected": false, + "label": "High Top Honey Dew", + "value": "High Top Honey Dew" + }, + { + "selected": false, + "label": "High Top Lemons", + "value": "High Top Lemons" + }, + { + "selected": false, + "label": "High Top Lettuce", + "value": "High Top Lettuce" + }, + { + "selected": false, + "label": "High Top Limes", + "value": "High Top Limes" + }, + { + "selected": false, + "label": "High Top Macintosh Apples", + "value": "High Top Macintosh Apples" + }, + { + "selected": false, + "label": "High Top Mandarin Oranges", + "value": "High Top Mandarin Oranges" + }, + { + "selected": false, + "label": "High Top Mixed Nuts", + "value": "High Top Mixed Nuts" + }, + { + "selected": false, + "label": "High Top Mushrooms", + "value": "High Top Mushrooms" + }, + { + "selected": false, + "label": "High Top New Potatos", + "value": "High Top New Potatos" + }, + { + "selected": false, + "label": "High Top Onions", + "value": "High Top Onions" + }, + { + "selected": false, + "label": "High Top Oranges", + "value": "High Top Oranges" + }, + { + "selected": false, + "label": "High Top Party Nuts", + "value": "High Top Party Nuts" + }, + { + "selected": false, + "label": "High Top Peaches", + "value": "High Top Peaches" + }, + { + "selected": false, + "label": "High Top Plums", + "value": "High Top Plums" + }, + { + "selected": false, + "label": "High Top Potatos", + "value": "High Top Potatos" + }, + { + "selected": false, + "label": "High Top Prepared Salad", + "value": "High Top Prepared Salad" + }, + { + "selected": false, + "label": "High Top Red Delcious Apples", + "value": "High Top Red Delcious Apples" + }, + { + "selected": false, + "label": "High Top Red Pepper", + "value": "High Top Red Pepper" + }, + { + "selected": false, + "label": "High Top Shitake Mushrooms", + "value": "High Top Shitake Mushrooms" + }, + { + "selected": false, + "label": "High Top Squash", + "value": "High Top Squash" + }, + { + "selected": false, + "label": "High Top Summer Squash", + "value": "High Top Summer Squash" + }, + { + "selected": false, + "label": "High Top Sweet Onion", + "value": "High Top Sweet Onion" + }, + { + "selected": false, + "label": "High Top Sweet Peas", + "value": "High Top Sweet Peas" + }, + { + "selected": false, + "label": "High Top Tangerines", + "value": "High Top Tangerines" + }, + { + "selected": false, + "label": "High Top Tomatos", + "value": "High Top Tomatos" + }, + { + "selected": false, + "label": "High Top Walnuts", + "value": "High Top Walnuts" + }, + { + "selected": false, + "label": "Hilltop 200 MG Acetominifen", + "value": "Hilltop 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Hilltop 200 MG Ibuprofen", + "value": "Hilltop 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Hilltop Angled Toothbrush", + "value": "Hilltop Angled Toothbrush" + }, + { + "selected": false, + "label": "Hilltop Apricot Shampoo", + "value": "Hilltop Apricot Shampoo" + }, + { + "selected": false, + "label": "Hilltop Buffered Aspirin", + "value": "Hilltop Buffered Aspirin" + }, + { + "selected": false, + "label": "Hilltop Childrens Aspirin", + "value": "Hilltop Childrens Aspirin" + }, + { + "selected": false, + "label": "Hilltop Childrens Cold Remedy", + "value": "Hilltop Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Hilltop Conditioning Shampoo", + "value": "Hilltop Conditioning Shampoo" + }, + { + "selected": false, + "label": "Hilltop Deodorant", + "value": "Hilltop Deodorant" + }, + { + "selected": false, + "label": "Hilltop Dishwasher Detergent", + "value": "Hilltop Dishwasher Detergent" + }, + { + "selected": false, + "label": "Hilltop Extra Moisture Shampoo", + "value": "Hilltop Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Hilltop HCL Nasal Spray", + "value": "Hilltop HCL Nasal Spray" + }, + { + "selected": false, + "label": "Hilltop Laundry Detergent", + "value": "Hilltop Laundry Detergent" + }, + { + "selected": false, + "label": "Hilltop Mint Mouthwash", + "value": "Hilltop Mint Mouthwash" + }, + { + "selected": false, + "label": "Hilltop Multi-Symptom Cold Remedy", + "value": "Hilltop Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Hilltop Silky Smooth Hair Conditioner", + "value": "Hilltop Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Hilltop Tartar Control Toothpaste", + "value": "Hilltop Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Hilltop Toothpaste", + "value": "Hilltop Toothpaste" + }, + { + "selected": false, + "label": "Hilltop Whitening Toothpast", + "value": "Hilltop Whitening Toothpast" + }, + { + "selected": false, + "label": "Horatio Apple Fruit Roll", + "value": "Horatio Apple Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Avocado Dip", + "value": "Horatio Avocado Dip" + }, + { + "selected": false, + "label": "Horatio BBQ Potato Chips", + "value": "Horatio BBQ Potato Chips" + }, + { + "selected": false, + "label": "Horatio Beef Jerky", + "value": "Horatio Beef Jerky" + }, + { + "selected": false, + "label": "Horatio Buttered Popcorn", + "value": "Horatio Buttered Popcorn" + }, + { + "selected": false, + "label": "Horatio Cheese Crackers", + "value": "Horatio Cheese Crackers" + }, + { + "selected": false, + "label": "Horatio Cheese Dip", + "value": "Horatio Cheese Dip" + }, + { + "selected": false, + "label": "Horatio Chocolate Chip Cookies", + "value": "Horatio Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Horatio Chocolate Donuts", + "value": "Horatio Chocolate Donuts" + }, + { + "selected": false, + "label": "Horatio Corn Chips", + "value": "Horatio Corn Chips" + }, + { + "selected": false, + "label": "Horatio Dried Apples", + "value": "Horatio Dried Apples" + }, + { + "selected": false, + "label": "Horatio Dried Apricots", + "value": "Horatio Dried Apricots" + }, + { + "selected": false, + "label": "Horatio Dried Dates", + "value": "Horatio Dried Dates" + }, + { + "selected": false, + "label": "Horatio Fondue Mix", + "value": "Horatio Fondue Mix" + }, + { + "selected": false, + "label": "Horatio Frosted Cookies", + "value": "Horatio Frosted Cookies" + }, + { + "selected": false, + "label": "Horatio Frosted Donuts", + "value": "Horatio Frosted Donuts" + }, + { + "selected": false, + "label": "Horatio Fudge Brownies", + "value": "Horatio Fudge Brownies" + }, + { + "selected": false, + "label": "Horatio Fudge Cookies", + "value": "Horatio Fudge Cookies" + }, + { + "selected": false, + "label": "Horatio Golden Raisins", + "value": "Horatio Golden Raisins" + }, + { + "selected": false, + "label": "Horatio Graham Crackers", + "value": "Horatio Graham Crackers" + }, + { + "selected": false, + "label": "Horatio Grape Fruit Roll", + "value": "Horatio Grape Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Lemon Cookies", + "value": "Horatio Lemon Cookies" + }, + { + "selected": false, + "label": "Horatio Low Fat BBQ Chips", + "value": "Horatio Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Horatio Low Fat Chips", + "value": "Horatio Low Fat Chips" + }, + { + "selected": false, + "label": "Horatio Low Fat Cookies", + "value": "Horatio Low Fat Cookies" + }, + { + "selected": false, + "label": "Horatio Low Fat Popcorn", + "value": "Horatio Low Fat Popcorn" + }, + { + "selected": false, + "label": "Horatio Mini Donuts", + "value": "Horatio Mini Donuts" + }, + { + "selected": false, + "label": "Horatio No Salt Popcorn", + "value": "Horatio No Salt Popcorn" + }, + { + "selected": false, + "label": "Horatio Potato Chips", + "value": "Horatio Potato Chips" + }, + { + "selected": false, + "label": "Horatio Raisins", + "value": "Horatio Raisins" + }, + { + "selected": false, + "label": "Horatio Raspberry Fruit Roll", + "value": "Horatio Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Salsa Dip", + "value": "Horatio Salsa Dip" + }, + { + "selected": false, + "label": "Horatio Salted Pretzels", + "value": "Horatio Salted Pretzels" + }, + { + "selected": false, + "label": "Horatio Sesame Crackers", + "value": "Horatio Sesame Crackers" + }, + { + "selected": false, + "label": "Horatio Strawberry Fruit Roll", + "value": "Horatio Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Sugar Cookies", + "value": "Horatio Sugar Cookies" + }, + { + "selected": false, + "label": "Imagine Apple Cinnamon Waffles", + "value": "Imagine Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Imagine Beef TV Dinner", + "value": "Imagine Beef TV Dinner" + }, + { + "selected": false, + "label": "Imagine Blueberry Waffles", + "value": "Imagine Blueberry Waffles" + }, + { + "selected": false, + "label": "Imagine Chicken TV Dinner", + "value": "Imagine Chicken TV Dinner" + }, + { + "selected": false, + "label": "Imagine Fajita French Fries", + "value": "Imagine Fajita French Fries" + }, + { + "selected": false, + "label": "Imagine Frozen Broccoli", + "value": "Imagine Frozen Broccoli" + }, + { + "selected": false, + "label": "Imagine Frozen Carrots", + "value": "Imagine Frozen Carrots" + }, + { + "selected": false, + "label": "Imagine Frozen Cauliflower", + "value": "Imagine Frozen Cauliflower" + }, + { + "selected": false, + "label": "Imagine Frozen Cheese Pizza", + "value": "Imagine Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Breast", + "value": "Imagine Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Thighs", + "value": "Imagine Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Wings", + "value": "Imagine Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Imagine Frozen Corn", + "value": "Imagine Frozen Corn" + }, + { + "selected": false, + "label": "Imagine Frozen Mushroom Pizza", + "value": "Imagine Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Pancakes", + "value": "Imagine Frozen Pancakes" + }, + { + "selected": false, + "label": "Imagine Frozen Peas", + "value": "Imagine Frozen Peas" + }, + { + "selected": false, + "label": "Imagine Frozen Pepperoni Pizza", + "value": "Imagine Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Sausage Pizza", + "value": "Imagine Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Imagine Grape Popsicles", + "value": "Imagine Grape Popsicles" + }, + { + "selected": false, + "label": "Imagine Home Style French Fries", + "value": "Imagine Home Style French Fries" + }, + { + "selected": false, + "label": "Imagine Ice Cream", + "value": "Imagine Ice Cream" + }, + { + "selected": false, + "label": "Imagine Ice Cream Sandwich", + "value": "Imagine Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Imagine Lemon Popsicles", + "value": "Imagine Lemon Popsicles" + }, + { + "selected": false, + "label": "Imagine Lime Popsicles", + "value": "Imagine Lime Popsicles" + }, + { + "selected": false, + "label": "Imagine Low Fat French Fries", + "value": "Imagine Low Fat French Fries" + }, + { + "selected": false, + "label": "Imagine Low Fat Waffles", + "value": "Imagine Low Fat Waffles" + }, + { + "selected": false, + "label": "Imagine Orange Popsicles", + "value": "Imagine Orange Popsicles" + }, + { + "selected": false, + "label": "Imagine Pancake Mix", + "value": "Imagine Pancake Mix" + }, + { + "selected": false, + "label": "Imagine Popsicles", + "value": "Imagine Popsicles" + }, + { + "selected": false, + "label": "Imagine Turkey TV Dinner", + "value": "Imagine Turkey TV Dinner" + }, + { + "selected": false, + "label": "Imagine Waffles", + "value": "Imagine Waffles" + }, + { + "selected": false, + "label": "James Bay City Map", + "value": "James Bay City Map" + }, + { + "selected": false, + "label": "James Bay Eyeglass Screwdriver", + "value": "James Bay Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Jardon Manicotti", + "value": "Jardon Manicotti" + }, + { + "selected": false, + "label": "Jardon Ravioli", + "value": "Jardon Ravioli" + }, + { + "selected": false, + "label": "Jardon Rice Medly", + "value": "Jardon Rice Medly" + }, + { + "selected": false, + "label": "Jardon Spaghetti", + "value": "Jardon Spaghetti" + }, + { + "selected": false, + "label": "Jardon Thai Rice", + "value": "Jardon Thai Rice" + }, + { + "selected": false, + "label": "Jeffers Corn Puffs", + "value": "Jeffers Corn Puffs" + }, + { + "selected": false, + "label": "Jeffers Grits", + "value": "Jeffers Grits" + }, + { + "selected": false, + "label": "Jeffers Oatmeal", + "value": "Jeffers Oatmeal" + }, + { + "selected": false, + "label": "Jeffers Wheat Puffs", + "value": "Jeffers Wheat Puffs" + }, + { + "selected": false, + "label": "Johnson Corn Puffs", + "value": "Johnson Corn Puffs" + }, + { + "selected": false, + "label": "Johnson Grits", + "value": "Johnson Grits" + }, + { + "selected": false, + "label": "Johnson Oatmeal", + "value": "Johnson Oatmeal" + }, + { + "selected": false, + "label": "Johnson Wheat Puffs", + "value": "Johnson Wheat Puffs" + }, + { + "selected": false, + "label": "Jumbo Egg Substitute", + "value": "Jumbo Egg Substitute" + }, + { + "selected": false, + "label": "Jumbo Large Brown Eggs", + "value": "Jumbo Large Brown Eggs" + }, + { + "selected": false, + "label": "Jumbo Large Eggs", + "value": "Jumbo Large Eggs" + }, + { + "selected": false, + "label": "Jumbo Small Brown Eggs", + "value": "Jumbo Small Brown Eggs" + }, + { + "selected": false, + "label": "Jumbo Small Eggs", + "value": "Jumbo Small Eggs" + }, + { + "selected": false, + "label": "Just Right Beef Soup", + "value": "Just Right Beef Soup" + }, + { + "selected": false, + "label": "Just Right Canned Beets", + "value": "Just Right Canned Beets" + }, + { + "selected": false, + "label": "Just Right Canned Peas", + "value": "Just Right Canned Peas" + }, + { + "selected": false, + "label": "Just Right Canned String Beans", + "value": "Just Right Canned String Beans" + }, + { + "selected": false, + "label": "Just Right Canned Tomatos", + "value": "Just Right Canned Tomatos" + }, + { + "selected": false, + "label": "Just Right Canned Tuna in Oil", + "value": "Just Right Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Just Right Canned Tuna in Water", + "value": "Just Right Canned Tuna in Water" + }, + { + "selected": false, + "label": "Just Right Canned Yams", + "value": "Just Right Canned Yams" + }, + { + "selected": false, + "label": "Just Right Chicken Noodle Soup", + "value": "Just Right Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Chicken Ramen Soup", + "value": "Just Right Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Just Right Chicken Soup", + "value": "Just Right Chicken Soup" + }, + { + "selected": false, + "label": "Just Right Creamed Corn", + "value": "Just Right Creamed Corn" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Anchovies", + "value": "Just Right Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Clams", + "value": "Just Right Fancy Canned Clams" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Oysters", + "value": "Just Right Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Sardines", + "value": "Just Right Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Just Right Large Canned Shrimp", + "value": "Just Right Large Canned Shrimp" + }, + { + "selected": false, + "label": "Just Right Noodle Soup", + "value": "Just Right Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Regular Ramen Soup", + "value": "Just Right Regular Ramen Soup" + }, + { + "selected": false, + "label": "Just Right Rice Soup", + "value": "Just Right Rice Soup" + }, + { + "selected": false, + "label": "Just Right Turkey Noodle Soup", + "value": "Just Right Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Vegetable Soup", + "value": "Just Right Vegetable Soup" + }, + { + "selected": false, + "label": "King Rosy Sunglasses", + "value": "King Rosy Sunglasses" + }, + { + "selected": false, + "label": "Kiwi Lox", + "value": "Kiwi Lox" + }, + { + "selected": false, + "label": "Kiwi Scallops", + "value": "Kiwi Scallops" + }, + { + "selected": false, + "label": "Lake Beef Bologna", + "value": "Lake Beef Bologna" + }, + { + "selected": false, + "label": "Lake Chicken Hot Dogs", + "value": "Lake Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Lake Cole Slaw", + "value": "Lake Cole Slaw" + }, + { + "selected": false, + "label": "Lake Corned Beef", + "value": "Lake Corned Beef" + }, + { + "selected": false, + "label": "Lake Foot-Long Hot Dogs", + "value": "Lake Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Lake Low Fat Bologna", + "value": "Lake Low Fat Bologna" + }, + { + "selected": false, + "label": "Lake Low Fat Cole Slaw", + "value": "Lake Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Lake Pimento Loaf", + "value": "Lake Pimento Loaf" + }, + { + "selected": false, + "label": "Lake Potato Salad", + "value": "Lake Potato Salad" + }, + { + "selected": false, + "label": "Lake Roasted Chicken", + "value": "Lake Roasted Chicken" + }, + { + "selected": false, + "label": "Lake Sliced Chicken", + "value": "Lake Sliced Chicken" + }, + { + "selected": false, + "label": "Lake Sliced Ham", + "value": "Lake Sliced Ham" + }, + { + "selected": false, + "label": "Lake Sliced Turkey", + "value": "Lake Sliced Turkey" + }, + { + "selected": false, + "label": "Lake Turkey Hot Dogs", + "value": "Lake Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Landslide Apple Butter", + "value": "Landslide Apple Butter" + }, + { + "selected": false, + "label": "Landslide Apple Jam", + "value": "Landslide Apple Jam" + }, + { + "selected": false, + "label": "Landslide Apple Jelly", + "value": "Landslide Apple Jelly" + }, + { + "selected": false, + "label": "Landslide Apple Preserves", + "value": "Landslide Apple Preserves" + }, + { + "selected": false, + "label": "Landslide Brown Sugar", + "value": "Landslide Brown Sugar" + }, + { + "selected": false, + "label": "Landslide Canola Oil", + "value": "Landslide Canola Oil" + }, + { + "selected": false, + "label": "Landslide Chunky Peanut Butter", + "value": "Landslide Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Landslide Columbian Coffee", + "value": "Landslide Columbian Coffee" + }, + { + "selected": false, + "label": "Landslide Corn Oil", + "value": "Landslide Corn Oil" + }, + { + "selected": false, + "label": "Landslide Creamy Peanut Butter", + "value": "Landslide Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Landslide Decaf Coffee", + "value": "Landslide Decaf Coffee" + }, + { + "selected": false, + "label": "Landslide Extra Chunky Peanut Butter", + "value": "Landslide Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Landslide French Roast Coffee", + "value": "Landslide French Roast Coffee" + }, + { + "selected": false, + "label": "Landslide Grape Jam", + "value": "Landslide Grape Jam" + }, + { + "selected": false, + "label": "Landslide Grape Jelly", + "value": "Landslide Grape Jelly" + }, + { + "selected": false, + "label": "Landslide Grape Preserves", + "value": "Landslide Grape Preserves" + }, + { + "selected": false, + "label": "Landslide Hot Chocolate", + "value": "Landslide Hot Chocolate" + }, + { + "selected": false, + "label": "Landslide Low Fat Apple Butter", + "value": "Landslide Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Landslide Oregano", + "value": "Landslide Oregano" + }, + { + "selected": false, + "label": "Landslide Pepper", + "value": "Landslide Pepper" + }, + { + "selected": false, + "label": "Landslide Regular Coffee", + "value": "Landslide Regular Coffee" + }, + { + "selected": false, + "label": "Landslide Salt", + "value": "Landslide Salt" + }, + { + "selected": false, + "label": "Landslide Sesame Oil", + "value": "Landslide Sesame Oil" + }, + { + "selected": false, + "label": "Landslide Strawberry Jam", + "value": "Landslide Strawberry Jam" + }, + { + "selected": false, + "label": "Landslide Strawberry Jelly", + "value": "Landslide Strawberry Jelly" + }, + { + "selected": false, + "label": "Landslide Strawberry Preserves", + "value": "Landslide Strawberry Preserves" + }, + { + "selected": false, + "label": "Landslide Tomato Sauce", + "value": "Landslide Tomato Sauce" + }, + { + "selected": false, + "label": "Landslide Vegetable Oil", + "value": "Landslide Vegetable Oil" + }, + { + "selected": false, + "label": "Landslide White Sugar", + "value": "Landslide White Sugar" + }, + { + "selected": false, + "label": "Medalist Manicotti", + "value": "Medalist Manicotti" + }, + { + "selected": false, + "label": "Medalist Ravioli", + "value": "Medalist Ravioli" + }, + { + "selected": false, + "label": "Medalist Rice Medly", + "value": "Medalist Rice Medly" + }, + { + "selected": false, + "label": "Medalist Spaghetti", + "value": "Medalist Spaghetti" + }, + { + "selected": false, + "label": "Medalist Thai Rice", + "value": "Medalist Thai Rice" + }, + { + "selected": false, + "label": "Mighty Good Monthly Auto Magazine", + "value": "Mighty Good Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Computer Magazine", + "value": "Mighty Good Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Fashion Magazine", + "value": "Mighty Good Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Home Magazine", + "value": "Mighty Good Monthly Home Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Sports Magazine", + "value": "Mighty Good Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Modell Bagels", + "value": "Modell Bagels" + }, + { + "selected": false, + "label": "Modell Blueberry Muffins", + "value": "Modell Blueberry Muffins" + }, + { + "selected": false, + "label": "Modell Cranberry Muffins", + "value": "Modell Cranberry Muffins" + }, + { + "selected": false, + "label": "Modell English Muffins", + "value": "Modell English Muffins" + }, + { + "selected": false, + "label": "Modell Muffins", + "value": "Modell Muffins" + }, + { + "selected": false, + "label": "Modell Pumpernickel Bread", + "value": "Modell Pumpernickel Bread" + }, + { + "selected": false, + "label": "Modell Rye Bread", + "value": "Modell Rye Bread" + }, + { + "selected": false, + "label": "Modell Wheat Bread", + "value": "Modell Wheat Bread" + }, + { + "selected": false, + "label": "Modell White Bread", + "value": "Modell White Bread" + }, + { + "selected": false, + "label": "Moms Beef Bologna", + "value": "Moms Beef Bologna" + }, + { + "selected": false, + "label": "Moms Chicken Hot Dogs", + "value": "Moms Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Moms Cole Slaw", + "value": "Moms Cole Slaw" + }, + { + "selected": false, + "label": "Moms Corned Beef", + "value": "Moms Corned Beef" + }, + { + "selected": false, + "label": "Moms Foot-Long Hot Dogs", + "value": "Moms Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Moms Low Fat Bologna", + "value": "Moms Low Fat Bologna" + }, + { + "selected": false, + "label": "Moms Low Fat Cole Slaw", + "value": "Moms Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Moms Pimento Loaf", + "value": "Moms Pimento Loaf" + }, + { + "selected": false, + "label": "Moms Potato Salad", + "value": "Moms Potato Salad" + }, + { + "selected": false, + "label": "Moms Roasted Chicken", + "value": "Moms Roasted Chicken" + }, + { + "selected": false, + "label": "Moms Sliced Chicken", + "value": "Moms Sliced Chicken" + }, + { + "selected": false, + "label": "Moms Sliced Ham", + "value": "Moms Sliced Ham" + }, + { + "selected": false, + "label": "Moms Sliced Turkey", + "value": "Moms Sliced Turkey" + }, + { + "selected": false, + "label": "Moms Turkey Hot Dogs", + "value": "Moms Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Monarch Manicotti", + "value": "Monarch Manicotti" + }, + { + "selected": false, + "label": "Monarch Ravioli", + "value": "Monarch Ravioli" + }, + { + "selected": false, + "label": "Monarch Rice Medly", + "value": "Monarch Rice Medly" + }, + { + "selected": false, + "label": "Monarch Spaghetti", + "value": "Monarch Spaghetti" + }, + { + "selected": false, + "label": "Monarch Thai Rice", + "value": "Monarch Thai Rice" + }, + { + "selected": false, + "label": "Musial Bubble Gum", + "value": "Musial Bubble Gum" + }, + { + "selected": false, + "label": "Musial Malted Milk Balls", + "value": "Musial Malted Milk Balls" + }, + { + "selected": false, + "label": "Musial Mint Chocolate Bar", + "value": "Musial Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Musial Mints", + "value": "Musial Mints" + }, + { + "selected": false, + "label": "Musial Semi-Sweet Chocolate Bar", + "value": "Musial Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Musial Spicy Mints", + "value": "Musial Spicy Mints" + }, + { + "selected": false, + "label": "Musial Tasty Candy Bar", + "value": "Musial Tasty Candy Bar" + }, + { + "selected": false, + "label": "Musial White Chocolate Bar", + "value": "Musial White Chocolate Bar" + }, + { + "selected": false, + "label": "National Egg Substitute", + "value": "National Egg Substitute" + }, + { + "selected": false, + "label": "National Large Brown Eggs", + "value": "National Large Brown Eggs" + }, + { + "selected": false, + "label": "National Large Eggs", + "value": "National Large Eggs" + }, + { + "selected": false, + "label": "National Small Brown Eggs", + "value": "National Small Brown Eggs" + }, + { + "selected": false, + "label": "National Small Eggs", + "value": "National Small Eggs" + }, + { + "selected": false, + "label": "Nationeel Apple Fruit Roll", + "value": "Nationeel Apple Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Avocado Dip", + "value": "Nationeel Avocado Dip" + }, + { + "selected": false, + "label": "Nationeel BBQ Potato Chips", + "value": "Nationeel BBQ Potato Chips" + }, + { + "selected": false, + "label": "Nationeel Beef Jerky", + "value": "Nationeel Beef Jerky" + }, + { + "selected": false, + "label": "Nationeel Buttered Popcorn", + "value": "Nationeel Buttered Popcorn" + }, + { + "selected": false, + "label": "Nationeel Cheese Crackers", + "value": "Nationeel Cheese Crackers" + }, + { + "selected": false, + "label": "Nationeel Cheese Dip", + "value": "Nationeel Cheese Dip" + }, + { + "selected": false, + "label": "Nationeel Chocolate Chip Cookies", + "value": "Nationeel Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Nationeel Chocolate Donuts", + "value": "Nationeel Chocolate Donuts" + }, + { + "selected": false, + "label": "Nationeel Corn Chips", + "value": "Nationeel Corn Chips" + }, + { + "selected": false, + "label": "Nationeel Dried Apples", + "value": "Nationeel Dried Apples" + }, + { + "selected": false, + "label": "Nationeel Dried Apricots", + "value": "Nationeel Dried Apricots" + }, + { + "selected": false, + "label": "Nationeel Dried Dates", + "value": "Nationeel Dried Dates" + }, + { + "selected": false, + "label": "Nationeel Fondue Mix", + "value": "Nationeel Fondue Mix" + }, + { + "selected": false, + "label": "Nationeel Frosted Cookies", + "value": "Nationeel Frosted Cookies" + }, + { + "selected": false, + "label": "Nationeel Frosted Donuts", + "value": "Nationeel Frosted Donuts" + }, + { + "selected": false, + "label": "Nationeel Fudge Brownies", + "value": "Nationeel Fudge Brownies" + }, + { + "selected": false, + "label": "Nationeel Fudge Cookies", + "value": "Nationeel Fudge Cookies" + }, + { + "selected": false, + "label": "Nationeel Golden Raisins", + "value": "Nationeel Golden Raisins" + }, + { + "selected": false, + "label": "Nationeel Graham Crackers", + "value": "Nationeel Graham Crackers" + }, + { + "selected": false, + "label": "Nationeel Grape Fruit Roll", + "value": "Nationeel Grape Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Lemon Cookies", + "value": "Nationeel Lemon Cookies" + }, + { + "selected": false, + "label": "Nationeel Low Fat BBQ Chips", + "value": "Nationeel Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Nationeel Low Fat Chips", + "value": "Nationeel Low Fat Chips" + }, + { + "selected": false, + "label": "Nationeel Low Fat Cookies", + "value": "Nationeel Low Fat Cookies" + }, + { + "selected": false, + "label": "Nationeel Low Fat Popcorn", + "value": "Nationeel Low Fat Popcorn" + }, + { + "selected": false, + "label": "Nationeel Mini Donuts", + "value": "Nationeel Mini Donuts" + }, + { + "selected": false, + "label": "Nationeel No Salt Popcorn", + "value": "Nationeel No Salt Popcorn" + }, + { + "selected": false, + "label": "Nationeel Potato Chips", + "value": "Nationeel Potato Chips" + }, + { + "selected": false, + "label": "Nationeel Raisins", + "value": "Nationeel Raisins" + }, + { + "selected": false, + "label": "Nationeel Raspberry Fruit Roll", + "value": "Nationeel Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Salsa Dip", + "value": "Nationeel Salsa Dip" + }, + { + "selected": false, + "label": "Nationeel Salted Pretzels", + "value": "Nationeel Salted Pretzels" + }, + { + "selected": false, + "label": "Nationeel Sesame Crackers", + "value": "Nationeel Sesame Crackers" + }, + { + "selected": false, + "label": "Nationeel Strawberry Fruit Roll", + "value": "Nationeel Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Sugar Cookies", + "value": "Nationeel Sugar Cookies" + }, + { + "selected": false, + "label": "Pearl Chablis Wine", + "value": "Pearl Chablis Wine" + }, + { + "selected": false, + "label": "Pearl Chardonnay", + "value": "Pearl Chardonnay" + }, + { + "selected": false, + "label": "Pearl Chardonnay Wine", + "value": "Pearl Chardonnay Wine" + }, + { + "selected": false, + "label": "Pearl Imported Beer", + "value": "Pearl Imported Beer" + }, + { + "selected": false, + "label": "Pearl Light Beer", + "value": "Pearl Light Beer" + }, + { + "selected": false, + "label": "Pearl Light Wine", + "value": "Pearl Light Wine" + }, + { + "selected": false, + "label": "Pearl Merlot Wine", + "value": "Pearl Merlot Wine" + }, + { + "selected": false, + "label": "Pearl White Zinfandel Wine", + "value": "Pearl White Zinfandel Wine" + }, + { + "selected": false, + "label": "PigTail Apple Cinnamon Waffles", + "value": "PigTail Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "PigTail Beef TV Dinner", + "value": "PigTail Beef TV Dinner" + }, + { + "selected": false, + "label": "PigTail Blueberry Waffles", + "value": "PigTail Blueberry Waffles" + }, + { + "selected": false, + "label": "PigTail Chicken TV Dinner", + "value": "PigTail Chicken TV Dinner" + }, + { + "selected": false, + "label": "PigTail Fajita French Fries", + "value": "PigTail Fajita French Fries" + }, + { + "selected": false, + "label": "PigTail Frozen Broccoli", + "value": "PigTail Frozen Broccoli" + }, + { + "selected": false, + "label": "PigTail Frozen Carrots", + "value": "PigTail Frozen Carrots" + }, + { + "selected": false, + "label": "PigTail Frozen Cauliflower", + "value": "PigTail Frozen Cauliflower" + }, + { + "selected": false, + "label": "PigTail Frozen Cheese Pizza", + "value": "PigTail Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Breast", + "value": "PigTail Frozen Chicken Breast" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Thighs", + "value": "PigTail Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Wings", + "value": "PigTail Frozen Chicken Wings" + }, + { + "selected": false, + "label": "PigTail Frozen Corn", + "value": "PigTail Frozen Corn" + }, + { + "selected": false, + "label": "PigTail Frozen Mushroom Pizza", + "value": "PigTail Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Pancakes", + "value": "PigTail Frozen Pancakes" + }, + { + "selected": false, + "label": "PigTail Frozen Peas", + "value": "PigTail Frozen Peas" + }, + { + "selected": false, + "label": "PigTail Frozen Pepperoni Pizza", + "value": "PigTail Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Sausage Pizza", + "value": "PigTail Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "PigTail Grape Popsicles", + "value": "PigTail Grape Popsicles" + }, + { + "selected": false, + "label": "PigTail Home Style French Fries", + "value": "PigTail Home Style French Fries" + }, + { + "selected": false, + "label": "PigTail Ice Cream", + "value": "PigTail Ice Cream" + }, + { + "selected": false, + "label": "PigTail Ice Cream Sandwich", + "value": "PigTail Ice Cream Sandwich" + }, + { + "selected": false, + "label": "PigTail Lemon Popsicles", + "value": "PigTail Lemon Popsicles" + }, + { + "selected": false, + "label": "PigTail Lime Popsicles", + "value": "PigTail Lime Popsicles" + }, + { + "selected": false, + "label": "PigTail Low Fat French Fries", + "value": "PigTail Low Fat French Fries" + }, + { + "selected": false, + "label": "PigTail Low Fat Waffles", + "value": "PigTail Low Fat Waffles" + }, + { + "selected": false, + "label": "PigTail Orange Popsicles", + "value": "PigTail Orange Popsicles" + }, + { + "selected": false, + "label": "PigTail Pancake Mix", + "value": "PigTail Pancake Mix" + }, + { + "selected": false, + "label": "PigTail Popsicles", + "value": "PigTail Popsicles" + }, + { + "selected": false, + "label": "PigTail Turkey TV Dinner", + "value": "PigTail Turkey TV Dinner" + }, + { + "selected": false, + "label": "PigTail Waffles", + "value": "PigTail Waffles" + }, + { + "selected": false, + "label": "Plato Apple Butter", + "value": "Plato Apple Butter" + }, + { + "selected": false, + "label": "Plato Apple Jam", + "value": "Plato Apple Jam" + }, + { + "selected": false, + "label": "Plato Apple Jelly", + "value": "Plato Apple Jelly" + }, + { + "selected": false, + "label": "Plato Apple Preserves", + "value": "Plato Apple Preserves" + }, + { + "selected": false, + "label": "Plato Brown Sugar", + "value": "Plato Brown Sugar" + }, + { + "selected": false, + "label": "Plato Canola Oil", + "value": "Plato Canola Oil" + }, + { + "selected": false, + "label": "Plato Chunky Peanut Butter", + "value": "Plato Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Plato Columbian Coffee", + "value": "Plato Columbian Coffee" + }, + { + "selected": false, + "label": "Plato Corn Oil", + "value": "Plato Corn Oil" + }, + { + "selected": false, + "label": "Plato Creamy Peanut Butter", + "value": "Plato Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Plato Decaf Coffee", + "value": "Plato Decaf Coffee" + }, + { + "selected": false, + "label": "Plato Extra Chunky Peanut Butter", + "value": "Plato Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Plato French Roast Coffee", + "value": "Plato French Roast Coffee" + }, + { + "selected": false, + "label": "Plato Grape Jam", + "value": "Plato Grape Jam" + }, + { + "selected": false, + "label": "Plato Grape Jelly", + "value": "Plato Grape Jelly" + }, + { + "selected": false, + "label": "Plato Grape Preserves", + "value": "Plato Grape Preserves" + }, + { + "selected": false, + "label": "Plato Hot Chocolate", + "value": "Plato Hot Chocolate" + }, + { + "selected": false, + "label": "Plato Low Fat Apple Butter", + "value": "Plato Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Plato Oregano", + "value": "Plato Oregano" + }, + { + "selected": false, + "label": "Plato Pepper", + "value": "Plato Pepper" + }, + { + "selected": false, + "label": "Plato Regular Coffee", + "value": "Plato Regular Coffee" + }, + { + "selected": false, + "label": "Plato Salt", + "value": "Plato Salt" + }, + { + "selected": false, + "label": "Plato Sesame Oil", + "value": "Plato Sesame Oil" + }, + { + "selected": false, + "label": "Plato Strawberry Jam", + "value": "Plato Strawberry Jam" + }, + { + "selected": false, + "label": "Plato Strawberry Jelly", + "value": "Plato Strawberry Jelly" + }, + { + "selected": false, + "label": "Plato Strawberry Preserves", + "value": "Plato Strawberry Preserves" + }, + { + "selected": false, + "label": "Plato Tomato Sauce", + "value": "Plato Tomato Sauce" + }, + { + "selected": false, + "label": "Plato Vegetable Oil", + "value": "Plato Vegetable Oil" + }, + { + "selected": false, + "label": "Plato White Sugar", + "value": "Plato White Sugar" + }, + { + "selected": false, + "label": "Pleasant Beef Soup", + "value": "Pleasant Beef Soup" + }, + { + "selected": false, + "label": "Pleasant Canned Beets", + "value": "Pleasant Canned Beets" + }, + { + "selected": false, + "label": "Pleasant Canned Peas", + "value": "Pleasant Canned Peas" + }, + { + "selected": false, + "label": "Pleasant Canned String Beans", + "value": "Pleasant Canned String Beans" + }, + { + "selected": false, + "label": "Pleasant Canned Tomatos", + "value": "Pleasant Canned Tomatos" + }, + { + "selected": false, + "label": "Pleasant Canned Tuna in Oil", + "value": "Pleasant Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Pleasant Canned Tuna in Water", + "value": "Pleasant Canned Tuna in Water" + }, + { + "selected": false, + "label": "Pleasant Canned Yams", + "value": "Pleasant Canned Yams" + }, + { + "selected": false, + "label": "Pleasant Chicken Noodle Soup", + "value": "Pleasant Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Chicken Ramen Soup", + "value": "Pleasant Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Pleasant Chicken Soup", + "value": "Pleasant Chicken Soup" + }, + { + "selected": false, + "label": "Pleasant Creamed Corn", + "value": "Pleasant Creamed Corn" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Anchovies", + "value": "Pleasant Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Clams", + "value": "Pleasant Fancy Canned Clams" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Oysters", + "value": "Pleasant Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Sardines", + "value": "Pleasant Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Pleasant Large Canned Shrimp", + "value": "Pleasant Large Canned Shrimp" + }, + { + "selected": false, + "label": "Pleasant Noodle Soup", + "value": "Pleasant Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Regular Ramen Soup", + "value": "Pleasant Regular Ramen Soup" + }, + { + "selected": false, + "label": "Pleasant Rice Soup", + "value": "Pleasant Rice Soup" + }, + { + "selected": false, + "label": "Pleasant Turkey Noodle Soup", + "value": "Pleasant Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Vegetable Soup", + "value": "Pleasant Vegetable Soup" + }, + { + "selected": false, + "label": "Portsmouth Chablis Wine", + "value": "Portsmouth Chablis Wine" + }, + { + "selected": false, + "label": "Portsmouth Chardonnay", + "value": "Portsmouth Chardonnay" + }, + { + "selected": false, + "label": "Portsmouth Chardonnay Wine", + "value": "Portsmouth Chardonnay Wine" + }, + { + "selected": false, + "label": "Portsmouth Imported Beer", + "value": "Portsmouth Imported Beer" + }, + { + "selected": false, + "label": "Portsmouth Light Beer", + "value": "Portsmouth Light Beer" + }, + { + "selected": false, + "label": "Portsmouth Light Wine", + "value": "Portsmouth Light Wine" + }, + { + "selected": false, + "label": "Portsmouth Merlot Wine", + "value": "Portsmouth Merlot Wine" + }, + { + "selected": false, + "label": "Portsmouth White Zinfandel Wine", + "value": "Portsmouth White Zinfandel Wine" + }, + { + "selected": false, + "label": "Prelude Rosy Sunglasses", + "value": "Prelude Rosy Sunglasses" + }, + { + "selected": false, + "label": "Queen City Map", + "value": "Queen City Map" + }, + { + "selected": false, + "label": "Queen Eyeglass Screwdriver", + "value": "Queen Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Quick Extra Lean Hamburger", + "value": "Quick Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Quick Seasoned Hamburger", + "value": "Quick Seasoned Hamburger" + }, + { + "selected": false, + "label": "Radius Corn Puffs", + "value": "Radius Corn Puffs" + }, + { + "selected": false, + "label": "Radius Grits", + "value": "Radius Grits" + }, + { + "selected": false, + "label": "Radius Oatmeal", + "value": "Radius Oatmeal" + }, + { + "selected": false, + "label": "Radius Wheat Puffs", + "value": "Radius Wheat Puffs" + }, + { + "selected": false, + "label": "Red Spade Beef Bologna", + "value": "Red Spade Beef Bologna" + }, + { + "selected": false, + "label": "Red Spade Chicken Hot Dogs", + "value": "Red Spade Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Red Spade Cole Slaw", + "value": "Red Spade Cole Slaw" + }, + { + "selected": false, + "label": "Red Spade Corned Beef", + "value": "Red Spade Corned Beef" + }, + { + "selected": false, + "label": "Red Spade Foot-Long Hot Dogs", + "value": "Red Spade Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Red Spade Low Fat Bologna", + "value": "Red Spade Low Fat Bologna" + }, + { + "selected": false, + "label": "Red Spade Low Fat Cole Slaw", + "value": "Red Spade Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Red Spade Pimento Loaf", + "value": "Red Spade Pimento Loaf" + }, + { + "selected": false, + "label": "Red Spade Potato Salad", + "value": "Red Spade Potato Salad" + }, + { + "selected": false, + "label": "Red Spade Roasted Chicken", + "value": "Red Spade Roasted Chicken" + }, + { + "selected": false, + "label": "Red Spade Sliced Chicken", + "value": "Red Spade Sliced Chicken" + }, + { + "selected": false, + "label": "Red Spade Sliced Ham", + "value": "Red Spade Sliced Ham" + }, + { + "selected": false, + "label": "Red Spade Sliced Turkey", + "value": "Red Spade Sliced Turkey" + }, + { + "selected": false, + "label": "Red Spade Turkey Hot Dogs", + "value": "Red Spade Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Red Wing 100 Watt Lightbulb", + "value": "Red Wing 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 25 Watt Lightbulb", + "value": "Red Wing 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 60 Watt Lightbulb", + "value": "Red Wing 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 75 Watt Lightbulb", + "value": "Red Wing 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing AAA-Size Batteries", + "value": "Red Wing AAA-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing AA-Size Batteries", + "value": "Red Wing AA-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing Bees Wax Candles", + "value": "Red Wing Bees Wax Candles" + }, + { + "selected": false, + "label": "Red Wing Copper Cleaner", + "value": "Red Wing Copper Cleaner" + }, + { + "selected": false, + "label": "Red Wing Copper Pot Scrubber", + "value": "Red Wing Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Red Wing Counter Cleaner", + "value": "Red Wing Counter Cleaner" + }, + { + "selected": false, + "label": "Red Wing C-Size Batteries", + "value": "Red Wing C-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing D-Size Batteries", + "value": "Red Wing D-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing Economy Toilet Brush", + "value": "Red Wing Economy Toilet Brush" + }, + { + "selected": false, + "label": "Red Wing Frying Pan", + "value": "Red Wing Frying Pan" + }, + { + "selected": false, + "label": "Red Wing Glass Cleaner", + "value": "Red Wing Glass Cleaner" + }, + { + "selected": false, + "label": "Red Wing Large Sponge", + "value": "Red Wing Large Sponge" + }, + { + "selected": false, + "label": "Red Wing Paper Cups", + "value": "Red Wing Paper Cups" + }, + { + "selected": false, + "label": "Red Wing Paper Plates", + "value": "Red Wing Paper Plates" + }, + { + "selected": false, + "label": "Red Wing Paper Towels", + "value": "Red Wing Paper Towels" + }, + { + "selected": false, + "label": "Red Wing Plastic Forks", + "value": "Red Wing Plastic Forks" + }, + { + "selected": false, + "label": "Red Wing Plastic Knives", + "value": "Red Wing Plastic Knives" + }, + { + "selected": false, + "label": "Red Wing Plastic Spoons", + "value": "Red Wing Plastic Spoons" + }, + { + "selected": false, + "label": "Red Wing Room Freshener", + "value": "Red Wing Room Freshener" + }, + { + "selected": false, + "label": "Red Wing Scented Tissue", + "value": "Red Wing Scented Tissue" + }, + { + "selected": false, + "label": "Red Wing Scented Toilet Tissue", + "value": "Red Wing Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Red Wing Scissors", + "value": "Red Wing Scissors" + }, + { + "selected": false, + "label": "Red Wing Screw Driver", + "value": "Red Wing Screw Driver" + }, + { + "selected": false, + "label": "Red Wing Silver Cleaner", + "value": "Red Wing Silver Cleaner" + }, + { + "selected": false, + "label": "Red Wing Soft Napkins", + "value": "Red Wing Soft Napkins" + }, + { + "selected": false, + "label": "Red Wing Tissues", + "value": "Red Wing Tissues" + }, + { + "selected": false, + "label": "Red Wing Toilet Bowl Cleaner", + "value": "Red Wing Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Red Wing Toilet Paper", + "value": "Red Wing Toilet Paper" + }, + { + "selected": false, + "label": "Robust Monthly Auto Magazine", + "value": "Robust Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Computer Magazine", + "value": "Robust Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Fashion Magazine", + "value": "Robust Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Home Magazine", + "value": "Robust Monthly Home Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Sports Magazine", + "value": "Robust Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Shady Lake Manicotti", + "value": "Shady Lake Manicotti" + }, + { + "selected": false, + "label": "Shady Lake Ravioli", + "value": "Shady Lake Ravioli" + }, + { + "selected": false, + "label": "Shady Lake Rice Medly", + "value": "Shady Lake Rice Medly" + }, + { + "selected": false, + "label": "Shady Lake Spaghetti", + "value": "Shady Lake Spaghetti" + }, + { + "selected": false, + "label": "Shady Lake Thai Rice", + "value": "Shady Lake Thai Rice" + }, + { + "selected": false, + "label": "Ship Shape Extra Lean Hamburger", + "value": "Ship Shape Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Ship Shape Seasoned Hamburger", + "value": "Ship Shape Seasoned Hamburger" + }, + { + "selected": false, + "label": "Skinner Apple Drink", + "value": "Skinner Apple Drink" + }, + { + "selected": false, + "label": "Skinner Apple Juice", + "value": "Skinner Apple Juice" + }, + { + "selected": false, + "label": "Skinner Berry Juice", + "value": "Skinner Berry Juice" + }, + { + "selected": false, + "label": "Skinner Cola", + "value": "Skinner Cola" + }, + { + "selected": false, + "label": "Skinner Cranberry Juice", + "value": "Skinner Cranberry Juice" + }, + { + "selected": false, + "label": "Skinner Cream Soda", + "value": "Skinner Cream Soda" + }, + { + "selected": false, + "label": "Skinner Diet Cola", + "value": "Skinner Diet Cola" + }, + { + "selected": false, + "label": "Skinner Diet Soda", + "value": "Skinner Diet Soda" + }, + { + "selected": false, + "label": "Skinner Mango Drink", + "value": "Skinner Mango Drink" + }, + { + "selected": false, + "label": "Skinner Orange Juice", + "value": "Skinner Orange Juice" + }, + { + "selected": false, + "label": "Skinner Strawberry Drink", + "value": "Skinner Strawberry Drink" + }, + { + "selected": false, + "label": "Special Corn Puffs", + "value": "Special Corn Puffs" + }, + { + "selected": false, + "label": "Special Grits", + "value": "Special Grits" + }, + { + "selected": false, + "label": "Special Oatmeal", + "value": "Special Oatmeal" + }, + { + "selected": false, + "label": "Special Wheat Puffs", + "value": "Special Wheat Puffs" + }, + { + "selected": false, + "label": "Sphinx Bagels", + "value": "Sphinx Bagels" + }, + { + "selected": false, + "label": "Sphinx Blueberry Muffins", + "value": "Sphinx Blueberry Muffins" + }, + { + "selected": false, + "label": "Sphinx Cranberry Muffins", + "value": "Sphinx Cranberry Muffins" + }, + { + "selected": false, + "label": "Sphinx English Muffins", + "value": "Sphinx English Muffins" + }, + { + "selected": false, + "label": "Sphinx Muffins", + "value": "Sphinx Muffins" + }, + { + "selected": false, + "label": "Sphinx Pumpernickel Bread", + "value": "Sphinx Pumpernickel Bread" + }, + { + "selected": false, + "label": "Sphinx Rye Bread", + "value": "Sphinx Rye Bread" + }, + { + "selected": false, + "label": "Sphinx Wheat Bread", + "value": "Sphinx Wheat Bread" + }, + { + "selected": false, + "label": "Sphinx White Bread", + "value": "Sphinx White Bread" + }, + { + "selected": false, + "label": "Steady 200 MG Acetominifen", + "value": "Steady 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Steady 200 MG Ibuprofen", + "value": "Steady 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Steady Angled Toothbrush", + "value": "Steady Angled Toothbrush" + }, + { + "selected": false, + "label": "Steady Apricot Shampoo", + "value": "Steady Apricot Shampoo" + }, + { + "selected": false, + "label": "Steady Buffered Aspirin", + "value": "Steady Buffered Aspirin" + }, + { + "selected": false, + "label": "Steady Childrens Aspirin", + "value": "Steady Childrens Aspirin" + }, + { + "selected": false, + "label": "Steady Childrens Cold Remedy", + "value": "Steady Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Steady Conditioning Shampoo", + "value": "Steady Conditioning Shampoo" + }, + { + "selected": false, + "label": "Steady Deodorant", + "value": "Steady Deodorant" + }, + { + "selected": false, + "label": "Steady Dishwasher Detergent", + "value": "Steady Dishwasher Detergent" + }, + { + "selected": false, + "label": "Steady Extra Moisture Shampoo", + "value": "Steady Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Steady HCL Nasal Spray", + "value": "Steady HCL Nasal Spray" + }, + { + "selected": false, + "label": "Steady Laundry Detergent", + "value": "Steady Laundry Detergent" + }, + { + "selected": false, + "label": "Steady Mint Mouthwash", + "value": "Steady Mint Mouthwash" + }, + { + "selected": false, + "label": "Steady Multi-Symptom Cold Remedy", + "value": "Steady Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Steady Silky Smooth Hair Conditioner", + "value": "Steady Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Steady Tartar Control Toothpaste", + "value": "Steady Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Steady Toothpaste", + "value": "Steady Toothpaste" + }, + { + "selected": false, + "label": "Steady Whitening Toothpast", + "value": "Steady Whitening Toothpast" + }, + { + "selected": false, + "label": "Sunset 100 Watt Lightbulb", + "value": "Sunset 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 25 Watt Lightbulb", + "value": "Sunset 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 60 Watt Lightbulb", + "value": "Sunset 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 75 Watt Lightbulb", + "value": "Sunset 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset AAA-Size Batteries", + "value": "Sunset AAA-Size Batteries" + }, + { + "selected": false, + "label": "Sunset AA-Size Batteries", + "value": "Sunset AA-Size Batteries" + }, + { + "selected": false, + "label": "Sunset Bees Wax Candles", + "value": "Sunset Bees Wax Candles" + }, + { + "selected": false, + "label": "Sunset Copper Cleaner", + "value": "Sunset Copper Cleaner" + }, + { + "selected": false, + "label": "Sunset Copper Pot Scrubber", + "value": "Sunset Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Sunset Counter Cleaner", + "value": "Sunset Counter Cleaner" + }, + { + "selected": false, + "label": "Sunset C-Size Batteries", + "value": "Sunset C-Size Batteries" + }, + { + "selected": false, + "label": "Sunset D-Size Batteries", + "value": "Sunset D-Size Batteries" + }, + { + "selected": false, + "label": "Sunset Economy Toilet Brush", + "value": "Sunset Economy Toilet Brush" + }, + { + "selected": false, + "label": "Sunset Frying Pan", + "value": "Sunset Frying Pan" + }, + { + "selected": false, + "label": "Sunset Glass Cleaner", + "value": "Sunset Glass Cleaner" + }, + { + "selected": false, + "label": "Sunset Large Sponge", + "value": "Sunset Large Sponge" + }, + { + "selected": false, + "label": "Sunset Paper Cups", + "value": "Sunset Paper Cups" + }, + { + "selected": false, + "label": "Sunset Paper Plates", + "value": "Sunset Paper Plates" + }, + { + "selected": false, + "label": "Sunset Paper Towels", + "value": "Sunset Paper Towels" + }, + { + "selected": false, + "label": "Sunset Plastic Forks", + "value": "Sunset Plastic Forks" + }, + { + "selected": false, + "label": "Sunset Plastic Knives", + "value": "Sunset Plastic Knives" + }, + { + "selected": false, + "label": "Sunset Plastic Spoons", + "value": "Sunset Plastic Spoons" + }, + { + "selected": false, + "label": "Sunset Room Freshener", + "value": "Sunset Room Freshener" + }, + { + "selected": false, + "label": "Sunset Scented Tissue", + "value": "Sunset Scented Tissue" + }, + { + "selected": false, + "label": "Sunset Scented Toilet Tissue", + "value": "Sunset Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Sunset Scissors", + "value": "Sunset Scissors" + }, + { + "selected": false, + "label": "Sunset Screw Driver", + "value": "Sunset Screw Driver" + }, + { + "selected": false, + "label": "Sunset Silver Cleaner", + "value": "Sunset Silver Cleaner" + }, + { + "selected": false, + "label": "Sunset Soft Napkins", + "value": "Sunset Soft Napkins" + }, + { + "selected": false, + "label": "Sunset Tissues", + "value": "Sunset Tissues" + }, + { + "selected": false, + "label": "Sunset Toilet Bowl Cleaner", + "value": "Sunset Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Sunset Toilet Paper", + "value": "Sunset Toilet Paper" + }, + { + "selected": false, + "label": "Super Apple Butter", + "value": "Super Apple Butter" + }, + { + "selected": false, + "label": "Super Apple Jam", + "value": "Super Apple Jam" + }, + { + "selected": false, + "label": "Super Apple Jelly", + "value": "Super Apple Jelly" + }, + { + "selected": false, + "label": "Super Apple Preserves", + "value": "Super Apple Preserves" + }, + { + "selected": false, + "label": "Super Brown Sugar", + "value": "Super Brown Sugar" + }, + { + "selected": false, + "label": "Super Canola Oil", + "value": "Super Canola Oil" + }, + { + "selected": false, + "label": "Super Chunky Peanut Butter", + "value": "Super Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Super Columbian Coffee", + "value": "Super Columbian Coffee" + }, + { + "selected": false, + "label": "Super Corn Oil", + "value": "Super Corn Oil" + }, + { + "selected": false, + "label": "Super Creamy Peanut Butter", + "value": "Super Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Super Decaf Coffee", + "value": "Super Decaf Coffee" + }, + { + "selected": false, + "label": "Super Extra Chunky Peanut Butter", + "value": "Super Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Super French Roast Coffee", + "value": "Super French Roast Coffee" + }, + { + "selected": false, + "label": "Super Grape Jam", + "value": "Super Grape Jam" + }, + { + "selected": false, + "label": "Super Grape Jelly", + "value": "Super Grape Jelly" + }, + { + "selected": false, + "label": "Super Grape Preserves", + "value": "Super Grape Preserves" + }, + { + "selected": false, + "label": "Super Hot Chocolate", + "value": "Super Hot Chocolate" + }, + { + "selected": false, + "label": "Super Low Fat Apple Butter", + "value": "Super Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Super Oregano", + "value": "Super Oregano" + }, + { + "selected": false, + "label": "Super Pepper", + "value": "Super Pepper" + }, + { + "selected": false, + "label": "Super Regular Coffee", + "value": "Super Regular Coffee" + }, + { + "selected": false, + "label": "Super Salt", + "value": "Super Salt" + }, + { + "selected": false, + "label": "Super Sesame Oil", + "value": "Super Sesame Oil" + }, + { + "selected": false, + "label": "Super Strawberry Jam", + "value": "Super Strawberry Jam" + }, + { + "selected": false, + "label": "Super Strawberry Jelly", + "value": "Super Strawberry Jelly" + }, + { + "selected": false, + "label": "Super Strawberry Preserves", + "value": "Super Strawberry Preserves" + }, + { + "selected": false, + "label": "Super Tomato Sauce", + "value": "Super Tomato Sauce" + }, + { + "selected": false, + "label": "Super Vegetable Oil", + "value": "Super Vegetable Oil" + }, + { + "selected": false, + "label": "Super White Sugar", + "value": "Super White Sugar" + }, + { + "selected": false, + "label": "Swell Canned Mixed Fruit", + "value": "Swell Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Swell Canned Peaches", + "value": "Swell Canned Peaches" + }, + { + "selected": false, + "label": "Symphony Rosy Sunglasses", + "value": "Symphony Rosy Sunglasses" + }, + { + "selected": false, + "label": "Tell Tale Almonds", + "value": "Tell Tale Almonds" + }, + { + "selected": false, + "label": "Tell Tale Asparagus", + "value": "Tell Tale Asparagus" + }, + { + "selected": false, + "label": "Tell Tale Baby Onion", + "value": "Tell Tale Baby Onion" + }, + { + "selected": false, + "label": "Tell Tale Beets", + "value": "Tell Tale Beets" + }, + { + "selected": false, + "label": "Tell Tale Broccoli", + "value": "Tell Tale Broccoli" + }, + { + "selected": false, + "label": "Tell Tale Canned Peanuts", + "value": "Tell Tale Canned Peanuts" + }, + { + "selected": false, + "label": "Tell Tale Cantelope", + "value": "Tell Tale Cantelope" + }, + { + "selected": false, + "label": "Tell Tale Cauliflower", + "value": "Tell Tale Cauliflower" + }, + { + "selected": false, + "label": "Tell Tale Corn on the Cob", + "value": "Tell Tale Corn on the Cob" + }, + { + "selected": false, + "label": "Tell Tale Dried Mushrooms", + "value": "Tell Tale Dried Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale Elephant Garlic", + "value": "Tell Tale Elephant Garlic" + }, + { + "selected": false, + "label": "Tell Tale Fancy Plums", + "value": "Tell Tale Fancy Plums" + }, + { + "selected": false, + "label": "Tell Tale Firm Tofu", + "value": "Tell Tale Firm Tofu" + }, + { + "selected": false, + "label": "Tell Tale Fresh Lima Beans", + "value": "Tell Tale Fresh Lima Beans" + }, + { + "selected": false, + "label": "Tell Tale Fuji Apples", + "value": "Tell Tale Fuji Apples" + }, + { + "selected": false, + "label": "Tell Tale Garlic", + "value": "Tell Tale Garlic" + }, + { + "selected": false, + "label": "Tell Tale Golden Delcious Apples", + "value": "Tell Tale Golden Delcious Apples" + }, + { + "selected": false, + "label": "Tell Tale Green Pepper", + "value": "Tell Tale Green Pepper" + }, + { + "selected": false, + "label": "Tell Tale Honey Dew", + "value": "Tell Tale Honey Dew" + }, + { + "selected": false, + "label": "Tell Tale Lemons", + "value": "Tell Tale Lemons" + }, + { + "selected": false, + "label": "Tell Tale Lettuce", + "value": "Tell Tale Lettuce" + }, + { + "selected": false, + "label": "Tell Tale Limes", + "value": "Tell Tale Limes" + }, + { + "selected": false, + "label": "Tell Tale Macintosh Apples", + "value": "Tell Tale Macintosh Apples" + }, + { + "selected": false, + "label": "Tell Tale Mandarin Oranges", + "value": "Tell Tale Mandarin Oranges" + }, + { + "selected": false, + "label": "Tell Tale Mixed Nuts", + "value": "Tell Tale Mixed Nuts" + }, + { + "selected": false, + "label": "Tell Tale Mushrooms", + "value": "Tell Tale Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale New Potatos", + "value": "Tell Tale New Potatos" + }, + { + "selected": false, + "label": "Tell Tale Onions", + "value": "Tell Tale Onions" + }, + { + "selected": false, + "label": "Tell Tale Oranges", + "value": "Tell Tale Oranges" + }, + { + "selected": false, + "label": "Tell Tale Party Nuts", + "value": "Tell Tale Party Nuts" + }, + { + "selected": false, + "label": "Tell Tale Peaches", + "value": "Tell Tale Peaches" + }, + { + "selected": false, + "label": "Tell Tale Plums", + "value": "Tell Tale Plums" + }, + { + "selected": false, + "label": "Tell Tale Potatos", + "value": "Tell Tale Potatos" + }, + { + "selected": false, + "label": "Tell Tale Prepared Salad", + "value": "Tell Tale Prepared Salad" + }, + { + "selected": false, + "label": "Tell Tale Red Delcious Apples", + "value": "Tell Tale Red Delcious Apples" + }, + { + "selected": false, + "label": "Tell Tale Red Pepper", + "value": "Tell Tale Red Pepper" + }, + { + "selected": false, + "label": "Tell Tale Shitake Mushrooms", + "value": "Tell Tale Shitake Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale Squash", + "value": "Tell Tale Squash" + }, + { + "selected": false, + "label": "Tell Tale Summer Squash", + "value": "Tell Tale Summer Squash" + }, + { + "selected": false, + "label": "Tell Tale Sweet Onion", + "value": "Tell Tale Sweet Onion" + }, + { + "selected": false, + "label": "Tell Tale Sweet Peas", + "value": "Tell Tale Sweet Peas" + }, + { + "selected": false, + "label": "Tell Tale Tangerines", + "value": "Tell Tale Tangerines" + }, + { + "selected": false, + "label": "Tell Tale Tomatos", + "value": "Tell Tale Tomatos" + }, + { + "selected": false, + "label": "Tell Tale Walnuts", + "value": "Tell Tale Walnuts" + }, + { + "selected": false, + "label": "Thresher Bubble Gum", + "value": "Thresher Bubble Gum" + }, + { + "selected": false, + "label": "Thresher Malted Milk Balls", + "value": "Thresher Malted Milk Balls" + }, + { + "selected": false, + "label": "Thresher Mint Chocolate Bar", + "value": "Thresher Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Thresher Mints", + "value": "Thresher Mints" + }, + { + "selected": false, + "label": "Thresher Semi-Sweet Chocolate Bar", + "value": "Thresher Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Thresher Spicy Mints", + "value": "Thresher Spicy Mints" + }, + { + "selected": false, + "label": "Thresher Tasty Candy Bar", + "value": "Thresher Tasty Candy Bar" + }, + { + "selected": false, + "label": "Thresher White Chocolate Bar", + "value": "Thresher White Chocolate Bar" + }, + { + "selected": false, + "label": "Tip Top Lox", + "value": "Tip Top Lox" + }, + { + "selected": false, + "label": "Tip Top Scallops", + "value": "Tip Top Scallops" + }, + { + "selected": false, + "label": "Token Apple Drink", + "value": "Token Apple Drink" + }, + { + "selected": false, + "label": "Token Apple Juice", + "value": "Token Apple Juice" + }, + { + "selected": false, + "label": "Token Berry Juice", + "value": "Token Berry Juice" + }, + { + "selected": false, + "label": "Token Cola", + "value": "Token Cola" + }, + { + "selected": false, + "label": "Token Cranberry Juice", + "value": "Token Cranberry Juice" + }, + { + "selected": false, + "label": "Token Cream Soda", + "value": "Token Cream Soda" + }, + { + "selected": false, + "label": "Token Diet Cola", + "value": "Token Diet Cola" + }, + { + "selected": false, + "label": "Token Diet Soda", + "value": "Token Diet Soda" + }, + { + "selected": false, + "label": "Token Mango Drink", + "value": "Token Mango Drink" + }, + { + "selected": false, + "label": "Token Orange Juice", + "value": "Token Orange Juice" + }, + { + "selected": false, + "label": "Token Strawberry Drink", + "value": "Token Strawberry Drink" + }, + { + "selected": false, + "label": "Top Measure Chablis Wine", + "value": "Top Measure Chablis Wine" + }, + { + "selected": false, + "label": "Top Measure Chardonnay", + "value": "Top Measure Chardonnay" + }, + { + "selected": false, + "label": "Top Measure Chardonnay Wine", + "value": "Top Measure Chardonnay Wine" + }, + { + "selected": false, + "label": "Top Measure Imported Beer", + "value": "Top Measure Imported Beer" + }, + { + "selected": false, + "label": "Top Measure Light Beer", + "value": "Top Measure Light Beer" + }, + { + "selected": false, + "label": "Top Measure Light Wine", + "value": "Top Measure Light Wine" + }, + { + "selected": false, + "label": "Top Measure Merlot Wine", + "value": "Top Measure Merlot Wine" + }, + { + "selected": false, + "label": "Top Measure White Zinfandel Wine", + "value": "Top Measure White Zinfandel Wine" + }, + { + "selected": false, + "label": "Toretti Rosy Sunglasses", + "value": "Toretti Rosy Sunglasses" + }, + { + "selected": false, + "label": "Toucan Canned Mixed Fruit", + "value": "Toucan Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Toucan Canned Peaches", + "value": "Toucan Canned Peaches" + }, + { + "selected": false, + "label": "Tri-State Almonds", + "value": "Tri-State Almonds" + }, + { + "selected": false, + "label": "Tri-State Asparagus", + "value": "Tri-State Asparagus" + }, + { + "selected": false, + "label": "Tri-State Baby Onion", + "value": "Tri-State Baby Onion" + }, + { + "selected": false, + "label": "Tri-State Beets", + "value": "Tri-State Beets" + }, + { + "selected": false, + "label": "Tri-State Broccoli", + "value": "Tri-State Broccoli" + }, + { + "selected": false, + "label": "Tri-State Canned Peanuts", + "value": "Tri-State Canned Peanuts" + }, + { + "selected": false, + "label": "Tri-State Cantelope", + "value": "Tri-State Cantelope" + }, + { + "selected": false, + "label": "Tri-State Cauliflower", + "value": "Tri-State Cauliflower" + }, + { + "selected": false, + "label": "Tri-State Corn on the Cob", + "value": "Tri-State Corn on the Cob" + }, + { + "selected": false, + "label": "Tri-State Dried Mushrooms", + "value": "Tri-State Dried Mushrooms" + }, + { + "selected": false, + "label": "Tri-State Elephant Garlic", + "value": "Tri-State Elephant Garlic" + }, + { + "selected": false, + "label": "Tri-State Fancy Plums", + "value": "Tri-State Fancy Plums" + }, + { + "selected": false, + "label": "Tri-State Firm Tofu", + "value": "Tri-State Firm Tofu" + }, + { + "selected": false, + "label": "Tri-State Fresh Lima Beans", + "value": "Tri-State Fresh Lima Beans" + }, + { + "selected": false, + "label": "Tri-State Fuji Apples", + "value": "Tri-State Fuji Apples" + }, + { + "selected": false, + "label": "Tri-State Garlic", + "value": "Tri-State Garlic" + }, + { + "selected": false, + "label": "Tri-State Golden Delcious Apples", + "value": "Tri-State Golden Delcious Apples" + }, + { + "selected": false, + "label": "Tri-State Green Pepper", + "value": "Tri-State Green Pepper" + }, + { + "selected": false, + "label": "Tri-State Honey Dew", + "value": "Tri-State Honey Dew" + }, + { + "selected": false, + "label": "Tri-State Lemons", + "value": "Tri-State Lemons" + }, + { + "selected": false, + "label": "Tri-State Lettuce", + "value": "Tri-State Lettuce" + }, + { + "selected": false, + "label": "Tri-State Limes", + "value": "Tri-State Limes" + }, + { + "selected": false, + "label": "Tri-State Macintosh Apples", + "value": "Tri-State Macintosh Apples" + }, + { + "selected": false, + "label": "Tri-State Mandarin Oranges", + "value": "Tri-State Mandarin Oranges" + }, + { + "selected": false, + "label": "Tri-State Mixed Nuts", + "value": "Tri-State Mixed Nuts" + }, + { + "selected": false, + "label": "Tri-State Mushrooms", + "value": "Tri-State Mushrooms" + }, + { + "selected": false, + "label": "Tri-State New Potatos", + "value": "Tri-State New Potatos" + }, + { + "selected": false, + "label": "Tri-State Onions", + "value": "Tri-State Onions" + }, + { + "selected": false, + "label": "Tri-State Oranges", + "value": "Tri-State Oranges" + }, + { + "selected": false, + "label": "Tri-State Party Nuts", + "value": "Tri-State Party Nuts" + }, + { + "selected": false, + "label": "Tri-State Peaches", + "value": "Tri-State Peaches" + }, + { + "selected": false, + "label": "Tri-State Plums", + "value": "Tri-State Plums" + }, + { + "selected": false, + "label": "Tri-State Potatos", + "value": "Tri-State Potatos" + }, + { + "selected": false, + "label": "Tri-State Prepared Salad", + "value": "Tri-State Prepared Salad" + }, + { + "selected": false, + "label": "Tri-State Red Delcious Apples", + "value": "Tri-State Red Delcious Apples" + }, + { + "selected": false, + "label": "Tri-State Red Pepper", + "value": "Tri-State Red Pepper" + }, + { + "selected": false, + "label": "Tri-State Shitake Mushrooms", + "value": "Tri-State Shitake Mushrooms" + }, + { + "selected": false, + "label": "Tri-State Squash", + "value": "Tri-State Squash" + }, + { + "selected": false, + "label": "Tri-State Summer Squash", + "value": "Tri-State Summer Squash" + }, + { + "selected": false, + "label": "Tri-State Sweet Onion", + "value": "Tri-State Sweet Onion" + }, + { + "selected": false, + "label": "Tri-State Sweet Peas", + "value": "Tri-State Sweet Peas" + }, + { + "selected": false, + "label": "Tri-State Tangerines", + "value": "Tri-State Tangerines" + }, + { + "selected": false, + "label": "Tri-State Tomatos", + "value": "Tri-State Tomatos" + }, + { + "selected": false, + "label": "Tri-State Walnuts", + "value": "Tri-State Walnuts" + }, + { + "selected": false, + "label": "Urban Egg Substitute", + "value": "Urban Egg Substitute" + }, + { + "selected": false, + "label": "Urban Large Brown Eggs", + "value": "Urban Large Brown Eggs" + }, + { + "selected": false, + "label": "Urban Large Eggs", + "value": "Urban Large Eggs" + }, + { + "selected": false, + "label": "Urban Small Brown Eggs", + "value": "Urban Small Brown Eggs" + }, + { + "selected": false, + "label": "Urban Small Eggs", + "value": "Urban Small Eggs" + }, + { + "selected": false, + "label": "Walrus Chablis Wine", + "value": "Walrus Chablis Wine" + }, + { + "selected": false, + "label": "Walrus Chardonnay", + "value": "Walrus Chardonnay" + }, + { + "selected": false, + "label": "Walrus Chardonnay Wine", + "value": "Walrus Chardonnay Wine" + }, + { + "selected": false, + "label": "Walrus Imported Beer", + "value": "Walrus Imported Beer" + }, + { + "selected": false, + "label": "Walrus Light Beer", + "value": "Walrus Light Beer" + }, + { + "selected": false, + "label": "Walrus Light Wine", + "value": "Walrus Light Wine" + }, + { + "selected": false, + "label": "Walrus Merlot Wine", + "value": "Walrus Merlot Wine" + }, + { + "selected": false, + "label": "Walrus White Zinfandel Wine", + "value": "Walrus White Zinfandel Wine" + }, + { + "selected": false, + "label": "Washington Apple Drink", + "value": "Washington Apple Drink" + }, + { + "selected": false, + "label": "Washington Apple Juice", + "value": "Washington Apple Juice" + }, + { + "selected": false, + "label": "Washington Berry Juice", + "value": "Washington Berry Juice" + }, + { + "selected": false, + "label": "Washington Cola", + "value": "Washington Cola" + }, + { + "selected": false, + "label": "Washington Cranberry Juice", + "value": "Washington Cranberry Juice" + }, + { + "selected": false, + "label": "Washington Cream Soda", + "value": "Washington Cream Soda" + }, + { + "selected": false, + "label": "Washington Diet Cola", + "value": "Washington Diet Cola" + }, + { + "selected": false, + "label": "Washington Diet Soda", + "value": "Washington Diet Soda" + }, + { + "selected": false, + "label": "Washington Mango Drink", + "value": "Washington Mango Drink" + }, + { + "selected": false, + "label": "Washington Orange Juice", + "value": "Washington Orange Juice" + }, + { + "selected": false, + "label": "Washington Strawberry Drink", + "value": "Washington Strawberry Drink" + } + ] + }, + { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", + "id": "sales__product__recyclable_package_1", + "options": [ + { + "selected": true, + "label": "true", + "value": "true" + }, + { + "selected": true, + "label": "false", + "value": "false" + } + ] + }, + { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", + "id": "sales__product__low_fat_1", + "options": [ + { + "selected": true, + "label": "true", + "value": "true" + }, + { + "selected": true, + "label": "false", + "value": "false" + } + ] + }, + { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", + "id": "sales_fact_ALL__store_sales_2013_1", + "value": "19" + } + ] +} \ No newline at end of file diff --git a/client-network/src/test/resources/json/input_controls_with_states.json b/client-network/src/test/resources/json/input_controls_with_states.json new file mode 100644 index 00000000..d30f1463 --- /dev/null +++ b/client-network/src/test/resources/json/input_controls_with_states.json @@ -0,0 +1,7891 @@ +{ + "inputControl": [ + { + "id": "sales_fact_ALL__store_sales_2013_1", + "type": "singleValueNumber", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", + "label": "Store Sales 2013 is greater than", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [], + "state": { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", + "id": "sales_fact_ALL__store_sales_2013_1", + "value": "19" + } + }, + { + "id": "sales__product__low_fat_1", + "type": "multiSelectCheckbox", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", + "label": "Low Fat", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [], + "state": { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", + "id": "sales__product__low_fat_1", + "options": [ + { + "selected": true, + "label": "true", + "value": "true" + }, + { + "selected": true, + "label": "false", + "value": "false" + } + ] + } + }, + { + "id": "sales__product__recyclable_package_1", + "type": "multiSelectCheckbox", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", + "label": "Recyclable Packaging", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [], + "state": { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", + "id": "sales__product__recyclable_package_1", + "options": [ + { + "selected": true, + "label": "true", + "value": "true" + }, + { + "selected": true, + "label": "false", + "value": "false" + } + ] + } + }, + { + "id": "sales__product__product_name_1", + "type": "multiSelect", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", + "label": "Product Name", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [], + "state": { + "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", + "id": "sales__product__product_name_1", + "options": [ + { + "selected": false, + "label": "ADJ Rosy Sunglasses", + "value": "ADJ Rosy Sunglasses" + }, + { + "selected": false, + "label": "Akron City Map", + "value": "Akron City Map" + }, + { + "selected": false, + "label": "Akron Eyeglass Screwdriver", + "value": "Akron Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "American Beef Bologna", + "value": "American Beef Bologna" + }, + { + "selected": false, + "label": "American Chicken Hot Dogs", + "value": "American Chicken Hot Dogs" + }, + { + "selected": false, + "label": "American Cole Slaw", + "value": "American Cole Slaw" + }, + { + "selected": false, + "label": "American Corned Beef", + "value": "American Corned Beef" + }, + { + "selected": false, + "label": "American Foot-Long Hot Dogs", + "value": "American Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "American Low Fat Bologna", + "value": "American Low Fat Bologna" + }, + { + "selected": false, + "label": "American Low Fat Cole Slaw", + "value": "American Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "American Pimento Loaf", + "value": "American Pimento Loaf" + }, + { + "selected": false, + "label": "American Potato Salad", + "value": "American Potato Salad" + }, + { + "selected": false, + "label": "American Roasted Chicken", + "value": "American Roasted Chicken" + }, + { + "selected": false, + "label": "American Sliced Chicken", + "value": "American Sliced Chicken" + }, + { + "selected": false, + "label": "American Sliced Ham", + "value": "American Sliced Ham" + }, + { + "selected": false, + "label": "American Sliced Turkey", + "value": "American Sliced Turkey" + }, + { + "selected": false, + "label": "American Turkey Hot Dogs", + "value": "American Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Amigo Lox", + "value": "Amigo Lox" + }, + { + "selected": false, + "label": "Amigo Scallops", + "value": "Amigo Scallops" + }, + { + "selected": false, + "label": "Applause Canned Mixed Fruit", + "value": "Applause Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Applause Canned Peaches", + "value": "Applause Canned Peaches" + }, + { + "selected": false, + "label": "Atomic Bubble Gum", + "value": "Atomic Bubble Gum" + }, + { + "selected": false, + "label": "Atomic Malted Milk Balls", + "value": "Atomic Malted Milk Balls" + }, + { + "selected": false, + "label": "Atomic Mint Chocolate Bar", + "value": "Atomic Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Atomic Mints", + "value": "Atomic Mints" + }, + { + "selected": false, + "label": "Atomic Semi-Sweet Chocolate Bar", + "value": "Atomic Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Atomic Spicy Mints", + "value": "Atomic Spicy Mints" + }, + { + "selected": false, + "label": "Atomic Tasty Candy Bar", + "value": "Atomic Tasty Candy Bar" + }, + { + "selected": false, + "label": "Atomic White Chocolate Bar", + "value": "Atomic White Chocolate Bar" + }, + { + "selected": false, + "label": "BBB Best Apple Butter", + "value": "BBB Best Apple Butter" + }, + { + "selected": false, + "label": "BBB Best Apple Jam", + "value": "BBB Best Apple Jam" + }, + { + "selected": false, + "label": "BBB Best Apple Jelly", + "value": "BBB Best Apple Jelly" + }, + { + "selected": false, + "label": "BBB Best Apple Preserves", + "value": "BBB Best Apple Preserves" + }, + { + "selected": false, + "label": "BBB Best Brown Sugar", + "value": "BBB Best Brown Sugar" + }, + { + "selected": false, + "label": "BBB Best Canola Oil", + "value": "BBB Best Canola Oil" + }, + { + "selected": false, + "label": "BBB Best Chunky Peanut Butter", + "value": "BBB Best Chunky Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best Columbian Coffee", + "value": "BBB Best Columbian Coffee" + }, + { + "selected": false, + "label": "BBB Best Corn Oil", + "value": "BBB Best Corn Oil" + }, + { + "selected": false, + "label": "BBB Best Creamy Peanut Butter", + "value": "BBB Best Creamy Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best Decaf Coffee", + "value": "BBB Best Decaf Coffee" + }, + { + "selected": false, + "label": "BBB Best Extra Chunky Peanut Butter", + "value": "BBB Best Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "BBB Best French Roast Coffee", + "value": "BBB Best French Roast Coffee" + }, + { + "selected": false, + "label": "BBB Best Grape Jam", + "value": "BBB Best Grape Jam" + }, + { + "selected": false, + "label": "BBB Best Grape Jelly", + "value": "BBB Best Grape Jelly" + }, + { + "selected": false, + "label": "BBB Best Grape Preserves", + "value": "BBB Best Grape Preserves" + }, + { + "selected": false, + "label": "BBB Best Hot Chocolate", + "value": "BBB Best Hot Chocolate" + }, + { + "selected": false, + "label": "BBB Best Low Fat Apple Butter", + "value": "BBB Best Low Fat Apple Butter" + }, + { + "selected": false, + "label": "BBB Best Oregano", + "value": "BBB Best Oregano" + }, + { + "selected": false, + "label": "BBB Best Pepper", + "value": "BBB Best Pepper" + }, + { + "selected": false, + "label": "BBB Best Regular Coffee", + "value": "BBB Best Regular Coffee" + }, + { + "selected": false, + "label": "BBB Best Salt", + "value": "BBB Best Salt" + }, + { + "selected": false, + "label": "BBB Best Sesame Oil", + "value": "BBB Best Sesame Oil" + }, + { + "selected": false, + "label": "BBB Best Strawberry Jam", + "value": "BBB Best Strawberry Jam" + }, + { + "selected": false, + "label": "BBB Best Strawberry Jelly", + "value": "BBB Best Strawberry Jelly" + }, + { + "selected": false, + "label": "BBB Best Strawberry Preserves", + "value": "BBB Best Strawberry Preserves" + }, + { + "selected": false, + "label": "BBB Best Tomato Sauce", + "value": "BBB Best Tomato Sauce" + }, + { + "selected": false, + "label": "BBB Best Vegetable Oil", + "value": "BBB Best Vegetable Oil" + }, + { + "selected": false, + "label": "BBB Best White Sugar", + "value": "BBB Best White Sugar" + }, + { + "selected": false, + "label": "Best Choice Apple Fruit Roll", + "value": "Best Choice Apple Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Avocado Dip", + "value": "Best Choice Avocado Dip" + }, + { + "selected": false, + "label": "Best Choice BBQ Potato Chips", + "value": "Best Choice BBQ Potato Chips" + }, + { + "selected": false, + "label": "Best Choice Beef Jerky", + "value": "Best Choice Beef Jerky" + }, + { + "selected": false, + "label": "Best Choice Buttered Popcorn", + "value": "Best Choice Buttered Popcorn" + }, + { + "selected": false, + "label": "Best Choice Cheese Crackers", + "value": "Best Choice Cheese Crackers" + }, + { + "selected": false, + "label": "Best Choice Cheese Dip", + "value": "Best Choice Cheese Dip" + }, + { + "selected": false, + "label": "Best Choice Chocolate Chip Cookies", + "value": "Best Choice Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Best Choice Chocolate Donuts", + "value": "Best Choice Chocolate Donuts" + }, + { + "selected": false, + "label": "Best Choice Corn Chips", + "value": "Best Choice Corn Chips" + }, + { + "selected": false, + "label": "Best Choice Dried Apples", + "value": "Best Choice Dried Apples" + }, + { + "selected": false, + "label": "Best Choice Dried Apricots", + "value": "Best Choice Dried Apricots" + }, + { + "selected": false, + "label": "Best Choice Dried Dates", + "value": "Best Choice Dried Dates" + }, + { + "selected": false, + "label": "Best Choice Fondue Mix", + "value": "Best Choice Fondue Mix" + }, + { + "selected": false, + "label": "Best Choice Frosted Cookies", + "value": "Best Choice Frosted Cookies" + }, + { + "selected": false, + "label": "Best Choice Frosted Donuts", + "value": "Best Choice Frosted Donuts" + }, + { + "selected": false, + "label": "Best Choice Fudge Brownies", + "value": "Best Choice Fudge Brownies" + }, + { + "selected": false, + "label": "Best Choice Fudge Cookies", + "value": "Best Choice Fudge Cookies" + }, + { + "selected": false, + "label": "Best Choice Golden Raisins", + "value": "Best Choice Golden Raisins" + }, + { + "selected": false, + "label": "Best Choice Graham Crackers", + "value": "Best Choice Graham Crackers" + }, + { + "selected": false, + "label": "Best Choice Grape Fruit Roll", + "value": "Best Choice Grape Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Lemon Cookies", + "value": "Best Choice Lemon Cookies" + }, + { + "selected": false, + "label": "Best Choice Low Fat BBQ Chips", + "value": "Best Choice Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Best Choice Low Fat Chips", + "value": "Best Choice Low Fat Chips" + }, + { + "selected": false, + "label": "Best Choice Low Fat Cookies", + "value": "Best Choice Low Fat Cookies" + }, + { + "selected": false, + "label": "Best Choice Low Fat Popcorn", + "value": "Best Choice Low Fat Popcorn" + }, + { + "selected": false, + "label": "Best Choice Mini Donuts", + "value": "Best Choice Mini Donuts" + }, + { + "selected": false, + "label": "Best Choice No Salt Popcorn", + "value": "Best Choice No Salt Popcorn" + }, + { + "selected": false, + "label": "Best Choice Potato Chips", + "value": "Best Choice Potato Chips" + }, + { + "selected": false, + "label": "Best Choice Raisins", + "value": "Best Choice Raisins" + }, + { + "selected": false, + "label": "Best Choice Raspberry Fruit Roll", + "value": "Best Choice Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Salsa Dip", + "value": "Best Choice Salsa Dip" + }, + { + "selected": false, + "label": "Best Choice Salted Pretzels", + "value": "Best Choice Salted Pretzels" + }, + { + "selected": false, + "label": "Best Choice Sesame Crackers", + "value": "Best Choice Sesame Crackers" + }, + { + "selected": false, + "label": "Best Choice Strawberry Fruit Roll", + "value": "Best Choice Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Best Choice Sugar Cookies", + "value": "Best Choice Sugar Cookies" + }, + { + "selected": false, + "label": "Best Corn Puffs", + "value": "Best Corn Puffs" + }, + { + "selected": false, + "label": "Best Grits", + "value": "Best Grits" + }, + { + "selected": false, + "label": "Best Oatmeal", + "value": "Best Oatmeal" + }, + { + "selected": false, + "label": "Best Wheat Puffs", + "value": "Best Wheat Puffs" + }, + { + "selected": false, + "label": "Better Beef Soup", + "value": "Better Beef Soup" + }, + { + "selected": false, + "label": "Better Canned Beets", + "value": "Better Canned Beets" + }, + { + "selected": false, + "label": "Better Canned Peas", + "value": "Better Canned Peas" + }, + { + "selected": false, + "label": "Better Canned String Beans", + "value": "Better Canned String Beans" + }, + { + "selected": false, + "label": "Better Canned Tomatos", + "value": "Better Canned Tomatos" + }, + { + "selected": false, + "label": "Better Canned Tuna in Oil", + "value": "Better Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Better Canned Tuna in Water", + "value": "Better Canned Tuna in Water" + }, + { + "selected": false, + "label": "Better Canned Yams", + "value": "Better Canned Yams" + }, + { + "selected": false, + "label": "Better Chicken Noodle Soup", + "value": "Better Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Better Chicken Ramen Soup", + "value": "Better Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Better Chicken Soup", + "value": "Better Chicken Soup" + }, + { + "selected": false, + "label": "Better Creamed Corn", + "value": "Better Creamed Corn" + }, + { + "selected": false, + "label": "Better Fancy Canned Anchovies", + "value": "Better Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Better Fancy Canned Clams", + "value": "Better Fancy Canned Clams" + }, + { + "selected": false, + "label": "Better Fancy Canned Oysters", + "value": "Better Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Better Fancy Canned Sardines", + "value": "Better Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Better Large Canned Shrimp", + "value": "Better Large Canned Shrimp" + }, + { + "selected": false, + "label": "Better Noodle Soup", + "value": "Better Noodle Soup" + }, + { + "selected": false, + "label": "Better Regular Ramen Soup", + "value": "Better Regular Ramen Soup" + }, + { + "selected": false, + "label": "Better Rice Soup", + "value": "Better Rice Soup" + }, + { + "selected": false, + "label": "Better Turkey Noodle Soup", + "value": "Better Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Better Vegetable Soup", + "value": "Better Vegetable Soup" + }, + { + "selected": false, + "label": "Big City Canned Mixed Fruit", + "value": "Big City Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Big City Canned Peaches", + "value": "Big City Canned Peaches" + }, + { + "selected": false, + "label": "Big Time Apple Cinnamon Waffles", + "value": "Big Time Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Big Time Beef TV Dinner", + "value": "Big Time Beef TV Dinner" + }, + { + "selected": false, + "label": "Big Time Blueberry Waffles", + "value": "Big Time Blueberry Waffles" + }, + { + "selected": false, + "label": "Big Time Chicken TV Dinner", + "value": "Big Time Chicken TV Dinner" + }, + { + "selected": false, + "label": "Big Time Fajita French Fries", + "value": "Big Time Fajita French Fries" + }, + { + "selected": false, + "label": "Big Time Frozen Broccoli", + "value": "Big Time Frozen Broccoli" + }, + { + "selected": false, + "label": "Big Time Frozen Carrots", + "value": "Big Time Frozen Carrots" + }, + { + "selected": false, + "label": "Big Time Frozen Cauliflower", + "value": "Big Time Frozen Cauliflower" + }, + { + "selected": false, + "label": "Big Time Frozen Cheese Pizza", + "value": "Big Time Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Breast", + "value": "Big Time Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Thighs", + "value": "Big Time Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Big Time Frozen Chicken Wings", + "value": "Big Time Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Big Time Frozen Corn", + "value": "Big Time Frozen Corn" + }, + { + "selected": false, + "label": "Big Time Frozen Mushroom Pizza", + "value": "Big Time Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Pancakes", + "value": "Big Time Frozen Pancakes" + }, + { + "selected": false, + "label": "Big Time Frozen Peas", + "value": "Big Time Frozen Peas" + }, + { + "selected": false, + "label": "Big Time Frozen Pepperoni Pizza", + "value": "Big Time Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Big Time Frozen Sausage Pizza", + "value": "Big Time Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Big Time Grape Popsicles", + "value": "Big Time Grape Popsicles" + }, + { + "selected": false, + "label": "Big Time Home Style French Fries", + "value": "Big Time Home Style French Fries" + }, + { + "selected": false, + "label": "Big Time Ice Cream", + "value": "Big Time Ice Cream" + }, + { + "selected": false, + "label": "Big Time Ice Cream Sandwich", + "value": "Big Time Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Big Time Lemon Popsicles", + "value": "Big Time Lemon Popsicles" + }, + { + "selected": false, + "label": "Big Time Lime Popsicles", + "value": "Big Time Lime Popsicles" + }, + { + "selected": false, + "label": "Big Time Low Fat French Fries", + "value": "Big Time Low Fat French Fries" + }, + { + "selected": false, + "label": "Big Time Low Fat Waffles", + "value": "Big Time Low Fat Waffles" + }, + { + "selected": false, + "label": "Big Time Orange Popsicles", + "value": "Big Time Orange Popsicles" + }, + { + "selected": false, + "label": "Big Time Pancake Mix", + "value": "Big Time Pancake Mix" + }, + { + "selected": false, + "label": "Big Time Popsicles", + "value": "Big Time Popsicles" + }, + { + "selected": false, + "label": "Big Time Turkey TV Dinner", + "value": "Big Time Turkey TV Dinner" + }, + { + "selected": false, + "label": "Big Time Waffles", + "value": "Big Time Waffles" + }, + { + "selected": false, + "label": "Bird Call 200 MG Acetominifen", + "value": "Bird Call 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Bird Call 200 MG Ibuprofen", + "value": "Bird Call 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Bird Call Angled Toothbrush", + "value": "Bird Call Angled Toothbrush" + }, + { + "selected": false, + "label": "Bird Call Apricot Shampoo", + "value": "Bird Call Apricot Shampoo" + }, + { + "selected": false, + "label": "Bird Call Buffered Aspirin", + "value": "Bird Call Buffered Aspirin" + }, + { + "selected": false, + "label": "Bird Call Childrens Aspirin", + "value": "Bird Call Childrens Aspirin" + }, + { + "selected": false, + "label": "Bird Call Childrens Cold Remedy", + "value": "Bird Call Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Bird Call Conditioning Shampoo", + "value": "Bird Call Conditioning Shampoo" + }, + { + "selected": false, + "label": "Bird Call Deodorant", + "value": "Bird Call Deodorant" + }, + { + "selected": false, + "label": "Bird Call Dishwasher Detergent", + "value": "Bird Call Dishwasher Detergent" + }, + { + "selected": false, + "label": "Bird Call Extra Moisture Shampoo", + "value": "Bird Call Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Bird Call HCL Nasal Spray", + "value": "Bird Call HCL Nasal Spray" + }, + { + "selected": false, + "label": "Bird Call Laundry Detergent", + "value": "Bird Call Laundry Detergent" + }, + { + "selected": false, + "label": "Bird Call Mint Mouthwash", + "value": "Bird Call Mint Mouthwash" + }, + { + "selected": false, + "label": "Bird Call Multi-Symptom Cold Remedy", + "value": "Bird Call Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Bird Call Silky Smooth Hair Conditioner", + "value": "Bird Call Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Bird Call Tartar Control Toothpaste", + "value": "Bird Call Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Bird Call Toothpaste", + "value": "Bird Call Toothpaste" + }, + { + "selected": false, + "label": "Bird Call Whitening Toothpast", + "value": "Bird Call Whitening Toothpast" + }, + { + "selected": false, + "label": "Black Tie City Map", + "value": "Black Tie City Map" + }, + { + "selected": false, + "label": "Black Tie Eyeglass Screwdriver", + "value": "Black Tie Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Blue Label Beef Soup", + "value": "Blue Label Beef Soup" + }, + { + "selected": false, + "label": "Blue Label Canned Beets", + "value": "Blue Label Canned Beets" + }, + { + "selected": false, + "label": "Blue Label Canned Peas", + "value": "Blue Label Canned Peas" + }, + { + "selected": false, + "label": "Blue Label Canned String Beans", + "value": "Blue Label Canned String Beans" + }, + { + "selected": false, + "label": "Blue Label Canned Tomatos", + "value": "Blue Label Canned Tomatos" + }, + { + "selected": false, + "label": "Blue Label Canned Tuna in Oil", + "value": "Blue Label Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Blue Label Canned Tuna in Water", + "value": "Blue Label Canned Tuna in Water" + }, + { + "selected": false, + "label": "Blue Label Canned Yams", + "value": "Blue Label Canned Yams" + }, + { + "selected": false, + "label": "Blue Label Chicken Noodle Soup", + "value": "Blue Label Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Chicken Ramen Soup", + "value": "Blue Label Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Blue Label Chicken Soup", + "value": "Blue Label Chicken Soup" + }, + { + "selected": false, + "label": "Blue Label Creamed Corn", + "value": "Blue Label Creamed Corn" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Anchovies", + "value": "Blue Label Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Clams", + "value": "Blue Label Fancy Canned Clams" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Oysters", + "value": "Blue Label Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Blue Label Fancy Canned Sardines", + "value": "Blue Label Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Blue Label Large Canned Shrimp", + "value": "Blue Label Large Canned Shrimp" + }, + { + "selected": false, + "label": "Blue Label Noodle Soup", + "value": "Blue Label Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Regular Ramen Soup", + "value": "Blue Label Regular Ramen Soup" + }, + { + "selected": false, + "label": "Blue Label Rice Soup", + "value": "Blue Label Rice Soup" + }, + { + "selected": false, + "label": "Blue Label Turkey Noodle Soup", + "value": "Blue Label Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Blue Label Vegetable Soup", + "value": "Blue Label Vegetable Soup" + }, + { + "selected": false, + "label": "Blue Medal Egg Substitute", + "value": "Blue Medal Egg Substitute" + }, + { + "selected": false, + "label": "Blue Medal Large Brown Eggs", + "value": "Blue Medal Large Brown Eggs" + }, + { + "selected": false, + "label": "Blue Medal Large Eggs", + "value": "Blue Medal Large Eggs" + }, + { + "selected": false, + "label": "Blue Medal Small Brown Eggs", + "value": "Blue Medal Small Brown Eggs" + }, + { + "selected": false, + "label": "Blue Medal Small Eggs", + "value": "Blue Medal Small Eggs" + }, + { + "selected": false, + "label": "Booker 1% Milk", + "value": "Booker 1% Milk" + }, + { + "selected": false, + "label": "Booker 2% Milk", + "value": "Booker 2% Milk" + }, + { + "selected": false, + "label": "Booker Blueberry Yogurt", + "value": "Booker Blueberry Yogurt" + }, + { + "selected": false, + "label": "Booker Buttermilk", + "value": "Booker Buttermilk" + }, + { + "selected": false, + "label": "Booker Cheese Spread", + "value": "Booker Cheese Spread" + }, + { + "selected": false, + "label": "Booker Chocolate Milk", + "value": "Booker Chocolate Milk" + }, + { + "selected": false, + "label": "Booker Havarti Cheese", + "value": "Booker Havarti Cheese" + }, + { + "selected": false, + "label": "Booker Head Cheese", + "value": "Booker Head Cheese" + }, + { + "selected": false, + "label": "Booker Jack Cheese", + "value": "Booker Jack Cheese" + }, + { + "selected": false, + "label": "Booker Large Curd Cottage Cheese", + "value": "Booker Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Booker Low Fat Cottage Cheese", + "value": "Booker Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Booker Low Fat Sour Cream", + "value": "Booker Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Booker Low Fat String Cheese", + "value": "Booker Low Fat String Cheese" + }, + { + "selected": false, + "label": "Booker Mild Cheddar Cheese", + "value": "Booker Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Booker Muenster Cheese", + "value": "Booker Muenster Cheese" + }, + { + "selected": false, + "label": "Booker Sharp Cheddar Cheese", + "value": "Booker Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Booker Sour Cream", + "value": "Booker Sour Cream" + }, + { + "selected": false, + "label": "Booker Strawberry Yogurt", + "value": "Booker Strawberry Yogurt" + }, + { + "selected": false, + "label": "Booker String Cheese", + "value": "Booker String Cheese" + }, + { + "selected": false, + "label": "Booker Whole Milk", + "value": "Booker Whole Milk" + }, + { + "selected": false, + "label": "Bravo Beef Soup", + "value": "Bravo Beef Soup" + }, + { + "selected": false, + "label": "Bravo Canned Beets", + "value": "Bravo Canned Beets" + }, + { + "selected": false, + "label": "Bravo Canned Peas", + "value": "Bravo Canned Peas" + }, + { + "selected": false, + "label": "Bravo Canned String Beans", + "value": "Bravo Canned String Beans" + }, + { + "selected": false, + "label": "Bravo Canned Tomatos", + "value": "Bravo Canned Tomatos" + }, + { + "selected": false, + "label": "Bravo Canned Tuna in Oil", + "value": "Bravo Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Bravo Canned Tuna in Water", + "value": "Bravo Canned Tuna in Water" + }, + { + "selected": false, + "label": "Bravo Canned Yams", + "value": "Bravo Canned Yams" + }, + { + "selected": false, + "label": "Bravo Chicken Noodle Soup", + "value": "Bravo Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Chicken Ramen Soup", + "value": "Bravo Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Bravo Chicken Soup", + "value": "Bravo Chicken Soup" + }, + { + "selected": false, + "label": "Bravo Creamed Corn", + "value": "Bravo Creamed Corn" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Anchovies", + "value": "Bravo Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Clams", + "value": "Bravo Fancy Canned Clams" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Oysters", + "value": "Bravo Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Bravo Fancy Canned Sardines", + "value": "Bravo Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Bravo Large Canned Shrimp", + "value": "Bravo Large Canned Shrimp" + }, + { + "selected": false, + "label": "Bravo Noodle Soup", + "value": "Bravo Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Regular Ramen Soup", + "value": "Bravo Regular Ramen Soup" + }, + { + "selected": false, + "label": "Bravo Rice Soup", + "value": "Bravo Rice Soup" + }, + { + "selected": false, + "label": "Bravo Turkey Noodle Soup", + "value": "Bravo Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Bravo Vegetable Soup", + "value": "Bravo Vegetable Soup" + }, + { + "selected": false, + "label": "Carlson 1% Milk", + "value": "Carlson 1% Milk" + }, + { + "selected": false, + "label": "Carlson 2% Milk", + "value": "Carlson 2% Milk" + }, + { + "selected": false, + "label": "Carlson Blueberry Yogurt", + "value": "Carlson Blueberry Yogurt" + }, + { + "selected": false, + "label": "Carlson Buttermilk", + "value": "Carlson Buttermilk" + }, + { + "selected": false, + "label": "Carlson Cheese Spread", + "value": "Carlson Cheese Spread" + }, + { + "selected": false, + "label": "Carlson Chocolate Milk", + "value": "Carlson Chocolate Milk" + }, + { + "selected": false, + "label": "Carlson Havarti Cheese", + "value": "Carlson Havarti Cheese" + }, + { + "selected": false, + "label": "Carlson Head Cheese", + "value": "Carlson Head Cheese" + }, + { + "selected": false, + "label": "Carlson Jack Cheese", + "value": "Carlson Jack Cheese" + }, + { + "selected": false, + "label": "Carlson Large Curd Cottage Cheese", + "value": "Carlson Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Carlson Low Fat Cottage Cheese", + "value": "Carlson Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Carlson Low Fat Sour Cream", + "value": "Carlson Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Carlson Low Fat String Cheese", + "value": "Carlson Low Fat String Cheese" + }, + { + "selected": false, + "label": "Carlson Mild Cheddar Cheese", + "value": "Carlson Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Carlson Muenster Cheese", + "value": "Carlson Muenster Cheese" + }, + { + "selected": false, + "label": "Carlson Sharp Cheddar Cheese", + "value": "Carlson Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Carlson Sour Cream", + "value": "Carlson Sour Cream" + }, + { + "selected": false, + "label": "Carlson Strawberry Yogurt", + "value": "Carlson Strawberry Yogurt" + }, + { + "selected": false, + "label": "Carlson String Cheese", + "value": "Carlson String Cheese" + }, + { + "selected": false, + "label": "Carlson Whole Milk", + "value": "Carlson Whole Milk" + }, + { + "selected": false, + "label": "Carrington Apple Cinnamon Waffles", + "value": "Carrington Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Carrington Beef TV Dinner", + "value": "Carrington Beef TV Dinner" + }, + { + "selected": false, + "label": "Carrington Blueberry Waffles", + "value": "Carrington Blueberry Waffles" + }, + { + "selected": false, + "label": "Carrington Chicken TV Dinner", + "value": "Carrington Chicken TV Dinner" + }, + { + "selected": false, + "label": "Carrington Fajita French Fries", + "value": "Carrington Fajita French Fries" + }, + { + "selected": false, + "label": "Carrington Frozen Broccoli", + "value": "Carrington Frozen Broccoli" + }, + { + "selected": false, + "label": "Carrington Frozen Carrots", + "value": "Carrington Frozen Carrots" + }, + { + "selected": false, + "label": "Carrington Frozen Cauliflower", + "value": "Carrington Frozen Cauliflower" + }, + { + "selected": false, + "label": "Carrington Frozen Cheese Pizza", + "value": "Carrington Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Breast", + "value": "Carrington Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Thighs", + "value": "Carrington Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Carrington Frozen Chicken Wings", + "value": "Carrington Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Carrington Frozen Corn", + "value": "Carrington Frozen Corn" + }, + { + "selected": false, + "label": "Carrington Frozen Mushroom Pizza", + "value": "Carrington Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Pancakes", + "value": "Carrington Frozen Pancakes" + }, + { + "selected": false, + "label": "Carrington Frozen Peas", + "value": "Carrington Frozen Peas" + }, + { + "selected": false, + "label": "Carrington Frozen Pepperoni Pizza", + "value": "Carrington Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Carrington Frozen Sausage Pizza", + "value": "Carrington Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Carrington Grape Popsicles", + "value": "Carrington Grape Popsicles" + }, + { + "selected": false, + "label": "Carrington Home Style French Fries", + "value": "Carrington Home Style French Fries" + }, + { + "selected": false, + "label": "Carrington Ice Cream", + "value": "Carrington Ice Cream" + }, + { + "selected": false, + "label": "Carrington Ice Cream Sandwich", + "value": "Carrington Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Carrington Lemon Popsicles", + "value": "Carrington Lemon Popsicles" + }, + { + "selected": false, + "label": "Carrington Lime Popsicles", + "value": "Carrington Lime Popsicles" + }, + { + "selected": false, + "label": "Carrington Low Fat French Fries", + "value": "Carrington Low Fat French Fries" + }, + { + "selected": false, + "label": "Carrington Low Fat Waffles", + "value": "Carrington Low Fat Waffles" + }, + { + "selected": false, + "label": "Carrington Orange Popsicles", + "value": "Carrington Orange Popsicles" + }, + { + "selected": false, + "label": "Carrington Pancake Mix", + "value": "Carrington Pancake Mix" + }, + { + "selected": false, + "label": "Carrington Popsicles", + "value": "Carrington Popsicles" + }, + { + "selected": false, + "label": "Carrington Turkey TV Dinner", + "value": "Carrington Turkey TV Dinner" + }, + { + "selected": false, + "label": "Carrington Waffles", + "value": "Carrington Waffles" + }, + { + "selected": false, + "label": "CDR Apple Butter", + "value": "CDR Apple Butter" + }, + { + "selected": false, + "label": "CDR Apple Jam", + "value": "CDR Apple Jam" + }, + { + "selected": false, + "label": "CDR Apple Jelly", + "value": "CDR Apple Jelly" + }, + { + "selected": false, + "label": "CDR Apple Preserves", + "value": "CDR Apple Preserves" + }, + { + "selected": false, + "label": "CDR Brown Sugar", + "value": "CDR Brown Sugar" + }, + { + "selected": false, + "label": "CDR Canola Oil", + "value": "CDR Canola Oil" + }, + { + "selected": false, + "label": "CDR Chunky Peanut Butter", + "value": "CDR Chunky Peanut Butter" + }, + { + "selected": false, + "label": "CDR Columbian Coffee", + "value": "CDR Columbian Coffee" + }, + { + "selected": false, + "label": "CDR Corn Oil", + "value": "CDR Corn Oil" + }, + { + "selected": false, + "label": "CDR Creamy Peanut Butter", + "value": "CDR Creamy Peanut Butter" + }, + { + "selected": false, + "label": "CDR Decaf Coffee", + "value": "CDR Decaf Coffee" + }, + { + "selected": false, + "label": "CDR Extra Chunky Peanut Butter", + "value": "CDR Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "CDR French Roast Coffee", + "value": "CDR French Roast Coffee" + }, + { + "selected": false, + "label": "CDR Grape Jam", + "value": "CDR Grape Jam" + }, + { + "selected": false, + "label": "CDR Grape Jelly", + "value": "CDR Grape Jelly" + }, + { + "selected": false, + "label": "CDR Grape Preserves", + "value": "CDR Grape Preserves" + }, + { + "selected": false, + "label": "CDR Hot Chocolate", + "value": "CDR Hot Chocolate" + }, + { + "selected": false, + "label": "CDR Low Fat Apple Butter", + "value": "CDR Low Fat Apple Butter" + }, + { + "selected": false, + "label": "CDR Oregano", + "value": "CDR Oregano" + }, + { + "selected": false, + "label": "CDR Pepper", + "value": "CDR Pepper" + }, + { + "selected": false, + "label": "CDR Regular Coffee", + "value": "CDR Regular Coffee" + }, + { + "selected": false, + "label": "CDR Salt", + "value": "CDR Salt" + }, + { + "selected": false, + "label": "CDR Sesame Oil", + "value": "CDR Sesame Oil" + }, + { + "selected": false, + "label": "CDR Strawberry Jam", + "value": "CDR Strawberry Jam" + }, + { + "selected": false, + "label": "CDR Strawberry Jelly", + "value": "CDR Strawberry Jelly" + }, + { + "selected": false, + "label": "CDR Strawberry Preserves", + "value": "CDR Strawberry Preserves" + }, + { + "selected": false, + "label": "CDR Tomato Sauce", + "value": "CDR Tomato Sauce" + }, + { + "selected": false, + "label": "CDR Vegetable Oil", + "value": "CDR Vegetable Oil" + }, + { + "selected": false, + "label": "CDR White Sugar", + "value": "CDR White Sugar" + }, + { + "selected": false, + "label": "Choice Bubble Gum", + "value": "Choice Bubble Gum" + }, + { + "selected": false, + "label": "Choice Malted Milk Balls", + "value": "Choice Malted Milk Balls" + }, + { + "selected": false, + "label": "Choice Mint Chocolate Bar", + "value": "Choice Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Choice Mints", + "value": "Choice Mints" + }, + { + "selected": false, + "label": "Choice Semi-Sweet Chocolate Bar", + "value": "Choice Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Choice Spicy Mints", + "value": "Choice Spicy Mints" + }, + { + "selected": false, + "label": "Choice Tasty Candy Bar", + "value": "Choice Tasty Candy Bar" + }, + { + "selected": false, + "label": "Choice White Chocolate Bar", + "value": "Choice White Chocolate Bar" + }, + { + "selected": false, + "label": "Club 1% Milk", + "value": "Club 1% Milk" + }, + { + "selected": false, + "label": "Club 2% Milk", + "value": "Club 2% Milk" + }, + { + "selected": false, + "label": "Club Blueberry Yogurt", + "value": "Club Blueberry Yogurt" + }, + { + "selected": false, + "label": "Club Buttermilk", + "value": "Club Buttermilk" + }, + { + "selected": false, + "label": "Club Cheese Spread", + "value": "Club Cheese Spread" + }, + { + "selected": false, + "label": "Club Chocolate Milk", + "value": "Club Chocolate Milk" + }, + { + "selected": false, + "label": "Club Havarti Cheese", + "value": "Club Havarti Cheese" + }, + { + "selected": false, + "label": "Club Head Cheese", + "value": "Club Head Cheese" + }, + { + "selected": false, + "label": "Club Jack Cheese", + "value": "Club Jack Cheese" + }, + { + "selected": false, + "label": "Club Large Curd Cottage Cheese", + "value": "Club Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Club Low Fat Cottage Cheese", + "value": "Club Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Club Low Fat Sour Cream", + "value": "Club Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Club Low Fat String Cheese", + "value": "Club Low Fat String Cheese" + }, + { + "selected": false, + "label": "Club Mild Cheddar Cheese", + "value": "Club Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Club Muenster Cheese", + "value": "Club Muenster Cheese" + }, + { + "selected": false, + "label": "Club Sharp Cheddar Cheese", + "value": "Club Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Club Sour Cream", + "value": "Club Sour Cream" + }, + { + "selected": false, + "label": "Club Strawberry Yogurt", + "value": "Club Strawberry Yogurt" + }, + { + "selected": false, + "label": "Club String Cheese", + "value": "Club String Cheese" + }, + { + "selected": false, + "label": "Club Whole Milk", + "value": "Club Whole Milk" + }, + { + "selected": false, + "label": "Colony Bagels", + "value": "Colony Bagels" + }, + { + "selected": false, + "label": "Colony Blueberry Muffins", + "value": "Colony Blueberry Muffins" + }, + { + "selected": false, + "label": "Colony Cranberry Muffins", + "value": "Colony Cranberry Muffins" + }, + { + "selected": false, + "label": "Colony English Muffins", + "value": "Colony English Muffins" + }, + { + "selected": false, + "label": "Colony Muffins", + "value": "Colony Muffins" + }, + { + "selected": false, + "label": "Colony Pumpernickel Bread", + "value": "Colony Pumpernickel Bread" + }, + { + "selected": false, + "label": "Colony Rye Bread", + "value": "Colony Rye Bread" + }, + { + "selected": false, + "label": "Colony Wheat Bread", + "value": "Colony Wheat Bread" + }, + { + "selected": false, + "label": "Colony White Bread", + "value": "Colony White Bread" + }, + { + "selected": false, + "label": "Colossal Manicotti", + "value": "Colossal Manicotti" + }, + { + "selected": false, + "label": "Colossal Ravioli", + "value": "Colossal Ravioli" + }, + { + "selected": false, + "label": "Colossal Rice Medly", + "value": "Colossal Rice Medly" + }, + { + "selected": false, + "label": "Colossal Spaghetti", + "value": "Colossal Spaghetti" + }, + { + "selected": false, + "label": "Colossal Thai Rice", + "value": "Colossal Thai Rice" + }, + { + "selected": false, + "label": "Consolidated 200 MG Acetominifen", + "value": "Consolidated 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Consolidated 200 MG Ibuprofen", + "value": "Consolidated 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Consolidated Angled Toothbrush", + "value": "Consolidated Angled Toothbrush" + }, + { + "selected": false, + "label": "Consolidated Apricot Shampoo", + "value": "Consolidated Apricot Shampoo" + }, + { + "selected": false, + "label": "Consolidated Buffered Aspirin", + "value": "Consolidated Buffered Aspirin" + }, + { + "selected": false, + "label": "Consolidated Childrens Aspirin", + "value": "Consolidated Childrens Aspirin" + }, + { + "selected": false, + "label": "Consolidated Childrens Cold Remedy", + "value": "Consolidated Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Consolidated Conditioning Shampoo", + "value": "Consolidated Conditioning Shampoo" + }, + { + "selected": false, + "label": "Consolidated Deodorant", + "value": "Consolidated Deodorant" + }, + { + "selected": false, + "label": "Consolidated Dishwasher Detergent", + "value": "Consolidated Dishwasher Detergent" + }, + { + "selected": false, + "label": "Consolidated Extra Moisture Shampoo", + "value": "Consolidated Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Consolidated HCL Nasal Spray", + "value": "Consolidated HCL Nasal Spray" + }, + { + "selected": false, + "label": "Consolidated Laundry Detergent", + "value": "Consolidated Laundry Detergent" + }, + { + "selected": false, + "label": "Consolidated Mint Mouthwash", + "value": "Consolidated Mint Mouthwash" + }, + { + "selected": false, + "label": "Consolidated Multi-Symptom Cold Remedy", + "value": "Consolidated Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Consolidated Silky Smooth Hair Conditioner", + "value": "Consolidated Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Consolidated Tartar Control Toothpaste", + "value": "Consolidated Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Consolidated Toothpaste", + "value": "Consolidated Toothpaste" + }, + { + "selected": false, + "label": "Consolidated Whitening Toothpast", + "value": "Consolidated Whitening Toothpast" + }, + { + "selected": false, + "label": "Cormorant 100 Watt Lightbulb", + "value": "Cormorant 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 25 Watt Lightbulb", + "value": "Cormorant 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 60 Watt Lightbulb", + "value": "Cormorant 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant 75 Watt Lightbulb", + "value": "Cormorant 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Cormorant AAA-Size Batteries", + "value": "Cormorant AAA-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant AA-Size Batteries", + "value": "Cormorant AA-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant Bees Wax Candles", + "value": "Cormorant Bees Wax Candles" + }, + { + "selected": false, + "label": "Cormorant Copper Cleaner", + "value": "Cormorant Copper Cleaner" + }, + { + "selected": false, + "label": "Cormorant Copper Pot Scrubber", + "value": "Cormorant Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Cormorant Counter Cleaner", + "value": "Cormorant Counter Cleaner" + }, + { + "selected": false, + "label": "Cormorant C-Size Batteries", + "value": "Cormorant C-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant D-Size Batteries", + "value": "Cormorant D-Size Batteries" + }, + { + "selected": false, + "label": "Cormorant Economy Toilet Brush", + "value": "Cormorant Economy Toilet Brush" + }, + { + "selected": false, + "label": "Cormorant Frying Pan", + "value": "Cormorant Frying Pan" + }, + { + "selected": false, + "label": "Cormorant Glass Cleaner", + "value": "Cormorant Glass Cleaner" + }, + { + "selected": false, + "label": "Cormorant Large Sponge", + "value": "Cormorant Large Sponge" + }, + { + "selected": false, + "label": "Cormorant Paper Cups", + "value": "Cormorant Paper Cups" + }, + { + "selected": false, + "label": "Cormorant Paper Plates", + "value": "Cormorant Paper Plates" + }, + { + "selected": false, + "label": "Cormorant Paper Towels", + "value": "Cormorant Paper Towels" + }, + { + "selected": false, + "label": "Cormorant Plastic Forks", + "value": "Cormorant Plastic Forks" + }, + { + "selected": false, + "label": "Cormorant Plastic Knives", + "value": "Cormorant Plastic Knives" + }, + { + "selected": false, + "label": "Cormorant Plastic Spoons", + "value": "Cormorant Plastic Spoons" + }, + { + "selected": false, + "label": "Cormorant Room Freshener", + "value": "Cormorant Room Freshener" + }, + { + "selected": false, + "label": "Cormorant Scented Tissue", + "value": "Cormorant Scented Tissue" + }, + { + "selected": false, + "label": "Cormorant Scented Toilet Tissue", + "value": "Cormorant Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Cormorant Scissors", + "value": "Cormorant Scissors" + }, + { + "selected": false, + "label": "Cormorant Screw Driver", + "value": "Cormorant Screw Driver" + }, + { + "selected": false, + "label": "Cormorant Silver Cleaner", + "value": "Cormorant Silver Cleaner" + }, + { + "selected": false, + "label": "Cormorant Soft Napkins", + "value": "Cormorant Soft Napkins" + }, + { + "selected": false, + "label": "Cormorant Tissues", + "value": "Cormorant Tissues" + }, + { + "selected": false, + "label": "Cormorant Toilet Bowl Cleaner", + "value": "Cormorant Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Cormorant Toilet Paper", + "value": "Cormorant Toilet Paper" + }, + { + "selected": false, + "label": "Curlew Lox", + "value": "Curlew Lox" + }, + { + "selected": false, + "label": "Curlew Scallops", + "value": "Curlew Scallops" + }, + { + "selected": false, + "label": "Cutting Edge Beef Bologna", + "value": "Cutting Edge Beef Bologna" + }, + { + "selected": false, + "label": "Cutting Edge Chicken Hot Dogs", + "value": "Cutting Edge Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Cutting Edge Cole Slaw", + "value": "Cutting Edge Cole Slaw" + }, + { + "selected": false, + "label": "Cutting Edge Corned Beef", + "value": "Cutting Edge Corned Beef" + }, + { + "selected": false, + "label": "Cutting Edge Foot-Long Hot Dogs", + "value": "Cutting Edge Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Cutting Edge Low Fat Bologna", + "value": "Cutting Edge Low Fat Bologna" + }, + { + "selected": false, + "label": "Cutting Edge Low Fat Cole Slaw", + "value": "Cutting Edge Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Cutting Edge Pimento Loaf", + "value": "Cutting Edge Pimento Loaf" + }, + { + "selected": false, + "label": "Cutting Edge Potato Salad", + "value": "Cutting Edge Potato Salad" + }, + { + "selected": false, + "label": "Cutting Edge Roasted Chicken", + "value": "Cutting Edge Roasted Chicken" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Chicken", + "value": "Cutting Edge Sliced Chicken" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Ham", + "value": "Cutting Edge Sliced Ham" + }, + { + "selected": false, + "label": "Cutting Edge Sliced Turkey", + "value": "Cutting Edge Sliced Turkey" + }, + { + "selected": false, + "label": "Cutting Edge Turkey Hot Dogs", + "value": "Cutting Edge Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Denny 100 Watt Lightbulb", + "value": "Denny 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 25 Watt Lightbulb", + "value": "Denny 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 60 Watt Lightbulb", + "value": "Denny 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny 75 Watt Lightbulb", + "value": "Denny 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Denny AAA-Size Batteries", + "value": "Denny AAA-Size Batteries" + }, + { + "selected": false, + "label": "Denny AA-Size Batteries", + "value": "Denny AA-Size Batteries" + }, + { + "selected": false, + "label": "Denny Bees Wax Candles", + "value": "Denny Bees Wax Candles" + }, + { + "selected": false, + "label": "Denny Copper Cleaner", + "value": "Denny Copper Cleaner" + }, + { + "selected": false, + "label": "Denny Copper Pot Scrubber", + "value": "Denny Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Denny Counter Cleaner", + "value": "Denny Counter Cleaner" + }, + { + "selected": false, + "label": "Denny C-Size Batteries", + "value": "Denny C-Size Batteries" + }, + { + "selected": false, + "label": "Denny D-Size Batteries", + "value": "Denny D-Size Batteries" + }, + { + "selected": false, + "label": "Denny Economy Toilet Brush", + "value": "Denny Economy Toilet Brush" + }, + { + "selected": false, + "label": "Denny Frying Pan", + "value": "Denny Frying Pan" + }, + { + "selected": false, + "label": "Denny Glass Cleaner", + "value": "Denny Glass Cleaner" + }, + { + "selected": false, + "label": "Denny Large Sponge", + "value": "Denny Large Sponge" + }, + { + "selected": false, + "label": "Denny Paper Cups", + "value": "Denny Paper Cups" + }, + { + "selected": false, + "label": "Denny Paper Plates", + "value": "Denny Paper Plates" + }, + { + "selected": false, + "label": "Denny Paper Towels", + "value": "Denny Paper Towels" + }, + { + "selected": false, + "label": "Denny Plastic Forks", + "value": "Denny Plastic Forks" + }, + { + "selected": false, + "label": "Denny Plastic Knives", + "value": "Denny Plastic Knives" + }, + { + "selected": false, + "label": "Denny Plastic Spoons", + "value": "Denny Plastic Spoons" + }, + { + "selected": false, + "label": "Denny Room Freshener", + "value": "Denny Room Freshener" + }, + { + "selected": false, + "label": "Denny Scented Tissue", + "value": "Denny Scented Tissue" + }, + { + "selected": false, + "label": "Denny Scented Toilet Tissue", + "value": "Denny Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Denny Scissors", + "value": "Denny Scissors" + }, + { + "selected": false, + "label": "Denny Screw Driver", + "value": "Denny Screw Driver" + }, + { + "selected": false, + "label": "Denny Silver Cleaner", + "value": "Denny Silver Cleaner" + }, + { + "selected": false, + "label": "Denny Soft Napkins", + "value": "Denny Soft Napkins" + }, + { + "selected": false, + "label": "Denny Tissues", + "value": "Denny Tissues" + }, + { + "selected": false, + "label": "Denny Toilet Bowl Cleaner", + "value": "Denny Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Denny Toilet Paper", + "value": "Denny Toilet Paper" + }, + { + "selected": false, + "label": "Discover Manicotti", + "value": "Discover Manicotti" + }, + { + "selected": false, + "label": "Discover Ravioli", + "value": "Discover Ravioli" + }, + { + "selected": false, + "label": "Discover Rice Medly", + "value": "Discover Rice Medly" + }, + { + "selected": false, + "label": "Discover Spaghetti", + "value": "Discover Spaghetti" + }, + { + "selected": false, + "label": "Discover Thai Rice", + "value": "Discover Thai Rice" + }, + { + "selected": false, + "label": "Dollar Monthly Auto Magazine", + "value": "Dollar Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Computer Magazine", + "value": "Dollar Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Fashion Magazine", + "value": "Dollar Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Home Magazine", + "value": "Dollar Monthly Home Magazine" + }, + { + "selected": false, + "label": "Dollar Monthly Sports Magazine", + "value": "Dollar Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Dual City Lox", + "value": "Dual City Lox" + }, + { + "selected": false, + "label": "Dual City Scallops", + "value": "Dual City Scallops" + }, + { + "selected": false, + "label": "Ebony Almonds", + "value": "Ebony Almonds" + }, + { + "selected": false, + "label": "Ebony Asparagus", + "value": "Ebony Asparagus" + }, + { + "selected": false, + "label": "Ebony Baby Onion", + "value": "Ebony Baby Onion" + }, + { + "selected": false, + "label": "Ebony Beets", + "value": "Ebony Beets" + }, + { + "selected": false, + "label": "Ebony Broccoli", + "value": "Ebony Broccoli" + }, + { + "selected": false, + "label": "Ebony Canned Peanuts", + "value": "Ebony Canned Peanuts" + }, + { + "selected": false, + "label": "Ebony Cantelope", + "value": "Ebony Cantelope" + }, + { + "selected": false, + "label": "Ebony Cauliflower", + "value": "Ebony Cauliflower" + }, + { + "selected": false, + "label": "Ebony Corn on the Cob", + "value": "Ebony Corn on the Cob" + }, + { + "selected": false, + "label": "Ebony Dried Mushrooms", + "value": "Ebony Dried Mushrooms" + }, + { + "selected": false, + "label": "Ebony Elephant Garlic", + "value": "Ebony Elephant Garlic" + }, + { + "selected": false, + "label": "Ebony Fancy Plums", + "value": "Ebony Fancy Plums" + }, + { + "selected": false, + "label": "Ebony Firm Tofu", + "value": "Ebony Firm Tofu" + }, + { + "selected": false, + "label": "Ebony Fresh Lima Beans", + "value": "Ebony Fresh Lima Beans" + }, + { + "selected": false, + "label": "Ebony Fuji Apples", + "value": "Ebony Fuji Apples" + }, + { + "selected": false, + "label": "Ebony Garlic", + "value": "Ebony Garlic" + }, + { + "selected": false, + "label": "Ebony Golden Delcious Apples", + "value": "Ebony Golden Delcious Apples" + }, + { + "selected": false, + "label": "Ebony Green Pepper", + "value": "Ebony Green Pepper" + }, + { + "selected": false, + "label": "Ebony Honey Dew", + "value": "Ebony Honey Dew" + }, + { + "selected": false, + "label": "Ebony Lemons", + "value": "Ebony Lemons" + }, + { + "selected": false, + "label": "Ebony Lettuce", + "value": "Ebony Lettuce" + }, + { + "selected": false, + "label": "Ebony Limes", + "value": "Ebony Limes" + }, + { + "selected": false, + "label": "Ebony Macintosh Apples", + "value": "Ebony Macintosh Apples" + }, + { + "selected": false, + "label": "Ebony Mandarin Oranges", + "value": "Ebony Mandarin Oranges" + }, + { + "selected": false, + "label": "Ebony Mixed Nuts", + "value": "Ebony Mixed Nuts" + }, + { + "selected": false, + "label": "Ebony Mushrooms", + "value": "Ebony Mushrooms" + }, + { + "selected": false, + "label": "Ebony New Potatos", + "value": "Ebony New Potatos" + }, + { + "selected": false, + "label": "Ebony Onions", + "value": "Ebony Onions" + }, + { + "selected": false, + "label": "Ebony Oranges", + "value": "Ebony Oranges" + }, + { + "selected": false, + "label": "Ebony Party Nuts", + "value": "Ebony Party Nuts" + }, + { + "selected": false, + "label": "Ebony Peaches", + "value": "Ebony Peaches" + }, + { + "selected": false, + "label": "Ebony Plums", + "value": "Ebony Plums" + }, + { + "selected": false, + "label": "Ebony Potatos", + "value": "Ebony Potatos" + }, + { + "selected": false, + "label": "Ebony Prepared Salad", + "value": "Ebony Prepared Salad" + }, + { + "selected": false, + "label": "Ebony Red Delcious Apples", + "value": "Ebony Red Delcious Apples" + }, + { + "selected": false, + "label": "Ebony Red Pepper", + "value": "Ebony Red Pepper" + }, + { + "selected": false, + "label": "Ebony Shitake Mushrooms", + "value": "Ebony Shitake Mushrooms" + }, + { + "selected": false, + "label": "Ebony Squash", + "value": "Ebony Squash" + }, + { + "selected": false, + "label": "Ebony Summer Squash", + "value": "Ebony Summer Squash" + }, + { + "selected": false, + "label": "Ebony Sweet Onion", + "value": "Ebony Sweet Onion" + }, + { + "selected": false, + "label": "Ebony Sweet Peas", + "value": "Ebony Sweet Peas" + }, + { + "selected": false, + "label": "Ebony Tangerines", + "value": "Ebony Tangerines" + }, + { + "selected": false, + "label": "Ebony Tomatos", + "value": "Ebony Tomatos" + }, + { + "selected": false, + "label": "Ebony Walnuts", + "value": "Ebony Walnuts" + }, + { + "selected": false, + "label": "Even Better 1% Milk", + "value": "Even Better 1% Milk" + }, + { + "selected": false, + "label": "Even Better 2% Milk", + "value": "Even Better 2% Milk" + }, + { + "selected": false, + "label": "Even Better Blueberry Yogurt", + "value": "Even Better Blueberry Yogurt" + }, + { + "selected": false, + "label": "Even Better Buttermilk", + "value": "Even Better Buttermilk" + }, + { + "selected": false, + "label": "Even Better Cheese Spread", + "value": "Even Better Cheese Spread" + }, + { + "selected": false, + "label": "Even Better Chocolate Milk", + "value": "Even Better Chocolate Milk" + }, + { + "selected": false, + "label": "Even Better Havarti Cheese", + "value": "Even Better Havarti Cheese" + }, + { + "selected": false, + "label": "Even Better Head Cheese", + "value": "Even Better Head Cheese" + }, + { + "selected": false, + "label": "Even Better Jack Cheese", + "value": "Even Better Jack Cheese" + }, + { + "selected": false, + "label": "Even Better Large Curd Cottage Cheese", + "value": "Even Better Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Even Better Low Fat Cottage Cheese", + "value": "Even Better Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Even Better Low Fat Sour Cream", + "value": "Even Better Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Even Better Low Fat String Cheese", + "value": "Even Better Low Fat String Cheese" + }, + { + "selected": false, + "label": "Even Better Mild Cheddar Cheese", + "value": "Even Better Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Even Better Muenster Cheese", + "value": "Even Better Muenster Cheese" + }, + { + "selected": false, + "label": "Even Better Sharp Cheddar Cheese", + "value": "Even Better Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Even Better Sour Cream", + "value": "Even Better Sour Cream" + }, + { + "selected": false, + "label": "Even Better Strawberry Yogurt", + "value": "Even Better Strawberry Yogurt" + }, + { + "selected": false, + "label": "Even Better String Cheese", + "value": "Even Better String Cheese" + }, + { + "selected": false, + "label": "Even Better Whole Milk", + "value": "Even Better Whole Milk" + }, + { + "selected": false, + "label": "Excellent Apple Drink", + "value": "Excellent Apple Drink" + }, + { + "selected": false, + "label": "Excellent Apple Juice", + "value": "Excellent Apple Juice" + }, + { + "selected": false, + "label": "Excellent Berry Juice", + "value": "Excellent Berry Juice" + }, + { + "selected": false, + "label": "Excellent Cola", + "value": "Excellent Cola" + }, + { + "selected": false, + "label": "Excellent Cranberry Juice", + "value": "Excellent Cranberry Juice" + }, + { + "selected": false, + "label": "Excellent Cream Soda", + "value": "Excellent Cream Soda" + }, + { + "selected": false, + "label": "Excellent Diet Cola", + "value": "Excellent Diet Cola" + }, + { + "selected": false, + "label": "Excellent Diet Soda", + "value": "Excellent Diet Soda" + }, + { + "selected": false, + "label": "Excellent Mango Drink", + "value": "Excellent Mango Drink" + }, + { + "selected": false, + "label": "Excellent Orange Juice", + "value": "Excellent Orange Juice" + }, + { + "selected": false, + "label": "Excellent Strawberry Drink", + "value": "Excellent Strawberry Drink" + }, + { + "selected": false, + "label": "Excel Monthly Auto Magazine", + "value": "Excel Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Computer Magazine", + "value": "Excel Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Fashion Magazine", + "value": "Excel Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Home Magazine", + "value": "Excel Monthly Home Magazine" + }, + { + "selected": false, + "label": "Excel Monthly Sports Magazine", + "value": "Excel Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Fabulous Apple Drink", + "value": "Fabulous Apple Drink" + }, + { + "selected": false, + "label": "Fabulous Apple Juice", + "value": "Fabulous Apple Juice" + }, + { + "selected": false, + "label": "Fabulous Berry Juice", + "value": "Fabulous Berry Juice" + }, + { + "selected": false, + "label": "Fabulous Cola", + "value": "Fabulous Cola" + }, + { + "selected": false, + "label": "Fabulous Cranberry Juice", + "value": "Fabulous Cranberry Juice" + }, + { + "selected": false, + "label": "Fabulous Cream Soda", + "value": "Fabulous Cream Soda" + }, + { + "selected": false, + "label": "Fabulous Diet Cola", + "value": "Fabulous Diet Cola" + }, + { + "selected": false, + "label": "Fabulous Diet Soda", + "value": "Fabulous Diet Soda" + }, + { + "selected": false, + "label": "Fabulous Mango Drink", + "value": "Fabulous Mango Drink" + }, + { + "selected": false, + "label": "Fabulous Orange Juice", + "value": "Fabulous Orange Juice" + }, + { + "selected": false, + "label": "Fabulous Strawberry Drink", + "value": "Fabulous Strawberry Drink" + }, + { + "selected": false, + "label": "Fantastic Bagels", + "value": "Fantastic Bagels" + }, + { + "selected": false, + "label": "Fantastic Blueberry Muffins", + "value": "Fantastic Blueberry Muffins" + }, + { + "selected": false, + "label": "Fantastic Cranberry Muffins", + "value": "Fantastic Cranberry Muffins" + }, + { + "selected": false, + "label": "Fantastic English Muffins", + "value": "Fantastic English Muffins" + }, + { + "selected": false, + "label": "Fantastic Muffins", + "value": "Fantastic Muffins" + }, + { + "selected": false, + "label": "Fantastic Pumpernickel Bread", + "value": "Fantastic Pumpernickel Bread" + }, + { + "selected": false, + "label": "Fantastic Rye Bread", + "value": "Fantastic Rye Bread" + }, + { + "selected": false, + "label": "Fantastic Wheat Bread", + "value": "Fantastic Wheat Bread" + }, + { + "selected": false, + "label": "Fantastic White Bread", + "value": "Fantastic White Bread" + }, + { + "selected": false, + "label": "Fast Apple Fruit Roll", + "value": "Fast Apple Fruit Roll" + }, + { + "selected": false, + "label": "Fast Avocado Dip", + "value": "Fast Avocado Dip" + }, + { + "selected": false, + "label": "Fast BBQ Potato Chips", + "value": "Fast BBQ Potato Chips" + }, + { + "selected": false, + "label": "Fast Beef Jerky", + "value": "Fast Beef Jerky" + }, + { + "selected": false, + "label": "Fast Buttered Popcorn", + "value": "Fast Buttered Popcorn" + }, + { + "selected": false, + "label": "Fast Cheese Crackers", + "value": "Fast Cheese Crackers" + }, + { + "selected": false, + "label": "Fast Cheese Dip", + "value": "Fast Cheese Dip" + }, + { + "selected": false, + "label": "Fast Chocolate Chip Cookies", + "value": "Fast Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Fast Chocolate Donuts", + "value": "Fast Chocolate Donuts" + }, + { + "selected": false, + "label": "Fast Corn Chips", + "value": "Fast Corn Chips" + }, + { + "selected": false, + "label": "Fast Dried Apples", + "value": "Fast Dried Apples" + }, + { + "selected": false, + "label": "Fast Dried Apricots", + "value": "Fast Dried Apricots" + }, + { + "selected": false, + "label": "Fast Dried Dates", + "value": "Fast Dried Dates" + }, + { + "selected": false, + "label": "Fast Fondue Mix", + "value": "Fast Fondue Mix" + }, + { + "selected": false, + "label": "Fast Frosted Cookies", + "value": "Fast Frosted Cookies" + }, + { + "selected": false, + "label": "Fast Frosted Donuts", + "value": "Fast Frosted Donuts" + }, + { + "selected": false, + "label": "Fast Fudge Brownies", + "value": "Fast Fudge Brownies" + }, + { + "selected": false, + "label": "Fast Fudge Cookies", + "value": "Fast Fudge Cookies" + }, + { + "selected": false, + "label": "Fast Golden Raisins", + "value": "Fast Golden Raisins" + }, + { + "selected": false, + "label": "Fast Graham Crackers", + "value": "Fast Graham Crackers" + }, + { + "selected": false, + "label": "Fast Grape Fruit Roll", + "value": "Fast Grape Fruit Roll" + }, + { + "selected": false, + "label": "Fast Lemon Cookies", + "value": "Fast Lemon Cookies" + }, + { + "selected": false, + "label": "Fast Low Fat BBQ Chips", + "value": "Fast Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Fast Low Fat Chips", + "value": "Fast Low Fat Chips" + }, + { + "selected": false, + "label": "Fast Low Fat Cookies", + "value": "Fast Low Fat Cookies" + }, + { + "selected": false, + "label": "Fast Low Fat Popcorn", + "value": "Fast Low Fat Popcorn" + }, + { + "selected": false, + "label": "Fast Mini Donuts", + "value": "Fast Mini Donuts" + }, + { + "selected": false, + "label": "Fast No Salt Popcorn", + "value": "Fast No Salt Popcorn" + }, + { + "selected": false, + "label": "Fast Potato Chips", + "value": "Fast Potato Chips" + }, + { + "selected": false, + "label": "Fast Raisins", + "value": "Fast Raisins" + }, + { + "selected": false, + "label": "Fast Raspberry Fruit Roll", + "value": "Fast Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Fast Salsa Dip", + "value": "Fast Salsa Dip" + }, + { + "selected": false, + "label": "Fast Salted Pretzels", + "value": "Fast Salted Pretzels" + }, + { + "selected": false, + "label": "Fast Sesame Crackers", + "value": "Fast Sesame Crackers" + }, + { + "selected": false, + "label": "Fast Strawberry Fruit Roll", + "value": "Fast Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Fast Sugar Cookies", + "value": "Fast Sugar Cookies" + }, + { + "selected": false, + "label": "Faux Products 200 MG Acetominifen", + "value": "Faux Products 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Faux Products 200 MG Ibuprofen", + "value": "Faux Products 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Faux Products Angled Toothbrush", + "value": "Faux Products Angled Toothbrush" + }, + { + "selected": false, + "label": "Faux Products Apricot Shampoo", + "value": "Faux Products Apricot Shampoo" + }, + { + "selected": false, + "label": "Faux Products Buffered Aspirin", + "value": "Faux Products Buffered Aspirin" + }, + { + "selected": false, + "label": "Faux Products Childrens Aspirin", + "value": "Faux Products Childrens Aspirin" + }, + { + "selected": false, + "label": "Faux Products Childrens Cold Remedy", + "value": "Faux Products Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Faux Products Conditioning Shampoo", + "value": "Faux Products Conditioning Shampoo" + }, + { + "selected": false, + "label": "Faux Products Deodorant", + "value": "Faux Products Deodorant" + }, + { + "selected": false, + "label": "Faux Products Dishwasher Detergent", + "value": "Faux Products Dishwasher Detergent" + }, + { + "selected": false, + "label": "Faux Products Extra Moisture Shampoo", + "value": "Faux Products Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Faux Products HCL Nasal Spray", + "value": "Faux Products HCL Nasal Spray" + }, + { + "selected": false, + "label": "Faux Products Laundry Detergent", + "value": "Faux Products Laundry Detergent" + }, + { + "selected": false, + "label": "Faux Products Mint Mouthwash", + "value": "Faux Products Mint Mouthwash" + }, + { + "selected": false, + "label": "Faux Products Multi-Symptom Cold Remedy", + "value": "Faux Products Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Faux Products Silky Smooth Hair Conditioner", + "value": "Faux Products Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Faux Products Tartar Control Toothpaste", + "value": "Faux Products Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Faux Products Toothpaste", + "value": "Faux Products Toothpaste" + }, + { + "selected": false, + "label": "Faux Products Whitening Toothpast", + "value": "Faux Products Whitening Toothpast" + }, + { + "selected": false, + "label": "Footnote Extra Lean Hamburger", + "value": "Footnote Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Footnote Seasoned Hamburger", + "value": "Footnote Seasoned Hamburger" + }, + { + "selected": false, + "label": "Fort West Apple Fruit Roll", + "value": "Fort West Apple Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Avocado Dip", + "value": "Fort West Avocado Dip" + }, + { + "selected": false, + "label": "Fort West BBQ Potato Chips", + "value": "Fort West BBQ Potato Chips" + }, + { + "selected": false, + "label": "Fort West Beef Jerky", + "value": "Fort West Beef Jerky" + }, + { + "selected": false, + "label": "Fort West Buttered Popcorn", + "value": "Fort West Buttered Popcorn" + }, + { + "selected": false, + "label": "Fort West Cheese Crackers", + "value": "Fort West Cheese Crackers" + }, + { + "selected": false, + "label": "Fort West Cheese Dip", + "value": "Fort West Cheese Dip" + }, + { + "selected": false, + "label": "Fort West Chocolate Chip Cookies", + "value": "Fort West Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Fort West Chocolate Donuts", + "value": "Fort West Chocolate Donuts" + }, + { + "selected": false, + "label": "Fort West Corn Chips", + "value": "Fort West Corn Chips" + }, + { + "selected": false, + "label": "Fort West Dried Apples", + "value": "Fort West Dried Apples" + }, + { + "selected": false, + "label": "Fort West Dried Apricots", + "value": "Fort West Dried Apricots" + }, + { + "selected": false, + "label": "Fort West Dried Dates", + "value": "Fort West Dried Dates" + }, + { + "selected": false, + "label": "Fort West Fondue Mix", + "value": "Fort West Fondue Mix" + }, + { + "selected": false, + "label": "Fort West Frosted Cookies", + "value": "Fort West Frosted Cookies" + }, + { + "selected": false, + "label": "Fort West Frosted Donuts", + "value": "Fort West Frosted Donuts" + }, + { + "selected": false, + "label": "Fort West Fudge Brownies", + "value": "Fort West Fudge Brownies" + }, + { + "selected": false, + "label": "Fort West Fudge Cookies", + "value": "Fort West Fudge Cookies" + }, + { + "selected": false, + "label": "Fort West Golden Raisins", + "value": "Fort West Golden Raisins" + }, + { + "selected": false, + "label": "Fort West Graham Crackers", + "value": "Fort West Graham Crackers" + }, + { + "selected": false, + "label": "Fort West Grape Fruit Roll", + "value": "Fort West Grape Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Lemon Cookies", + "value": "Fort West Lemon Cookies" + }, + { + "selected": false, + "label": "Fort West Low Fat BBQ Chips", + "value": "Fort West Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Fort West Low Fat Chips", + "value": "Fort West Low Fat Chips" + }, + { + "selected": false, + "label": "Fort West Low Fat Cookies", + "value": "Fort West Low Fat Cookies" + }, + { + "selected": false, + "label": "Fort West Low Fat Popcorn", + "value": "Fort West Low Fat Popcorn" + }, + { + "selected": false, + "label": "Fort West Mini Donuts", + "value": "Fort West Mini Donuts" + }, + { + "selected": false, + "label": "Fort West No Salt Popcorn", + "value": "Fort West No Salt Popcorn" + }, + { + "selected": false, + "label": "Fort West Potato Chips", + "value": "Fort West Potato Chips" + }, + { + "selected": false, + "label": "Fort West Raisins", + "value": "Fort West Raisins" + }, + { + "selected": false, + "label": "Fort West Raspberry Fruit Roll", + "value": "Fort West Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Salsa Dip", + "value": "Fort West Salsa Dip" + }, + { + "selected": false, + "label": "Fort West Salted Pretzels", + "value": "Fort West Salted Pretzels" + }, + { + "selected": false, + "label": "Fort West Sesame Crackers", + "value": "Fort West Sesame Crackers" + }, + { + "selected": false, + "label": "Fort West Strawberry Fruit Roll", + "value": "Fort West Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Fort West Sugar Cookies", + "value": "Fort West Sugar Cookies" + }, + { + "selected": false, + "label": "Framton City Map", + "value": "Framton City Map" + }, + { + "selected": false, + "label": "Framton Eyeglass Screwdriver", + "value": "Framton Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Gauss Monthly Auto Magazine", + "value": "Gauss Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Computer Magazine", + "value": "Gauss Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Fashion Magazine", + "value": "Gauss Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Home Magazine", + "value": "Gauss Monthly Home Magazine" + }, + { + "selected": false, + "label": "Gauss Monthly Sports Magazine", + "value": "Gauss Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Genteel Extra Lean Hamburger", + "value": "Genteel Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Genteel Seasoned Hamburger", + "value": "Genteel Seasoned Hamburger" + }, + { + "selected": false, + "label": "Gerolli Extra Lean Hamburger", + "value": "Gerolli Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Gerolli Seasoned Hamburger", + "value": "Gerolli Seasoned Hamburger" + }, + { + "selected": false, + "label": "Giant Egg Substitute", + "value": "Giant Egg Substitute" + }, + { + "selected": false, + "label": "Giant Large Brown Eggs", + "value": "Giant Large Brown Eggs" + }, + { + "selected": false, + "label": "Giant Large Eggs", + "value": "Giant Large Eggs" + }, + { + "selected": false, + "label": "Giant Small Brown Eggs", + "value": "Giant Small Brown Eggs" + }, + { + "selected": false, + "label": "Giant Small Eggs", + "value": "Giant Small Eggs" + }, + { + "selected": false, + "label": "Golden Apple Cinnamon Waffles", + "value": "Golden Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Golden Beef TV Dinner", + "value": "Golden Beef TV Dinner" + }, + { + "selected": false, + "label": "Golden Blueberry Waffles", + "value": "Golden Blueberry Waffles" + }, + { + "selected": false, + "label": "Golden Chicken TV Dinner", + "value": "Golden Chicken TV Dinner" + }, + { + "selected": false, + "label": "Golden Fajita French Fries", + "value": "Golden Fajita French Fries" + }, + { + "selected": false, + "label": "Golden Frozen Broccoli", + "value": "Golden Frozen Broccoli" + }, + { + "selected": false, + "label": "Golden Frozen Carrots", + "value": "Golden Frozen Carrots" + }, + { + "selected": false, + "label": "Golden Frozen Cauliflower", + "value": "Golden Frozen Cauliflower" + }, + { + "selected": false, + "label": "Golden Frozen Cheese Pizza", + "value": "Golden Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Breast", + "value": "Golden Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Thighs", + "value": "Golden Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Golden Frozen Chicken Wings", + "value": "Golden Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Golden Frozen Corn", + "value": "Golden Frozen Corn" + }, + { + "selected": false, + "label": "Golden Frozen Mushroom Pizza", + "value": "Golden Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Pancakes", + "value": "Golden Frozen Pancakes" + }, + { + "selected": false, + "label": "Golden Frozen Peas", + "value": "Golden Frozen Peas" + }, + { + "selected": false, + "label": "Golden Frozen Pepperoni Pizza", + "value": "Golden Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Golden Frozen Sausage Pizza", + "value": "Golden Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Golden Grape Popsicles", + "value": "Golden Grape Popsicles" + }, + { + "selected": false, + "label": "Golden Home Style French Fries", + "value": "Golden Home Style French Fries" + }, + { + "selected": false, + "label": "Golden Ice Cream", + "value": "Golden Ice Cream" + }, + { + "selected": false, + "label": "Golden Ice Cream Sandwich", + "value": "Golden Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Golden Lemon Popsicles", + "value": "Golden Lemon Popsicles" + }, + { + "selected": false, + "label": "Golden Lime Popsicles", + "value": "Golden Lime Popsicles" + }, + { + "selected": false, + "label": "Golden Low Fat French Fries", + "value": "Golden Low Fat French Fries" + }, + { + "selected": false, + "label": "Golden Low Fat Waffles", + "value": "Golden Low Fat Waffles" + }, + { + "selected": false, + "label": "Golden Orange Popsicles", + "value": "Golden Orange Popsicles" + }, + { + "selected": false, + "label": "Golden Pancake Mix", + "value": "Golden Pancake Mix" + }, + { + "selected": false, + "label": "Golden Popsicles", + "value": "Golden Popsicles" + }, + { + "selected": false, + "label": "Golden Turkey TV Dinner", + "value": "Golden Turkey TV Dinner" + }, + { + "selected": false, + "label": "Golden Waffles", + "value": "Golden Waffles" + }, + { + "selected": false, + "label": "Good Chablis Wine", + "value": "Good Chablis Wine" + }, + { + "selected": false, + "label": "Good Chardonnay", + "value": "Good Chardonnay" + }, + { + "selected": false, + "label": "Good Chardonnay Wine", + "value": "Good Chardonnay Wine" + }, + { + "selected": false, + "label": "Good Imported Beer", + "value": "Good Imported Beer" + }, + { + "selected": false, + "label": "Good Light Beer", + "value": "Good Light Beer" + }, + { + "selected": false, + "label": "Good Light Wine", + "value": "Good Light Wine" + }, + { + "selected": false, + "label": "Good Merlot Wine", + "value": "Good Merlot Wine" + }, + { + "selected": false, + "label": "Good White Zinfandel Wine", + "value": "Good White Zinfandel Wine" + }, + { + "selected": false, + "label": "Gorilla 1% Milk", + "value": "Gorilla 1% Milk" + }, + { + "selected": false, + "label": "Gorilla 2% Milk", + "value": "Gorilla 2% Milk" + }, + { + "selected": false, + "label": "Gorilla Blueberry Yogurt", + "value": "Gorilla Blueberry Yogurt" + }, + { + "selected": false, + "label": "Gorilla Buttermilk", + "value": "Gorilla Buttermilk" + }, + { + "selected": false, + "label": "Gorilla Cheese Spread", + "value": "Gorilla Cheese Spread" + }, + { + "selected": false, + "label": "Gorilla Chocolate Milk", + "value": "Gorilla Chocolate Milk" + }, + { + "selected": false, + "label": "Gorilla Havarti Cheese", + "value": "Gorilla Havarti Cheese" + }, + { + "selected": false, + "label": "Gorilla Head Cheese", + "value": "Gorilla Head Cheese" + }, + { + "selected": false, + "label": "Gorilla Jack Cheese", + "value": "Gorilla Jack Cheese" + }, + { + "selected": false, + "label": "Gorilla Large Curd Cottage Cheese", + "value": "Gorilla Large Curd Cottage Cheese" + }, + { + "selected": false, + "label": "Gorilla Low Fat Cottage Cheese", + "value": "Gorilla Low Fat Cottage Cheese" + }, + { + "selected": false, + "label": "Gorilla Low Fat Sour Cream", + "value": "Gorilla Low Fat Sour Cream" + }, + { + "selected": false, + "label": "Gorilla Low Fat String Cheese", + "value": "Gorilla Low Fat String Cheese" + }, + { + "selected": false, + "label": "Gorilla Mild Cheddar Cheese", + "value": "Gorilla Mild Cheddar Cheese" + }, + { + "selected": false, + "label": "Gorilla Muenster Cheese", + "value": "Gorilla Muenster Cheese" + }, + { + "selected": false, + "label": "Gorilla Sharp Cheddar Cheese", + "value": "Gorilla Sharp Cheddar Cheese" + }, + { + "selected": false, + "label": "Gorilla Sour Cream", + "value": "Gorilla Sour Cream" + }, + { + "selected": false, + "label": "Gorilla Strawberry Yogurt", + "value": "Gorilla Strawberry Yogurt" + }, + { + "selected": false, + "label": "Gorilla String Cheese", + "value": "Gorilla String Cheese" + }, + { + "selected": false, + "label": "Gorilla Whole Milk", + "value": "Gorilla Whole Milk" + }, + { + "selected": false, + "label": "Great Bagels", + "value": "Great Bagels" + }, + { + "selected": false, + "label": "Great Blueberry Muffins", + "value": "Great Blueberry Muffins" + }, + { + "selected": false, + "label": "Great Cranberry Muffins", + "value": "Great Cranberry Muffins" + }, + { + "selected": false, + "label": "Great English Muffins", + "value": "Great English Muffins" + }, + { + "selected": false, + "label": "Great Muffins", + "value": "Great Muffins" + }, + { + "selected": false, + "label": "Great Pumpernickel Bread", + "value": "Great Pumpernickel Bread" + }, + { + "selected": false, + "label": "Great Rye Bread", + "value": "Great Rye Bread" + }, + { + "selected": false, + "label": "Great Wheat Bread", + "value": "Great Wheat Bread" + }, + { + "selected": false, + "label": "Great White Bread", + "value": "Great White Bread" + }, + { + "selected": false, + "label": "Green Ribbon Canned Mixed Fruit", + "value": "Green Ribbon Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Green Ribbon Canned Peaches", + "value": "Green Ribbon Canned Peaches" + }, + { + "selected": false, + "label": "Gulf Coast Bubble Gum", + "value": "Gulf Coast Bubble Gum" + }, + { + "selected": false, + "label": "Gulf Coast Malted Milk Balls", + "value": "Gulf Coast Malted Milk Balls" + }, + { + "selected": false, + "label": "Gulf Coast Mint Chocolate Bar", + "value": "Gulf Coast Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Gulf Coast Mints", + "value": "Gulf Coast Mints" + }, + { + "selected": false, + "label": "Gulf Coast Semi-Sweet Chocolate Bar", + "value": "Gulf Coast Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Gulf Coast Spicy Mints", + "value": "Gulf Coast Spicy Mints" + }, + { + "selected": false, + "label": "Gulf Coast Tasty Candy Bar", + "value": "Gulf Coast Tasty Candy Bar" + }, + { + "selected": false, + "label": "Gulf Coast White Chocolate Bar", + "value": "Gulf Coast White Chocolate Bar" + }, + { + "selected": false, + "label": "Hermanos Almonds", + "value": "Hermanos Almonds" + }, + { + "selected": false, + "label": "Hermanos Asparagus", + "value": "Hermanos Asparagus" + }, + { + "selected": false, + "label": "Hermanos Baby Onion", + "value": "Hermanos Baby Onion" + }, + { + "selected": false, + "label": "Hermanos Beets", + "value": "Hermanos Beets" + }, + { + "selected": false, + "label": "Hermanos Broccoli", + "value": "Hermanos Broccoli" + }, + { + "selected": false, + "label": "Hermanos Canned Peanuts", + "value": "Hermanos Canned Peanuts" + }, + { + "selected": false, + "label": "Hermanos Cantelope", + "value": "Hermanos Cantelope" + }, + { + "selected": false, + "label": "Hermanos Cauliflower", + "value": "Hermanos Cauliflower" + }, + { + "selected": false, + "label": "Hermanos Corn on the Cob", + "value": "Hermanos Corn on the Cob" + }, + { + "selected": false, + "label": "Hermanos Dried Mushrooms", + "value": "Hermanos Dried Mushrooms" + }, + { + "selected": false, + "label": "Hermanos Elephant Garlic", + "value": "Hermanos Elephant Garlic" + }, + { + "selected": false, + "label": "Hermanos Fancy Plums", + "value": "Hermanos Fancy Plums" + }, + { + "selected": false, + "label": "Hermanos Firm Tofu", + "value": "Hermanos Firm Tofu" + }, + { + "selected": false, + "label": "Hermanos Fresh Lima Beans", + "value": "Hermanos Fresh Lima Beans" + }, + { + "selected": false, + "label": "Hermanos Fuji Apples", + "value": "Hermanos Fuji Apples" + }, + { + "selected": false, + "label": "Hermanos Garlic", + "value": "Hermanos Garlic" + }, + { + "selected": false, + "label": "Hermanos Golden Delcious Apples", + "value": "Hermanos Golden Delcious Apples" + }, + { + "selected": false, + "label": "Hermanos Green Pepper", + "value": "Hermanos Green Pepper" + }, + { + "selected": false, + "label": "Hermanos Honey Dew", + "value": "Hermanos Honey Dew" + }, + { + "selected": false, + "label": "Hermanos Lemons", + "value": "Hermanos Lemons" + }, + { + "selected": false, + "label": "Hermanos Lettuce", + "value": "Hermanos Lettuce" + }, + { + "selected": false, + "label": "Hermanos Limes", + "value": "Hermanos Limes" + }, + { + "selected": false, + "label": "Hermanos Macintosh Apples", + "value": "Hermanos Macintosh Apples" + }, + { + "selected": false, + "label": "Hermanos Mandarin Oranges", + "value": "Hermanos Mandarin Oranges" + }, + { + "selected": false, + "label": "Hermanos Mixed Nuts", + "value": "Hermanos Mixed Nuts" + }, + { + "selected": false, + "label": "Hermanos Mushrooms", + "value": "Hermanos Mushrooms" + }, + { + "selected": false, + "label": "Hermanos New Potatos", + "value": "Hermanos New Potatos" + }, + { + "selected": false, + "label": "Hermanos Onions", + "value": "Hermanos Onions" + }, + { + "selected": false, + "label": "Hermanos Oranges", + "value": "Hermanos Oranges" + }, + { + "selected": false, + "label": "Hermanos Party Nuts", + "value": "Hermanos Party Nuts" + }, + { + "selected": false, + "label": "Hermanos Peaches", + "value": "Hermanos Peaches" + }, + { + "selected": false, + "label": "Hermanos Plums", + "value": "Hermanos Plums" + }, + { + "selected": false, + "label": "Hermanos Potatos", + "value": "Hermanos Potatos" + }, + { + "selected": false, + "label": "Hermanos Prepared Salad", + "value": "Hermanos Prepared Salad" + }, + { + "selected": false, + "label": "Hermanos Red Delcious Apples", + "value": "Hermanos Red Delcious Apples" + }, + { + "selected": false, + "label": "Hermanos Red Pepper", + "value": "Hermanos Red Pepper" + }, + { + "selected": false, + "label": "Hermanos Shitake Mushrooms", + "value": "Hermanos Shitake Mushrooms" + }, + { + "selected": false, + "label": "Hermanos Squash", + "value": "Hermanos Squash" + }, + { + "selected": false, + "label": "Hermanos Summer Squash", + "value": "Hermanos Summer Squash" + }, + { + "selected": false, + "label": "Hermanos Sweet Onion", + "value": "Hermanos Sweet Onion" + }, + { + "selected": false, + "label": "Hermanos Sweet Peas", + "value": "Hermanos Sweet Peas" + }, + { + "selected": false, + "label": "Hermanos Tangerines", + "value": "Hermanos Tangerines" + }, + { + "selected": false, + "label": "Hermanos Tomatos", + "value": "Hermanos Tomatos" + }, + { + "selected": false, + "label": "Hermanos Walnuts", + "value": "Hermanos Walnuts" + }, + { + "selected": false, + "label": "High Quality 100 Watt Lightbulb", + "value": "High Quality 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 25 Watt Lightbulb", + "value": "High Quality 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 60 Watt Lightbulb", + "value": "High Quality 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality 75 Watt Lightbulb", + "value": "High Quality 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "High Quality AAA-Size Batteries", + "value": "High Quality AAA-Size Batteries" + }, + { + "selected": false, + "label": "High Quality AA-Size Batteries", + "value": "High Quality AA-Size Batteries" + }, + { + "selected": false, + "label": "High Quality Bees Wax Candles", + "value": "High Quality Bees Wax Candles" + }, + { + "selected": false, + "label": "High Quality Copper Cleaner", + "value": "High Quality Copper Cleaner" + }, + { + "selected": false, + "label": "High Quality Copper Pot Scrubber", + "value": "High Quality Copper Pot Scrubber" + }, + { + "selected": false, + "label": "High Quality Counter Cleaner", + "value": "High Quality Counter Cleaner" + }, + { + "selected": false, + "label": "High Quality C-Size Batteries", + "value": "High Quality C-Size Batteries" + }, + { + "selected": false, + "label": "High Quality D-Size Batteries", + "value": "High Quality D-Size Batteries" + }, + { + "selected": false, + "label": "High Quality Economy Toilet Brush", + "value": "High Quality Economy Toilet Brush" + }, + { + "selected": false, + "label": "High Quality Frying Pan", + "value": "High Quality Frying Pan" + }, + { + "selected": false, + "label": "High Quality Glass Cleaner", + "value": "High Quality Glass Cleaner" + }, + { + "selected": false, + "label": "High Quality Large Sponge", + "value": "High Quality Large Sponge" + }, + { + "selected": false, + "label": "High Quality Paper Cups", + "value": "High Quality Paper Cups" + }, + { + "selected": false, + "label": "High Quality Paper Plates", + "value": "High Quality Paper Plates" + }, + { + "selected": false, + "label": "High Quality Paper Towels", + "value": "High Quality Paper Towels" + }, + { + "selected": false, + "label": "High Quality Plastic Forks", + "value": "High Quality Plastic Forks" + }, + { + "selected": false, + "label": "High Quality Plastic Knives", + "value": "High Quality Plastic Knives" + }, + { + "selected": false, + "label": "High Quality Plastic Spoons", + "value": "High Quality Plastic Spoons" + }, + { + "selected": false, + "label": "High Quality Room Freshener", + "value": "High Quality Room Freshener" + }, + { + "selected": false, + "label": "High Quality Scented Tissue", + "value": "High Quality Scented Tissue" + }, + { + "selected": false, + "label": "High Quality Scented Toilet Tissue", + "value": "High Quality Scented Toilet Tissue" + }, + { + "selected": false, + "label": "High Quality Scissors", + "value": "High Quality Scissors" + }, + { + "selected": false, + "label": "High Quality Screw Driver", + "value": "High Quality Screw Driver" + }, + { + "selected": false, + "label": "High Quality Silver Cleaner", + "value": "High Quality Silver Cleaner" + }, + { + "selected": false, + "label": "High Quality Soft Napkins", + "value": "High Quality Soft Napkins" + }, + { + "selected": false, + "label": "High Quality Tissues", + "value": "High Quality Tissues" + }, + { + "selected": false, + "label": "High Quality Toilet Bowl Cleaner", + "value": "High Quality Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "High Quality Toilet Paper", + "value": "High Quality Toilet Paper" + }, + { + "selected": false, + "label": "High Top Almonds", + "value": "High Top Almonds" + }, + { + "selected": false, + "label": "High Top Asparagus", + "value": "High Top Asparagus" + }, + { + "selected": false, + "label": "High Top Baby Onion", + "value": "High Top Baby Onion" + }, + { + "selected": false, + "label": "High Top Beets", + "value": "High Top Beets" + }, + { + "selected": false, + "label": "High Top Broccoli", + "value": "High Top Broccoli" + }, + { + "selected": false, + "label": "High Top Canned Peanuts", + "value": "High Top Canned Peanuts" + }, + { + "selected": false, + "label": "High Top Cantelope", + "value": "High Top Cantelope" + }, + { + "selected": false, + "label": "High Top Cauliflower", + "value": "High Top Cauliflower" + }, + { + "selected": false, + "label": "High Top Corn on the Cob", + "value": "High Top Corn on the Cob" + }, + { + "selected": false, + "label": "High Top Dried Mushrooms", + "value": "High Top Dried Mushrooms" + }, + { + "selected": false, + "label": "High Top Elephant Garlic", + "value": "High Top Elephant Garlic" + }, + { + "selected": false, + "label": "High Top Fancy Plums", + "value": "High Top Fancy Plums" + }, + { + "selected": false, + "label": "High Top Firm Tofu", + "value": "High Top Firm Tofu" + }, + { + "selected": false, + "label": "High Top Fresh Lima Beans", + "value": "High Top Fresh Lima Beans" + }, + { + "selected": false, + "label": "High Top Fuji Apples", + "value": "High Top Fuji Apples" + }, + { + "selected": false, + "label": "High Top Garlic", + "value": "High Top Garlic" + }, + { + "selected": false, + "label": "High Top Golden Delcious Apples", + "value": "High Top Golden Delcious Apples" + }, + { + "selected": false, + "label": "High Top Green Pepper", + "value": "High Top Green Pepper" + }, + { + "selected": false, + "label": "High Top Honey Dew", + "value": "High Top Honey Dew" + }, + { + "selected": false, + "label": "High Top Lemons", + "value": "High Top Lemons" + }, + { + "selected": false, + "label": "High Top Lettuce", + "value": "High Top Lettuce" + }, + { + "selected": false, + "label": "High Top Limes", + "value": "High Top Limes" + }, + { + "selected": false, + "label": "High Top Macintosh Apples", + "value": "High Top Macintosh Apples" + }, + { + "selected": false, + "label": "High Top Mandarin Oranges", + "value": "High Top Mandarin Oranges" + }, + { + "selected": false, + "label": "High Top Mixed Nuts", + "value": "High Top Mixed Nuts" + }, + { + "selected": false, + "label": "High Top Mushrooms", + "value": "High Top Mushrooms" + }, + { + "selected": false, + "label": "High Top New Potatos", + "value": "High Top New Potatos" + }, + { + "selected": false, + "label": "High Top Onions", + "value": "High Top Onions" + }, + { + "selected": false, + "label": "High Top Oranges", + "value": "High Top Oranges" + }, + { + "selected": false, + "label": "High Top Party Nuts", + "value": "High Top Party Nuts" + }, + { + "selected": false, + "label": "High Top Peaches", + "value": "High Top Peaches" + }, + { + "selected": false, + "label": "High Top Plums", + "value": "High Top Plums" + }, + { + "selected": false, + "label": "High Top Potatos", + "value": "High Top Potatos" + }, + { + "selected": false, + "label": "High Top Prepared Salad", + "value": "High Top Prepared Salad" + }, + { + "selected": false, + "label": "High Top Red Delcious Apples", + "value": "High Top Red Delcious Apples" + }, + { + "selected": false, + "label": "High Top Red Pepper", + "value": "High Top Red Pepper" + }, + { + "selected": false, + "label": "High Top Shitake Mushrooms", + "value": "High Top Shitake Mushrooms" + }, + { + "selected": false, + "label": "High Top Squash", + "value": "High Top Squash" + }, + { + "selected": false, + "label": "High Top Summer Squash", + "value": "High Top Summer Squash" + }, + { + "selected": false, + "label": "High Top Sweet Onion", + "value": "High Top Sweet Onion" + }, + { + "selected": false, + "label": "High Top Sweet Peas", + "value": "High Top Sweet Peas" + }, + { + "selected": false, + "label": "High Top Tangerines", + "value": "High Top Tangerines" + }, + { + "selected": false, + "label": "High Top Tomatos", + "value": "High Top Tomatos" + }, + { + "selected": false, + "label": "High Top Walnuts", + "value": "High Top Walnuts" + }, + { + "selected": false, + "label": "Hilltop 200 MG Acetominifen", + "value": "Hilltop 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Hilltop 200 MG Ibuprofen", + "value": "Hilltop 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Hilltop Angled Toothbrush", + "value": "Hilltop Angled Toothbrush" + }, + { + "selected": false, + "label": "Hilltop Apricot Shampoo", + "value": "Hilltop Apricot Shampoo" + }, + { + "selected": false, + "label": "Hilltop Buffered Aspirin", + "value": "Hilltop Buffered Aspirin" + }, + { + "selected": false, + "label": "Hilltop Childrens Aspirin", + "value": "Hilltop Childrens Aspirin" + }, + { + "selected": false, + "label": "Hilltop Childrens Cold Remedy", + "value": "Hilltop Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Hilltop Conditioning Shampoo", + "value": "Hilltop Conditioning Shampoo" + }, + { + "selected": false, + "label": "Hilltop Deodorant", + "value": "Hilltop Deodorant" + }, + { + "selected": false, + "label": "Hilltop Dishwasher Detergent", + "value": "Hilltop Dishwasher Detergent" + }, + { + "selected": false, + "label": "Hilltop Extra Moisture Shampoo", + "value": "Hilltop Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Hilltop HCL Nasal Spray", + "value": "Hilltop HCL Nasal Spray" + }, + { + "selected": false, + "label": "Hilltop Laundry Detergent", + "value": "Hilltop Laundry Detergent" + }, + { + "selected": false, + "label": "Hilltop Mint Mouthwash", + "value": "Hilltop Mint Mouthwash" + }, + { + "selected": false, + "label": "Hilltop Multi-Symptom Cold Remedy", + "value": "Hilltop Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Hilltop Silky Smooth Hair Conditioner", + "value": "Hilltop Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Hilltop Tartar Control Toothpaste", + "value": "Hilltop Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Hilltop Toothpaste", + "value": "Hilltop Toothpaste" + }, + { + "selected": false, + "label": "Hilltop Whitening Toothpast", + "value": "Hilltop Whitening Toothpast" + }, + { + "selected": false, + "label": "Horatio Apple Fruit Roll", + "value": "Horatio Apple Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Avocado Dip", + "value": "Horatio Avocado Dip" + }, + { + "selected": false, + "label": "Horatio BBQ Potato Chips", + "value": "Horatio BBQ Potato Chips" + }, + { + "selected": false, + "label": "Horatio Beef Jerky", + "value": "Horatio Beef Jerky" + }, + { + "selected": false, + "label": "Horatio Buttered Popcorn", + "value": "Horatio Buttered Popcorn" + }, + { + "selected": false, + "label": "Horatio Cheese Crackers", + "value": "Horatio Cheese Crackers" + }, + { + "selected": false, + "label": "Horatio Cheese Dip", + "value": "Horatio Cheese Dip" + }, + { + "selected": false, + "label": "Horatio Chocolate Chip Cookies", + "value": "Horatio Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Horatio Chocolate Donuts", + "value": "Horatio Chocolate Donuts" + }, + { + "selected": false, + "label": "Horatio Corn Chips", + "value": "Horatio Corn Chips" + }, + { + "selected": false, + "label": "Horatio Dried Apples", + "value": "Horatio Dried Apples" + }, + { + "selected": false, + "label": "Horatio Dried Apricots", + "value": "Horatio Dried Apricots" + }, + { + "selected": false, + "label": "Horatio Dried Dates", + "value": "Horatio Dried Dates" + }, + { + "selected": false, + "label": "Horatio Fondue Mix", + "value": "Horatio Fondue Mix" + }, + { + "selected": false, + "label": "Horatio Frosted Cookies", + "value": "Horatio Frosted Cookies" + }, + { + "selected": false, + "label": "Horatio Frosted Donuts", + "value": "Horatio Frosted Donuts" + }, + { + "selected": false, + "label": "Horatio Fudge Brownies", + "value": "Horatio Fudge Brownies" + }, + { + "selected": false, + "label": "Horatio Fudge Cookies", + "value": "Horatio Fudge Cookies" + }, + { + "selected": false, + "label": "Horatio Golden Raisins", + "value": "Horatio Golden Raisins" + }, + { + "selected": false, + "label": "Horatio Graham Crackers", + "value": "Horatio Graham Crackers" + }, + { + "selected": false, + "label": "Horatio Grape Fruit Roll", + "value": "Horatio Grape Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Lemon Cookies", + "value": "Horatio Lemon Cookies" + }, + { + "selected": false, + "label": "Horatio Low Fat BBQ Chips", + "value": "Horatio Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Horatio Low Fat Chips", + "value": "Horatio Low Fat Chips" + }, + { + "selected": false, + "label": "Horatio Low Fat Cookies", + "value": "Horatio Low Fat Cookies" + }, + { + "selected": false, + "label": "Horatio Low Fat Popcorn", + "value": "Horatio Low Fat Popcorn" + }, + { + "selected": false, + "label": "Horatio Mini Donuts", + "value": "Horatio Mini Donuts" + }, + { + "selected": false, + "label": "Horatio No Salt Popcorn", + "value": "Horatio No Salt Popcorn" + }, + { + "selected": false, + "label": "Horatio Potato Chips", + "value": "Horatio Potato Chips" + }, + { + "selected": false, + "label": "Horatio Raisins", + "value": "Horatio Raisins" + }, + { + "selected": false, + "label": "Horatio Raspberry Fruit Roll", + "value": "Horatio Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Salsa Dip", + "value": "Horatio Salsa Dip" + }, + { + "selected": false, + "label": "Horatio Salted Pretzels", + "value": "Horatio Salted Pretzels" + }, + { + "selected": false, + "label": "Horatio Sesame Crackers", + "value": "Horatio Sesame Crackers" + }, + { + "selected": false, + "label": "Horatio Strawberry Fruit Roll", + "value": "Horatio Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Horatio Sugar Cookies", + "value": "Horatio Sugar Cookies" + }, + { + "selected": false, + "label": "Imagine Apple Cinnamon Waffles", + "value": "Imagine Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "Imagine Beef TV Dinner", + "value": "Imagine Beef TV Dinner" + }, + { + "selected": false, + "label": "Imagine Blueberry Waffles", + "value": "Imagine Blueberry Waffles" + }, + { + "selected": false, + "label": "Imagine Chicken TV Dinner", + "value": "Imagine Chicken TV Dinner" + }, + { + "selected": false, + "label": "Imagine Fajita French Fries", + "value": "Imagine Fajita French Fries" + }, + { + "selected": false, + "label": "Imagine Frozen Broccoli", + "value": "Imagine Frozen Broccoli" + }, + { + "selected": false, + "label": "Imagine Frozen Carrots", + "value": "Imagine Frozen Carrots" + }, + { + "selected": false, + "label": "Imagine Frozen Cauliflower", + "value": "Imagine Frozen Cauliflower" + }, + { + "selected": false, + "label": "Imagine Frozen Cheese Pizza", + "value": "Imagine Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Breast", + "value": "Imagine Frozen Chicken Breast" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Thighs", + "value": "Imagine Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "Imagine Frozen Chicken Wings", + "value": "Imagine Frozen Chicken Wings" + }, + { + "selected": false, + "label": "Imagine Frozen Corn", + "value": "Imagine Frozen Corn" + }, + { + "selected": false, + "label": "Imagine Frozen Mushroom Pizza", + "value": "Imagine Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Pancakes", + "value": "Imagine Frozen Pancakes" + }, + { + "selected": false, + "label": "Imagine Frozen Peas", + "value": "Imagine Frozen Peas" + }, + { + "selected": false, + "label": "Imagine Frozen Pepperoni Pizza", + "value": "Imagine Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "Imagine Frozen Sausage Pizza", + "value": "Imagine Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "Imagine Grape Popsicles", + "value": "Imagine Grape Popsicles" + }, + { + "selected": false, + "label": "Imagine Home Style French Fries", + "value": "Imagine Home Style French Fries" + }, + { + "selected": false, + "label": "Imagine Ice Cream", + "value": "Imagine Ice Cream" + }, + { + "selected": false, + "label": "Imagine Ice Cream Sandwich", + "value": "Imagine Ice Cream Sandwich" + }, + { + "selected": false, + "label": "Imagine Lemon Popsicles", + "value": "Imagine Lemon Popsicles" + }, + { + "selected": false, + "label": "Imagine Lime Popsicles", + "value": "Imagine Lime Popsicles" + }, + { + "selected": false, + "label": "Imagine Low Fat French Fries", + "value": "Imagine Low Fat French Fries" + }, + { + "selected": false, + "label": "Imagine Low Fat Waffles", + "value": "Imagine Low Fat Waffles" + }, + { + "selected": false, + "label": "Imagine Orange Popsicles", + "value": "Imagine Orange Popsicles" + }, + { + "selected": false, + "label": "Imagine Pancake Mix", + "value": "Imagine Pancake Mix" + }, + { + "selected": false, + "label": "Imagine Popsicles", + "value": "Imagine Popsicles" + }, + { + "selected": false, + "label": "Imagine Turkey TV Dinner", + "value": "Imagine Turkey TV Dinner" + }, + { + "selected": false, + "label": "Imagine Waffles", + "value": "Imagine Waffles" + }, + { + "selected": false, + "label": "James Bay City Map", + "value": "James Bay City Map" + }, + { + "selected": false, + "label": "James Bay Eyeglass Screwdriver", + "value": "James Bay Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Jardon Manicotti", + "value": "Jardon Manicotti" + }, + { + "selected": false, + "label": "Jardon Ravioli", + "value": "Jardon Ravioli" + }, + { + "selected": false, + "label": "Jardon Rice Medly", + "value": "Jardon Rice Medly" + }, + { + "selected": false, + "label": "Jardon Spaghetti", + "value": "Jardon Spaghetti" + }, + { + "selected": false, + "label": "Jardon Thai Rice", + "value": "Jardon Thai Rice" + }, + { + "selected": false, + "label": "Jeffers Corn Puffs", + "value": "Jeffers Corn Puffs" + }, + { + "selected": false, + "label": "Jeffers Grits", + "value": "Jeffers Grits" + }, + { + "selected": false, + "label": "Jeffers Oatmeal", + "value": "Jeffers Oatmeal" + }, + { + "selected": false, + "label": "Jeffers Wheat Puffs", + "value": "Jeffers Wheat Puffs" + }, + { + "selected": false, + "label": "Johnson Corn Puffs", + "value": "Johnson Corn Puffs" + }, + { + "selected": false, + "label": "Johnson Grits", + "value": "Johnson Grits" + }, + { + "selected": false, + "label": "Johnson Oatmeal", + "value": "Johnson Oatmeal" + }, + { + "selected": false, + "label": "Johnson Wheat Puffs", + "value": "Johnson Wheat Puffs" + }, + { + "selected": false, + "label": "Jumbo Egg Substitute", + "value": "Jumbo Egg Substitute" + }, + { + "selected": false, + "label": "Jumbo Large Brown Eggs", + "value": "Jumbo Large Brown Eggs" + }, + { + "selected": false, + "label": "Jumbo Large Eggs", + "value": "Jumbo Large Eggs" + }, + { + "selected": false, + "label": "Jumbo Small Brown Eggs", + "value": "Jumbo Small Brown Eggs" + }, + { + "selected": false, + "label": "Jumbo Small Eggs", + "value": "Jumbo Small Eggs" + }, + { + "selected": false, + "label": "Just Right Beef Soup", + "value": "Just Right Beef Soup" + }, + { + "selected": false, + "label": "Just Right Canned Beets", + "value": "Just Right Canned Beets" + }, + { + "selected": false, + "label": "Just Right Canned Peas", + "value": "Just Right Canned Peas" + }, + { + "selected": false, + "label": "Just Right Canned String Beans", + "value": "Just Right Canned String Beans" + }, + { + "selected": false, + "label": "Just Right Canned Tomatos", + "value": "Just Right Canned Tomatos" + }, + { + "selected": false, + "label": "Just Right Canned Tuna in Oil", + "value": "Just Right Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Just Right Canned Tuna in Water", + "value": "Just Right Canned Tuna in Water" + }, + { + "selected": false, + "label": "Just Right Canned Yams", + "value": "Just Right Canned Yams" + }, + { + "selected": false, + "label": "Just Right Chicken Noodle Soup", + "value": "Just Right Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Chicken Ramen Soup", + "value": "Just Right Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Just Right Chicken Soup", + "value": "Just Right Chicken Soup" + }, + { + "selected": false, + "label": "Just Right Creamed Corn", + "value": "Just Right Creamed Corn" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Anchovies", + "value": "Just Right Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Clams", + "value": "Just Right Fancy Canned Clams" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Oysters", + "value": "Just Right Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Just Right Fancy Canned Sardines", + "value": "Just Right Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Just Right Large Canned Shrimp", + "value": "Just Right Large Canned Shrimp" + }, + { + "selected": false, + "label": "Just Right Noodle Soup", + "value": "Just Right Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Regular Ramen Soup", + "value": "Just Right Regular Ramen Soup" + }, + { + "selected": false, + "label": "Just Right Rice Soup", + "value": "Just Right Rice Soup" + }, + { + "selected": false, + "label": "Just Right Turkey Noodle Soup", + "value": "Just Right Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Just Right Vegetable Soup", + "value": "Just Right Vegetable Soup" + }, + { + "selected": false, + "label": "King Rosy Sunglasses", + "value": "King Rosy Sunglasses" + }, + { + "selected": false, + "label": "Kiwi Lox", + "value": "Kiwi Lox" + }, + { + "selected": false, + "label": "Kiwi Scallops", + "value": "Kiwi Scallops" + }, + { + "selected": false, + "label": "Lake Beef Bologna", + "value": "Lake Beef Bologna" + }, + { + "selected": false, + "label": "Lake Chicken Hot Dogs", + "value": "Lake Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Lake Cole Slaw", + "value": "Lake Cole Slaw" + }, + { + "selected": false, + "label": "Lake Corned Beef", + "value": "Lake Corned Beef" + }, + { + "selected": false, + "label": "Lake Foot-Long Hot Dogs", + "value": "Lake Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Lake Low Fat Bologna", + "value": "Lake Low Fat Bologna" + }, + { + "selected": false, + "label": "Lake Low Fat Cole Slaw", + "value": "Lake Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Lake Pimento Loaf", + "value": "Lake Pimento Loaf" + }, + { + "selected": false, + "label": "Lake Potato Salad", + "value": "Lake Potato Salad" + }, + { + "selected": false, + "label": "Lake Roasted Chicken", + "value": "Lake Roasted Chicken" + }, + { + "selected": false, + "label": "Lake Sliced Chicken", + "value": "Lake Sliced Chicken" + }, + { + "selected": false, + "label": "Lake Sliced Ham", + "value": "Lake Sliced Ham" + }, + { + "selected": false, + "label": "Lake Sliced Turkey", + "value": "Lake Sliced Turkey" + }, + { + "selected": false, + "label": "Lake Turkey Hot Dogs", + "value": "Lake Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Landslide Apple Butter", + "value": "Landslide Apple Butter" + }, + { + "selected": false, + "label": "Landslide Apple Jam", + "value": "Landslide Apple Jam" + }, + { + "selected": false, + "label": "Landslide Apple Jelly", + "value": "Landslide Apple Jelly" + }, + { + "selected": false, + "label": "Landslide Apple Preserves", + "value": "Landslide Apple Preserves" + }, + { + "selected": false, + "label": "Landslide Brown Sugar", + "value": "Landslide Brown Sugar" + }, + { + "selected": false, + "label": "Landslide Canola Oil", + "value": "Landslide Canola Oil" + }, + { + "selected": false, + "label": "Landslide Chunky Peanut Butter", + "value": "Landslide Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Landslide Columbian Coffee", + "value": "Landslide Columbian Coffee" + }, + { + "selected": false, + "label": "Landslide Corn Oil", + "value": "Landslide Corn Oil" + }, + { + "selected": false, + "label": "Landslide Creamy Peanut Butter", + "value": "Landslide Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Landslide Decaf Coffee", + "value": "Landslide Decaf Coffee" + }, + { + "selected": false, + "label": "Landslide Extra Chunky Peanut Butter", + "value": "Landslide Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Landslide French Roast Coffee", + "value": "Landslide French Roast Coffee" + }, + { + "selected": false, + "label": "Landslide Grape Jam", + "value": "Landslide Grape Jam" + }, + { + "selected": false, + "label": "Landslide Grape Jelly", + "value": "Landslide Grape Jelly" + }, + { + "selected": false, + "label": "Landslide Grape Preserves", + "value": "Landslide Grape Preserves" + }, + { + "selected": false, + "label": "Landslide Hot Chocolate", + "value": "Landslide Hot Chocolate" + }, + { + "selected": false, + "label": "Landslide Low Fat Apple Butter", + "value": "Landslide Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Landslide Oregano", + "value": "Landslide Oregano" + }, + { + "selected": false, + "label": "Landslide Pepper", + "value": "Landslide Pepper" + }, + { + "selected": false, + "label": "Landslide Regular Coffee", + "value": "Landslide Regular Coffee" + }, + { + "selected": false, + "label": "Landslide Salt", + "value": "Landslide Salt" + }, + { + "selected": false, + "label": "Landslide Sesame Oil", + "value": "Landslide Sesame Oil" + }, + { + "selected": false, + "label": "Landslide Strawberry Jam", + "value": "Landslide Strawberry Jam" + }, + { + "selected": false, + "label": "Landslide Strawberry Jelly", + "value": "Landslide Strawberry Jelly" + }, + { + "selected": false, + "label": "Landslide Strawberry Preserves", + "value": "Landslide Strawberry Preserves" + }, + { + "selected": false, + "label": "Landslide Tomato Sauce", + "value": "Landslide Tomato Sauce" + }, + { + "selected": false, + "label": "Landslide Vegetable Oil", + "value": "Landslide Vegetable Oil" + }, + { + "selected": false, + "label": "Landslide White Sugar", + "value": "Landslide White Sugar" + }, + { + "selected": false, + "label": "Medalist Manicotti", + "value": "Medalist Manicotti" + }, + { + "selected": false, + "label": "Medalist Ravioli", + "value": "Medalist Ravioli" + }, + { + "selected": false, + "label": "Medalist Rice Medly", + "value": "Medalist Rice Medly" + }, + { + "selected": false, + "label": "Medalist Spaghetti", + "value": "Medalist Spaghetti" + }, + { + "selected": false, + "label": "Medalist Thai Rice", + "value": "Medalist Thai Rice" + }, + { + "selected": false, + "label": "Mighty Good Monthly Auto Magazine", + "value": "Mighty Good Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Computer Magazine", + "value": "Mighty Good Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Fashion Magazine", + "value": "Mighty Good Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Home Magazine", + "value": "Mighty Good Monthly Home Magazine" + }, + { + "selected": false, + "label": "Mighty Good Monthly Sports Magazine", + "value": "Mighty Good Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Modell Bagels", + "value": "Modell Bagels" + }, + { + "selected": false, + "label": "Modell Blueberry Muffins", + "value": "Modell Blueberry Muffins" + }, + { + "selected": false, + "label": "Modell Cranberry Muffins", + "value": "Modell Cranberry Muffins" + }, + { + "selected": false, + "label": "Modell English Muffins", + "value": "Modell English Muffins" + }, + { + "selected": false, + "label": "Modell Muffins", + "value": "Modell Muffins" + }, + { + "selected": false, + "label": "Modell Pumpernickel Bread", + "value": "Modell Pumpernickel Bread" + }, + { + "selected": false, + "label": "Modell Rye Bread", + "value": "Modell Rye Bread" + }, + { + "selected": false, + "label": "Modell Wheat Bread", + "value": "Modell Wheat Bread" + }, + { + "selected": false, + "label": "Modell White Bread", + "value": "Modell White Bread" + }, + { + "selected": false, + "label": "Moms Beef Bologna", + "value": "Moms Beef Bologna" + }, + { + "selected": false, + "label": "Moms Chicken Hot Dogs", + "value": "Moms Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Moms Cole Slaw", + "value": "Moms Cole Slaw" + }, + { + "selected": false, + "label": "Moms Corned Beef", + "value": "Moms Corned Beef" + }, + { + "selected": false, + "label": "Moms Foot-Long Hot Dogs", + "value": "Moms Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Moms Low Fat Bologna", + "value": "Moms Low Fat Bologna" + }, + { + "selected": false, + "label": "Moms Low Fat Cole Slaw", + "value": "Moms Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Moms Pimento Loaf", + "value": "Moms Pimento Loaf" + }, + { + "selected": false, + "label": "Moms Potato Salad", + "value": "Moms Potato Salad" + }, + { + "selected": false, + "label": "Moms Roasted Chicken", + "value": "Moms Roasted Chicken" + }, + { + "selected": false, + "label": "Moms Sliced Chicken", + "value": "Moms Sliced Chicken" + }, + { + "selected": false, + "label": "Moms Sliced Ham", + "value": "Moms Sliced Ham" + }, + { + "selected": false, + "label": "Moms Sliced Turkey", + "value": "Moms Sliced Turkey" + }, + { + "selected": false, + "label": "Moms Turkey Hot Dogs", + "value": "Moms Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Monarch Manicotti", + "value": "Monarch Manicotti" + }, + { + "selected": false, + "label": "Monarch Ravioli", + "value": "Monarch Ravioli" + }, + { + "selected": false, + "label": "Monarch Rice Medly", + "value": "Monarch Rice Medly" + }, + { + "selected": false, + "label": "Monarch Spaghetti", + "value": "Monarch Spaghetti" + }, + { + "selected": false, + "label": "Monarch Thai Rice", + "value": "Monarch Thai Rice" + }, + { + "selected": false, + "label": "Musial Bubble Gum", + "value": "Musial Bubble Gum" + }, + { + "selected": false, + "label": "Musial Malted Milk Balls", + "value": "Musial Malted Milk Balls" + }, + { + "selected": false, + "label": "Musial Mint Chocolate Bar", + "value": "Musial Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Musial Mints", + "value": "Musial Mints" + }, + { + "selected": false, + "label": "Musial Semi-Sweet Chocolate Bar", + "value": "Musial Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Musial Spicy Mints", + "value": "Musial Spicy Mints" + }, + { + "selected": false, + "label": "Musial Tasty Candy Bar", + "value": "Musial Tasty Candy Bar" + }, + { + "selected": false, + "label": "Musial White Chocolate Bar", + "value": "Musial White Chocolate Bar" + }, + { + "selected": false, + "label": "National Egg Substitute", + "value": "National Egg Substitute" + }, + { + "selected": false, + "label": "National Large Brown Eggs", + "value": "National Large Brown Eggs" + }, + { + "selected": false, + "label": "National Large Eggs", + "value": "National Large Eggs" + }, + { + "selected": false, + "label": "National Small Brown Eggs", + "value": "National Small Brown Eggs" + }, + { + "selected": false, + "label": "National Small Eggs", + "value": "National Small Eggs" + }, + { + "selected": false, + "label": "Nationeel Apple Fruit Roll", + "value": "Nationeel Apple Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Avocado Dip", + "value": "Nationeel Avocado Dip" + }, + { + "selected": false, + "label": "Nationeel BBQ Potato Chips", + "value": "Nationeel BBQ Potato Chips" + }, + { + "selected": false, + "label": "Nationeel Beef Jerky", + "value": "Nationeel Beef Jerky" + }, + { + "selected": false, + "label": "Nationeel Buttered Popcorn", + "value": "Nationeel Buttered Popcorn" + }, + { + "selected": false, + "label": "Nationeel Cheese Crackers", + "value": "Nationeel Cheese Crackers" + }, + { + "selected": false, + "label": "Nationeel Cheese Dip", + "value": "Nationeel Cheese Dip" + }, + { + "selected": false, + "label": "Nationeel Chocolate Chip Cookies", + "value": "Nationeel Chocolate Chip Cookies" + }, + { + "selected": false, + "label": "Nationeel Chocolate Donuts", + "value": "Nationeel Chocolate Donuts" + }, + { + "selected": false, + "label": "Nationeel Corn Chips", + "value": "Nationeel Corn Chips" + }, + { + "selected": false, + "label": "Nationeel Dried Apples", + "value": "Nationeel Dried Apples" + }, + { + "selected": false, + "label": "Nationeel Dried Apricots", + "value": "Nationeel Dried Apricots" + }, + { + "selected": false, + "label": "Nationeel Dried Dates", + "value": "Nationeel Dried Dates" + }, + { + "selected": false, + "label": "Nationeel Fondue Mix", + "value": "Nationeel Fondue Mix" + }, + { + "selected": false, + "label": "Nationeel Frosted Cookies", + "value": "Nationeel Frosted Cookies" + }, + { + "selected": false, + "label": "Nationeel Frosted Donuts", + "value": "Nationeel Frosted Donuts" + }, + { + "selected": false, + "label": "Nationeel Fudge Brownies", + "value": "Nationeel Fudge Brownies" + }, + { + "selected": false, + "label": "Nationeel Fudge Cookies", + "value": "Nationeel Fudge Cookies" + }, + { + "selected": false, + "label": "Nationeel Golden Raisins", + "value": "Nationeel Golden Raisins" + }, + { + "selected": false, + "label": "Nationeel Graham Crackers", + "value": "Nationeel Graham Crackers" + }, + { + "selected": false, + "label": "Nationeel Grape Fruit Roll", + "value": "Nationeel Grape Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Lemon Cookies", + "value": "Nationeel Lemon Cookies" + }, + { + "selected": false, + "label": "Nationeel Low Fat BBQ Chips", + "value": "Nationeel Low Fat BBQ Chips" + }, + { + "selected": false, + "label": "Nationeel Low Fat Chips", + "value": "Nationeel Low Fat Chips" + }, + { + "selected": false, + "label": "Nationeel Low Fat Cookies", + "value": "Nationeel Low Fat Cookies" + }, + { + "selected": false, + "label": "Nationeel Low Fat Popcorn", + "value": "Nationeel Low Fat Popcorn" + }, + { + "selected": false, + "label": "Nationeel Mini Donuts", + "value": "Nationeel Mini Donuts" + }, + { + "selected": false, + "label": "Nationeel No Salt Popcorn", + "value": "Nationeel No Salt Popcorn" + }, + { + "selected": false, + "label": "Nationeel Potato Chips", + "value": "Nationeel Potato Chips" + }, + { + "selected": false, + "label": "Nationeel Raisins", + "value": "Nationeel Raisins" + }, + { + "selected": false, + "label": "Nationeel Raspberry Fruit Roll", + "value": "Nationeel Raspberry Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Salsa Dip", + "value": "Nationeel Salsa Dip" + }, + { + "selected": false, + "label": "Nationeel Salted Pretzels", + "value": "Nationeel Salted Pretzels" + }, + { + "selected": false, + "label": "Nationeel Sesame Crackers", + "value": "Nationeel Sesame Crackers" + }, + { + "selected": false, + "label": "Nationeel Strawberry Fruit Roll", + "value": "Nationeel Strawberry Fruit Roll" + }, + { + "selected": false, + "label": "Nationeel Sugar Cookies", + "value": "Nationeel Sugar Cookies" + }, + { + "selected": false, + "label": "Pearl Chablis Wine", + "value": "Pearl Chablis Wine" + }, + { + "selected": false, + "label": "Pearl Chardonnay", + "value": "Pearl Chardonnay" + }, + { + "selected": false, + "label": "Pearl Chardonnay Wine", + "value": "Pearl Chardonnay Wine" + }, + { + "selected": false, + "label": "Pearl Imported Beer", + "value": "Pearl Imported Beer" + }, + { + "selected": false, + "label": "Pearl Light Beer", + "value": "Pearl Light Beer" + }, + { + "selected": false, + "label": "Pearl Light Wine", + "value": "Pearl Light Wine" + }, + { + "selected": false, + "label": "Pearl Merlot Wine", + "value": "Pearl Merlot Wine" + }, + { + "selected": false, + "label": "Pearl White Zinfandel Wine", + "value": "Pearl White Zinfandel Wine" + }, + { + "selected": false, + "label": "PigTail Apple Cinnamon Waffles", + "value": "PigTail Apple Cinnamon Waffles" + }, + { + "selected": false, + "label": "PigTail Beef TV Dinner", + "value": "PigTail Beef TV Dinner" + }, + { + "selected": false, + "label": "PigTail Blueberry Waffles", + "value": "PigTail Blueberry Waffles" + }, + { + "selected": false, + "label": "PigTail Chicken TV Dinner", + "value": "PigTail Chicken TV Dinner" + }, + { + "selected": false, + "label": "PigTail Fajita French Fries", + "value": "PigTail Fajita French Fries" + }, + { + "selected": false, + "label": "PigTail Frozen Broccoli", + "value": "PigTail Frozen Broccoli" + }, + { + "selected": false, + "label": "PigTail Frozen Carrots", + "value": "PigTail Frozen Carrots" + }, + { + "selected": false, + "label": "PigTail Frozen Cauliflower", + "value": "PigTail Frozen Cauliflower" + }, + { + "selected": false, + "label": "PigTail Frozen Cheese Pizza", + "value": "PigTail Frozen Cheese Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Breast", + "value": "PigTail Frozen Chicken Breast" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Thighs", + "value": "PigTail Frozen Chicken Thighs" + }, + { + "selected": false, + "label": "PigTail Frozen Chicken Wings", + "value": "PigTail Frozen Chicken Wings" + }, + { + "selected": false, + "label": "PigTail Frozen Corn", + "value": "PigTail Frozen Corn" + }, + { + "selected": false, + "label": "PigTail Frozen Mushroom Pizza", + "value": "PigTail Frozen Mushroom Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Pancakes", + "value": "PigTail Frozen Pancakes" + }, + { + "selected": false, + "label": "PigTail Frozen Peas", + "value": "PigTail Frozen Peas" + }, + { + "selected": false, + "label": "PigTail Frozen Pepperoni Pizza", + "value": "PigTail Frozen Pepperoni Pizza" + }, + { + "selected": false, + "label": "PigTail Frozen Sausage Pizza", + "value": "PigTail Frozen Sausage Pizza" + }, + { + "selected": false, + "label": "PigTail Grape Popsicles", + "value": "PigTail Grape Popsicles" + }, + { + "selected": false, + "label": "PigTail Home Style French Fries", + "value": "PigTail Home Style French Fries" + }, + { + "selected": false, + "label": "PigTail Ice Cream", + "value": "PigTail Ice Cream" + }, + { + "selected": false, + "label": "PigTail Ice Cream Sandwich", + "value": "PigTail Ice Cream Sandwich" + }, + { + "selected": false, + "label": "PigTail Lemon Popsicles", + "value": "PigTail Lemon Popsicles" + }, + { + "selected": false, + "label": "PigTail Lime Popsicles", + "value": "PigTail Lime Popsicles" + }, + { + "selected": false, + "label": "PigTail Low Fat French Fries", + "value": "PigTail Low Fat French Fries" + }, + { + "selected": false, + "label": "PigTail Low Fat Waffles", + "value": "PigTail Low Fat Waffles" + }, + { + "selected": false, + "label": "PigTail Orange Popsicles", + "value": "PigTail Orange Popsicles" + }, + { + "selected": false, + "label": "PigTail Pancake Mix", + "value": "PigTail Pancake Mix" + }, + { + "selected": false, + "label": "PigTail Popsicles", + "value": "PigTail Popsicles" + }, + { + "selected": false, + "label": "PigTail Turkey TV Dinner", + "value": "PigTail Turkey TV Dinner" + }, + { + "selected": false, + "label": "PigTail Waffles", + "value": "PigTail Waffles" + }, + { + "selected": false, + "label": "Plato Apple Butter", + "value": "Plato Apple Butter" + }, + { + "selected": false, + "label": "Plato Apple Jam", + "value": "Plato Apple Jam" + }, + { + "selected": false, + "label": "Plato Apple Jelly", + "value": "Plato Apple Jelly" + }, + { + "selected": false, + "label": "Plato Apple Preserves", + "value": "Plato Apple Preserves" + }, + { + "selected": false, + "label": "Plato Brown Sugar", + "value": "Plato Brown Sugar" + }, + { + "selected": false, + "label": "Plato Canola Oil", + "value": "Plato Canola Oil" + }, + { + "selected": false, + "label": "Plato Chunky Peanut Butter", + "value": "Plato Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Plato Columbian Coffee", + "value": "Plato Columbian Coffee" + }, + { + "selected": false, + "label": "Plato Corn Oil", + "value": "Plato Corn Oil" + }, + { + "selected": false, + "label": "Plato Creamy Peanut Butter", + "value": "Plato Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Plato Decaf Coffee", + "value": "Plato Decaf Coffee" + }, + { + "selected": false, + "label": "Plato Extra Chunky Peanut Butter", + "value": "Plato Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Plato French Roast Coffee", + "value": "Plato French Roast Coffee" + }, + { + "selected": false, + "label": "Plato Grape Jam", + "value": "Plato Grape Jam" + }, + { + "selected": false, + "label": "Plato Grape Jelly", + "value": "Plato Grape Jelly" + }, + { + "selected": false, + "label": "Plato Grape Preserves", + "value": "Plato Grape Preserves" + }, + { + "selected": false, + "label": "Plato Hot Chocolate", + "value": "Plato Hot Chocolate" + }, + { + "selected": false, + "label": "Plato Low Fat Apple Butter", + "value": "Plato Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Plato Oregano", + "value": "Plato Oregano" + }, + { + "selected": false, + "label": "Plato Pepper", + "value": "Plato Pepper" + }, + { + "selected": false, + "label": "Plato Regular Coffee", + "value": "Plato Regular Coffee" + }, + { + "selected": false, + "label": "Plato Salt", + "value": "Plato Salt" + }, + { + "selected": false, + "label": "Plato Sesame Oil", + "value": "Plato Sesame Oil" + }, + { + "selected": false, + "label": "Plato Strawberry Jam", + "value": "Plato Strawberry Jam" + }, + { + "selected": false, + "label": "Plato Strawberry Jelly", + "value": "Plato Strawberry Jelly" + }, + { + "selected": false, + "label": "Plato Strawberry Preserves", + "value": "Plato Strawberry Preserves" + }, + { + "selected": false, + "label": "Plato Tomato Sauce", + "value": "Plato Tomato Sauce" + }, + { + "selected": false, + "label": "Plato Vegetable Oil", + "value": "Plato Vegetable Oil" + }, + { + "selected": false, + "label": "Plato White Sugar", + "value": "Plato White Sugar" + }, + { + "selected": false, + "label": "Pleasant Beef Soup", + "value": "Pleasant Beef Soup" + }, + { + "selected": false, + "label": "Pleasant Canned Beets", + "value": "Pleasant Canned Beets" + }, + { + "selected": false, + "label": "Pleasant Canned Peas", + "value": "Pleasant Canned Peas" + }, + { + "selected": false, + "label": "Pleasant Canned String Beans", + "value": "Pleasant Canned String Beans" + }, + { + "selected": false, + "label": "Pleasant Canned Tomatos", + "value": "Pleasant Canned Tomatos" + }, + { + "selected": false, + "label": "Pleasant Canned Tuna in Oil", + "value": "Pleasant Canned Tuna in Oil" + }, + { + "selected": false, + "label": "Pleasant Canned Tuna in Water", + "value": "Pleasant Canned Tuna in Water" + }, + { + "selected": false, + "label": "Pleasant Canned Yams", + "value": "Pleasant Canned Yams" + }, + { + "selected": false, + "label": "Pleasant Chicken Noodle Soup", + "value": "Pleasant Chicken Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Chicken Ramen Soup", + "value": "Pleasant Chicken Ramen Soup" + }, + { + "selected": false, + "label": "Pleasant Chicken Soup", + "value": "Pleasant Chicken Soup" + }, + { + "selected": false, + "label": "Pleasant Creamed Corn", + "value": "Pleasant Creamed Corn" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Anchovies", + "value": "Pleasant Fancy Canned Anchovies" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Clams", + "value": "Pleasant Fancy Canned Clams" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Oysters", + "value": "Pleasant Fancy Canned Oysters" + }, + { + "selected": false, + "label": "Pleasant Fancy Canned Sardines", + "value": "Pleasant Fancy Canned Sardines" + }, + { + "selected": false, + "label": "Pleasant Large Canned Shrimp", + "value": "Pleasant Large Canned Shrimp" + }, + { + "selected": false, + "label": "Pleasant Noodle Soup", + "value": "Pleasant Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Regular Ramen Soup", + "value": "Pleasant Regular Ramen Soup" + }, + { + "selected": false, + "label": "Pleasant Rice Soup", + "value": "Pleasant Rice Soup" + }, + { + "selected": false, + "label": "Pleasant Turkey Noodle Soup", + "value": "Pleasant Turkey Noodle Soup" + }, + { + "selected": false, + "label": "Pleasant Vegetable Soup", + "value": "Pleasant Vegetable Soup" + }, + { + "selected": false, + "label": "Portsmouth Chablis Wine", + "value": "Portsmouth Chablis Wine" + }, + { + "selected": false, + "label": "Portsmouth Chardonnay", + "value": "Portsmouth Chardonnay" + }, + { + "selected": false, + "label": "Portsmouth Chardonnay Wine", + "value": "Portsmouth Chardonnay Wine" + }, + { + "selected": false, + "label": "Portsmouth Imported Beer", + "value": "Portsmouth Imported Beer" + }, + { + "selected": false, + "label": "Portsmouth Light Beer", + "value": "Portsmouth Light Beer" + }, + { + "selected": false, + "label": "Portsmouth Light Wine", + "value": "Portsmouth Light Wine" + }, + { + "selected": false, + "label": "Portsmouth Merlot Wine", + "value": "Portsmouth Merlot Wine" + }, + { + "selected": false, + "label": "Portsmouth White Zinfandel Wine", + "value": "Portsmouth White Zinfandel Wine" + }, + { + "selected": false, + "label": "Prelude Rosy Sunglasses", + "value": "Prelude Rosy Sunglasses" + }, + { + "selected": false, + "label": "Queen City Map", + "value": "Queen City Map" + }, + { + "selected": false, + "label": "Queen Eyeglass Screwdriver", + "value": "Queen Eyeglass Screwdriver" + }, + { + "selected": false, + "label": "Quick Extra Lean Hamburger", + "value": "Quick Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Quick Seasoned Hamburger", + "value": "Quick Seasoned Hamburger" + }, + { + "selected": false, + "label": "Radius Corn Puffs", + "value": "Radius Corn Puffs" + }, + { + "selected": false, + "label": "Radius Grits", + "value": "Radius Grits" + }, + { + "selected": false, + "label": "Radius Oatmeal", + "value": "Radius Oatmeal" + }, + { + "selected": false, + "label": "Radius Wheat Puffs", + "value": "Radius Wheat Puffs" + }, + { + "selected": false, + "label": "Red Spade Beef Bologna", + "value": "Red Spade Beef Bologna" + }, + { + "selected": false, + "label": "Red Spade Chicken Hot Dogs", + "value": "Red Spade Chicken Hot Dogs" + }, + { + "selected": false, + "label": "Red Spade Cole Slaw", + "value": "Red Spade Cole Slaw" + }, + { + "selected": false, + "label": "Red Spade Corned Beef", + "value": "Red Spade Corned Beef" + }, + { + "selected": false, + "label": "Red Spade Foot-Long Hot Dogs", + "value": "Red Spade Foot-Long Hot Dogs" + }, + { + "selected": false, + "label": "Red Spade Low Fat Bologna", + "value": "Red Spade Low Fat Bologna" + }, + { + "selected": false, + "label": "Red Spade Low Fat Cole Slaw", + "value": "Red Spade Low Fat Cole Slaw" + }, + { + "selected": false, + "label": "Red Spade Pimento Loaf", + "value": "Red Spade Pimento Loaf" + }, + { + "selected": false, + "label": "Red Spade Potato Salad", + "value": "Red Spade Potato Salad" + }, + { + "selected": false, + "label": "Red Spade Roasted Chicken", + "value": "Red Spade Roasted Chicken" + }, + { + "selected": false, + "label": "Red Spade Sliced Chicken", + "value": "Red Spade Sliced Chicken" + }, + { + "selected": false, + "label": "Red Spade Sliced Ham", + "value": "Red Spade Sliced Ham" + }, + { + "selected": false, + "label": "Red Spade Sliced Turkey", + "value": "Red Spade Sliced Turkey" + }, + { + "selected": false, + "label": "Red Spade Turkey Hot Dogs", + "value": "Red Spade Turkey Hot Dogs" + }, + { + "selected": false, + "label": "Red Wing 100 Watt Lightbulb", + "value": "Red Wing 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 25 Watt Lightbulb", + "value": "Red Wing 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 60 Watt Lightbulb", + "value": "Red Wing 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing 75 Watt Lightbulb", + "value": "Red Wing 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Red Wing AAA-Size Batteries", + "value": "Red Wing AAA-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing AA-Size Batteries", + "value": "Red Wing AA-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing Bees Wax Candles", + "value": "Red Wing Bees Wax Candles" + }, + { + "selected": false, + "label": "Red Wing Copper Cleaner", + "value": "Red Wing Copper Cleaner" + }, + { + "selected": false, + "label": "Red Wing Copper Pot Scrubber", + "value": "Red Wing Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Red Wing Counter Cleaner", + "value": "Red Wing Counter Cleaner" + }, + { + "selected": false, + "label": "Red Wing C-Size Batteries", + "value": "Red Wing C-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing D-Size Batteries", + "value": "Red Wing D-Size Batteries" + }, + { + "selected": false, + "label": "Red Wing Economy Toilet Brush", + "value": "Red Wing Economy Toilet Brush" + }, + { + "selected": false, + "label": "Red Wing Frying Pan", + "value": "Red Wing Frying Pan" + }, + { + "selected": false, + "label": "Red Wing Glass Cleaner", + "value": "Red Wing Glass Cleaner" + }, + { + "selected": false, + "label": "Red Wing Large Sponge", + "value": "Red Wing Large Sponge" + }, + { + "selected": false, + "label": "Red Wing Paper Cups", + "value": "Red Wing Paper Cups" + }, + { + "selected": false, + "label": "Red Wing Paper Plates", + "value": "Red Wing Paper Plates" + }, + { + "selected": false, + "label": "Red Wing Paper Towels", + "value": "Red Wing Paper Towels" + }, + { + "selected": false, + "label": "Red Wing Plastic Forks", + "value": "Red Wing Plastic Forks" + }, + { + "selected": false, + "label": "Red Wing Plastic Knives", + "value": "Red Wing Plastic Knives" + }, + { + "selected": false, + "label": "Red Wing Plastic Spoons", + "value": "Red Wing Plastic Spoons" + }, + { + "selected": false, + "label": "Red Wing Room Freshener", + "value": "Red Wing Room Freshener" + }, + { + "selected": false, + "label": "Red Wing Scented Tissue", + "value": "Red Wing Scented Tissue" + }, + { + "selected": false, + "label": "Red Wing Scented Toilet Tissue", + "value": "Red Wing Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Red Wing Scissors", + "value": "Red Wing Scissors" + }, + { + "selected": false, + "label": "Red Wing Screw Driver", + "value": "Red Wing Screw Driver" + }, + { + "selected": false, + "label": "Red Wing Silver Cleaner", + "value": "Red Wing Silver Cleaner" + }, + { + "selected": false, + "label": "Red Wing Soft Napkins", + "value": "Red Wing Soft Napkins" + }, + { + "selected": false, + "label": "Red Wing Tissues", + "value": "Red Wing Tissues" + }, + { + "selected": false, + "label": "Red Wing Toilet Bowl Cleaner", + "value": "Red Wing Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Red Wing Toilet Paper", + "value": "Red Wing Toilet Paper" + }, + { + "selected": false, + "label": "Robust Monthly Auto Magazine", + "value": "Robust Monthly Auto Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Computer Magazine", + "value": "Robust Monthly Computer Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Fashion Magazine", + "value": "Robust Monthly Fashion Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Home Magazine", + "value": "Robust Monthly Home Magazine" + }, + { + "selected": false, + "label": "Robust Monthly Sports Magazine", + "value": "Robust Monthly Sports Magazine" + }, + { + "selected": false, + "label": "Shady Lake Manicotti", + "value": "Shady Lake Manicotti" + }, + { + "selected": false, + "label": "Shady Lake Ravioli", + "value": "Shady Lake Ravioli" + }, + { + "selected": false, + "label": "Shady Lake Rice Medly", + "value": "Shady Lake Rice Medly" + }, + { + "selected": false, + "label": "Shady Lake Spaghetti", + "value": "Shady Lake Spaghetti" + }, + { + "selected": false, + "label": "Shady Lake Thai Rice", + "value": "Shady Lake Thai Rice" + }, + { + "selected": false, + "label": "Ship Shape Extra Lean Hamburger", + "value": "Ship Shape Extra Lean Hamburger" + }, + { + "selected": false, + "label": "Ship Shape Seasoned Hamburger", + "value": "Ship Shape Seasoned Hamburger" + }, + { + "selected": false, + "label": "Skinner Apple Drink", + "value": "Skinner Apple Drink" + }, + { + "selected": false, + "label": "Skinner Apple Juice", + "value": "Skinner Apple Juice" + }, + { + "selected": false, + "label": "Skinner Berry Juice", + "value": "Skinner Berry Juice" + }, + { + "selected": false, + "label": "Skinner Cola", + "value": "Skinner Cola" + }, + { + "selected": false, + "label": "Skinner Cranberry Juice", + "value": "Skinner Cranberry Juice" + }, + { + "selected": false, + "label": "Skinner Cream Soda", + "value": "Skinner Cream Soda" + }, + { + "selected": false, + "label": "Skinner Diet Cola", + "value": "Skinner Diet Cola" + }, + { + "selected": false, + "label": "Skinner Diet Soda", + "value": "Skinner Diet Soda" + }, + { + "selected": false, + "label": "Skinner Mango Drink", + "value": "Skinner Mango Drink" + }, + { + "selected": false, + "label": "Skinner Orange Juice", + "value": "Skinner Orange Juice" + }, + { + "selected": false, + "label": "Skinner Strawberry Drink", + "value": "Skinner Strawberry Drink" + }, + { + "selected": false, + "label": "Special Corn Puffs", + "value": "Special Corn Puffs" + }, + { + "selected": false, + "label": "Special Grits", + "value": "Special Grits" + }, + { + "selected": false, + "label": "Special Oatmeal", + "value": "Special Oatmeal" + }, + { + "selected": false, + "label": "Special Wheat Puffs", + "value": "Special Wheat Puffs" + }, + { + "selected": false, + "label": "Sphinx Bagels", + "value": "Sphinx Bagels" + }, + { + "selected": false, + "label": "Sphinx Blueberry Muffins", + "value": "Sphinx Blueberry Muffins" + }, + { + "selected": false, + "label": "Sphinx Cranberry Muffins", + "value": "Sphinx Cranberry Muffins" + }, + { + "selected": false, + "label": "Sphinx English Muffins", + "value": "Sphinx English Muffins" + }, + { + "selected": false, + "label": "Sphinx Muffins", + "value": "Sphinx Muffins" + }, + { + "selected": false, + "label": "Sphinx Pumpernickel Bread", + "value": "Sphinx Pumpernickel Bread" + }, + { + "selected": false, + "label": "Sphinx Rye Bread", + "value": "Sphinx Rye Bread" + }, + { + "selected": false, + "label": "Sphinx Wheat Bread", + "value": "Sphinx Wheat Bread" + }, + { + "selected": false, + "label": "Sphinx White Bread", + "value": "Sphinx White Bread" + }, + { + "selected": false, + "label": "Steady 200 MG Acetominifen", + "value": "Steady 200 MG Acetominifen" + }, + { + "selected": false, + "label": "Steady 200 MG Ibuprofen", + "value": "Steady 200 MG Ibuprofen" + }, + { + "selected": false, + "label": "Steady Angled Toothbrush", + "value": "Steady Angled Toothbrush" + }, + { + "selected": false, + "label": "Steady Apricot Shampoo", + "value": "Steady Apricot Shampoo" + }, + { + "selected": false, + "label": "Steady Buffered Aspirin", + "value": "Steady Buffered Aspirin" + }, + { + "selected": false, + "label": "Steady Childrens Aspirin", + "value": "Steady Childrens Aspirin" + }, + { + "selected": false, + "label": "Steady Childrens Cold Remedy", + "value": "Steady Childrens Cold Remedy" + }, + { + "selected": false, + "label": "Steady Conditioning Shampoo", + "value": "Steady Conditioning Shampoo" + }, + { + "selected": false, + "label": "Steady Deodorant", + "value": "Steady Deodorant" + }, + { + "selected": false, + "label": "Steady Dishwasher Detergent", + "value": "Steady Dishwasher Detergent" + }, + { + "selected": false, + "label": "Steady Extra Moisture Shampoo", + "value": "Steady Extra Moisture Shampoo" + }, + { + "selected": false, + "label": "Steady HCL Nasal Spray", + "value": "Steady HCL Nasal Spray" + }, + { + "selected": false, + "label": "Steady Laundry Detergent", + "value": "Steady Laundry Detergent" + }, + { + "selected": false, + "label": "Steady Mint Mouthwash", + "value": "Steady Mint Mouthwash" + }, + { + "selected": false, + "label": "Steady Multi-Symptom Cold Remedy", + "value": "Steady Multi-Symptom Cold Remedy" + }, + { + "selected": false, + "label": "Steady Silky Smooth Hair Conditioner", + "value": "Steady Silky Smooth Hair Conditioner" + }, + { + "selected": false, + "label": "Steady Tartar Control Toothpaste", + "value": "Steady Tartar Control Toothpaste" + }, + { + "selected": false, + "label": "Steady Toothpaste", + "value": "Steady Toothpaste" + }, + { + "selected": false, + "label": "Steady Whitening Toothpast", + "value": "Steady Whitening Toothpast" + }, + { + "selected": false, + "label": "Sunset 100 Watt Lightbulb", + "value": "Sunset 100 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 25 Watt Lightbulb", + "value": "Sunset 25 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 60 Watt Lightbulb", + "value": "Sunset 60 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset 75 Watt Lightbulb", + "value": "Sunset 75 Watt Lightbulb" + }, + { + "selected": false, + "label": "Sunset AAA-Size Batteries", + "value": "Sunset AAA-Size Batteries" + }, + { + "selected": false, + "label": "Sunset AA-Size Batteries", + "value": "Sunset AA-Size Batteries" + }, + { + "selected": false, + "label": "Sunset Bees Wax Candles", + "value": "Sunset Bees Wax Candles" + }, + { + "selected": false, + "label": "Sunset Copper Cleaner", + "value": "Sunset Copper Cleaner" + }, + { + "selected": false, + "label": "Sunset Copper Pot Scrubber", + "value": "Sunset Copper Pot Scrubber" + }, + { + "selected": false, + "label": "Sunset Counter Cleaner", + "value": "Sunset Counter Cleaner" + }, + { + "selected": false, + "label": "Sunset C-Size Batteries", + "value": "Sunset C-Size Batteries" + }, + { + "selected": false, + "label": "Sunset D-Size Batteries", + "value": "Sunset D-Size Batteries" + }, + { + "selected": false, + "label": "Sunset Economy Toilet Brush", + "value": "Sunset Economy Toilet Brush" + }, + { + "selected": false, + "label": "Sunset Frying Pan", + "value": "Sunset Frying Pan" + }, + { + "selected": false, + "label": "Sunset Glass Cleaner", + "value": "Sunset Glass Cleaner" + }, + { + "selected": false, + "label": "Sunset Large Sponge", + "value": "Sunset Large Sponge" + }, + { + "selected": false, + "label": "Sunset Paper Cups", + "value": "Sunset Paper Cups" + }, + { + "selected": false, + "label": "Sunset Paper Plates", + "value": "Sunset Paper Plates" + }, + { + "selected": false, + "label": "Sunset Paper Towels", + "value": "Sunset Paper Towels" + }, + { + "selected": false, + "label": "Sunset Plastic Forks", + "value": "Sunset Plastic Forks" + }, + { + "selected": false, + "label": "Sunset Plastic Knives", + "value": "Sunset Plastic Knives" + }, + { + "selected": false, + "label": "Sunset Plastic Spoons", + "value": "Sunset Plastic Spoons" + }, + { + "selected": false, + "label": "Sunset Room Freshener", + "value": "Sunset Room Freshener" + }, + { + "selected": false, + "label": "Sunset Scented Tissue", + "value": "Sunset Scented Tissue" + }, + { + "selected": false, + "label": "Sunset Scented Toilet Tissue", + "value": "Sunset Scented Toilet Tissue" + }, + { + "selected": false, + "label": "Sunset Scissors", + "value": "Sunset Scissors" + }, + { + "selected": false, + "label": "Sunset Screw Driver", + "value": "Sunset Screw Driver" + }, + { + "selected": false, + "label": "Sunset Silver Cleaner", + "value": "Sunset Silver Cleaner" + }, + { + "selected": false, + "label": "Sunset Soft Napkins", + "value": "Sunset Soft Napkins" + }, + { + "selected": false, + "label": "Sunset Tissues", + "value": "Sunset Tissues" + }, + { + "selected": false, + "label": "Sunset Toilet Bowl Cleaner", + "value": "Sunset Toilet Bowl Cleaner" + }, + { + "selected": false, + "label": "Sunset Toilet Paper", + "value": "Sunset Toilet Paper" + }, + { + "selected": false, + "label": "Super Apple Butter", + "value": "Super Apple Butter" + }, + { + "selected": false, + "label": "Super Apple Jam", + "value": "Super Apple Jam" + }, + { + "selected": false, + "label": "Super Apple Jelly", + "value": "Super Apple Jelly" + }, + { + "selected": false, + "label": "Super Apple Preserves", + "value": "Super Apple Preserves" + }, + { + "selected": false, + "label": "Super Brown Sugar", + "value": "Super Brown Sugar" + }, + { + "selected": false, + "label": "Super Canola Oil", + "value": "Super Canola Oil" + }, + { + "selected": false, + "label": "Super Chunky Peanut Butter", + "value": "Super Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Super Columbian Coffee", + "value": "Super Columbian Coffee" + }, + { + "selected": false, + "label": "Super Corn Oil", + "value": "Super Corn Oil" + }, + { + "selected": false, + "label": "Super Creamy Peanut Butter", + "value": "Super Creamy Peanut Butter" + }, + { + "selected": false, + "label": "Super Decaf Coffee", + "value": "Super Decaf Coffee" + }, + { + "selected": false, + "label": "Super Extra Chunky Peanut Butter", + "value": "Super Extra Chunky Peanut Butter" + }, + { + "selected": false, + "label": "Super French Roast Coffee", + "value": "Super French Roast Coffee" + }, + { + "selected": false, + "label": "Super Grape Jam", + "value": "Super Grape Jam" + }, + { + "selected": false, + "label": "Super Grape Jelly", + "value": "Super Grape Jelly" + }, + { + "selected": false, + "label": "Super Grape Preserves", + "value": "Super Grape Preserves" + }, + { + "selected": false, + "label": "Super Hot Chocolate", + "value": "Super Hot Chocolate" + }, + { + "selected": false, + "label": "Super Low Fat Apple Butter", + "value": "Super Low Fat Apple Butter" + }, + { + "selected": false, + "label": "Super Oregano", + "value": "Super Oregano" + }, + { + "selected": false, + "label": "Super Pepper", + "value": "Super Pepper" + }, + { + "selected": false, + "label": "Super Regular Coffee", + "value": "Super Regular Coffee" + }, + { + "selected": false, + "label": "Super Salt", + "value": "Super Salt" + }, + { + "selected": false, + "label": "Super Sesame Oil", + "value": "Super Sesame Oil" + }, + { + "selected": false, + "label": "Super Strawberry Jam", + "value": "Super Strawberry Jam" + }, + { + "selected": false, + "label": "Super Strawberry Jelly", + "value": "Super Strawberry Jelly" + }, + { + "selected": false, + "label": "Super Strawberry Preserves", + "value": "Super Strawberry Preserves" + }, + { + "selected": false, + "label": "Super Tomato Sauce", + "value": "Super Tomato Sauce" + }, + { + "selected": false, + "label": "Super Vegetable Oil", + "value": "Super Vegetable Oil" + }, + { + "selected": false, + "label": "Super White Sugar", + "value": "Super White Sugar" + }, + { + "selected": false, + "label": "Swell Canned Mixed Fruit", + "value": "Swell Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Swell Canned Peaches", + "value": "Swell Canned Peaches" + }, + { + "selected": false, + "label": "Symphony Rosy Sunglasses", + "value": "Symphony Rosy Sunglasses" + }, + { + "selected": false, + "label": "Tell Tale Almonds", + "value": "Tell Tale Almonds" + }, + { + "selected": false, + "label": "Tell Tale Asparagus", + "value": "Tell Tale Asparagus" + }, + { + "selected": false, + "label": "Tell Tale Baby Onion", + "value": "Tell Tale Baby Onion" + }, + { + "selected": false, + "label": "Tell Tale Beets", + "value": "Tell Tale Beets" + }, + { + "selected": false, + "label": "Tell Tale Broccoli", + "value": "Tell Tale Broccoli" + }, + { + "selected": false, + "label": "Tell Tale Canned Peanuts", + "value": "Tell Tale Canned Peanuts" + }, + { + "selected": false, + "label": "Tell Tale Cantelope", + "value": "Tell Tale Cantelope" + }, + { + "selected": false, + "label": "Tell Tale Cauliflower", + "value": "Tell Tale Cauliflower" + }, + { + "selected": false, + "label": "Tell Tale Corn on the Cob", + "value": "Tell Tale Corn on the Cob" + }, + { + "selected": false, + "label": "Tell Tale Dried Mushrooms", + "value": "Tell Tale Dried Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale Elephant Garlic", + "value": "Tell Tale Elephant Garlic" + }, + { + "selected": false, + "label": "Tell Tale Fancy Plums", + "value": "Tell Tale Fancy Plums" + }, + { + "selected": false, + "label": "Tell Tale Firm Tofu", + "value": "Tell Tale Firm Tofu" + }, + { + "selected": false, + "label": "Tell Tale Fresh Lima Beans", + "value": "Tell Tale Fresh Lima Beans" + }, + { + "selected": false, + "label": "Tell Tale Fuji Apples", + "value": "Tell Tale Fuji Apples" + }, + { + "selected": false, + "label": "Tell Tale Garlic", + "value": "Tell Tale Garlic" + }, + { + "selected": false, + "label": "Tell Tale Golden Delcious Apples", + "value": "Tell Tale Golden Delcious Apples" + }, + { + "selected": false, + "label": "Tell Tale Green Pepper", + "value": "Tell Tale Green Pepper" + }, + { + "selected": false, + "label": "Tell Tale Honey Dew", + "value": "Tell Tale Honey Dew" + }, + { + "selected": false, + "label": "Tell Tale Lemons", + "value": "Tell Tale Lemons" + }, + { + "selected": false, + "label": "Tell Tale Lettuce", + "value": "Tell Tale Lettuce" + }, + { + "selected": false, + "label": "Tell Tale Limes", + "value": "Tell Tale Limes" + }, + { + "selected": false, + "label": "Tell Tale Macintosh Apples", + "value": "Tell Tale Macintosh Apples" + }, + { + "selected": false, + "label": "Tell Tale Mandarin Oranges", + "value": "Tell Tale Mandarin Oranges" + }, + { + "selected": false, + "label": "Tell Tale Mixed Nuts", + "value": "Tell Tale Mixed Nuts" + }, + { + "selected": false, + "label": "Tell Tale Mushrooms", + "value": "Tell Tale Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale New Potatos", + "value": "Tell Tale New Potatos" + }, + { + "selected": false, + "label": "Tell Tale Onions", + "value": "Tell Tale Onions" + }, + { + "selected": false, + "label": "Tell Tale Oranges", + "value": "Tell Tale Oranges" + }, + { + "selected": false, + "label": "Tell Tale Party Nuts", + "value": "Tell Tale Party Nuts" + }, + { + "selected": false, + "label": "Tell Tale Peaches", + "value": "Tell Tale Peaches" + }, + { + "selected": false, + "label": "Tell Tale Plums", + "value": "Tell Tale Plums" + }, + { + "selected": false, + "label": "Tell Tale Potatos", + "value": "Tell Tale Potatos" + }, + { + "selected": false, + "label": "Tell Tale Prepared Salad", + "value": "Tell Tale Prepared Salad" + }, + { + "selected": false, + "label": "Tell Tale Red Delcious Apples", + "value": "Tell Tale Red Delcious Apples" + }, + { + "selected": false, + "label": "Tell Tale Red Pepper", + "value": "Tell Tale Red Pepper" + }, + { + "selected": false, + "label": "Tell Tale Shitake Mushrooms", + "value": "Tell Tale Shitake Mushrooms" + }, + { + "selected": false, + "label": "Tell Tale Squash", + "value": "Tell Tale Squash" + }, + { + "selected": false, + "label": "Tell Tale Summer Squash", + "value": "Tell Tale Summer Squash" + }, + { + "selected": false, + "label": "Tell Tale Sweet Onion", + "value": "Tell Tale Sweet Onion" + }, + { + "selected": false, + "label": "Tell Tale Sweet Peas", + "value": "Tell Tale Sweet Peas" + }, + { + "selected": false, + "label": "Tell Tale Tangerines", + "value": "Tell Tale Tangerines" + }, + { + "selected": false, + "label": "Tell Tale Tomatos", + "value": "Tell Tale Tomatos" + }, + { + "selected": false, + "label": "Tell Tale Walnuts", + "value": "Tell Tale Walnuts" + }, + { + "selected": false, + "label": "Thresher Bubble Gum", + "value": "Thresher Bubble Gum" + }, + { + "selected": false, + "label": "Thresher Malted Milk Balls", + "value": "Thresher Malted Milk Balls" + }, + { + "selected": false, + "label": "Thresher Mint Chocolate Bar", + "value": "Thresher Mint Chocolate Bar" + }, + { + "selected": false, + "label": "Thresher Mints", + "value": "Thresher Mints" + }, + { + "selected": false, + "label": "Thresher Semi-Sweet Chocolate Bar", + "value": "Thresher Semi-Sweet Chocolate Bar" + }, + { + "selected": false, + "label": "Thresher Spicy Mints", + "value": "Thresher Spicy Mints" + }, + { + "selected": false, + "label": "Thresher Tasty Candy Bar", + "value": "Thresher Tasty Candy Bar" + }, + { + "selected": false, + "label": "Thresher White Chocolate Bar", + "value": "Thresher White Chocolate Bar" + }, + { + "selected": false, + "label": "Tip Top Lox", + "value": "Tip Top Lox" + }, + { + "selected": false, + "label": "Tip Top Scallops", + "value": "Tip Top Scallops" + }, + { + "selected": false, + "label": "Token Apple Drink", + "value": "Token Apple Drink" + }, + { + "selected": false, + "label": "Token Apple Juice", + "value": "Token Apple Juice" + }, + { + "selected": false, + "label": "Token Berry Juice", + "value": "Token Berry Juice" + }, + { + "selected": false, + "label": "Token Cola", + "value": "Token Cola" + }, + { + "selected": false, + "label": "Token Cranberry Juice", + "value": "Token Cranberry Juice" + }, + { + "selected": false, + "label": "Token Cream Soda", + "value": "Token Cream Soda" + }, + { + "selected": false, + "label": "Token Diet Cola", + "value": "Token Diet Cola" + }, + { + "selected": false, + "label": "Token Diet Soda", + "value": "Token Diet Soda" + }, + { + "selected": false, + "label": "Token Mango Drink", + "value": "Token Mango Drink" + }, + { + "selected": false, + "label": "Token Orange Juice", + "value": "Token Orange Juice" + }, + { + "selected": false, + "label": "Token Strawberry Drink", + "value": "Token Strawberry Drink" + }, + { + "selected": false, + "label": "Top Measure Chablis Wine", + "value": "Top Measure Chablis Wine" + }, + { + "selected": false, + "label": "Top Measure Chardonnay", + "value": "Top Measure Chardonnay" + }, + { + "selected": false, + "label": "Top Measure Chardonnay Wine", + "value": "Top Measure Chardonnay Wine" + }, + { + "selected": false, + "label": "Top Measure Imported Beer", + "value": "Top Measure Imported Beer" + }, + { + "selected": false, + "label": "Top Measure Light Beer", + "value": "Top Measure Light Beer" + }, + { + "selected": false, + "label": "Top Measure Light Wine", + "value": "Top Measure Light Wine" + }, + { + "selected": false, + "label": "Top Measure Merlot Wine", + "value": "Top Measure Merlot Wine" + }, + { + "selected": false, + "label": "Top Measure White Zinfandel Wine", + "value": "Top Measure White Zinfandel Wine" + }, + { + "selected": false, + "label": "Toretti Rosy Sunglasses", + "value": "Toretti Rosy Sunglasses" + }, + { + "selected": false, + "label": "Toucan Canned Mixed Fruit", + "value": "Toucan Canned Mixed Fruit" + }, + { + "selected": false, + "label": "Toucan Canned Peaches", + "value": "Toucan Canned Peaches" + }, + { + "selected": false, + "label": "Tri-State Almonds", + "value": "Tri-State Almonds" + }, + { + "selected": false, + "label": "Tri-State Asparagus", + "value": "Tri-State Asparagus" + }, + { + "selected": false, + "label": "Tri-State Baby Onion", + "value": "Tri-State Baby Onion" + }, + { + "selected": false, + "label": "Tri-State Beets", + "value": "Tri-State Beets" + }, + { + "selected": false, + "label": "Tri-State Broccoli", + "value": "Tri-State Broccoli" + }, + { + "selected": false, + "label": "Tri-State Canned Peanuts", + "value": "Tri-State Canned Peanuts" + }, + { + "selected": false, + "label": "Tri-State Cantelope", + "value": "Tri-State Cantelope" + }, + { + "selected": false, + "label": "Tri-State Cauliflower", + "value": "Tri-State Cauliflower" + }, + { + "selected": false, + "label": "Tri-State Corn on the Cob", + "value": "Tri-State Corn on the Cob" + }, + { + "selected": false, + "label": "Tri-State Dried Mushrooms", + "value": "Tri-State Dried Mushrooms" + }, + { + "selected": false, + "label": "Tri-State Elephant Garlic", + "value": "Tri-State Elephant Garlic" + }, + { + "selected": false, + "label": "Tri-State Fancy Plums", + "value": "Tri-State Fancy Plums" + }, + { + "selected": false, + "label": "Tri-State Firm Tofu", + "value": "Tri-State Firm Tofu" + }, + { + "selected": false, + "label": "Tri-State Fresh Lima Beans", + "value": "Tri-State Fresh Lima Beans" + }, + { + "selected": false, + "label": "Tri-State Fuji Apples", + "value": "Tri-State Fuji Apples" + }, + { + "selected": false, + "label": "Tri-State Garlic", + "value": "Tri-State Garlic" + }, + { + "selected": false, + "label": "Tri-State Golden Delcious Apples", + "value": "Tri-State Golden Delcious Apples" + }, + { + "selected": false, + "label": "Tri-State Green Pepper", + "value": "Tri-State Green Pepper" + }, + { + "selected": false, + "label": "Tri-State Honey Dew", + "value": "Tri-State Honey Dew" + }, + { + "selected": false, + "label": "Tri-State Lemons", + "value": "Tri-State Lemons" + }, + { + "selected": false, + "label": "Tri-State Lettuce", + "value": "Tri-State Lettuce" + }, + { + "selected": false, + "label": "Tri-State Limes", + "value": "Tri-State Limes" + }, + { + "selected": false, + "label": "Tri-State Macintosh Apples", + "value": "Tri-State Macintosh Apples" + }, + { + "selected": false, + "label": "Tri-State Mandarin Oranges", + "value": "Tri-State Mandarin Oranges" + }, + { + "selected": false, + "label": "Tri-State Mixed Nuts", + "value": "Tri-State Mixed Nuts" + }, + { + "selected": false, + "label": "Tri-State Mushrooms", + "value": "Tri-State Mushrooms" + }, + { + "selected": false, + "label": "Tri-State New Potatos", + "value": "Tri-State New Potatos" + }, + { + "selected": false, + "label": "Tri-State Onions", + "value": "Tri-State Onions" + }, + { + "selected": false, + "label": "Tri-State Oranges", + "value": "Tri-State Oranges" + }, + { + "selected": false, + "label": "Tri-State Party Nuts", + "value": "Tri-State Party Nuts" + }, + { + "selected": false, + "label": "Tri-State Peaches", + "value": "Tri-State Peaches" + }, + { + "selected": false, + "label": "Tri-State Plums", + "value": "Tri-State Plums" + }, + { + "selected": false, + "label": "Tri-State Potatos", + "value": "Tri-State Potatos" + }, + { + "selected": false, + "label": "Tri-State Prepared Salad", + "value": "Tri-State Prepared Salad" + }, + { + "selected": false, + "label": "Tri-State Red Delcious Apples", + "value": "Tri-State Red Delcious Apples" + }, + { + "selected": false, + "label": "Tri-State Red Pepper", + "value": "Tri-State Red Pepper" + }, + { + "selected": false, + "label": "Tri-State Shitake Mushrooms", + "value": "Tri-State Shitake Mushrooms" + }, + { + "selected": false, + "label": "Tri-State Squash", + "value": "Tri-State Squash" + }, + { + "selected": false, + "label": "Tri-State Summer Squash", + "value": "Tri-State Summer Squash" + }, + { + "selected": false, + "label": "Tri-State Sweet Onion", + "value": "Tri-State Sweet Onion" + }, + { + "selected": false, + "label": "Tri-State Sweet Peas", + "value": "Tri-State Sweet Peas" + }, + { + "selected": false, + "label": "Tri-State Tangerines", + "value": "Tri-State Tangerines" + }, + { + "selected": false, + "label": "Tri-State Tomatos", + "value": "Tri-State Tomatos" + }, + { + "selected": false, + "label": "Tri-State Walnuts", + "value": "Tri-State Walnuts" + }, + { + "selected": false, + "label": "Urban Egg Substitute", + "value": "Urban Egg Substitute" + }, + { + "selected": false, + "label": "Urban Large Brown Eggs", + "value": "Urban Large Brown Eggs" + }, + { + "selected": false, + "label": "Urban Large Eggs", + "value": "Urban Large Eggs" + }, + { + "selected": false, + "label": "Urban Small Brown Eggs", + "value": "Urban Small Brown Eggs" + }, + { + "selected": false, + "label": "Urban Small Eggs", + "value": "Urban Small Eggs" + }, + { + "selected": false, + "label": "Walrus Chablis Wine", + "value": "Walrus Chablis Wine" + }, + { + "selected": false, + "label": "Walrus Chardonnay", + "value": "Walrus Chardonnay" + }, + { + "selected": false, + "label": "Walrus Chardonnay Wine", + "value": "Walrus Chardonnay Wine" + }, + { + "selected": false, + "label": "Walrus Imported Beer", + "value": "Walrus Imported Beer" + }, + { + "selected": false, + "label": "Walrus Light Beer", + "value": "Walrus Light Beer" + }, + { + "selected": false, + "label": "Walrus Light Wine", + "value": "Walrus Light Wine" + }, + { + "selected": false, + "label": "Walrus Merlot Wine", + "value": "Walrus Merlot Wine" + }, + { + "selected": false, + "label": "Walrus White Zinfandel Wine", + "value": "Walrus White Zinfandel Wine" + }, + { + "selected": false, + "label": "Washington Apple Drink", + "value": "Washington Apple Drink" + }, + { + "selected": false, + "label": "Washington Apple Juice", + "value": "Washington Apple Juice" + }, + { + "selected": false, + "label": "Washington Berry Juice", + "value": "Washington Berry Juice" + }, + { + "selected": false, + "label": "Washington Cola", + "value": "Washington Cola" + }, + { + "selected": false, + "label": "Washington Cranberry Juice", + "value": "Washington Cranberry Juice" + }, + { + "selected": false, + "label": "Washington Cream Soda", + "value": "Washington Cream Soda" + }, + { + "selected": false, + "label": "Washington Diet Cola", + "value": "Washington Diet Cola" + }, + { + "selected": false, + "label": "Washington Diet Soda", + "value": "Washington Diet Soda" + }, + { + "selected": false, + "label": "Washington Mango Drink", + "value": "Washington Mango Drink" + }, + { + "selected": false, + "label": "Washington Orange Juice", + "value": "Washington Orange Juice" + }, + { + "selected": false, + "label": "Washington Strawberry Drink", + "value": "Washington Strawberry Drink" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/client-network/src/test/resources/json/input_controls_without_states.json b/client-network/src/test/resources/json/input_controls_without_states.json new file mode 100644 index 00000000..c5032071 --- /dev/null +++ b/client-network/src/test/resources/json/input_controls_without_states.json @@ -0,0 +1,48 @@ +{ + "inputControl": [ + { + "id": "sales_fact_ALL__store_sales_2013_1", + "type": "singleValueNumber", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", + "label": "Store Sales 2013 is greater than", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [] + }, + { + "id": "sales__product__low_fat_1", + "type": "multiSelectCheckbox", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", + "label": "Low Fat", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [] + }, + { + "id": "sales__product__recyclable_package_1", + "type": "multiSelectCheckbox", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", + "label": "Recyclable Packaging", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [] + }, + { + "id": "sales__product__product_name_1", + "type": "multiSelect", + "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", + "label": "Product Name", + "mandatory": false, + "readOnly": false, + "visible": true, + "masterDependencies": [], + "slaveDependencies": [] + } + ] +} \ No newline at end of file From 5265382358f6b854c2689ceb40ecfc865cd09cef Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 09:05:36 +0300 Subject: [PATCH 225/457] Add explicit token parameter for ReportOptionsRestApi --- .../sdk/network/api/ReportOptionRestApi.java | 19 +- .../network/api/ReportOptionRestApiImpl.java | 43 +++-- .../api/ReportOptionRestApiBuilderTest.java | 26 --- .../network/api/ReportOptionRestApiTest.java | 162 +++++++++++++----- .../api/ReportOptionRestApiTest.java | 9 +- .../test/resources/json/report_option.json | 5 + .../resources/json/report_options_list.json | 9 + 7 files changed, 179 insertions(+), 94 deletions(-) create mode 100644 client-network/src/test/resources/json/report_option.json create mode 100644 client-network/src/test/resources/json/report_options_list.json diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 9a4f0697..432106a7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -40,25 +40,28 @@ public interface ReportOptionRestApi { @NonNull @WorkerThread - Set requestReportOptionsList(@NonNull String reportUnitUri); + Set requestReportOptionsList(@NonNull String reportUnitUri, @NonNull String token); @NonNull @WorkerThread ReportOption createReportOption(@NonNull String reportUnitUri, - @NonNull String optionLabel, - @NonNull Map> controlsValues, - boolean overwrite); + @NonNull String optionLabel, + @NonNull Map> controlsValues, + boolean overwrite, + @NonNull String token); @WorkerThread void updateReportOption(@NonNull String reportUnitUri, - @NonNull String optionId, - @NonNull Map> controlsValues); + @NonNull String optionId, + @NonNull Map> controlsValues, + @NonNull String token); @WorkerThread void deleteReportOption(@NonNull String reportUnitUri, - @NonNull String optionId); + @NonNull String optionId, + @NonNull String token); - final class Builder extends GenericAuthBuilder { + final class Builder extends GenericBuilder { @Override ReportOptionRestApi createApi() { return new ReportOptionRestApiImpl(getAdapter().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java index ec507f92..75964868 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -41,6 +41,7 @@ import retrofit.http.Body; import retrofit.http.DELETE; import retrofit.http.GET; +import retrofit.http.Header; import retrofit.http.Headers; import retrofit.http.POST; import retrofit.http.PUT; @@ -62,10 +63,12 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { @NonNull @Override - public Set requestReportOptionsList(@Nullable String reportUnitUri) { + public Set requestReportOptionsList(@Nullable String reportUnitUri, + @Nullable String token) { checkNotNull(reportUnitUri, "Report uri should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestReportOptionsList(reportUnitUri); + Call call = mRestApi.requestReportOptionsList(reportUnitUri, token); try { ReportOptionSet options = CallWrapper.wrap(call).body(); return options.get(); @@ -82,36 +85,42 @@ public Set requestReportOptionsList(@Nullable String reportUnitUri @NonNull @Override public ReportOption createReportOption(@Nullable String reportUnitUri, - @Nullable String optionLabel, - @Nullable Map> controlsValues, - boolean overwrite) { + @Nullable String optionLabel, + @Nullable Map> controlsValues, + boolean overwrite, + @Nullable String token) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionLabel, "Option label should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite); + Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite, token); return CallWrapper.wrap(call).body(); } @Override public void updateReportOption(@Nullable String reportUnitUri, - @Nullable String optionId, - @Nullable Map> controlsValues) { + @Nullable String optionId, + @Nullable Map> controlsValues, + @Nullable String token) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionId, "Option id should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues); + Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues, token); CallWrapper.wrap(call).body(); } @Override public void deleteReportOption(@Nullable String reportUnitUri, - @Nullable String optionId) { + @Nullable String optionId, + @Nullable String token) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionId, "Option id should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.deleteReportOption(reportUnitUri, optionId); + Call call = mRestApi.deleteReportOption(reportUnitUri, optionId, token); CallWrapper.wrap(call).body(); } @@ -120,7 +129,8 @@ private interface RestApi { @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitUri}/options") Call requestReportOptionsList( - @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); + @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @@ -129,7 +139,8 @@ Call createReportOption( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Query("label") String optionLabel, @NonNull @Body Map> controlsValues, - @Query("overwrite") boolean overwrite); + @Query("overwrite") boolean overwrite, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @@ -137,13 +148,15 @@ Call createReportOption( Call updateReportOption( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NonNull @Path(value = "optionId", encoded = true) String optionId, - @NonNull @Body Map> controlsValues); + @NonNull @Body Map> controlsValues, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") Call deleteReportOption( @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NonNull @Path(value = "optionId", encoded = true) String optionId); + @NonNull @Path(value = "optionId", encoded = true) String optionId, + @Header("Cookie") String cookie); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java index d1e4571a..a6b7118c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java @@ -64,30 +64,4 @@ public void builderShouldNotAllowEmptyUrl() { public void builderShouldAllowNullLogLevel() { builderUnderTest.logger(null); } - - @Test - public void builderShouldEnsureBaseUrlNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Base url should be supplied to work with JRS API"); - - builderUnderTest.tokenProvider(FakeTokenProvider.get()); - builderUnderTest.build(); - } - - @Test - public void builderShouldEnsureTokenNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication tokenProvider"); - - builderUnderTest.baseUrl("http://localhost"); - builderUnderTest.build(); - } - - @Test - public void builderShouldAllowNullToken() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("tokenProvider == null"); - - builderUnderTest.tokenProvider(null); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index 4da9e8aa..4dcdcbd8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -24,8 +24,12 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; +import com.jaspersoft.android.sdk.test.resource.ResourceFile; +import com.jaspersoft.android.sdk.test.resource.TestResource; +import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; import com.squareup.okhttp.mockwebserver.RecordedRequest; @@ -33,7 +37,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.MockitoAnnotations; import java.util.Collections; import java.util.HashMap; @@ -41,7 +44,9 @@ import java.util.Set; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; /** * @author Tom Koptel @@ -56,11 +61,15 @@ public class ReportOptionRestApiTest { private ReportOptionRestApi restApiUnderTest; + @ResourceFile("json/report_option.json") + TestResource reportOption; + @ResourceFile("json/report_options_list.json") + TestResource reportOptionsList; + @Before public void setup() { - MockitoAnnotations.initMocks(this); + TestResourceInjector.inject(this); restApiUnderTest = new ReportOptionRestApi.Builder() - .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } @@ -69,103 +78,176 @@ public void setup() { public void requestReportOptionsListShouldNotAllowNullReportUnitUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportOptionsList(null); - } - - @Test - public void requestReportOptionsListShouldThrow500Error() { - mExpectedException.expect(RestError.class); - - mWebMockRule.enqueue(MockResponseFactory.create500()); - - restApiUnderTest.requestReportOptionsList("any_id"); - } - - @Test - public void updateReportOptionShouldThrowRestErrorFor500() { - mExpectedException.expect(RestError.class); - - mWebMockRule.enqueue(MockResponseFactory.create500()); - - restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP); + restApiUnderTest.requestReportOptionsList(null, "cookie"); } @Test - public void deleteReportOptionShouldThrowRestErrorFor500() { - mExpectedException.expect(RestError.class); - - mWebMockRule.enqueue(MockResponseFactory.create500()); - - restApiUnderTest.deleteReportOption("any_id", "option_id"); + public void requestReportOptionsListShouldNotAllowNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + restApiUnderTest.requestReportOptionsList("/my/uri", null); } @Test public void createReportOptionShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.createReportOption(null, "label", Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption(null, "label", Collections.EMPTY_MAP, false, "cookie"); } + @Test + public void createReportOptionShouldNotAllowNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + restApiUnderTest.createReportOption("/my/uri", "label", Collections.EMPTY_MAP, false, null); + } @Test public void createReportOptionShouldNotAllowNullOptionLabel() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option label should not be null"); - restApiUnderTest.createReportOption("any_id", null, Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption("any_id", null, Collections.EMPTY_MAP, false, "cookie"); } @Test public void createReportOptionShouldNotAllowNullControlsValues() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.createReportOption("any_id", "label", null, false); + restApiUnderTest.createReportOption("any_id", "label", null, false, "cookie"); } @Test public void updateReportOptionShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.updateReportOption(null, "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption(null, "option_id", Collections.EMPTY_MAP, "cookie"); } @Test public void updateReportOptionShouldNotAllowNullOptionId() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.updateReportOption("any_id", null, Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption("any_id", null, Collections.EMPTY_MAP, "cookie"); } @Test public void updateReportOptionShouldNotAllowNullControlsValues() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.updateReportOption("any_id", "option_id", null); + restApiUnderTest.updateReportOption("any_id", "option_id", null, "cookie"); + } + + @Test + public void updateReportOptionShouldNotAllowNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP, null); } @Test public void deleteReportOptionShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.deleteReportOption(null, "option_id"); + restApiUnderTest.deleteReportOption(null, "option_id", "cookie"); } @Test public void deleteReportOptionShouldNotAllowNullOptionId() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.deleteReportOption("any_id", null); + restApiUnderTest.deleteReportOption("any_id", null, "cookie"); + } + + @Test + public void deleteReportOptionShouldNotAllowNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + restApiUnderTest.deleteReportOption("any_id", "option_id", null); + } + + @Test + public void apiShouldListReportOptions() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200().setBody(reportOptionsList.asString()); + mWebMockRule.enqueue(mockResponse); + + Set response = restApiUnderTest.requestReportOptionsList("/any/uri", "cookie"); + assertThat(response, is(not(empty()))); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options")); + assertThat(request.getHeader("Cookie"), is("cookie")); } @Test - public void shouldNotEncodeReportOptionLabelDuringCreation() throws Exception { - MockResponse mockResponse = MockResponseFactory.create200(); + public void apiShouldCreateReportOption() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200().setBody(reportOption.asString()); mWebMockRule.enqueue(mockResponse); Map> params = new HashMap<>(); - params.put("key", Collections.emptySet()); + params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19")); + + ReportOption reportOption = restApiUnderTest.createReportOption("/any/uri", "my label", params, true, "cookie"); + assertThat(reportOption.getId(), is("my_label")); + assertThat(reportOption.getLabel(), is("my label")); + assertThat(reportOption.getUri(), is("/public/Samples/Reports/my_label")); - restApiUnderTest.createReportOption("/any/uri", "my label", params, true); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options?label=my%20label&overwrite=true")); + assertThat(request.getBody().readUtf8(), is("{\"sales_fact_ALL__store_sales_2013_1\":[\"19\"]}")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void apiShouldUpdateReportOption() throws Exception { + mWebMockRule.enqueue(MockResponseFactory.create200()); + + Map> params = new HashMap<>(); + params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("22")); + + restApiUnderTest.updateReportOption("/any/uri", "option_id", params, "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); + assertThat(request.getMethod(), is("PUT")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void apiShouldDeleteReportOption() throws Exception { + mWebMockRule.enqueue(MockResponseFactory.create200()); + + restApiUnderTest.deleteReportOption("/any/uri", "option_id", "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); + assertThat(request.getMethod(), is("DELETE")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void requestReportOptionsListShouldThrow500Error() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.requestReportOptionsList("any_id", "cookie"); + } + + @Test + public void updateReportOptionShouldThrowRestErrorFor500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP, "cookie"); + } + + @Test + public void deleteReportOptionShouldThrowRestErrorFor500() { + mExpectedException.expect(RestError.class); + + mWebMockRule.enqueue(MockResponseFactory.create500()); + + restApiUnderTest.deleteReportOption("any_id", "option_id", "cookie"); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 52ecd955..b358e023 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -67,7 +67,6 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportOptionRestApi.Builder() .logger(TestLogger.get(this)) - .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .build(); } @@ -75,17 +74,17 @@ public void setup() { @Test public void shouldRequestReportOptionsList() { - Set response = apiUnderTest.requestReportOptionsList(REPORT_URI); + Set response = apiUnderTest.requestReportOptionsList(REPORT_URI, mAuthenticator.token()); assertThat(response, is(not(nullValue()))); } @Test public void apiSupportsCrudForReportOption() { - ReportOption response = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true); + ReportOption response = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true, mAuthenticator.token()); assertThat(response.getLabel(), is("label")); - apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS); + apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS, mAuthenticator.token()); - apiUnderTest.deleteReportOption(REPORT_URI, response.getId()); + apiUnderTest.deleteReportOption(REPORT_URI, response.getId(), mAuthenticator.token()); } } diff --git a/client-network/src/test/resources/json/report_option.json b/client-network/src/test/resources/json/report_option.json new file mode 100644 index 00000000..87029b37 --- /dev/null +++ b/client-network/src/test/resources/json/report_option.json @@ -0,0 +1,5 @@ +{ + "uri": "/public/Samples/Reports/my_label", + "id": "my_label", + "label": "my label" +} \ No newline at end of file diff --git a/client-network/src/test/resources/json/report_options_list.json b/client-network/src/test/resources/json/report_options_list.json new file mode 100644 index 00000000..2fe47887 --- /dev/null +++ b/client-network/src/test/resources/json/report_options_list.json @@ -0,0 +1,9 @@ +{ + "reportOptionsSummary": [ + { + "uri": "/public/Samples/Reports/my_label", + "id": "my_label", + "label": "my label" + } + ] +} \ No newline at end of file From 70ca390977e8991f2d3046d3ffe4185426a50663 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 13:45:33 +0300 Subject: [PATCH 226/457] Add explicit token parameter for ReportExecutionRestApi --- .../sdk/network/api/LoggingInterceptor.java | 4 +- .../network/api/ReportExecutionRestApi.java | 17 +- .../api/ReportExecutionRestApiImpl.java | 55 +++-- .../ReportExecutionRestApiBuilderTest.java | 26 --- .../api/ReportExecutionRestApiTest.java | 205 ++++++++++++++---- .../api/ReportExecutionRestApiTest.java | 35 ++- .../api/ReportExportRestApiTest.java | 3 +- 7 files changed, 231 insertions(+), 114 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java index 69c6d8bf..66355834 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java @@ -58,8 +58,8 @@ public Response intercept(Interceptor.Chain chain) throws IOException { long t2 = System.nanoTime(); String bodyString = response.body().string(); logger.log(String.format("<-----------------------------------------------------Received response" + - "%nUrl: %s%nTime spent: %.1fms%n%s%nBody: %s", - response.request().url(), (t2 - t1) / 1e6d, response.headers(), bodyString)); + "%nUrl: %s%nCode: %d%nTime spent: %.1fms%n%s%nBody: %s", + response.request().url(), response.code(), (t2 - t1) / 1e6d, response.headers(), bodyString)); return response.newBuilder() .body(ResponseBody.create(response.body().contentType(), bodyString)) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 3be339cb..8cbf4223 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -32,6 +32,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import java.util.Collection; import java.util.Map; import java.util.Set; @@ -43,30 +44,32 @@ public interface ReportExecutionRestApi { @NonNull @WorkerThread - ReportExecutionDescriptor runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions); + ReportExecutionDescriptor runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions, @NonNull String token); @NonNull @WorkerThread - ReportExecutionDescriptor requestReportExecutionDetails(@NonNull String executionId); + ReportExecutionDescriptor requestReportExecutionDetails(@NonNull String executionId, @NonNull String token); @NonNull @WorkerThread - ExecutionStatus requestReportExecutionStatus(@NonNull String executionId); + ExecutionStatus requestReportExecutionStatus(@NonNull String executionId, @NonNull String token); @WorkerThread - boolean cancelReportExecution(@NonNull String executionId); + boolean cancelReportExecution(@NonNull String executionId, @NonNull String token); @WorkerThread - boolean updateReportExecution(@NonNull String executionId, @NonNull Map> params); + boolean updateReportExecution(@NonNull String executionId, + @NonNull Collection>> params, + @NonNull String token); /** * TODO: API is broken requires investigation before release */ @NonNull @WorkerThread - ReportExecutionSearchResponse searchReportExecution(Map params); + ReportExecutionSearchResponse searchReportExecution(Map params, @NonNull String token); - final class Builder extends GenericAuthBuilder { + final class Builder extends GenericBuilder { @Override ReportExecutionRestApi createApi() { return new ReportExecutionRestApiImpl(getAdapter().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 59778868..8959bc15 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -32,6 +32,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import java.util.Collection; import java.util.Map; import java.util.Set; @@ -40,6 +41,7 @@ import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; +import retrofit.http.Header; import retrofit.http.Headers; import retrofit.http.POST; import retrofit.http.PUT; @@ -63,47 +65,55 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NonNull @Override - public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) { + public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions, @Nullable String token) { checkNotNull(executionOptions, "Execution options should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.runReportExecution(executionOptions); + Call call = mRestApi.runReportExecution(executionOptions, token); return CallWrapper.wrap(call).body(); } @NonNull @Override - public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String executionId) { + public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String executionId, @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestReportExecutionDetails(executionId); + Call call = mRestApi.requestReportExecutionDetails(executionId, token); return CallWrapper.wrap(call).body(); } @NonNull @Override - public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId) { + public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId, @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestReportExecutionStatus(executionId); + Call call = mRestApi.requestReportExecutionStatus(executionId, token); return CallWrapper.wrap(call).body(); } @Override - public boolean cancelReportExecution(@Nullable String executionId) { + public boolean cancelReportExecution(@Nullable String executionId, @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus()); + Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus(), token); Response response = CallWrapper.wrap(call).response(); int status = response.code(); return status != 204; } @Override - public boolean updateReportExecution(@Nullable String executionId, @Nullable Map> params) { + public boolean updateReportExecution(@Nullable String executionId, + @Nullable Collection>> params, + @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(params, "Execution params id should not be null"); + checkNotNull(params, "Execution params should not be null"); + checkArgument(params.isEmpty(), "Execution params should not be empty"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.updateReportExecution(executionId, params); + Call call = mRestApi.updateReportExecution(executionId, params, token); Response response = CallWrapper.wrap(call).response(); int status = response.code(); return status == 204; @@ -111,11 +121,12 @@ public boolean updateReportExecution(@Nullable String executionId, @Nullable Map @NonNull @Override - public ReportExecutionSearchResponse searchReportExecution(@Nullable Map params) { + public ReportExecutionSearchResponse searchReportExecution(@Nullable Map params, @Nullable String token) { checkNotNull(params, "Search params should not be null"); checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.searchReportExecution(params); + Call call = mRestApi.searchReportExecution(params, token); ReportExecutionSearchResponse body = CallWrapper.wrap(call).body(); if (body == null) { return ReportExecutionSearchResponse.empty(); @@ -127,32 +138,38 @@ interface RestApi { @NonNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions") - Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions); + Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}") - Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId); + Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/status") - Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId); + Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/parameters") Call updateReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body Map> params); + @NonNull @Body Collection>> params, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @PUT("rest_v2/reportExecutions/{executionId}/status") Call cancelReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body ExecutionStatus statusResponse); + @NonNull @Body ExecutionStatus statusResponse, + @Header("Cookie") String cookie); @Headers("Accept: application/json") @GET("rest_v2/reportExecutions") - Call searchReportExecution(@Nullable @QueryMap(encoded = true) Map params); + Call searchReportExecution(@Nullable @QueryMap(encoded = true) Map params, + @Header("Cookie") String cookie); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java index 8d0ce0c2..a0d276c2 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java @@ -62,30 +62,4 @@ public void builderShouldNotAllowEmptyUrl() { public void builderShouldAllowNullLogLevel() { builderUnderTest.logger(null); } - - @Test - public void builderShouldEnsureBaseUrlNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Base url should be supplied to work with JRS API"); - - builderUnderTest.tokenProvider(FakeTokenProvider.get()); - builderUnderTest.build(); - } - - @Test - public void builderShouldEnsureTokenNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication tokenProvider"); - - builderUnderTest.baseUrl("http://localhost"); - builderUnderTest.build(); - } - - @Test - public void builderShouldAllowNullToken() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("tokenProvider == null"); - - builderUnderTest.tokenProvider(null); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index d4669f4a..889a3daa 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -24,13 +24,17 @@ package com.jaspersoft.android.sdk.network.api; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.RecordedRequest; import org.junit.Before; import org.junit.Rule; @@ -38,11 +42,16 @@ import org.junit.rules.ExpectedException; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertThat; @@ -54,6 +63,13 @@ public class ReportExecutionRestApiTest { private static final Map SEARCH_PARAMS = new HashMap(); + private static final List>> PARAMS = new ArrayList<>(); + static { + Map> reportParameter = new HashMap<>(); + reportParameter.put("key", new HashSet(Collections.singletonList("value"))); + PARAMS.add(reportParameter); + } + static { SEARCH_PARAMS.put("key", "value"); } @@ -62,6 +78,10 @@ public class ReportExecutionRestApiTest { TestResource cancelledResponse; @ResourceFile("json/search_execution_response.json") TestResource searchExecutionResponse; + @ResourceFile("json/report_execution_response.json") + TestResource reportExecutionResponse; + @ResourceFile("json/report_execution_details.json") + TestResource reportExecutionDetailsResponse; @Rule public final WebMockRule mWebMockRule = new WebMockRule(); @@ -73,7 +93,6 @@ public class ReportExecutionRestApiTest { public void setup() { TestResourceInjector.inject(this); restApiUnderTest = new ReportExecutionRestApi.Builder() - .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } @@ -82,9 +101,9 @@ public void setup() { public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mExpectedException.expect(RestError.class); - mWebMockRule.enqueue(create500Response()); + mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri")); + restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri"), "cookie"); } @Test @@ -92,100 +111,194 @@ public void bodyParameterShouldNotBeNullForRunReportExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runReportExecution(null); + restApiUnderTest.runReportExecution(null, "cookie"); + } + + @Test + public void tokenShouldNotBeNullForRunReportExecution() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/uri"); + restApiUnderTest.runReportExecution(options, null); } @Test - public void pathParameterShouldNotBeNullForRequestExecutionDetails() { + public void executionIdShouldNotBeNullForRequestExecutionDetails() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionDetails(null); + restApiUnderTest.requestReportExecutionDetails(null, "cookie"); } @Test - public void pathParameterShouldNotBeNullForRequestExecutionStatus() { + public void tokenShouldNotBeNullForRequestExecutionDetails() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.requestReportExecutionDetails("exec_id", null); + } + + @Test + public void executionIdShouldNotBeNullForRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionStatus(null); + restApiUnderTest.requestReportExecutionStatus(null, "cookie"); } @Test - public void pathParameterShouldNotBeNullForCancelRequestExecution() { + public void tokenShouldNotBeNullForRequestExecutionStatus() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.requestReportExecutionStatus("exec_id", null); + } + + @Test + public void executionIdShouldNotBeNullForCancelRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.cancelReportExecution(null); + restApiUnderTest.cancelReportExecution(null, "cookie"); + } + + @Test + public void tokenShouldNotBeNullForCancelRequestExecution() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.cancelReportExecution("exec_id", null); + } + + @Test + public void bodyParameterShouldNotBeNullForExecutionUpdate() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Execution params should not be null"); + + restApiUnderTest.updateReportExecution("any_id", null, "cookie"); + } + + @Test + public void bodyParameterShouldNotBeEmptyForExecutionUpdate() { + mExpectedException.expect(IllegalArgumentException.class); + mExpectedException.expectMessage("Execution params should not be empty"); + + restApiUnderTest.updateReportExecution("any_id", Collections.>>emptyList(), "cookie"); + } + + @Test + public void shouldStartReportExecution() throws Exception { + MockResponse response = MockResponseFactory.create200().setBody(reportExecutionResponse.asString()); + mWebMockRule.enqueue(response); + + ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/my/uri"); + restApiUnderTest.runReportExecution(options, "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions")); + assertThat(request.getBody().readUtf8(), is("{\"reportUnitUri\":\"/my/uri\"}")); + assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getMethod(), is("POST")); + } + + @Test + public void shouldRequestReportExecutionDetails() throws Exception { + MockResponse response = MockResponseFactory.create200().setBody(reportExecutionDetailsResponse.asString()); + mWebMockRule.enqueue(response); + + ReportExecutionDescriptor details = restApiUnderTest.requestReportExecutionDetails("exec_id", "cookie"); + assertThat(details, is(notNullValue())); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id")); + assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getMethod(), is("GET")); + } + + @Test + public void shouldRequestReportExecutionStatus() throws Exception { + MockResponse response = MockResponseFactory.create200().setBody("{\"value\":\"execution\"}"); + mWebMockRule.enqueue(response); + + ExecutionStatus status = restApiUnderTest.requestReportExecutionStatus("exec_id", "cookie"); + assertThat(status, is(notNullValue())); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); + assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getMethod(), is("GET")); + } + + @Test + public void shouldCancelReportExecution() throws Exception { + MockResponse response = MockResponseFactory.create200(); + mWebMockRule.enqueue(response); + + restApiUnderTest.cancelReportExecution("exec_id", "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); + assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getBody().readUtf8(), is("{\"value\":\"cancelled\"}")); + assertThat(request.getMethod(), is("PUT")); + } + + @Test + public void shouldUpdateReportExecution() throws Exception { + MockResponse response = MockResponseFactory.create204(); + mWebMockRule.enqueue(response); + + restApiUnderTest.updateReportExecution("exec_id", PARAMS, "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/parameters")); + assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getBody().readUtf8(), is("[{\"key\":[\"value\"]}]")); + assertThat(request.getMethod(), is("POST")); } @Test public void responseShouldNotBeCancelledIfResponseIs204() { - mWebMockRule.enqueue(create204Response()); + mWebMockRule.enqueue(MockResponseFactory.create204()); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id", "cookie"); assertThat(cancelled, is(false)); } @Test public void responseShouldBeCancelledIfResponseIs200() { - MockResponse response = create200Response(); - response.setBody(cancelledResponse.asString()); + MockResponse response = MockResponseFactory.create200().setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id", "cookie"); assertThat(cancelled, is(true)); } @Test public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws IOException { - mWebMockRule.enqueue(create204Response()); + mWebMockRule.enqueue(MockResponseFactory.create204()); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS, "cookie"); assertThat(response.getItems(), is(empty())); } @Test public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOException { - MockResponse mockResponse = create200Response(); + MockResponse mockResponse = MockResponseFactory.create200(); mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS, "cookie"); assertThat(response.getItems(), is(not(empty()))); } @Test - @SuppressWarnings("unchecked") public void executionUpdateRequestShouldBeSuccessIfResponseIs204() { - mWebMockRule.enqueue(create204Response()); - - boolean response = restApiUnderTest.updateReportExecution("any_id", Collections.EMPTY_MAP ); + mWebMockRule.enqueue(MockResponseFactory.create204()); + boolean response = restApiUnderTest.updateReportExecution("any_id", PARAMS, "cookie"); assertThat(response, is(true)); } - - @Test - public void bodyParameterShouldNotBeNullForExecutionUpdate() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Execution params id should not be null"); - - restApiUnderTest.updateReportExecution("any_id", null); - } - - private MockResponse create200Response() { - return new MockResponse() - .setStatus("HTTP/1.1 200 Ok"); - } - - private MockResponse create204Response() { - return new MockResponse() - .setStatus("HTTP/1.1 204 No Content"); - } - - private MockResponse create500Response() { - return new MockResponse() - .setStatus("HTTP/1.1 500 Internal Server Error"); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 1ba12540..cc56f853 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -40,9 +40,13 @@ import org.junit.Test; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; @@ -56,8 +60,7 @@ */ public class ReportExecutionRestApiTest { - private final String REPORT_URI1 = "/public/Samples/Reports/AllAccounts"; - private final String REPORT_URI2 = "/public/Samples/Reports/ProfitDetailReport"; + private final String REPORT_URI = "/public/Samples/Reports/ProfitDetailReport"; ReportExecutionRestApi apiUnderTest; @@ -68,7 +71,6 @@ public class ReportExecutionRestApiTest { public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportExecutionRestApi.Builder() - .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -85,10 +87,10 @@ public void shouldStartReportExecution() { /** * TODO: TEST IS FLAKY provide workaround */ - @Ignore + @Test public void shouldCancelReportExecution() throws InterruptedException { ReportExecutionDescriptor response = startExecution(); - boolean cancelled = apiUnderTest.cancelReportExecution(response.getExecutionId()); + boolean cancelled = apiUnderTest.cancelReportExecution(response.getExecutionId(), mAuthenticator.token()); assertThat(cancelled, is(true)); } @@ -97,7 +99,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionDescriptor executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId()); + ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId(), mAuthenticator.token()); assertThat(response.getExecutionId(), is(executionId)); } @@ -105,7 +107,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionDescriptor executionResponse = startExecution(); - ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId()); + ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId(), mAuthenticator.token()); assertThat(response.getStatus(), is(notNullValue())); } @@ -119,15 +121,20 @@ public void searchForExecutionShouldReturnResult() throws IOException { Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); - ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(params); + ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(params, mAuthenticator.token()); assertThat(response.getItems(), is(not(empty()))); } @Test public void updateOfParametersForExecutionShouldReturnResult() { - ReportExecutionDescriptor executionResponse = startExecution(); + List>> list = new ArrayList<>(); - boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.EMPTY_MAP); + Map> reportParameter = new HashMap<>(); + reportParameter.put("ProductFamily", new HashSet(Collections.singletonList("Drink"))); + list.add(reportParameter); + + ReportExecutionDescriptor executionResponse = startExecution(); + boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), list, mAuthenticator.token()); assertThat(success, is(true)); } @@ -136,12 +143,16 @@ public void updateOfParametersForExecutionShouldReturnResult() { */ @NonNull private ReportExecutionDescriptor startExecution() { - return startExecution(REPORT_URI1); + return startExecution(REPORT_URI); } @NonNull private ReportExecutionDescriptor startExecution(String uri) { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); - return apiUnderTest.runReportExecution(executionRequestOptions); + Map> params = new HashMap<>(); + params.put("ProductFamily", new HashSet(Collections.singletonList("Food"))); + executionRequestOptions.withParameters(params); + + return apiUnderTest.runReportExecution(executionRequestOptions, mAuthenticator.token()); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 4c83f2c6..0492ce8f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -64,7 +64,6 @@ public class ReportExportRestApiTest { public void setup() { if (mExecApi == null) { mExecApi = new ReportExecutionRestApi.Builder() - .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -119,6 +118,6 @@ private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor @NonNull private ReportExecutionDescriptor startExecution() { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); - return mExecApi.runReportExecution(executionRequestOptions); + return mExecApi.runReportExecution(executionRequestOptions, mAuthenticator.token()); } } From 45a2dfe032168e320f8cea4a9d32260cf0c978a9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 14:56:53 +0300 Subject: [PATCH 227/457] Add explicit token parameter for ReportExportRestApi --- .../sdk/network/api/ReportExportRestApi.java | 19 ++- .../network/api/ReportExportRestApiImpl.java | 41 +++++-- .../api/ReportExportRestApiBuilderTest.java | 26 ----- .../network/api/ReportExportRestApiTest.java | 109 +++++++++++++++--- .../api/ReportExportRestApiTest.java | 7 +- 5 files changed, 136 insertions(+), 66 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 27f241b2..220ecb4b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -41,21 +41,30 @@ public interface ReportExportRestApi { @NonNull @WorkerThread - ExportExecutionDescriptor runExportExecution(@NonNull String executionId, @NonNull ExecutionRequestOptions executionOptions); + ExportExecutionDescriptor runExportExecution(@NonNull String executionId, + @NonNull ExecutionRequestOptions executionOptions, + @NonNull String token); @NonNull @WorkerThread - ExecutionStatus checkExportExecutionStatus(@NonNull String executionId, @NonNull String exportId); + ExecutionStatus checkExportExecutionStatus(@NonNull String executionId, + @NonNull String exportId, + @NonNull String token); @NonNull @WorkerThread - ExportOutputResource requestExportOutput(@NonNull String executionId, @NonNull String exportId); + ExportOutputResource requestExportOutput(@NonNull String executionId, + @NonNull String exportId, + @NonNull String token); @NonNull @WorkerThread - OutputResource requestExportAttachment(@NonNull String executionId, @NonNull String exportId, @NonNull String attachmentId); + OutputResource requestExportAttachment(@NonNull String executionId, + @NonNull String exportId, + @NonNull String attachmentId, + @NonNull String token); - final class Builder extends GenericAuthBuilder { + final class Builder extends GenericBuilder { @Override ReportExportRestApi createApi() { return new ReportExportRestApiImpl(getAdapter().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index 092a9d7e..46945eaa 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -39,6 +39,7 @@ import retrofit.Retrofit; import retrofit.http.Body; import retrofit.http.GET; +import retrofit.http.Header; import retrofit.http.Headers; import retrofit.http.POST; import retrofit.http.Path; @@ -59,31 +60,39 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @NonNull @Override public ExportExecutionDescriptor runExportExecution(@Nullable String executionId, - @Nullable ExecutionRequestOptions executionOptions) { + @Nullable ExecutionRequestOptions executionOptions, + @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(executionOptions, "Execution options should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.runReportExportExecution(executionId, executionOptions); + Call call = mRestApi.runReportExportExecution(executionId, executionOptions, token); return CallWrapper.wrap(call).body(); } @NonNull @Override - public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, @Nullable String exportId) { + public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, + @Nullable String exportId, + @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.checkReportExportStatus(executionId, exportId); + Call call = mRestApi.checkReportExportStatus(executionId, exportId, token); return CallWrapper.wrap(call).body(); } @NonNull @Override - public ExportOutputResource requestExportOutput(@Nullable String executionId, @Nullable String exportId) { + public ExportOutputResource requestExportOutput(@Nullable String executionId, + @Nullable String exportId, + @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestReportExportOutput(executionId, exportId); + Call call = mRestApi.requestReportExportOutput(executionId, exportId, token); Response rawResponse = CallWrapper.wrap(call).response(); com.squareup.okhttp.Headers headers = rawResponse.headers(); @@ -96,12 +105,16 @@ public ExportOutputResource requestExportOutput(@Nullable String executionId, @N @NonNull @Override - public OutputResource requestExportAttachment(@Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) { + public OutputResource requestExportAttachment(@Nullable String executionId, + @Nullable String exportId, + @Nullable String attachmentId, + @Nullable String token) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); checkNotNull(attachmentId, "Attachment id should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); + Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId, token); Response rawResponse = CallWrapper.wrap(call).response(); ResponseBody body = rawResponse.body(); return new RetrofitOutputResource(body); @@ -112,13 +125,15 @@ private interface RestApi { @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/exports") Call runReportExportExecution(@NonNull @Path("executionId") String executionId, - @NonNull @Body ExecutionRequestOptions executionOptions); + @NonNull @Body ExecutionRequestOptions executionOptions, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") Call checkReportExportStatus(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId); + @NonNull @Path("exportId") String exportId, + @Header("Cookie") String cookie); /** * 'suppressContentDisposition' used due to security implications this header has @@ -126,12 +141,14 @@ Call checkReportExportStatus(@NonNull @Path("executionId") Stri @NonNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") Call requestReportExportOutput(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId); + @NonNull @Path("exportId") String exportId, + @Header("Cookie") String cookie); @NonNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") Call requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, @NonNull @Path("exportId") String exportId, - @NonNull @Path("attachmentId") String attachmentId); + @NonNull @Path("attachmentId") String attachmentId, + @Header("Cookie") String cookie); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java index f699b2eb..251fa1ec 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java @@ -62,30 +62,4 @@ public void builderShouldNotAllowEmptyUrl() { public void builderShouldAllowNullLogLevel() { builderUnderTest.logger(null); } - - @Test - public void builderShouldEnsureBaseUrlNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Base url should be supplied to work with JRS API"); - - builderUnderTest.tokenProvider(FakeTokenProvider.get()); - builderUnderTest.build(); - } - - @Test - public void builderShouldEnsureTokenNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication tokenProvider"); - - builderUnderTest.baseUrl("http://localhost"); - builderUnderTest.build(); - } - - @Test - public void builderShouldAllowNullToken() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("tokenProvider == null"); - - builderUnderTest.tokenProvider(null); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index 55d56181..71d0bc8d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -33,13 +33,13 @@ import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.RecordedRequest; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import java.io.IOException; import java.io.InputStream; import static org.hamcrest.core.Is.is; @@ -66,17 +66,16 @@ public class ReportExportRestApiTest { public void setup() { TestResourceInjector.inject(this); restApiUnderTest = new ReportExportRestApi.Builder() - .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } @Test - public void pathParameterShouldNotBeNullForRunRequestExecution() { + public void executionIdShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.create(), "cookie"); } @Test @@ -84,7 +83,15 @@ public void bodyShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runExportExecution("any_id", null); + restApiUnderTest.runExportExecution("any_id", null, "cookie"); + } + + @Test + public void tokenShouldNotBeNullForRunRequestExecution() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create(), null); } @Test @@ -92,7 +99,7 @@ public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.checkExportExecutionStatus(null, "any_id"); + restApiUnderTest.checkExportExecutionStatus(null, "any_id", "cookie"); } @Test @@ -100,7 +107,15 @@ public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.checkExportExecutionStatus("any_id", null); + restApiUnderTest.checkExportExecutionStatus("any_id", null, "cookie"); + } + + @Test + public void tokenShouldNotBeNullForCheckRequestExecutionStatus() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.checkExportExecutionStatus("any_id", "any_id", null); } @Test @@ -108,7 +123,7 @@ public void executionIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestExportAttachment(null, "any_id", "any_id"); + restApiUnderTest.requestExportAttachment(null, "any_id", "any_id", "cookie"); } @Test @@ -116,7 +131,7 @@ public void exportIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.requestExportAttachment("any_id", null, "any_id"); + restApiUnderTest.requestExportAttachment("any_id", null, "any_id", "cookie"); } @Test @@ -124,7 +139,15 @@ public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Attachment id should not be null"); - restApiUnderTest.requestExportAttachment("any_id", "any_id", null); + restApiUnderTest.requestExportAttachment("any_id", "any_id", null, "cookie"); + } + + @Test + public void tokenIdParameterShouldNotBeNullForAttachmentRequest() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id", null); } @Test @@ -134,40 +157,88 @@ public void requestForOutputShouldParsePagesFromHeader() { .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("any_id", "any_id", "cookie"); assertThat(resource.getPages(), is("1-10")); } @Test - public void requestForOutputShouldParseIsFinalHeader() { + public void requestForOutputShouldParseIsFinalHeader() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody("") .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("execution_id", "export_id", "cookie"); assertThat(resource.isFinal(), is(true)); } @Test - public void requestForAttachmentShouldBeWrappedInsideInput() throws IOException { + public void shouldRequestExportOutput() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200(); + mWebMockRule.enqueue(mockResponse); + restApiUnderTest.requestExportOutput("execution_id", "export_id", "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/outputResource?suppressContentDisposition=true")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void requestForAttachmentShouldBeWrappedInsideInput() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - OutputResource resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); + OutputResource resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id", "cookie"); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); } + @Test + public void shouldRequestExportAttachment() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200() + .setBody(mResource.asString()); + mWebMockRule.enqueue(mockResponse); + + restApiUnderTest.requestExportAttachment("execution_id", "export_id", "attachment_id", "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/attachments/attachment_id")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void shouldRunExportExecution() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200(); + mWebMockRule.enqueue(mockResponse); + + restApiUnderTest.runExportExecution("execution_id", ExecutionRequestOptions.create(), "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void shouldCheckExportExecutionStatus() throws Exception { + MockResponse mockResponse = MockResponseFactory.create200(); + mWebMockRule.enqueue(mockResponse); + + restApiUnderTest.checkExportExecutionStatus("execution_id", "export_id", "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/status")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + @Test public void runExportExecutionShouldThrowRestErrorOn500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create(), "cookie"); } @Test @@ -176,7 +247,7 @@ public void checkExportExecutionStatusShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.checkExportExecutionStatus("any_id", "any_id"); + restApiUnderTest.checkExportExecutionStatus("any_id", "any_id", "cookie"); } @Test @@ -185,7 +256,7 @@ public void requestExportOutputShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportOutput("any_id", "any_id"); + restApiUnderTest.requestExportOutput("any_id", "any_id", "cookie"); } @Test @@ -194,6 +265,6 @@ public void requestExportAttachmentShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); + restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id", "cookie"); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 0492ce8f..bc08c4da 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -71,7 +71,6 @@ public void setup() { if (apiUnderTest == null) { apiUnderTest = new ReportExportRestApi.Builder() - .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -89,7 +88,7 @@ public void runExportRequestShouldReturnResult() { public void checkExportRequestStatusShouldReturnResult() throws IOException { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); - ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); + ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId(), mAuthenticator.token()); assertThat(response, is(notNullValue())); } @@ -97,7 +96,7 @@ public void checkExportRequestStatusShouldReturnResult() throws IOException { public void requestExportOutputShouldReturnResult() { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); - ExportOutputResource output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); + ExportOutputResource output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId(), mAuthenticator.token()); assertThat(output.getOutputResource(), is(notNullValue())); assertThat(output.getPages(), is("1-2")); @@ -112,7 +111,7 @@ private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") .withOutputFormat("PDF"); - return apiUnderTest.runExportExecution(exec.getExecutionId(), options); + return apiUnderTest.runExportExecution(exec.getExecutionId(), options, mAuthenticator.token()); } @NonNull From dc9ec9f52f43ec12455918084d84079347fb2592 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 15:14:10 +0300 Subject: [PATCH 228/457] Add explicit token parameter for RepositoryRestApiTest --- .../sdk/network/api/RepositoryRestApi.java | 8 +- .../network/api/RepositoryRestApiImpl.java | 30 ++++--- .../api/RepositoryRestApiBuilderTest.java | 25 ------ .../network/api/RepositoryRestApiTest.java | 84 +++++++++++++++---- .../api/RepositoryRestApiTest.java | 7 +- 5 files changed, 93 insertions(+), 61 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 2d743297..6888dee1 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -41,17 +41,17 @@ public interface RepositoryRestApi { @NonNull @WorkerThread - ResourceSearchResult searchResources(@Nullable Map searchParams); + ResourceSearchResult searchResources(@Nullable Map searchParams, @NonNull String token); @NonNull @WorkerThread - ReportLookup requestReportResource(@NonNull String resourceUri); + ReportLookup requestReportResource(@NonNull String resourceUri, @NonNull String token); @NonNull @WorkerThread - FolderLookup requestFolderResource(@NonNull String resourceUri); + FolderLookup requestFolderResource(@NonNull String resourceUri, @NonNull String token); - final class Builder extends GenericAuthBuilder { + final class Builder extends GenericBuilder { @Override RepositoryRestApi createApi() { return new RepositoryRestApiImpl(getAdapter().build()); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index f9d73466..10857934 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -38,6 +38,7 @@ import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; +import retrofit.http.Header; import retrofit.http.Headers; import retrofit.http.Path; import retrofit.http.Query; @@ -59,25 +60,27 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NonNull @Override - public ResourceSearchResult searchResources(@Nullable Map searchParams) { + public ResourceSearchResult searchResources(@Nullable Map searchParams, @Nullable String token) { + checkNotNull(token, "Request token should not be null"); + Iterable types = null; Call call; if (searchParams == null) { - call = mRestApi.searchResources(null, null); + call = mRestApi.searchResources(null, null, token); } else { Map copy = new HashMap<>(searchParams); Object typeValues = copy.get("type"); copy.remove("type"); if (typeValues == null) { - throw new IllegalStateException("Found null for key 'type'. Ensure this to be not a null"); + types = null; } if (typeValues instanceof Iterable) { types = (Iterable) typeValues; } - call = mRestApi.searchResources(copy, types); + call = mRestApi.searchResources(copy, types, token); } Response rawResponse = CallWrapper.wrap(call).response(); @@ -105,19 +108,21 @@ public ResourceSearchResult searchResources(@Nullable Map search @NonNull @Override - public ReportLookup requestReportResource(@Nullable String resourceUri) { + public ReportLookup requestReportResource(@Nullable String resourceUri, @Nullable String token) { checkNotNull(resourceUri, "Report uri should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestReportResource(resourceUri); + Call call = mRestApi.requestReportResource(resourceUri, token); return CallWrapper.wrap(call).body(); } @NonNull @Override - public FolderLookup requestFolderResource(@Nullable String resourceUri) { + public FolderLookup requestFolderResource(@Nullable String resourceUri, @Nullable String token) { checkNotNull(resourceUri, "Folder uri should not be null"); + checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestFolderResource(resourceUri); + Call call = mRestApi.requestFolderResource(resourceUri, token); return CallWrapper.wrap(call).body(); } @@ -127,18 +132,21 @@ private interface RestApi { @GET("rest_v2/resources") Call searchResources( @Nullable @QueryMap Map searchParams, - @Nullable @Query("type") Iterable types); + @Nullable @Query("type") Iterable types, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/repository.reportUnit+json") @GET("rest_v2/resources{resourceUri}") Call requestReportResource( - @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); + @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri, + @Header("Cookie") String cookie); @NonNull @Headers("Accept: application/repository.folder+json") @GET("rest_v2/resources{resourceUri}") Call requestFolderResource( - @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri); + @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri, + @Header("Cookie") String cookie); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java index 0200ea99..3e73facf 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java @@ -63,29 +63,4 @@ public void builderShouldAllowNullLogLevel() { builderUnderTest.logger(null); } - @Test - public void builderShouldEnsureBaseUrlNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Base url should be supplied to work with JRS API"); - - builderUnderTest.tokenProvider(FakeTokenProvider.get()); - builderUnderTest.build(); - } - - @Test - public void builderShouldEnsureTokenNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("This API requires authentication tokenProvider"); - - builderUnderTest.baseUrl("http://localhost"); - builderUnderTest.build(); - } - - @Test - public void builderShouldAllowNullToken() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("tokenProvider == null"); - - builderUnderTest.tokenProvider(null); - } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index 85c93913..b03d63f7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -69,7 +69,6 @@ public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); restApiUnderTest = new RepositoryRestApi.Builder() - .tokenProvider(FakeTokenProvider.get()) .baseUrl(mWebMockRule.getRootUrl()) .build(); } @@ -78,7 +77,7 @@ public void setup() { public void shouldReturnEmptyResponseForNoContentResponse() { mWebMockRule.enqueue(MockResponseFactory.create204()); - ResourceSearchResult response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); assertThat(response.getResources(), is(empty())); } @@ -89,7 +88,7 @@ public void requestForSearchShouldParseHeaderResultCount() { .addHeader("Result-Count", "100"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); assertThat(response.getResultCount(), is(100)); } @@ -100,7 +99,7 @@ public void requestForSearchShouldParseHeaderTotalCount() { .addHeader("Total-Count", "1000"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); assertThat(response.getTotalCount(), is(1000)); } @@ -111,7 +110,7 @@ public void requestForSearchShouldParseHeaderStartIndex() { .addHeader("Start-Index", "5"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); assertThat(response.getStartIndex(), is(5)); } @@ -122,16 +121,32 @@ public void requestForSearchShouldParseHeaderNextOffset() { .addHeader("Next-Offset", "10"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null); + ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); assertThat(response.getNextOffset(), is(10)); } + @Test + public void searchResourcesShouldNotAcceptNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.searchResources(null, null); + } + @Test public void requestForReportResourceShouldNotAcceptNullUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportResource(null); + restApiUnderTest.requestReportResource(null, "cookie"); + } + + @Test + public void requestForReportResourceShouldNotAcceptNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.requestReportResource("/uri", null); } @Test @@ -139,7 +154,15 @@ public void requestForFolderResourceShouldNotAcceptNullUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Folder uri should not be null"); - restApiUnderTest.requestFolderResource(null); + restApiUnderTest.requestFolderResource(null, "cookie"); + } + + @Test + public void requestForFolderResourceShouldNotAcceptNullToken() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Request token should not be null"); + + restApiUnderTest.requestFolderResource("/my/uri", null); } @Test @@ -148,7 +171,7 @@ public void searchResourcesShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.searchResources(null); + restApiUnderTest.searchResources(null, "cookie"); } @Test @@ -157,7 +180,7 @@ public void requestReportResourceShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestReportResource("any_id"); + restApiUnderTest.requestReportResource("any_id", "cookie"); } @Test @@ -166,7 +189,7 @@ public void requestFolderResourceShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestFolderResource("any_id"); + restApiUnderTest.requestFolderResource("any_id", "cookie"); } @Test @@ -183,20 +206,47 @@ public void searchEndpointShouldHandleMultipleResourceTypes() throws Exception { types.add("dashboard"); params.put("type", types); - restApiUnderTest.searchResources(params); + restApiUnderTest.searchResources(params, "cookie"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?folderUri=/&type=reportUnit&type=dashboard")); } @Test - public void searchEndpointShouldNotAcceptNullVorTypeKey() throws Exception { - mExpectedException.expect(IllegalStateException.class); - mExpectedException.expectMessage("Found null for key 'type'. Ensure this to be not a null"); + public void shouldSearchResources() throws Exception { + mWebMockRule.enqueue(MockResponseFactory.create200()); Map params = new HashMap<>(); - params.put("type", null); + params.put("limit", 100); + params.put("offset", 100); + restApiUnderTest.searchResources(params, "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void shouldRequestReportResources() throws Exception { + mWebMockRule.enqueue(MockResponseFactory.create200()); + + restApiUnderTest.requestReportResource("/my/uri", "cookie"); - restApiUnderTest.searchResources(params); + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); + assertThat(request.getHeader("Accept"), is("application/repository.reportUnit+json")); + assertThat(request.getHeader("Cookie"), is("cookie")); + } + + @Test + public void shouldRequestFolderResource() throws Exception { + mWebMockRule.enqueue(MockResponseFactory.create200()); + + restApiUnderTest.requestReportResource("/my/uri", "cookie"); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); + assertThat(request.getHeader("Accept"), is("application/repository.folder+json")); + assertThat(request.getHeader("Cookie"), is("cookie")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index b7096553..8789c897 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -55,7 +55,6 @@ public class RepositoryRestApiTest { public void setup() { if (api == null) { api = new RepositoryRestApi.Builder() - .tokenProvider(mAuthenticator) .baseUrl(mMetadata.getServerUrl()) .logger(TestLogger.get(this)) .build(); @@ -64,21 +63,21 @@ public void setup() { @Test public void shouldRequestListOfResources() { - ResourceSearchResult resourceSearchResult = api.searchResources(null); + ResourceSearchResult resourceSearchResult = api.searchResources(null, mAuthenticator.token()); assertThat(resourceSearchResult, is(notNullValue())); assertThat(resourceSearchResult.getResources(), is(not(empty()))); } @Test public void shouldRequestReport() { - ReportLookup report = api.requestReportResource("/public/Samples/Reports/AllAccounts"); + ReportLookup report = api.requestReportResource("/public/Samples/Reports/AllAccounts", mAuthenticator.token()); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @Test public void shouldRequestRootFolder() { - FolderLookup folder = api.requestFolderResource("/"); + FolderLookup folder = api.requestFolderResource("/", mAuthenticator.token()); assertThat(folder, is(notNullValue())); } } \ No newline at end of file From 68e5b01985981db11826d6f16ccd0985f427d637 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 15:33:55 +0300 Subject: [PATCH 229/457] Removing Token Abstraction from network layer --- .../android/sdk/network/api/AuthBuilder.java | 94 ------------------- .../network/api/AuthenticationRestApi.java | 3 +- .../api/AuthenticationRestApiImpl.java | 30 +----- .../sdk/network/api/GenericAuthBuilder.java | 80 ---------------- .../android/sdk/network/api/TokenFactory.java | 9 +- .../sdk/network/api/auth/TokenProvider.java | 36 ------- .../api/AuthenticationRestApiTest.java | 3 +- .../sdk/network/api/FakeTokenProvider.java | 47 ---------- .../network/api/RepositoryRestApiTest.java | 6 +- .../sdk/network/api/TokenFactoryTest.java | 5 +- .../entity/resource/ReportLookupTest.java | 6 -- .../api/AuthenticationRestApiTest.java | 5 +- .../api/utils/DummyTokenProvider.java | 11 +-- .../sdk/service}/auth/AbstractToken.java | 2 +- .../android/sdk/service/auth/AuthService.java | 2 - .../sdk/service}/auth/CookieToken.java | 2 +- .../sdk/service/auth/SpringAuthService.java | 4 +- .../service/auth/SpringAuthServiceTest.java | 5 +- 18 files changed, 26 insertions(+), 324 deletions(-) delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/TokenProvider.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java rename {client-network/src/main/java/com/jaspersoft/android/sdk/network/api => client-service/src/main/java/com/jaspersoft/android/sdk/service}/auth/AbstractToken.java (95%) rename {client-network/src/main/java/com/jaspersoft/android/sdk/network/api => client-service/src/main/java/com/jaspersoft/android/sdk/service}/auth/CookieToken.java (96%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java deleted file mode 100644 index 1461cd03..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthBuilder.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; -import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; -import com.squareup.okhttp.Interceptor; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; - -import java.io.IOException; - -import retrofit.Retrofit; - -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class AuthBuilder { - private final AdapterBuilder mAdapterBuilder; - private TokenProvider mTokenProvider; - - public AuthBuilder(AdapterBuilder adapterBuilder) { - mAdapterBuilder = adapterBuilder; - } - - public AuthBuilder setTokenProvider(TokenProvider tokenProvider) { - checkNotNull(tokenProvider, "tokenProvider == null"); - mTokenProvider = tokenProvider; - return this; - } - - void ensureDefaults() { - if (mTokenProvider == null) { - throw new IllegalStateException("This API requires authentication tokenProvider"); - } - } - - Retrofit.Builder getAdapter() { - - OkHttpClient client = mAdapterBuilder.clientBuilder.getClient(); - client.interceptors().add(CookieAuthInterceptor.create(mTokenProvider)); - - return mAdapterBuilder.getAdapter(); - } - - private static final class CookieAuthInterceptor implements Interceptor { - private final TokenProvider mTokenProvider; - - CookieAuthInterceptor(TokenProvider tokenProvider) { - mTokenProvider = tokenProvider; - } - - public static CookieAuthInterceptor create(TokenProvider tokenProvider) { - checkNotNull(tokenProvider, "Token should not be null"); - return new CookieAuthInterceptor(tokenProvider); - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request originalRequest = chain.request(); - AbstractToken token = mTokenProvider.provideToken(); - Request compressedRequest = originalRequest.newBuilder() - .header("Cookie", token.get()) - .build(); - return chain.proceed(compressedRequest); - } - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index aac68c8e..4c726ce4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -28,7 +28,6 @@ import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; @@ -42,7 +41,7 @@ public interface AuthenticationRestApi { @NonNull @WorkerThread - AbstractToken authenticate(@NonNull String username, + String authenticate(@NonNull String username, @NonNull String password, @Nullable String organization, @Nullable Map params); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 48a5f4ef..fab667f5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -27,12 +27,10 @@ import android.support.annotation.NonNull; import com.google.gson.JsonSyntaxException; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.Call; import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; @@ -43,6 +41,7 @@ import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; +import retrofit.http.Header; import retrofit.http.Headers; /** @@ -64,7 +63,7 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { @NonNull @Override - public AbstractToken authenticate(@NonNull final String username, + public String authenticate(@NonNull final String username, @NonNull final String password, final String organization, final Map params) { @@ -107,14 +106,12 @@ public AbstractToken authenticate(@NonNull final String username, public EncryptionKey requestEncryptionMetadata() { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); - AbstractToken anonymousToken = TokenFactory.create(response.raw()); + String anonymousToken = TokenFactory.create(response.raw()); - mClient.interceptors().add(new CookieAuthInterceptor(anonymousToken)); - mRestAdapterBuilder.client(mClient); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); try { - return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata()).body(); + return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata(anonymousToken)).body(); } catch (JsonSyntaxException ex) { /** * This possible when security option is disabled on JRS side. @@ -157,23 +154,6 @@ private Request createAuthRequest( .build(); } - private static final class CookieAuthInterceptor implements Interceptor { - private final AbstractToken mToken; - - CookieAuthInterceptor(AbstractToken token) { - mToken = token; - } - - @Override - public com.squareup.okhttp.Response intercept(Chain chain) throws IOException { - Request originalRequest = chain.request(); - Request compressedRequest = originalRequest.newBuilder() - .header("Cookie", mToken.get()) - .build(); - return chain.proceed(compressedRequest); - } - } - private interface RestApi { @NonNull @Headers("Accept: text/plain") @@ -182,6 +162,6 @@ private interface RestApi { @NonNull @GET("GetEncryptionKey") - retrofit.Call requestEncryptionMetadata(); + retrofit.Call requestEncryptionMetadata(@NonNull @Header("Cookie") String cookie); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java deleted file mode 100644 index 5d4a4ad3..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericAuthBuilder.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api; - -import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; - -import retrofit.Retrofit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -abstract class GenericAuthBuilder { - private final ClientBuilder mClientBuilder; - private final AdapterBuilder mAdapterBuilder; - private final AuthBuilder mAuthBuilder; - - public GenericAuthBuilder() { - mClientBuilder = new ClientBuilder(); - mAdapterBuilder = new AdapterBuilder(mClientBuilder); - mAuthBuilder = new AuthBuilder(mAdapterBuilder); - } - - @SuppressWarnings("unchecked") - public TargetBuilder baseUrl(String baseUrl) { - mAdapterBuilder.baseUrl(baseUrl); - return (TargetBuilder) this; - } - - @SuppressWarnings("unchecked") - public TargetBuilder logger(RestApiLog log) { - mClientBuilder.setLog(log); - return (TargetBuilder) this; - } - - @SuppressWarnings("unchecked") - public TargetBuilder tokenProvider(TokenProvider tokenProvider) { - mAuthBuilder.setTokenProvider(tokenProvider); - return (TargetBuilder) this; - } - - abstract Api createApi(); - - public Api build() { - ensureDefaults(); - return createApi(); - } - - void ensureDefaults() { - mClientBuilder.ensureDefaults(); - mAdapterBuilder.ensureDefaults(); - mAuthBuilder.ensureDefaults(); - } - - Retrofit.Builder getAdapter() { - return mAuthBuilder.getAdapter(); - } -} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java index 411ba4fb..3eebd834 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; -import com.jaspersoft.android.sdk.network.api.auth.CookieToken; import com.squareup.okhttp.Response; import java.util.Iterator; @@ -43,15 +41,14 @@ final class TokenFactory { mCookieParts = parts; } - public static AbstractToken create(Response response) { + public static String create(Response response) { List parts = response.headers().values("Set-Cookie"); TokenFactory responseFactory = new TokenFactory(parts); return responseFactory.create(); } - private AbstractToken create() { - String cookie = joinCookieParts().toString(); - return CookieToken.create(cookie); + private String create() { + return joinCookieParts().toString(); } private StringBuilder joinCookieParts() { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/TokenProvider.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/TokenProvider.java deleted file mode 100644 index 1bc1b1a1..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/TokenProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network.api.auth; - -import android.support.annotation.NonNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface TokenProvider { - @NonNull - AbstractToken provideToken(); -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java index e7477049..8c7be215 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -75,7 +74,7 @@ public void shouldReturnResponseForSuccessRedirect() { .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - AbstractToken response = mRestApi.authenticate("joeuser", "joeuser", null, null); + String response = mRestApi.authenticate("joeuser", "joeuser", null, null); assertThat(response, is(notNullValue())); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java deleted file mode 100644 index 5fa1398d..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/FakeTokenProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.network.api; - -import android.support.annotation.NonNull; - -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; -import com.jaspersoft.android.sdk.network.api.auth.CookieToken; -import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class FakeTokenProvider implements TokenProvider { - - public static TokenProvider get() { - return new FakeTokenProvider(); - } - - @NonNull - @Override - public AbstractToken provideToken() { - return CookieToken.create("cookie"); - } -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index b03d63f7..b553726a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -214,7 +214,7 @@ public void searchEndpointShouldHandleMultipleResourceTypes() throws Exception { @Test public void shouldSearchResources() throws Exception { - mWebMockRule.enqueue(MockResponseFactory.create200()); + mWebMockRule.enqueue(MockResponseFactory.create204()); Map params = new HashMap<>(); params.put("limit", 100); @@ -222,7 +222,7 @@ public void shouldSearchResources() throws Exception { restApiUnderTest.searchResources(params, "cookie"); RecordedRequest request = mWebMockRule.get().takeRequest(); - assertThat(request.getPath(), is("/rest_v2")); + assertThat(request.getPath(), is("/rest_v2/resources?offset=100&limit=100")); assertThat(request.getHeader("Cookie"), is("cookie")); } @@ -242,7 +242,7 @@ public void shouldRequestReportResources() throws Exception { public void shouldRequestFolderResource() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.requestReportResource("/my/uri", "cookie"); + restApiUnderTest.requestFolderResource("/my/uri", "cookie"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java index 8378b35a..97e5935c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.squareup.okhttp.Protocol; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; @@ -60,7 +59,7 @@ public void shouldExtractTokenFromNetworkResponse() { .request(mRequest) .build(); - AbstractToken token = TokenFactory.create(mockResponse); - assertThat(token.get(), is("cookie1;cookie2")); + String token = TokenFactory.create(mockResponse); + assertThat(token, is("cookie1;cookie2")); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java index e6e53d9c..0f7752af 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java @@ -46,13 +46,7 @@ public class ReportLookupTest { @Test @Parameters({ - "dataSource", - "jrxml", - "inputControlRenderingView", - "reportRenderingView", "alwaysPromptControls", - "controlsLayout", - "resources", }) public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { Field field = ReportLookup.class.getDeclaredField(fieldName); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index cc5d64ff..bb936235 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.TestLogger; @@ -64,7 +63,7 @@ public void shouldEncryptWithPassword() throws Exception { JSEncryptionAlgorithm generator = JSEncryptionAlgorithm.create(new BouncyCastleProvider()); String cipher = generator.encrypt(key.getModulus(), key.getExponent(), "superuser"); - AbstractToken authResponse = restApi.authenticate("superuser", cipher, null, null); + String authResponse = restApi.authenticate("superuser", cipher, null, null); assertThat(authResponse, is(notNullValue())); } @@ -74,7 +73,7 @@ public void shouldReturnResponseForSpringRequest() throws IOException { .baseUrl(mobileDemo2) .logger(TestLogger.get(this)) .build(); - AbstractToken response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); + String response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); assertThat(response, is(notNullValue())); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index 7972e715..ea4df183 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -27,17 +27,15 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; -import com.jaspersoft.android.sdk.network.api.auth.TokenProvider; /** * @author Tom Koptel * @since 2.0 */ -public final class DummyTokenProvider implements TokenProvider { +public final class DummyTokenProvider { private final JrsMetadata mJrsMetadata; - private AbstractToken mToken; + private String mToken; public DummyTokenProvider(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; @@ -48,8 +46,7 @@ public static DummyTokenProvider create(JrsMetadata metadata) { } @NonNull - @Override - public AbstractToken provideToken() { + public String provideToken() { if (mToken == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() .baseUrl(mJrsMetadata.getServerUrl()) @@ -61,6 +58,6 @@ public AbstractToken provideToken() { } public String token() { - return provideToken().get(); + return provideToken(); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AbstractToken.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AbstractToken.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AbstractToken.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AbstractToken.java index 3e6e0fa8..36ff9882 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/AbstractToken.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AbstractToken.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api.auth; +package com.jaspersoft.android.sdk.service.auth; /** * @author Tom Koptel diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 2bab2a23..1075c800 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -26,8 +26,6 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; - /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/CookieToken.java similarity index 96% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/CookieToken.java index d8a7df3c..a08cbc24 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/auth/CookieToken.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/CookieToken.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api.auth; +package com.jaspersoft.android.sdk.service.auth; /** * @author Tom Koptel diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 79bc8978..cedc2a1a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -30,7 +30,6 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import java.util.HashMap; @@ -83,7 +82,8 @@ public AbstractToken authenticate() { } Map params = prepareOptionals(); - return mRestApi.authenticate(mUsername, password, mOrganization, params); + String cookie = mRestApi.authenticate(mUsername, password, mOrganization, params); + return CookieToken.create(cookie); } private Map prepareOptionals() { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index 99c19c0c..894e9375 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -2,7 +2,6 @@ import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; -import com.jaspersoft.android.sdk.network.api.auth.AbstractToken; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import org.junit.Before; @@ -39,8 +38,6 @@ public class SpringAuthServiceTest { @Mock AuthenticationRestApi mRestApi; @Mock - AbstractToken mToken; - @Mock JSEncryptionAlgorithm mAlgorithm; @Mock EncryptionKey mKey; @@ -71,7 +68,7 @@ public void setup() { when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); - when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(mToken); + when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn("cookie"); } @Test From f7fa8a1c2eca80038cb69063309a1e5c9314ef9f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 16:07:11 +0300 Subject: [PATCH 230/457] Implementing and integrating TokenProvider API --- .../sdk/service/GreedyInfoProvider.java | 7 ++++ .../android/sdk/service/InfoProvider.java | 5 ++- .../sdk/service/ServerInfoService.java | 6 ++++ .../sdk/service/auth/TokenProvider.java | 9 +++++ .../repository/EmeraldMR2SearchStrategy.java | 9 +++-- .../repository/EmeraldMR3SearchStrategy.java | 9 +++-- .../service/repository/RepositoryService.java | 14 +++++--- .../service/repository/SearchStrategy.java | 12 +++---- .../service/repository/SearchTaskImpl.java | 17 +++++---- .../EmeraldMR2SearchStrategyTest.java | 36 ++++++++++++------- .../EmeraldMR3SearchStrategyTest.java | 33 +++++++++++------ .../repository/RepositoryServiceTest.java | 13 +++---- .../repository/SearchStrategyTest.java | 13 +++++-- .../repository/SearchTaskImplTest.java | 28 ++++++++------- 14 files changed, 142 insertions(+), 69 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java index 0922f641..2c568b8d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java @@ -29,6 +29,7 @@ import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; /** * Always make call on server @@ -55,4 +56,10 @@ public static InfoProvider newInstance(String serverUrl) { public ServerInfo provideInfo() { return mServerInfoService.requestServerInfo(); } + + @NonNull + @Override + public ServerVersion provideVersion() { + return mServerInfoService.requestServerVersion(); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java index 49cf6fe6..56a86aee 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java @@ -27,6 +27,7 @@ import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; /** * Internal interface to abstract out server info generation strategy @@ -34,7 +35,9 @@ * @author Tom Koptel * @since 2.0 */ -interface InfoProvider { +public interface InfoProvider { @NonNull ServerInfo provideInfo(); + @NonNull + ServerVersion provideVersion(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index ce27dc7d..04043a6a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -5,6 +5,7 @@ import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; /** * @author Tom Koptel @@ -36,4 +37,9 @@ public ServerInfo requestServerInfo() { ServerInfoData response = mRestApi.requestServerInfo(); return mTransformer.transform(response); } + + public ServerVersion requestServerVersion() { + String version = mRestApi.requestVersion(); + return ServerVersion.defaultParser().parse(version); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java new file mode 100644 index 00000000..9aa92b1e --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.auth; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface TokenProvider { + AbstractToken provideToken(); +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 43f1a406..25fa6992 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; import java.util.Collection; import java.util.Collections; @@ -45,13 +46,17 @@ final class EmeraldMR2SearchStrategy implements SearchStrategy { private final RepositoryRestApi mRepoFactoryRestApi; private final InternalCriteria mInitialCriteria; + private final TokenProvider mTokenProvider; private int mServerDisposition; private List mBuffer = new LinkedList<>(); private boolean mEndReached; - public EmeraldMR2SearchStrategy(RepositoryRestApi repositoryApiFactory, InternalCriteria criteria) { + public EmeraldMR2SearchStrategy(InternalCriteria criteria, + RepositoryRestApi repositoryApiFactory, + TokenProvider tokenProvider) { mRepoFactoryRestApi = repositoryApiFactory; + mTokenProvider = tokenProvider; mInitialCriteria = criteria; mEndReached = false; } @@ -114,6 +119,6 @@ private ResourceSearchResult performSearch(int limit) { .offset(mServerDisposition) .limit(limit) .create(); - return mRepoFactoryRestApi.searchResources(nextCriteria.toMap()); + return mRepoFactoryRestApi.searchResources(nextCriteria.toMap(), mTokenProvider.provideToken().get()); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 01168a7d..62ec633f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; import java.util.Collection; import java.util.Collections; @@ -43,13 +44,17 @@ final class EmeraldMR3SearchStrategy implements SearchStrategy { private final RepositoryRestApi mRepositoryRestApi; private final InternalCriteria mInitialCriteria; + private final TokenProvider mTokenProvider; private int mUserOffset; private int mInternalOffset = UNDEFINED; private boolean mEndReached; - public EmeraldMR3SearchStrategy(RepositoryRestApi repositoryApiFactory, InternalCriteria criteria) { + public EmeraldMR3SearchStrategy(InternalCriteria criteria, + RepositoryRestApi repositoryApiFactory, + TokenProvider tokenProvider) { mRepositoryRestApi = repositoryApiFactory; + mTokenProvider = tokenProvider; // Internally enabling 'forceFullPageFlag' mInitialCriteria = criteria.newBuilder() .forceFullPage(true) @@ -84,7 +89,7 @@ private Collection performLookup() { @NonNull private ResourceSearchResult performApiCall(InternalCriteria newSearchCriteria) { - return mRepositoryRestApi.searchResources(newSearchCriteria.toMap()); + return mRepositoryRestApi.searchResources(newSearchCriteria.toMap(), mTokenProvider.provideToken().get()); } private void defineInternalOffset() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index ff5acf2c..49171047 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -25,7 +25,8 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; /** * @author Tom Koptel @@ -33,15 +34,18 @@ */ public class RepositoryService { private final RepositoryRestApi mRepositoryRestApi; - private final ServerRestApi mServerRestApi; + private final TokenProvider mTokenProvider; + private final InfoProvider mInfoProvider; public RepositoryService(RepositoryRestApi repositoryRestApi, - ServerRestApi infoApiFactory) { + TokenProvider tokenProvider, + InfoProvider infoProvider) { mRepositoryRestApi = repositoryRestApi; - mServerRestApi = infoApiFactory; + mTokenProvider = tokenProvider; + mInfoProvider = infoProvider; } public SearchTask search(SearchCriteria criteria) { - return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryRestApi, mServerRestApi); + return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryRestApi, mTokenProvider, mInfoProvider); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index a3777dcc..21c6a587 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.util.Collection; @@ -39,17 +40,14 @@ interface SearchStrategy { boolean hasNext(); class Factory { - public static SearchStrategy get(String serverVersion, - RepositoryRestApi repositoryRestApi, - InternalCriteria criteria) { - ServerVersion version = ServerVersion.defaultParser().parse(serverVersion); + public static SearchStrategy get(ServerVersion version, InternalCriteria criteria, RepositoryRestApi repositoryRestApi, TokenProvider tokenProvider) { if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { - return new EmeraldMR2SearchStrategy(repositoryRestApi, criteria); + return new EmeraldMR2SearchStrategy(criteria, repositoryRestApi, tokenProvider); } if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { - return new EmeraldMR3SearchStrategy(repositoryRestApi, criteria); + return new EmeraldMR3SearchStrategy(criteria, repositoryRestApi, tokenProvider); } - throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + serverVersion); + throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + version.getRawValue()); } } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 9e5940f2..12005e44 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -28,8 +28,10 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.util.Collection; @@ -40,17 +42,20 @@ final class SearchTaskImpl implements SearchTask { private final InternalCriteria mCriteria; private final RepositoryRestApi mRepositoryRestApi; - private final ServerRestApi mServerRestApi; + private final TokenProvider mTokenProvider; + private final InfoProvider mInfoProvider; @Nullable private SearchStrategy strategy; SearchTaskImpl(InternalCriteria criteria, RepositoryRestApi repositoryRestApi, - ServerRestApi serverRestApi) { + TokenProvider tokenProvider, + InfoProvider infoProvider) { mCriteria = criteria; mRepositoryRestApi = repositoryRestApi; - mServerRestApi = serverRestApi; + mTokenProvider = tokenProvider; + mInfoProvider = infoProvider; } @NonNull @@ -73,8 +78,8 @@ public boolean hasNext() { private SearchStrategy defineSearchStrategy() { if (strategy == null) { - String version = mServerRestApi.requestVersion(); - strategy = SearchStrategy.Factory.get(version, mRepositoryRestApi, mCriteria); + ServerVersion version = mInfoProvider.provideVersion(); + strategy = SearchStrategy.Factory.get(version, mCriteria, mRepositoryRestApi, mTokenProvider); } return strategy; } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index a5498163..1694b2ce 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -3,6 +3,8 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.auth.AbstractToken; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.junit.Before; import org.junit.Test; @@ -25,6 +27,8 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.anyMap; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -43,7 +47,10 @@ public class EmeraldMR2SearchStrategyTest { RepositoryRestApi mApi; @Mock ResourceSearchResult mResponse; - + @Mock + TokenProvider mTokenProvider; + @Mock + AbstractToken mAbstractToken; /** * Objects under test */ @@ -55,16 +62,19 @@ public class EmeraldMR2SearchStrategyTest { public void setupMocks() { MockitoAnnotations.initMocks(this); - when(mApi.searchResources(anyMap())).thenReturn(mResponse); + when(mTokenProvider.provideToken()).thenReturn(mAbstractToken); + when(mAbstractToken.get()).thenReturn("cookie"); + + when(mApi.searchResources(anyMap(), anyString())).thenReturn(mResponse); List stubLookup = Collections.singletonList(new ResourceLookup()); when(mResponse.getResources()).thenReturn(stubLookup); InternalCriteria criteria = InternalCriteria.builder().limit(10).create(); - search10itemsStrategy = new EmeraldMR2SearchStrategy(mApi, criteria); + search10itemsStrategy = new EmeraldMR2SearchStrategy(criteria, mApi, mTokenProvider); InternalCriteria userCriteria = criteria.newBuilder().offset(5).create(); - search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(mApi, userCriteria); + search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(userCriteria, mApi, mTokenProvider); } @Test @@ -76,12 +86,12 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce Map params = new HashMap<>(); params.put("limit", "10"); - verify(mApi).searchResources(params); + verify(mApi).searchResources(params, "cookie"); params = new HashMap<>(); params.put("limit", "10"); params.put("offset", "10"); - verify(mApi).searchResources(params); + verify(mApi).searchResources(params, "cookie"); } @Test @@ -92,7 +102,7 @@ public void willRetry5timesIfApiReturnsNoElements()throws Exception { assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); - verify(mApi, times(6)).searchResources(anyMap()); + verify(mApi, times(6)).searchResources(anyMap(), eq("cookie")); } @Test @@ -102,7 +112,7 @@ public void willReturnAsMuchElementsAsLeftIfEndReached()throws Exception { Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(2)); - verify(mApi, times(6)).searchResources(anyMap()); + verify(mApi, times(6)).searchResources(anyMap(), eq("cookie")); } @Test @@ -113,26 +123,26 @@ public void forCustomOffsetShouldCalculateServerDisposition()throws Exception { Map params1 = new HashMap<>(); params1.put("limit", "5"); - verify(mApi).searchResources(params1); + verify(mApi).searchResources(params1, "cookie"); Map params2 = new HashMap<>(); params2.put("limit", "10"); params2.put("offset", "5"); - verify(mApi).searchResources(params2); + verify(mApi).searchResources(params2, "cookie"); Map params3 = new HashMap<>(); params3.put("limit", "10"); params3.put("offset", "15"); - verify(mApi).searchResources(params3); + verify(mApi).searchResources(params3, "cookie"); - verify(mApi, times(3)).searchResources(anyMap()); + verify(mApi, times(3)).searchResources(anyMap(), eq("cookie")); verifyNoMoreInteractions(mApi); } @Test public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(mApi, userCriteria); + EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(userCriteria, mApi, mTokenProvider); Collection result = strategy.searchNext(); assertThat(result, is(empty())); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index a395499e..86e4ab46 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -3,6 +3,8 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.auth.AbstractToken; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.hamcrest.Matchers; import org.junit.Before; @@ -23,6 +25,8 @@ import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.anyMap; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; @@ -41,12 +45,19 @@ public class EmeraldMR3SearchStrategyTest { RepositoryRestApi mApi; @Mock ResourceSearchResult mResponse; + @Mock + TokenProvider mTokenProvider; + @Mock + AbstractToken mAbstractToken; @Before public void setupMocks() { MockitoAnnotations.initMocks(this); - when(mApi.searchResources(anyMap())).thenReturn(mResponse); + when(mTokenProvider.provideToken()).thenReturn(mAbstractToken); + when(mAbstractToken.get()).thenReturn("cookie"); + + when(mApi.searchResources(anyMap(), anyString())).thenReturn(mResponse); List stubLookup = Collections.singletonList(new ResourceLookup()); when(mResponse.getResources()).thenReturn(stubLookup); @@ -55,22 +66,22 @@ public void setupMocks() { @Test public void shouldMakeImmediateCallOnApiForUserOffsetZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, searchCriteria); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mApi, mTokenProvider); - when(mApi.searchResources(anyMap())).thenReturn(mResponse); + when(mApi.searchResources(anyMap(), anyString())).thenReturn(mResponse); strategy.searchNext(); Map params = new HashMap<>(); params.put("forceFullPage", "true"); - verify(mApi, times(1)).searchResources(params); + verify(mApi, times(1)).searchResources(eq(params), eq("cookie")); } @Test public void makesAdditionalCallOnApiIfUserOffsetNotZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, searchCriteria); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mApi, mTokenProvider); strategy.searchNext(); @@ -78,13 +89,13 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() { params.put("forceFullPage", "true"); params.put("limit", "5"); - verify(mApi, times(1)).searchResources(params); + verify(mApi, times(1)).searchResources(eq(params), eq("cookie")); } @Test public void secondSearchLookupShouldUseNextOffset() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, searchCriteria); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mApi, mTokenProvider); when(mResponse.getNextOffset()).thenReturn(133); strategy.searchNext(); @@ -98,12 +109,12 @@ public void secondSearchLookupShouldUseNextOffset() { params.put("offset", "133"); verify(mResponse, times(2)).getNextOffset(); - verify(mApi, times(1)).searchResources(params); + verify(mApi).searchResources(eq(params), eq("cookie")); } @Test public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, NO_CRITERIA); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(NO_CRITERIA, mApi, mTokenProvider); when(mResponse.getNextOffset()).thenReturn(133); strategy.searchNext(); @@ -116,13 +127,13 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { assertThat(strategy.hasNext(), is(false)); verify(mResponse, times(2)).getNextOffset(); - verify(mApi, times(2)).searchResources(anyMap()); + verify(mApi, times(2)).searchResources(anyMap(), eq("cookie")); } @Test public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - SearchStrategy strategy = new EmeraldMR3SearchStrategy(mApi, userCriteria); + SearchStrategy strategy = new EmeraldMR3SearchStrategy(userCriteria, mApi, mTokenProvider); Collection result = strategy.searchNext(); assertThat(result, Matchers.is(Matchers.empty())); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 231143a8..a10ae3ef 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -25,9 +25,8 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.junit.Before; import org.junit.Rule; @@ -48,11 +47,9 @@ public class RepositoryServiceTest { @Mock RepositoryRestApi repoApi; @Mock - ServerRestApi infoApi; + TokenProvider mTokenProvider; @Mock - FolderLookup mFolderResponse; - @Mock - ReportLookup mReportResponse; + InfoProvider mInfoProvider; private RepositoryService objectUnderTest; @@ -62,7 +59,7 @@ public class RepositoryServiceTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new RepositoryService(repoApi, infoApi); + objectUnderTest = new RepositoryService(repoApi, mTokenProvider, mInfoProvider); } @Test diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index 0ce14aa0..2b32c290 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -25,6 +25,9 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; @@ -48,6 +51,10 @@ public class SearchStrategyTest { @Mock RepositoryRestApi mRepoApi; + @Mock + TokenProvider mTokenProvider; + @Mock + InfoProvider mInfoProvider; @Before public void before() { @@ -60,7 +67,8 @@ public void before() { "5.5", }) public void factoryCreatesEmeraldMR2Strategy(String version) { - SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mRepoApi, CRITERIA); + ServerVersion serverVersion = ServerVersion.defaultParser().parse(version); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(serverVersion, CRITERIA, mRepoApi, mTokenProvider); assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); } @@ -70,7 +78,8 @@ public void factoryCreatesEmeraldMR2Strategy(String version) { "6.0.1", }) public void factoryCreatesEmeraldMR3Strategy(String version) { - SearchStrategy searchStrategy = SearchStrategy.Factory.get(version, mRepoApi, CRITERIA); + ServerVersion serverVersion = ServerVersion.defaultParser().parse(version); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(serverVersion, CRITERIA, mRepoApi, mTokenProvider); assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index 985b35ce..5fdca3f2 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -25,7 +25,9 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; @@ -37,7 +39,6 @@ import org.powermock.modules.junit4.PowerMockRunner; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -55,46 +56,49 @@ public class SearchTaskImplTest { @Mock RepositoryRestApi mRepoApi; @Mock - ServerRestApi mInfoApi; - @Mock SearchStrategy mSearchStrategy; + @Mock + TokenProvider mTokenProvider; + @Mock + InfoProvider mInfoProvider; private SearchTaskImpl objectUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApi, mInfoApi); + objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApi, mTokenProvider, mInfoProvider); when(mSearchStrategy.searchNext()).thenReturn(null); PowerMockito.mockStatic(SearchStrategy.Factory.class); - PowerMockito.when(SearchStrategy.Factory.get(anyString(), any(RepositoryRestApi.class), any(InternalCriteria.class))).thenReturn(mSearchStrategy); + PowerMockito.when(SearchStrategy.Factory.get(any(ServerVersion.class), any(InternalCriteria.class), + any(RepositoryRestApi.class), any(TokenProvider.class))).thenReturn(mSearchStrategy); } @Test public void nextLookupShouldDefineSearchStrategy() { - when(mInfoApi.requestVersion()).thenReturn("5.5"); + when(mInfoProvider.provideVersion()).thenReturn(ServerVersion.EMERALD_MR2); objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApi), eq(CRITERIA)); + SearchStrategy.Factory.get(eq(ServerVersion.EMERALD_MR2), eq(CRITERIA), eq(mRepoApi), eq(mTokenProvider)); - verify(mInfoApi, times(1)).requestVersion(); + verify(mInfoProvider).provideVersion(); verify(mSearchStrategy, times(1)).searchNext(); } @Test public void secondLookupShouldUseCachedStrategy() { - when(mInfoApi.requestVersion()).thenReturn("5.5"); + when(mInfoProvider.provideVersion()).thenReturn(ServerVersion.EMERALD_MR2); objectUnderTest.nextLookup(); objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq("5.5"), eq(mRepoApi), eq(CRITERIA)); + SearchStrategy.Factory.get(eq(ServerVersion.EMERALD_MR2), eq(CRITERIA), eq(mRepoApi), eq(mTokenProvider)); - verify(mInfoApi, times(1)).requestVersion(); + verify(mInfoProvider).provideVersion(); verify(mSearchStrategy, times(2)).searchNext(); } } \ No newline at end of file From d1bd9dee4013e87b0f6e998b5fde79bf28d7fb39 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 16:54:25 +0300 Subject: [PATCH 231/457] Swaping order of token argument --- .../sdk/network/api/InputControlRestApi.java | 20 ++++----- .../network/api/InputControlRestApiImpl.java | 18 ++++---- .../network/api/ReportExecutionRestApi.java | 16 +++---- .../api/ReportExecutionRestApiImpl.java | 16 +++---- .../sdk/network/api/ReportExportRestApi.java | 24 +++++------ .../network/api/ReportExportRestApiImpl.java | 24 +++++------ .../sdk/network/api/ReportOptionRestApi.java | 17 ++++---- .../network/api/ReportOptionRestApiImpl.java | 22 +++++----- .../sdk/network/api/RepositoryRestApi.java | 6 +-- .../network/api/RepositoryRestApiImpl.java | 8 ++-- .../network/api/InputControlRestApiTest.java | 24 +++++------ .../api/ReportExecutionRestApiTest.java | 42 +++++++++---------- .../network/api/ReportExportRestApiTest.java | 42 +++++++++---------- .../network/api/ReportOptionRestApiTest.java | 40 +++++++++--------- .../network/api/RepositoryRestApiTest.java | 32 +++++++------- .../api/InputControlRestApiTest.java | 8 ++-- .../api/ReportExecutionRestApiTest.java | 12 +++--- .../api/ReportExportRestApiTest.java | 8 ++-- .../api/ReportOptionRestApiTest.java | 8 ++-- .../api/RepositoryRestApiTest.java | 6 +-- .../repository/EmeraldMR2SearchStrategy.java | 2 +- .../repository/EmeraldMR3SearchStrategy.java | 2 +- .../EmeraldMR2SearchStrategyTest.java | 25 +++++------ .../EmeraldMR3SearchStrategyTest.java | 12 +++--- 24 files changed, 217 insertions(+), 217 deletions(-) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index b0da0159..7e445c7b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -45,22 +45,22 @@ public interface InputControlRestApi { *

* ATTENTION: Exclude flag works only on JRS instances 6.0+ * + * @param token is a key API sends to authorize client * @param reportUri uri of report * @param excludeState exclude field state which incorporates options values for control - * @param token is a key API sends to authorize client * @return unmodifiable list of {@link InputControl} */ @NonNull @WorkerThread - Collection requestInputControls(@NonNull String reportUri, - boolean excludeState, - @NonNull String token); + Collection requestInputControls(@NonNull String token, + @NonNull String reportUri, + boolean excludeState); @NonNull @WorkerThread - Collection requestInputControlsInitialStates(@NonNull String reportUri, - boolean freshData, - @NonNull String token); + Collection requestInputControlsInitialStates(@NonNull String token, + @NonNull String reportUri, + boolean freshData); /** * Provides values for specified controls. This API helpful to @@ -73,10 +73,10 @@ Collection requestInputControlsInitialStates(@NonNull String */ @NonNull @WorkerThread - Collection requestInputControlsStates(@NonNull String reportUri, + Collection requestInputControlsStates(@NonNull String token, + @NonNull String reportUri, @NonNull Map> controlsValues, - boolean freshData, - @NonNull String token); + boolean freshData); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index 88479488..e2b80a90 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -61,9 +61,9 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NonNull @Override - public Collection requestInputControls(@Nullable String reportUri, - boolean excludeState, - @Nullable String token) { + public Collection requestInputControls(@Nullable String token, + @Nullable String reportUri, + boolean excludeState) { checkNotNull(reportUri, "Report URI should not be null"); checkNotNull(token, "Request token should not be null"); @@ -75,9 +75,9 @@ public Collection requestInputControls(@Nullable String reportUri, @NonNull @Override - public Collection requestInputControlsInitialStates(@Nullable String reportUri, - boolean freshData, - @Nullable String token) { + public Collection requestInputControlsInitialStates(@Nullable String token, + @Nullable String reportUri, + boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); checkNotNull(token, "Request token should not be null"); @@ -88,10 +88,10 @@ public Collection requestInputControlsInitialStates(@Nullable @NonNull @Override - public Collection requestInputControlsStates(@Nullable String reportUri, + public Collection requestInputControlsStates(@Nullable String token, + @Nullable String reportUri, @Nullable Map> controlsValues, - boolean freshData, - @Nullable String token) { + boolean freshData) { checkNotNull(reportUri, "Report URI should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); checkNotNull(token, "Request token should not be null"); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index 8cbf4223..b3997c8f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -44,30 +44,30 @@ public interface ReportExecutionRestApi { @NonNull @WorkerThread - ReportExecutionDescriptor runReportExecution(@NonNull ReportExecutionRequestOptions executionOptions, @NonNull String token); + ReportExecutionDescriptor runReportExecution(@NonNull String token, @NonNull ReportExecutionRequestOptions executionOptions); @NonNull @WorkerThread - ReportExecutionDescriptor requestReportExecutionDetails(@NonNull String executionId, @NonNull String token); + ReportExecutionDescriptor requestReportExecutionDetails(@NonNull String token, @NonNull String executionId); @NonNull @WorkerThread - ExecutionStatus requestReportExecutionStatus(@NonNull String executionId, @NonNull String token); + ExecutionStatus requestReportExecutionStatus(@NonNull String token, @NonNull String executionId); @WorkerThread - boolean cancelReportExecution(@NonNull String executionId, @NonNull String token); + boolean cancelReportExecution(@NonNull String token, @NonNull String executionId); @WorkerThread - boolean updateReportExecution(@NonNull String executionId, - @NonNull Collection>> params, - @NonNull String token); + boolean updateReportExecution(@NonNull String token, + @NonNull String executionId, + @NonNull Collection>> params); /** * TODO: API is broken requires investigation before release */ @NonNull @WorkerThread - ReportExecutionSearchResponse searchReportExecution(Map params, @NonNull String token); + ReportExecutionSearchResponse searchReportExecution(@NonNull String token, Map params); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index 8959bc15..d4d08d5d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -65,7 +65,7 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NonNull @Override - public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions, @Nullable String token) { + public ReportExecutionDescriptor runReportExecution(@Nullable String token, @Nullable ReportExecutionRequestOptions executionOptions) { checkNotNull(executionOptions, "Execution options should not be null"); checkNotNull(token, "Request token should not be null"); @@ -75,7 +75,7 @@ public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionReq @NonNull @Override - public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String executionId, @Nullable String token) { + public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String token, @Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(token, "Request token should not be null"); @@ -85,7 +85,7 @@ public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String @NonNull @Override - public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId, @Nullable String token) { + public ExecutionStatus requestReportExecutionStatus(@Nullable String token, @Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(token, "Request token should not be null"); @@ -94,7 +94,7 @@ public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId } @Override - public boolean cancelReportExecution(@Nullable String executionId, @Nullable String token) { + public boolean cancelReportExecution(@Nullable String token, @Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(token, "Request token should not be null"); @@ -105,9 +105,9 @@ public boolean cancelReportExecution(@Nullable String executionId, @Nullable Str } @Override - public boolean updateReportExecution(@Nullable String executionId, - @Nullable Collection>> params, - @Nullable String token) { + public boolean updateReportExecution(@Nullable String token, + @Nullable String executionId, + @Nullable Collection>> params) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(params, "Execution params should not be null"); checkArgument(params.isEmpty(), "Execution params should not be empty"); @@ -121,7 +121,7 @@ public boolean updateReportExecution(@Nullable String executionId, @NonNull @Override - public ReportExecutionSearchResponse searchReportExecution(@Nullable Map params, @Nullable String token) { + public ReportExecutionSearchResponse searchReportExecution(@Nullable String token, @Nullable Map params) { checkNotNull(params, "Search params should not be null"); checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); checkNotNull(token, "Request token should not be null"); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 220ecb4b..561d1e6f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -41,28 +41,28 @@ public interface ReportExportRestApi { @NonNull @WorkerThread - ExportExecutionDescriptor runExportExecution(@NonNull String executionId, - @NonNull ExecutionRequestOptions executionOptions, - @NonNull String token); + ExportExecutionDescriptor runExportExecution(@NonNull String token, + @NonNull String executionId, + @NonNull ExecutionRequestOptions executionOptions); @NonNull @WorkerThread - ExecutionStatus checkExportExecutionStatus(@NonNull String executionId, - @NonNull String exportId, - @NonNull String token); + ExecutionStatus checkExportExecutionStatus(@NonNull String token, + @NonNull String executionId, + @NonNull String exportId); @NonNull @WorkerThread - ExportOutputResource requestExportOutput(@NonNull String executionId, - @NonNull String exportId, - @NonNull String token); + ExportOutputResource requestExportOutput(@NonNull String token, + @NonNull String executionId, + @NonNull String exportId); @NonNull @WorkerThread - OutputResource requestExportAttachment(@NonNull String executionId, + OutputResource requestExportAttachment(@NonNull String token, + @NonNull String executionId, @NonNull String exportId, - @NonNull String attachmentId, - @NonNull String token); + @NonNull String attachmentId); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index 46945eaa..445f93a5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -59,9 +59,9 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @NonNull @Override - public ExportExecutionDescriptor runExportExecution(@Nullable String executionId, - @Nullable ExecutionRequestOptions executionOptions, - @Nullable String token) { + public ExportExecutionDescriptor runExportExecution(@Nullable String token, + @Nullable String executionId, + @Nullable ExecutionRequestOptions executionOptions) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(executionOptions, "Execution options should not be null"); checkNotNull(token, "Request token should not be null"); @@ -72,9 +72,9 @@ public ExportExecutionDescriptor runExportExecution(@Nullable String executionId @NonNull @Override - public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, - @Nullable String exportId, - @Nullable String token) { + public ExecutionStatus checkExportExecutionStatus(@Nullable String token, + @Nullable String executionId, + @Nullable String exportId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); checkNotNull(token, "Request token should not be null"); @@ -85,9 +85,9 @@ public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, @NonNull @Override - public ExportOutputResource requestExportOutput(@Nullable String executionId, - @Nullable String exportId, - @Nullable String token) { + public ExportOutputResource requestExportOutput(@Nullable String token, + @Nullable String executionId, + @Nullable String exportId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); checkNotNull(token, "Request token should not be null"); @@ -105,10 +105,10 @@ public ExportOutputResource requestExportOutput(@Nullable String executionId, @NonNull @Override - public OutputResource requestExportAttachment(@Nullable String executionId, + public OutputResource requestExportAttachment(@Nullable String token, + @Nullable String executionId, @Nullable String exportId, - @Nullable String attachmentId, - @Nullable String token) { + @Nullable String attachmentId) { checkNotNull(executionId, "Execution id should not be null"); checkNotNull(exportId, "Export id should not be null"); checkNotNull(attachmentId, "Attachment id should not be null"); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index 432106a7..d2aeb420 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -44,22 +44,21 @@ public interface ReportOptionRestApi { @NonNull @WorkerThread - ReportOption createReportOption(@NonNull String reportUnitUri, + ReportOption createReportOption(@NonNull String token, @NonNull String reportUnitUri, @NonNull String optionLabel, @NonNull Map> controlsValues, - boolean overwrite, - @NonNull String token); + boolean overwrite); @WorkerThread - void updateReportOption(@NonNull String reportUnitUri, + void updateReportOption(@NonNull String token, + @NonNull String reportUnitUri, @NonNull String optionId, - @NonNull Map> controlsValues, - @NonNull String token); + @NonNull Map> controlsValues); @WorkerThread - void deleteReportOption(@NonNull String reportUnitUri, - @NonNull String optionId, - @NonNull String token); + void deleteReportOption(@NonNull String token, + @NonNull String reportUnitUri, + @NonNull String optionId); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java index 75964868..3dbdc4ab 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -63,8 +63,8 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { @NonNull @Override - public Set requestReportOptionsList(@Nullable String reportUnitUri, - @Nullable String token) { + public Set requestReportOptionsList(@Nullable String token, + @Nullable String reportUnitUri) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(token, "Request token should not be null"); @@ -84,11 +84,11 @@ public Set requestReportOptionsList(@Nullable String reportUnitUri @NonNull @Override - public ReportOption createReportOption(@Nullable String reportUnitUri, + public ReportOption createReportOption(@Nullable String token, + @Nullable String reportUnitUri, @Nullable String optionLabel, @Nullable Map> controlsValues, - boolean overwrite, - @Nullable String token) { + boolean overwrite) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionLabel, "Option label should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); @@ -99,10 +99,10 @@ public ReportOption createReportOption(@Nullable String reportUnitUri, } @Override - public void updateReportOption(@Nullable String reportUnitUri, + public void updateReportOption(@Nullable String token, + @Nullable String reportUnitUri, @Nullable String optionId, - @Nullable Map> controlsValues, - @Nullable String token) { + @Nullable Map> controlsValues) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionId, "Option id should not be null"); checkNotNull(controlsValues, "Controls values should not be null"); @@ -113,9 +113,9 @@ public void updateReportOption(@Nullable String reportUnitUri, } @Override - public void deleteReportOption(@Nullable String reportUnitUri, - @Nullable String optionId, - @Nullable String token) { + public void deleteReportOption(@Nullable String token, + @Nullable String reportUnitUri, + @Nullable String optionId) { checkNotNull(reportUnitUri, "Report uri should not be null"); checkNotNull(optionId, "Option id should not be null"); checkNotNull(token, "Request token should not be null"); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index 6888dee1..deaa758e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -41,15 +41,15 @@ public interface RepositoryRestApi { @NonNull @WorkerThread - ResourceSearchResult searchResources(@Nullable Map searchParams, @NonNull String token); + ResourceSearchResult searchResources(@NonNull String token, @Nullable Map searchParams); @NonNull @WorkerThread - ReportLookup requestReportResource(@NonNull String resourceUri, @NonNull String token); + ReportLookup requestReportResource( @NonNull String token, @NonNull String resourceUri); @NonNull @WorkerThread - FolderLookup requestFolderResource(@NonNull String resourceUri, @NonNull String token); + FolderLookup requestFolderResource(@NonNull String token, @NonNull String resourceUri); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 10857934..687ee6f8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -60,7 +60,7 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NonNull @Override - public ResourceSearchResult searchResources(@Nullable Map searchParams, @Nullable String token) { + public ResourceSearchResult searchResources(@Nullable String token, @Nullable Map searchParams) { checkNotNull(token, "Request token should not be null"); Iterable types = null; @@ -108,7 +108,7 @@ public ResourceSearchResult searchResources(@Nullable Map search @NonNull @Override - public ReportLookup requestReportResource(@Nullable String resourceUri, @Nullable String token) { + public ReportLookup requestReportResource(@Nullable String token, @Nullable String resourceUri) { checkNotNull(resourceUri, "Report uri should not be null"); checkNotNull(token, "Request token should not be null"); @@ -118,11 +118,11 @@ public ReportLookup requestReportResource(@Nullable String resourceUri, @Nullabl @NonNull @Override - public FolderLookup requestFolderResource(@Nullable String resourceUri, @Nullable String token) { + public FolderLookup requestFolderResource(@Nullable String token, @Nullable String resourceUri) { checkNotNull(resourceUri, "Folder uri should not be null"); checkNotNull(token, "Request token should not be null"); - Call call = mRestApi.requestFolderResource(resourceUri, token); + Call call = mRestApi.requestFolderResource(resourceUri, token); return CallWrapper.wrap(call).body(); } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java index 7efe5c34..cd288da1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java @@ -63,56 +63,56 @@ public void setup() { public void requestInputControlsShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControls(null, false, "cookie"); + restApiUnderTest.requestInputControls("cookie", null, false); } @Test public void requestInputControlsInitialStatesShouldNotAllowNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestInputControlsInitialStates("/uri", false, null); + restApiUnderTest.requestInputControlsInitialStates(null, "/uri", false); } @Test public void requestInputControlsStatesShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP, true, "cookie"); + restApiUnderTest.requestInputControlsStates("cookie", null, Collections.EMPTY_MAP, true); } @Test public void requestInputControlsStatesShouldNotAllowNullControlParams() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.requestInputControlsStates("any_id", null, true, "cookie"); + restApiUnderTest.requestInputControlsStates("cookie", "any_id", null, true); } @Test public void requestInputControlsStatesShouldNotAllowNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true, null); + restApiUnderTest.requestInputControlsStates(null, "any_id", Collections.EMPTY_MAP, true); } @Test public void requestInputControlsShouldThrowRestErrorFor500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControls("any_id", true, "cookie"); + restApiUnderTest.requestInputControls("cookie", "any_id", true); } @Test public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsInitialStates("any_id", true, "cookie"); + restApiUnderTest.requestInputControlsInitialStates("cookie", "any_id", true); } @Test public void requestInputControlsStatesShouldThrowRestErrorFor500() { mExpectedException.expect(RestError.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true, "cookie"); + restApiUnderTest.requestInputControlsStates("cookie", "any_id", Collections.EMPTY_MAP, true); } @Test @@ -121,7 +121,7 @@ public void apiShouldProvideListOfInputControlsInitialStatesWithFreshData() thro .setBody(icsStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection states = restApiUnderTest.requestInputControlsInitialStates("/my/uri", true, "cookie"); + Collection states = restApiUnderTest.requestInputControlsInitialStates("cookie", "/my/uri", true); assertThat(states, is(not(empty()))); RecordedRequest response = mWebMockRule.get().takeRequest(); @@ -140,7 +140,7 @@ public void apiShouldProvideFreshStatesForInputControls() throws Exception { .setBody(icsStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection states = restApiUnderTest.requestInputControlsStates("/my/uri", parameters, true, "cookie"); + Collection states = restApiUnderTest.requestInputControlsStates("cookie", "/my/uri", parameters, true); assertThat(states, Matchers.is(not(Matchers.empty()))); RecordedRequest response = mWebMockRule.get().takeRequest(); @@ -154,7 +154,7 @@ public void apiShouldProvideInputControlsListIfStateExcluded() throws Exception .setBody(icsWithoutStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection controls = restApiUnderTest.requestInputControls("/my/uri", true, "cookie"); + Collection controls = restApiUnderTest.requestInputControls("cookie", "/my/uri", true); assertThat(controls, Matchers.is(not(Matchers.empty()))); assertThat(new ArrayList<>(controls).get(0).getState(), is(nullValue())); @@ -169,7 +169,7 @@ public void apiShouldProvideInputControlsWithStates() throws Exception { .setBody(icsWithStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection controls = restApiUnderTest.requestInputControls("/my/uri", false, "cookie"); + Collection controls = restApiUnderTest.requestInputControls("cookie", "/my/uri", false); assertThat(controls, Matchers.is(not(Matchers.empty()))); assertThat(new ArrayList<>(controls).get(0).getState(), is(not(nullValue()))); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java index 889a3daa..a907ee86 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java @@ -103,7 +103,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri"), "cookie"); + restApiUnderTest.runReportExecution("cookie", ReportExecutionRequestOptions.newRequest("/any/uri")); } @Test @@ -111,7 +111,7 @@ public void bodyParameterShouldNotBeNullForRunReportExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runReportExecution(null, "cookie"); + restApiUnderTest.runReportExecution("cookie", null); } @Test @@ -120,7 +120,7 @@ public void tokenShouldNotBeNullForRunReportExecution() { mExpectedException.expectMessage("Request token should not be null"); ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/uri"); - restApiUnderTest.runReportExecution(options, null); + restApiUnderTest.runReportExecution(null, options); } @Test @@ -128,7 +128,7 @@ public void executionIdShouldNotBeNullForRequestExecutionDetails() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionDetails(null, "cookie"); + restApiUnderTest.requestReportExecutionDetails("cookie", null); } @Test @@ -136,7 +136,7 @@ public void tokenShouldNotBeNullForRequestExecutionDetails() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestReportExecutionDetails("exec_id", null); + restApiUnderTest.requestReportExecutionDetails(null, "exec_id"); } @Test @@ -144,7 +144,7 @@ public void executionIdShouldNotBeNullForRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionStatus(null, "cookie"); + restApiUnderTest.requestReportExecutionStatus("cookie", null); } @Test @@ -152,7 +152,7 @@ public void tokenShouldNotBeNullForRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestReportExecutionStatus("exec_id", null); + restApiUnderTest.requestReportExecutionStatus(null, "exec_id"); } @Test @@ -160,7 +160,7 @@ public void executionIdShouldNotBeNullForCancelRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.cancelReportExecution(null, "cookie"); + restApiUnderTest.cancelReportExecution("cookie", null); } @Test @@ -168,7 +168,7 @@ public void tokenShouldNotBeNullForCancelRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.cancelReportExecution("exec_id", null); + restApiUnderTest.cancelReportExecution(null, "exec_id"); } @Test @@ -176,7 +176,7 @@ public void bodyParameterShouldNotBeNullForExecutionUpdate() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution params should not be null"); - restApiUnderTest.updateReportExecution("any_id", null, "cookie"); + restApiUnderTest.updateReportExecution("cookie", "any_id", null); } @Test @@ -184,7 +184,7 @@ public void bodyParameterShouldNotBeEmptyForExecutionUpdate() { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Execution params should not be empty"); - restApiUnderTest.updateReportExecution("any_id", Collections.>>emptyList(), "cookie"); + restApiUnderTest.updateReportExecution("cookie", "any_id", Collections.>>emptyList()); } @Test @@ -193,7 +193,7 @@ public void shouldStartReportExecution() throws Exception { mWebMockRule.enqueue(response); ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/my/uri"); - restApiUnderTest.runReportExecution(options, "cookie"); + restApiUnderTest.runReportExecution("cookie", options); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions")); @@ -207,7 +207,7 @@ public void shouldRequestReportExecutionDetails() throws Exception { MockResponse response = MockResponseFactory.create200().setBody(reportExecutionDetailsResponse.asString()); mWebMockRule.enqueue(response); - ReportExecutionDescriptor details = restApiUnderTest.requestReportExecutionDetails("exec_id", "cookie"); + ReportExecutionDescriptor details = restApiUnderTest.requestReportExecutionDetails("cookie", "exec_id"); assertThat(details, is(notNullValue())); RecordedRequest request = mWebMockRule.get().takeRequest(); @@ -221,7 +221,7 @@ public void shouldRequestReportExecutionStatus() throws Exception { MockResponse response = MockResponseFactory.create200().setBody("{\"value\":\"execution\"}"); mWebMockRule.enqueue(response); - ExecutionStatus status = restApiUnderTest.requestReportExecutionStatus("exec_id", "cookie"); + ExecutionStatus status = restApiUnderTest.requestReportExecutionStatus("cookie", "exec_id"); assertThat(status, is(notNullValue())); RecordedRequest request = mWebMockRule.get().takeRequest(); @@ -235,7 +235,7 @@ public void shouldCancelReportExecution() throws Exception { MockResponse response = MockResponseFactory.create200(); mWebMockRule.enqueue(response); - restApiUnderTest.cancelReportExecution("exec_id", "cookie"); + restApiUnderTest.cancelReportExecution("cookie", "exec_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); @@ -249,7 +249,7 @@ public void shouldUpdateReportExecution() throws Exception { MockResponse response = MockResponseFactory.create204(); mWebMockRule.enqueue(response); - restApiUnderTest.updateReportExecution("exec_id", PARAMS, "cookie"); + restApiUnderTest.updateReportExecution("cookie", "exec_id", PARAMS); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/parameters")); @@ -262,7 +262,7 @@ public void shouldUpdateReportExecution() throws Exception { public void responseShouldNotBeCancelledIfResponseIs204() { mWebMockRule.enqueue(MockResponseFactory.create204()); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id", "cookie"); + boolean cancelled = restApiUnderTest.cancelReportExecution("cookie", "any_id"); assertThat(cancelled, is(false)); } @@ -272,7 +272,7 @@ public void responseShouldBeCancelledIfResponseIs200() { MockResponse response = MockResponseFactory.create200().setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); - boolean cancelled = restApiUnderTest.cancelReportExecution("any_id", "cookie"); + boolean cancelled = restApiUnderTest.cancelReportExecution("cookie", "any_id"); assertThat(cancelled, is(true)); } @@ -281,7 +281,7 @@ public void responseShouldBeCancelledIfResponseIs200() { public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws IOException { mWebMockRule.enqueue(MockResponseFactory.create204()); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS, "cookie"); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution("cookie", SEARCH_PARAMS); assertThat(response.getItems(), is(empty())); } @@ -291,14 +291,14 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOEx mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS, "cookie"); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution("cookie", SEARCH_PARAMS); assertThat(response.getItems(), is(not(empty()))); } @Test public void executionUpdateRequestShouldBeSuccessIfResponseIs204() { mWebMockRule.enqueue(MockResponseFactory.create204()); - boolean response = restApiUnderTest.updateReportExecution("any_id", PARAMS, "cookie"); + boolean response = restApiUnderTest.updateReportExecution("cookie", "any_id", PARAMS); assertThat(response, is(true)); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java index 71d0bc8d..54b71757 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java @@ -75,7 +75,7 @@ public void executionIdShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.create(), "cookie"); + restApiUnderTest.runExportExecution("cookie", null, ExecutionRequestOptions.create()); } @Test @@ -83,7 +83,7 @@ public void bodyShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runExportExecution("any_id", null, "cookie"); + restApiUnderTest.runExportExecution("cookie", "any_id", null); } @Test @@ -91,7 +91,7 @@ public void tokenShouldNotBeNullForRunRequestExecution() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create(), null); + restApiUnderTest.runExportExecution(null, "any_id", ExecutionRequestOptions.create()); } @Test @@ -99,7 +99,7 @@ public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.checkExportExecutionStatus(null, "any_id", "cookie"); + restApiUnderTest.checkExportExecutionStatus("cookie", null, "any_id"); } @Test @@ -107,7 +107,7 @@ public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.checkExportExecutionStatus("any_id", null, "cookie"); + restApiUnderTest.checkExportExecutionStatus("cookie", "any_id", null); } @Test @@ -115,7 +115,7 @@ public void tokenShouldNotBeNullForCheckRequestExecutionStatus() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.checkExportExecutionStatus("any_id", "any_id", null); + restApiUnderTest.checkExportExecutionStatus(null, "any_id", "any_id"); } @Test @@ -123,7 +123,7 @@ public void executionIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestExportAttachment(null, "any_id", "any_id", "cookie"); + restApiUnderTest.requestExportAttachment("cookie", null, "any_id", "any_id"); } @Test @@ -131,7 +131,7 @@ public void exportIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.requestExportAttachment("any_id", null, "any_id", "cookie"); + restApiUnderTest.requestExportAttachment("cookie", "any_id", null, "any_id"); } @Test @@ -139,7 +139,7 @@ public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Attachment id should not be null"); - restApiUnderTest.requestExportAttachment("any_id", "any_id", null, "cookie"); + restApiUnderTest.requestExportAttachment("cookie", "any_id", "any_id", null); } @Test @@ -147,7 +147,7 @@ public void tokenIdParameterShouldNotBeNullForAttachmentRequest() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id", null); + restApiUnderTest.requestExportAttachment(null, "any_id", "any_id", "any_id"); } @Test @@ -157,7 +157,7 @@ public void requestForOutputShouldParsePagesFromHeader() { .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput("any_id", "any_id", "cookie"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("cookie", "any_id", "any_id"); assertThat(resource.getPages(), is("1-10")); } @@ -168,7 +168,7 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput("execution_id", "export_id", "cookie"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("cookie", "execution_id", "export_id"); assertThat(resource.isFinal(), is(true)); } @@ -176,7 +176,7 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { public void shouldRequestExportOutput() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportOutput("execution_id", "export_id", "cookie"); + restApiUnderTest.requestExportOutput("cookie", "execution_id", "export_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/outputResource?suppressContentDisposition=true")); @@ -189,7 +189,7 @@ public void requestForAttachmentShouldBeWrappedInsideInput() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - OutputResource resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id", "cookie"); + OutputResource resource = restApiUnderTest.requestExportAttachment("cookie", "any_id", "any_id", "any_id"); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); @@ -201,7 +201,7 @@ public void shouldRequestExportAttachment() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportAttachment("execution_id", "export_id", "attachment_id", "cookie"); + restApiUnderTest.requestExportAttachment("cookie", "execution_id", "export_id", "attachment_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/attachments/attachment_id")); @@ -213,7 +213,7 @@ public void shouldRunExportExecution() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.runExportExecution("execution_id", ExecutionRequestOptions.create(), "cookie"); + restApiUnderTest.runExportExecution("cookie", "execution_id", ExecutionRequestOptions.create()); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports")); @@ -225,7 +225,7 @@ public void shouldCheckExportExecutionStatus() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.checkExportExecutionStatus("execution_id", "export_id", "cookie"); + restApiUnderTest.checkExportExecutionStatus("cookie", "execution_id", "export_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/status")); @@ -238,7 +238,7 @@ public void runExportExecutionShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create(), "cookie"); + restApiUnderTest.runExportExecution("cookie", "any_id", ExecutionRequestOptions.create()); } @Test @@ -247,7 +247,7 @@ public void checkExportExecutionStatusShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.checkExportExecutionStatus("any_id", "any_id", "cookie"); + restApiUnderTest.checkExportExecutionStatus("cookie", "any_id", "any_id"); } @Test @@ -256,7 +256,7 @@ public void requestExportOutputShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportOutput("any_id", "any_id", "cookie"); + restApiUnderTest.requestExportOutput("cookie", "any_id", "any_id"); } @Test @@ -265,6 +265,6 @@ public void requestExportAttachmentShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id", "cookie"); + restApiUnderTest.requestExportAttachment("cookie", "any_id", "any_id", "any_id"); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java index 4dcdcbd8..8be884f8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java @@ -78,91 +78,91 @@ public void setup() { public void requestReportOptionsListShouldNotAllowNullReportUnitUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportOptionsList(null, "cookie"); + restApiUnderTest.requestReportOptionsList("cookie", null); } @Test public void requestReportOptionsListShouldNotAllowNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestReportOptionsList("/my/uri", null); + restApiUnderTest.requestReportOptionsList(null, "/my/uri"); } @Test public void createReportOptionShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.createReportOption(null, "label", Collections.EMPTY_MAP, false, "cookie"); + restApiUnderTest.createReportOption("cookie", null, "label", Collections.EMPTY_MAP, false); } @Test public void createReportOptionShouldNotAllowNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.createReportOption("/my/uri", "label", Collections.EMPTY_MAP, false, null); + restApiUnderTest.createReportOption(null, "/my/uri", "label", Collections.EMPTY_MAP, false); } @Test public void createReportOptionShouldNotAllowNullOptionLabel() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option label should not be null"); - restApiUnderTest.createReportOption("any_id", null, Collections.EMPTY_MAP, false, "cookie"); + restApiUnderTest.createReportOption("cookie", "any_id", null, Collections.EMPTY_MAP, false); } @Test public void createReportOptionShouldNotAllowNullControlsValues() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.createReportOption("any_id", "label", null, false, "cookie"); + restApiUnderTest.createReportOption("cookie", "any_id", "label", null, false); } @Test public void updateReportOptionShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.updateReportOption(null, "option_id", Collections.EMPTY_MAP, "cookie"); + restApiUnderTest.updateReportOption("cookie", null, "option_id", Collections.EMPTY_MAP); } @Test public void updateReportOptionShouldNotAllowNullOptionId() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.updateReportOption("any_id", null, Collections.EMPTY_MAP, "cookie"); + restApiUnderTest.updateReportOption("cookie", "any_id", null, Collections.EMPTY_MAP); } @Test public void updateReportOptionShouldNotAllowNullControlsValues() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.updateReportOption("any_id", "option_id", null, "cookie"); + restApiUnderTest.updateReportOption("cookie", "any_id", "option_id", null); } @Test public void updateReportOptionShouldNotAllowNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP, null); + restApiUnderTest.updateReportOption(null, "any_id", "option_id", Collections.EMPTY_MAP); } @Test public void deleteReportOptionShouldNotAllowNullReportUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.deleteReportOption(null, "option_id", "cookie"); + restApiUnderTest.deleteReportOption("cookie", null, "option_id"); } @Test public void deleteReportOptionShouldNotAllowNullOptionId() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.deleteReportOption("any_id", null, "cookie"); + restApiUnderTest.deleteReportOption("cookie", "any_id", null); } @Test public void deleteReportOptionShouldNotAllowNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.deleteReportOption("any_id", "option_id", null); + restApiUnderTest.deleteReportOption(null, "any_id", "option_id"); } @Test @@ -170,7 +170,7 @@ public void apiShouldListReportOptions() throws Exception { MockResponse mockResponse = MockResponseFactory.create200().setBody(reportOptionsList.asString()); mWebMockRule.enqueue(mockResponse); - Set response = restApiUnderTest.requestReportOptionsList("/any/uri", "cookie"); + Set response = restApiUnderTest.requestReportOptionsList("cookie", "/any/uri"); assertThat(response, is(not(empty()))); RecordedRequest request = mWebMockRule.get().takeRequest(); @@ -186,7 +186,7 @@ public void apiShouldCreateReportOption() throws Exception { Map> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19")); - ReportOption reportOption = restApiUnderTest.createReportOption("/any/uri", "my label", params, true, "cookie"); + ReportOption reportOption = restApiUnderTest.createReportOption("cookie", "/any/uri", "my label", params, true); assertThat(reportOption.getId(), is("my_label")); assertThat(reportOption.getLabel(), is("my label")); assertThat(reportOption.getUri(), is("/public/Samples/Reports/my_label")); @@ -204,7 +204,7 @@ public void apiShouldUpdateReportOption() throws Exception { Map> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("22")); - restApiUnderTest.updateReportOption("/any/uri", "option_id", params, "cookie"); + restApiUnderTest.updateReportOption("cookie", "/any/uri", "option_id", params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); @@ -216,7 +216,7 @@ public void apiShouldUpdateReportOption() throws Exception { public void apiShouldDeleteReportOption() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.deleteReportOption("/any/uri", "option_id", "cookie"); + restApiUnderTest.deleteReportOption("cookie", "/any/uri", "option_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); @@ -230,7 +230,7 @@ public void requestReportOptionsListShouldThrow500Error() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestReportOptionsList("any_id", "cookie"); + restApiUnderTest.requestReportOptionsList("cookie", "any_id"); } @Test @@ -239,7 +239,7 @@ public void updateReportOptionShouldThrowRestErrorFor500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP, "cookie"); + restApiUnderTest.updateReportOption("cookie", "any_id", "option_id", Collections.EMPTY_MAP); } @Test @@ -248,6 +248,6 @@ public void deleteReportOptionShouldThrowRestErrorFor500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.deleteReportOption("any_id", "option_id", "cookie"); + restApiUnderTest.deleteReportOption("cookie", "any_id", "option_id"); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java index b553726a..61ec2b72 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java @@ -77,7 +77,7 @@ public void setup() { public void shouldReturnEmptyResponseForNoContentResponse() { mWebMockRule.enqueue(MockResponseFactory.create204()); - ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); + ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); assertThat(response.getResources(), is(empty())); } @@ -88,7 +88,7 @@ public void requestForSearchShouldParseHeaderResultCount() { .addHeader("Result-Count", "100"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); + ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); assertThat(response.getResultCount(), is(100)); } @@ -99,7 +99,7 @@ public void requestForSearchShouldParseHeaderTotalCount() { .addHeader("Total-Count", "1000"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); + ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); assertThat(response.getTotalCount(), is(1000)); } @@ -110,7 +110,7 @@ public void requestForSearchShouldParseHeaderStartIndex() { .addHeader("Start-Index", "5"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); + ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); assertThat(response.getStartIndex(), is(5)); } @@ -121,7 +121,7 @@ public void requestForSearchShouldParseHeaderNextOffset() { .addHeader("Next-Offset", "10"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(null, "cookie"); + ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); assertThat(response.getNextOffset(), is(10)); } @@ -138,7 +138,7 @@ public void requestForReportResourceShouldNotAcceptNullUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportResource(null, "cookie"); + restApiUnderTest.requestReportResource("cookie", null); } @Test @@ -146,7 +146,7 @@ public void requestForReportResourceShouldNotAcceptNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestReportResource("/uri", null); + restApiUnderTest.requestReportResource(null, "/uri"); } @Test @@ -154,7 +154,7 @@ public void requestForFolderResourceShouldNotAcceptNullUri() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Folder uri should not be null"); - restApiUnderTest.requestFolderResource(null, "cookie"); + restApiUnderTest.requestFolderResource("cookie", null); } @Test @@ -162,7 +162,7 @@ public void requestForFolderResourceShouldNotAcceptNullToken() { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); - restApiUnderTest.requestFolderResource("/my/uri", null); + restApiUnderTest.requestFolderResource(null, "/my/uri"); } @Test @@ -171,7 +171,7 @@ public void searchResourcesShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.searchResources(null, "cookie"); + restApiUnderTest.searchResources("cookie", null); } @Test @@ -180,7 +180,7 @@ public void requestReportResourceShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestReportResource("any_id", "cookie"); + restApiUnderTest.requestReportResource("cookie", "any_id"); } @Test @@ -189,7 +189,7 @@ public void requestFolderResourceShouldThrowRestErrorOn500() { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestFolderResource("any_id", "cookie"); + restApiUnderTest.requestFolderResource("cookie", "any_id"); } @Test @@ -206,7 +206,7 @@ public void searchEndpointShouldHandleMultipleResourceTypes() throws Exception { types.add("dashboard"); params.put("type", types); - restApiUnderTest.searchResources(params, "cookie"); + restApiUnderTest.searchResources("cookie", params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?folderUri=/&type=reportUnit&type=dashboard")); @@ -219,7 +219,7 @@ public void shouldSearchResources() throws Exception { Map params = new HashMap<>(); params.put("limit", 100); params.put("offset", 100); - restApiUnderTest.searchResources(params, "cookie"); + restApiUnderTest.searchResources("cookie", params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?offset=100&limit=100")); @@ -230,7 +230,7 @@ public void shouldSearchResources() throws Exception { public void shouldRequestReportResources() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.requestReportResource("/my/uri", "cookie"); + restApiUnderTest.requestReportResource("cookie", "/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); @@ -242,7 +242,7 @@ public void shouldRequestReportResources() throws Exception { public void shouldRequestFolderResource() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.requestFolderResource("/my/uri", "cookie"); + restApiUnderTest.requestFolderResource("cookie", "/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 2dc1a351..20c10147 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -75,7 +75,7 @@ public void setup() { @Test public void shouldProvideInputControlsList() { - Collection controls = mRestApi.requestInputControls(REPORT_URI, false, mAuthenticator.token()); + Collection controls = mRestApi.requestInputControls(mAuthenticator.token(), REPORT_URI, false); assertThat(controls, is(not(empty()))); InputControl control = new ArrayList<>(controls).get(0); @@ -87,7 +87,7 @@ public void shouldProvideInputControlsList() { */ @Test public void shouldProvideInputControlsListIfStateExcluded() { - Collection controls = mRestApi.requestInputControls(REPORT_URI, true, mAuthenticator.token()); + Collection controls = mRestApi.requestInputControls(mAuthenticator.token(), REPORT_URI, true); assertThat(controls, is(not(empty()))); InputControl control = new ArrayList<>(controls).get(0); @@ -96,13 +96,13 @@ public void shouldProvideInputControlsListIfStateExcluded() { @Test public void shouldProvideFreshInitialInputControlsValues() { - Collection states = mRestApi.requestInputControlsInitialStates(REPORT_URI, true, mAuthenticator.token()); + Collection states = mRestApi.requestInputControlsInitialStates(mAuthenticator.token(), REPORT_URI, true); assertThat(states, is(not(empty()))); } @Test public void shouldProvideFreshStatesForInputControls() { - Collection states = mRestApi.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true, mAuthenticator.token()); + Collection states = mRestApi.requestInputControlsStates(mAuthenticator.token(), REPORT_URI, CONTROL_PARAMETERS, true); assertThat(states, is(not(empty()))); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index cc56f853..2e18efb9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -90,7 +90,7 @@ public void shouldStartReportExecution() { @Test public void shouldCancelReportExecution() throws InterruptedException { ReportExecutionDescriptor response = startExecution(); - boolean cancelled = apiUnderTest.cancelReportExecution(response.getExecutionId(), mAuthenticator.token()); + boolean cancelled = apiUnderTest.cancelReportExecution(mAuthenticator.token(), response.getExecutionId()); assertThat(cancelled, is(true)); } @@ -99,7 +99,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { ReportExecutionDescriptor executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId(), mAuthenticator.token()); + ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(mAuthenticator.token(), executionResponse.getExecutionId()); assertThat(response.getExecutionId(), is(executionId)); } @@ -107,7 +107,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { public void shouldCheckReportExecutionStatus() throws IOException { ReportExecutionDescriptor executionResponse = startExecution(); - ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId(), mAuthenticator.token()); + ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(mAuthenticator.token(), executionResponse.getExecutionId()); assertThat(response.getStatus(), is(notNullValue())); } @@ -121,7 +121,7 @@ public void searchForExecutionShouldReturnResult() throws IOException { Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); - ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(params, mAuthenticator.token()); + ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(mAuthenticator.token(), params); assertThat(response.getItems(), is(not(empty()))); } @@ -134,7 +134,7 @@ public void updateOfParametersForExecutionShouldReturnResult() { list.add(reportParameter); ReportExecutionDescriptor executionResponse = startExecution(); - boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), list, mAuthenticator.token()); + boolean success = apiUnderTest.updateReportExecution(mAuthenticator.token(), executionResponse.getExecutionId(), list); assertThat(success, is(true)); } @@ -153,6 +153,6 @@ private ReportExecutionDescriptor startExecution(String uri) { params.put("ProductFamily", new HashSet(Collections.singletonList("Food"))); executionRequestOptions.withParameters(params); - return apiUnderTest.runReportExecution(executionRequestOptions, mAuthenticator.token()); + return apiUnderTest.runReportExecution(mAuthenticator.token(), executionRequestOptions); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index bc08c4da..7e6a8d3c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -88,7 +88,7 @@ public void runExportRequestShouldReturnResult() { public void checkExportRequestStatusShouldReturnResult() throws IOException { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); - ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId(), mAuthenticator.token()); + ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(mAuthenticator.token(), exec.getExecutionId(), execDetails.getExportId()); assertThat(response, is(notNullValue())); } @@ -96,7 +96,7 @@ public void checkExportRequestStatusShouldReturnResult() throws IOException { public void requestExportOutputShouldReturnResult() { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); - ExportOutputResource output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId(), mAuthenticator.token()); + ExportOutputResource output = apiUnderTest.requestExportOutput(mAuthenticator.token(), exec.getExecutionId(), execDetails.getExportId()); assertThat(output.getOutputResource(), is(notNullValue())); assertThat(output.getPages(), is("1-2")); @@ -111,12 +111,12 @@ private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") .withOutputFormat("PDF"); - return apiUnderTest.runExportExecution(exec.getExecutionId(), options, mAuthenticator.token()); + return apiUnderTest.runExportExecution(mAuthenticator.token(), exec.getExecutionId(), options); } @NonNull private ReportExecutionDescriptor startExecution() { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); - return mExecApi.runReportExecution(executionRequestOptions, mAuthenticator.token()); + return mExecApi.runReportExecution(mAuthenticator.token(), executionRequestOptions); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index b358e023..dc0829d3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -74,17 +74,17 @@ public void setup() { @Test public void shouldRequestReportOptionsList() { - Set response = apiUnderTest.requestReportOptionsList(REPORT_URI, mAuthenticator.token()); + Set response = apiUnderTest.requestReportOptionsList(mAuthenticator.token(), REPORT_URI); assertThat(response, is(not(nullValue()))); } @Test public void apiSupportsCrudForReportOption() { - ReportOption response = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true, mAuthenticator.token()); + ReportOption response = apiUnderTest.createReportOption(mAuthenticator.token(), REPORT_URI, "label", CONTROL_PARAMETERS, true); assertThat(response.getLabel(), is("label")); - apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS, mAuthenticator.token()); + apiUnderTest.updateReportOption(mAuthenticator.token(), REPORT_URI, response.getId(), CONTROL_PARAMETERS); - apiUnderTest.deleteReportOption(REPORT_URI, response.getId(), mAuthenticator.token()); + apiUnderTest.deleteReportOption(mAuthenticator.token(), REPORT_URI, response.getId()); } } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 8789c897..348e12dd 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -63,21 +63,21 @@ public void setup() { @Test public void shouldRequestListOfResources() { - ResourceSearchResult resourceSearchResult = api.searchResources(null, mAuthenticator.token()); + ResourceSearchResult resourceSearchResult = api.searchResources(mAuthenticator.token(), null); assertThat(resourceSearchResult, is(notNullValue())); assertThat(resourceSearchResult.getResources(), is(not(empty()))); } @Test public void shouldRequestReport() { - ReportLookup report = api.requestReportResource("/public/Samples/Reports/AllAccounts", mAuthenticator.token()); + ReportLookup report = api.requestReportResource(mAuthenticator.token(), "/public/Samples/Reports/AllAccounts"); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @Test public void shouldRequestRootFolder() { - FolderLookup folder = api.requestFolderResource("/", mAuthenticator.token()); + FolderLookup folder = api.requestFolderResource(mAuthenticator.token(), "/"); assertThat(folder, is(notNullValue())); } } \ No newline at end of file diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 25fa6992..86d6196b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -119,6 +119,6 @@ private ResourceSearchResult performSearch(int limit) { .offset(mServerDisposition) .limit(limit) .create(); - return mRepoFactoryRestApi.searchResources(nextCriteria.toMap(), mTokenProvider.provideToken().get()); + return mRepoFactoryRestApi.searchResources(mTokenProvider.provideToken().get(), nextCriteria.toMap()); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 62ec633f..5ea85755 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -89,7 +89,7 @@ private Collection performLookup() { @NonNull private ResourceSearchResult performApiCall(InternalCriteria newSearchCriteria) { - return mRepositoryRestApi.searchResources(newSearchCriteria.toMap(), mTokenProvider.provideToken().get()); + return mRepositoryRestApi.searchResources(mTokenProvider.provideToken().get(), newSearchCriteria.toMap()); } private void defineInternalOffset() { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index 1694b2ce..49b676b5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -65,7 +65,7 @@ public void setupMocks() { when(mTokenProvider.provideToken()).thenReturn(mAbstractToken); when(mAbstractToken.get()).thenReturn("cookie"); - when(mApi.searchResources(anyMap(), anyString())).thenReturn(mResponse); + when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); List stubLookup = Collections.singletonList(new ResourceLookup()); when(mResponse.getResources()).thenReturn(stubLookup); @@ -86,56 +86,56 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce Map params = new HashMap<>(); params.put("limit", "10"); - verify(mApi).searchResources(params, "cookie"); + verify(mApi).searchResources("cookie", params); params = new HashMap<>(); params.put("limit", "10"); params.put("offset", "10"); - verify(mApi).searchResources(params, "cookie"); + verify(mApi).searchResources("cookie", params); } @Test - public void willRetry5timesIfApiReturnsNoElements()throws Exception { + public void willRetry5timesIfApiReturnsNoElements() throws Exception { when(mResponse.getResources()).thenReturn(Collections.emptyList()); Collection result = search10itemsStrategy.searchNext(); assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); - verify(mApi, times(6)).searchResources(anyMap(), eq("cookie")); + verify(mApi, times(6)).searchResources( eq("cookie"), anyMap()); } @Test - public void willReturnAsMuchElementsAsLeftIfEndReached()throws Exception { + public void willReturnAsMuchElementsAsLeftIfEndReached() throws Exception { when(mResponse.getResources()).then(OnlyTwoItems.INSTANCE); Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(2)); - verify(mApi, times(6)).searchResources(anyMap(), eq("cookie")); + verify(mApi, times(6)).searchResources( eq("cookie"), anyMap()); } @Test - public void forCustomOffsetShouldCalculateServerDisposition()throws Exception { + public void forCustomOffsetShouldCalculateServerDisposition() throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); search10itemsStrategyWithUserOffset5.searchNext(); Map params1 = new HashMap<>(); params1.put("limit", "5"); - verify(mApi).searchResources(params1, "cookie"); + verify(mApi).searchResources("cookie", params1); Map params2 = new HashMap<>(); params2.put("limit", "10"); params2.put("offset", "5"); - verify(mApi).searchResources(params2, "cookie"); + verify(mApi).searchResources("cookie", params2); Map params3 = new HashMap<>(); params3.put("limit", "10"); params3.put("offset", "15"); - verify(mApi).searchResources(params3, "cookie"); + verify(mApi).searchResources("cookie", params3); - verify(mApi, times(3)).searchResources(anyMap(), eq("cookie")); + verify(mApi, times(3)).searchResources(eq("cookie"), anyMap()); verifyNoMoreInteractions(mApi); } @@ -157,6 +157,7 @@ private static class OnlyTwoItems implements Answer> private final List zeroItems = Collections.emptyList(); private int count = 0; + @Override public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { if (count == 0) { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index 86e4ab46..02e7cab7 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -57,7 +57,7 @@ public void setupMocks() { when(mTokenProvider.provideToken()).thenReturn(mAbstractToken); when(mAbstractToken.get()).thenReturn("cookie"); - when(mApi.searchResources(anyMap(), anyString())).thenReturn(mResponse); + when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); List stubLookup = Collections.singletonList(new ResourceLookup()); when(mResponse.getResources()).thenReturn(stubLookup); @@ -68,14 +68,14 @@ public void shouldMakeImmediateCallOnApiForUserOffsetZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mApi, mTokenProvider); - when(mApi.searchResources(anyMap(), anyString())).thenReturn(mResponse); + when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); strategy.searchNext(); Map params = new HashMap<>(); params.put("forceFullPage", "true"); - verify(mApi, times(1)).searchResources(eq(params), eq("cookie")); + verify(mApi, times(1)).searchResources(eq("cookie"), eq(params)); } @Test @@ -89,7 +89,7 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() { params.put("forceFullPage", "true"); params.put("limit", "5"); - verify(mApi, times(1)).searchResources(eq(params), eq("cookie")); + verify(mApi, times(1)).searchResources(eq("cookie"), eq(params)); } @Test @@ -109,7 +109,7 @@ public void secondSearchLookupShouldUseNextOffset() { params.put("offset", "133"); verify(mResponse, times(2)).getNextOffset(); - verify(mApi).searchResources(eq(params), eq("cookie")); + verify(mApi).searchResources(eq("cookie"), eq(params)); } @Test @@ -127,7 +127,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { assertThat(strategy.hasNext(), is(false)); verify(mResponse, times(2)).getNextOffset(); - verify(mApi, times(2)).searchResources(anyMap(), eq("cookie")); + verify(mApi, times(2)).searchResources(eq("cookie"), anyMap()); } @Test From 4d779ac438a927391e3d42f3693abd86a5c41db5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 22 Oct 2015 18:12:19 +0300 Subject: [PATCH 232/457] Remove Token abstraction from middle layer --- .../sdk/service/auth/AbstractToken.java | 33 ------------- .../android/sdk/service/auth/AuthService.java | 2 +- .../android/sdk/service/auth/CookieToken.java | 47 ------------------- .../sdk/service/auth/SpringAuthService.java | 5 +- .../sdk/service/auth/TokenProvider.java | 2 +- .../repository/EmeraldMR2SearchStrategy.java | 2 +- .../repository/EmeraldMR3SearchStrategy.java | 2 +- .../EmeraldMR2SearchStrategyTest.java | 6 +-- .../EmeraldMR3SearchStrategyTest.java | 6 +-- 9 files changed, 8 insertions(+), 97 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AbstractToken.java delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/CookieToken.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AbstractToken.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AbstractToken.java deleted file mode 100644 index 36ff9882..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AbstractToken.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.auth; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public abstract class AbstractToken { - public abstract String get(); -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 1075c800..17851748 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -33,5 +33,5 @@ */ public interface AuthService { @NonNull - AbstractToken authenticate(); + String authenticate(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/CookieToken.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/CookieToken.java deleted file mode 100644 index a08cbc24..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/CookieToken.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.auth; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class CookieToken extends AbstractToken { - private final String mCookie; - - private CookieToken(String cookie) { - mCookie = cookie; - } - - public static CookieToken create(String cookie) { - return new CookieToken(cookie); - } - - @Override - public String get() { - return mCookie; - } - -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index cedc2a1a..770d0c09 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -73,7 +73,7 @@ public final class SpringAuthService implements AuthService { @NonNull @Override - public AbstractToken authenticate() { + public String authenticate() { String password = mPassword; EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); @@ -82,8 +82,7 @@ public AbstractToken authenticate() { } Map params = prepareOptionals(); - String cookie = mRestApi.authenticate(mUsername, password, mOrganization, params); - return CookieToken.create(cookie); + return mRestApi.authenticate(mUsername, password, mOrganization, params); } private Map prepareOptionals() { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java index 9aa92b1e..6513b8de 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java @@ -5,5 +5,5 @@ * @since 2.0 */ public interface TokenProvider { - AbstractToken provideToken(); + String provideToken(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 86d6196b..c28ebc19 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -119,6 +119,6 @@ private ResourceSearchResult performSearch(int limit) { .offset(mServerDisposition) .limit(limit) .create(); - return mRepoFactoryRestApi.searchResources(mTokenProvider.provideToken().get(), nextCriteria.toMap()); + return mRepoFactoryRestApi.searchResources(mTokenProvider.provideToken(), nextCriteria.toMap()); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 5ea85755..c1c925a0 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -89,7 +89,7 @@ private Collection performLookup() { @NonNull private ResourceSearchResult performApiCall(InternalCriteria newSearchCriteria) { - return mRepositoryRestApi.searchResources(mTokenProvider.provideToken().get(), newSearchCriteria.toMap()); + return mRepositoryRestApi.searchResources(mTokenProvider.provideToken(), newSearchCriteria.toMap()); } private void defineInternalOffset() { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index 49b676b5..847ab998 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -3,7 +3,6 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.auth.AbstractToken; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.junit.Before; @@ -49,8 +48,6 @@ public class EmeraldMR2SearchStrategyTest { ResourceSearchResult mResponse; @Mock TokenProvider mTokenProvider; - @Mock - AbstractToken mAbstractToken; /** * Objects under test */ @@ -62,8 +59,7 @@ public class EmeraldMR2SearchStrategyTest { public void setupMocks() { MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn(mAbstractToken); - when(mAbstractToken.get()).thenReturn("cookie"); + when(mTokenProvider.provideToken()).thenReturn("cookie"); when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index 02e7cab7..a8283826 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -3,7 +3,6 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.auth.AbstractToken; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.hamcrest.Matchers; @@ -47,15 +46,12 @@ public class EmeraldMR3SearchStrategyTest { ResourceSearchResult mResponse; @Mock TokenProvider mTokenProvider; - @Mock - AbstractToken mAbstractToken; @Before public void setupMocks() { MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn(mAbstractToken); - when(mAbstractToken.get()).thenReturn("cookie"); + when(mTokenProvider.provideToken()).thenReturn("cookie"); when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); From ffa6e1dc5bca9ee66e1137ba877bb21add1c222b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 26 Oct 2015 11:46:29 +0200 Subject: [PATCH 233/457] Refactor TokenFactory -> CookieExtractor --- .../api/AuthenticationRestApiImpl.java | 6 +++--- ...TokenFactory.java => CookieExtractor.java} | 20 ++++++------------- ...toryTest.java => CookieExtractorTest.java} | 4 ++-- 3 files changed, 11 insertions(+), 19 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/api/{TokenFactory.java => CookieExtractor.java} (76%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/api/{TokenFactoryTest.java => CookieExtractorTest.java} (95%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index fab667f5..3ce0a78b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -73,7 +73,7 @@ public String authenticate(@NonNull final String username, com.squareup.okhttp.Response response = call.execute(); int statusCode = response.code(); if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request - return TokenFactory.create(response); + return CookieExtractor.extract(response); } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request String location = response.headers().get("Location"); if (location == null) { @@ -82,7 +82,7 @@ public String authenticate(@NonNull final String username, HttpUrl url = HttpUrl.parse(location); String errorQueryParameter = url.queryParameter("error"); if (errorQueryParameter == null) { - return TokenFactory.create(response); + return CookieExtractor.extract(response); } else { com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() .protocol(response.protocol()) @@ -106,7 +106,7 @@ public String authenticate(@NonNull final String username, public EncryptionKey requestEncryptionMetadata() { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); - String anonymousToken = TokenFactory.create(response.raw()); + String anonymousToken = CookieExtractor.extract(response.raw()); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieExtractor.java similarity index 76% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieExtractor.java index 3eebd834..9cf33be8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/TokenFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieExtractor.java @@ -34,26 +34,18 @@ * @author Tom Koptel * @since 2.0 */ -final class TokenFactory { - private final List mCookieParts; - - TokenFactory(List parts) { - mCookieParts = parts; +final class CookieExtractor { + private CookieExtractor() { } - public static String create(Response response) { + public static String extract(Response response) { List parts = response.headers().values("Set-Cookie"); - TokenFactory responseFactory = new TokenFactory(parts); - return responseFactory.create(); - } - - private String create() { - return joinCookieParts().toString(); + return joinCookieParts(parts).toString(); } - private StringBuilder joinCookieParts() { + private static StringBuilder joinCookieParts(List parts) { StringBuilder stringBuilder = new StringBuilder(); - Iterator iterator = mCookieParts.iterator(); + Iterator iterator = parts.iterator(); while (iterator.hasNext()) { String cookie = iterator.next(); stringBuilder.append(cookie); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/CookieExtractorTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/api/CookieExtractorTest.java index 97e5935c..240d7d7d 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/TokenFactoryTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/CookieExtractorTest.java @@ -38,7 +38,7 @@ * @author Tom Koptel * @since 2.0 */ -public class TokenFactoryTest { +public class CookieExtractorTest { private Request mRequest; @@ -59,7 +59,7 @@ public void shouldExtractTokenFromNetworkResponse() { .request(mRequest) .build(); - String token = TokenFactory.create(mockResponse); + String token = CookieExtractor.extract(mockResponse); assertThat(token, is("cookie1;cookie2")); } } From 0e01880b1b151685d5af32d9e62495d13325759b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 26 Oct 2015 13:23:11 +0200 Subject: [PATCH 234/457] Apply SearchUseCase for interaction --- .../sdk/service/GreedyInfoProvider.java | 8 ++ .../android/sdk/service/InfoProvider.java | 6 +- .../sdk/service/ServerInfoService.java | 7 ++ .../repository/EmeraldMR2SearchStrategy.java | 32 +++--- .../repository/EmeraldMR3SearchStrategy.java | 33 +++---- .../service/repository/InternalCriteria.java | 52 ++++++++++ .../repository/SearchResultMapper.java | 53 ---------- .../service/repository/SearchStrategy.java | 19 +++- .../sdk/service/repository/SearchTask.java | 4 +- .../service/repository/SearchTaskImpl.java | 8 +- .../sdk/service/repository/SearchUseCase.java | 29 ++++-- .../EmeraldMR2SearchStrategyTest.java | 98 ++++++++----------- .../EmeraldMR3SearchStrategyTest.java | 75 +++++++------- .../repository/SearchResultMapperTest.java | 71 -------------- .../repository/SearchStrategyTest.java | 9 +- .../repository/SearchTaskImplTest.java | 24 ++--- .../service/repository/SearchUseCaseTest.java | 36 +++++-- 17 files changed, 263 insertions(+), 301 deletions(-) delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java delete mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java index 2c568b8d..d37785ac 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java @@ -31,6 +31,8 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import java.text.SimpleDateFormat; + /** * Always make call on server * @@ -62,4 +64,10 @@ public ServerInfo provideInfo() { public ServerVersion provideVersion() { return mServerInfoService.requestServerVersion(); } + + @NonNull + @Override + public SimpleDateFormat provideDateTimeFormat() { + return mServerInfoService.requestServerDateTimeFormat(); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java index 56a86aee..44089868 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -29,6 +29,8 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import java.text.SimpleDateFormat; + /** * Internal interface to abstract out server info generation strategy * @@ -40,4 +42,6 @@ public interface InfoProvider { ServerInfo provideInfo(); @NonNull ServerVersion provideVersion(); + @NonNull + SimpleDateFormat provideDateTimeFormat(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index 04043a6a..2d65f203 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -7,6 +7,8 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import java.text.SimpleDateFormat; + /** * @author Tom Koptel * @since 2.0 @@ -42,4 +44,9 @@ public ServerVersion requestServerVersion() { String version = mRestApi.requestVersion(); return ServerVersion.defaultParser().parse(version); } + + public SimpleDateFormat requestServerDateTimeFormat() { + String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); + return new SimpleDateFormat(dateTimeFormat); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index c28ebc19..576e4803 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -26,10 +26,8 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import java.util.Collection; import java.util.Collections; @@ -41,28 +39,26 @@ * @since 2.0 */ final class EmeraldMR2SearchStrategy implements SearchStrategy { - private static final Collection EMPTY_RESPONSE = Collections.emptyList(); + private static final Collection EMPTY_RESPONSE = Collections.emptyList(); private static final int MAX_RETRY_COUNT = 5; - private final RepositoryRestApi mRepoFactoryRestApi; private final InternalCriteria mInitialCriteria; - private final TokenProvider mTokenProvider; + private final SearchUseCase mSearchUserCase; + private List mBuffer = new LinkedList<>(); private int mServerDisposition; - private List mBuffer = new LinkedList<>(); private boolean mEndReached; public EmeraldMR2SearchStrategy(InternalCriteria criteria, - RepositoryRestApi repositoryApiFactory, - TokenProvider tokenProvider) { - mRepoFactoryRestApi = repositoryApiFactory; - mTokenProvider = tokenProvider; + SearchUseCase searchUseCase) { + + mSearchUserCase = searchUseCase; mInitialCriteria = criteria; mEndReached = false; } @Override - public Collection searchNext() { + public Collection searchNext() { int limit = mInitialCriteria.getLimit(); int offset = mInitialCriteria.getOffset(); @@ -86,10 +82,10 @@ private void calculateDisposition(int offset) { } @NonNull - private Collection internalSearch(int limit) { + private Collection internalSearch(int limit) { int count = 0; while (mBuffer.size() < limit && hasNext()) { - ResourceSearchResult response = performSearch(limit); + SearchResult response = performSearch(limit); mBuffer.addAll(response.getResources()); mServerDisposition += limit; @@ -108,17 +104,17 @@ private Collection internalSearch(int limit) { } int median = Math.min(limit, mBuffer.size()); - Collection result = mBuffer.subList(0, median); + Collection result = mBuffer.subList(0, median); mBuffer = mBuffer.subList(median, mBuffer.size()); return result; } @NonNull - private ResourceSearchResult performSearch(int limit) { + private SearchResult performSearch(int limit) { InternalCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) .limit(limit) .create(); - return mRepoFactoryRestApi.searchResources(mTokenProvider.provideToken(), nextCriteria.toMap()); + return mSearchUserCase.performSearch(nextCriteria); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index c1c925a0..8294bcfb 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -26,10 +26,8 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import java.util.Collection; import java.util.Collections; @@ -39,22 +37,19 @@ * @since 2.0 */ final class EmeraldMR3SearchStrategy implements SearchStrategy { - public static final Collection EMPTY_RESPONSE = Collections.emptyList(); + public static final Collection EMPTY_RESPONSE = Collections.emptyList(); private final static int UNDEFINED = -1; - private final RepositoryRestApi mRepositoryRestApi; private final InternalCriteria mInitialCriteria; - private final TokenProvider mTokenProvider; + private final SearchUseCase mSearchUseCase; private int mUserOffset; private int mInternalOffset = UNDEFINED; private boolean mEndReached; - public EmeraldMR3SearchStrategy(InternalCriteria criteria, - RepositoryRestApi repositoryApiFactory, - TokenProvider tokenProvider) { - mRepositoryRestApi = repositoryApiFactory; - mTokenProvider = tokenProvider; + public EmeraldMR3SearchStrategy(InternalCriteria criteria, SearchUseCase searchUseCase) { + mSearchUseCase = searchUseCase; + // Internally enabling 'forceFullPageFlag' mInitialCriteria = criteria.newBuilder() .forceFullPage(true) @@ -63,7 +58,7 @@ public EmeraldMR3SearchStrategy(InternalCriteria criteria, } @Override - public Collection searchNext() { + public Collection searchNext() { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } @@ -80,16 +75,16 @@ public boolean hasNext() { } @NonNull - private Collection performLookup() { + private Collection performLookup() { InternalCriteria newSearchCriteria = createNextCriteria(); - ResourceSearchResult result = performApiCall(newSearchCriteria); + SearchResult result = performApiCall(newSearchCriteria); updateInternalOffset(result); return result.getResources(); } @NonNull - private ResourceSearchResult performApiCall(InternalCriteria newSearchCriteria) { - return mRepositoryRestApi.searchResources(mTokenProvider.provideToken(), newSearchCriteria.toMap()); + private SearchResult performApiCall(InternalCriteria newSearchCriteria) { + return mSearchUseCase.performSearch(newSearchCriteria); } private void defineInternalOffset() { @@ -100,12 +95,12 @@ private void defineInternalOffset() { .limit(mUserOffset) .offset(0) .create(); - ResourceSearchResult result = performApiCall(newCriteria); + SearchResult result = performApiCall(newCriteria); mInternalOffset = result.getNextOffset(); } } - private void updateInternalOffset(ResourceSearchResult result) { + private void updateInternalOffset(SearchResult result) { int nextOffset = result.getNextOffset(); mEndReached = (nextOffset == 0); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index 64b22a46..649af1c6 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -211,6 +211,58 @@ private void populateTypes(Map params) { } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + InternalCriteria criteria = (InternalCriteria) o; + + if (mLimit != criteria.mLimit) return false; + if (mOffset != criteria.mOffset) return false; + if (mResourceMask != criteria.mResourceMask) return false; + if (mRecursive != null ? !mRecursive.equals(criteria.mRecursive) : criteria.mRecursive != null) + return false; + if (mForceFullPage != null ? !mForceFullPage.equals(criteria.mForceFullPage) : criteria.mForceFullPage != null) + return false; + if (mForceTotalCount != null ? !mForceTotalCount.equals(criteria.mForceTotalCount) : criteria.mForceTotalCount != null) + return false; + if (mQuery != null ? !mQuery.equals(criteria.mQuery) : criteria.mQuery != null) + return false; + if (mSortBy != null ? !mSortBy.equals(criteria.mSortBy) : criteria.mSortBy != null) + return false; + return !(mFolderUri != null ? !mFolderUri.equals(criteria.mFolderUri) : criteria.mFolderUri != null); + } + + @Override + public int hashCode() { + int result = mLimit; + result = 31 * result + mOffset; + result = 31 * result + mResourceMask; + result = 31 * result + (mRecursive != null ? mRecursive.hashCode() : 0); + result = 31 * result + (mForceFullPage != null ? mForceFullPage.hashCode() : 0); + result = 31 * result + (mForceTotalCount != null ? mForceTotalCount.hashCode() : 0); + result = 31 * result + (mQuery != null ? mQuery.hashCode() : 0); + result = 31 * result + (mSortBy != null ? mSortBy.hashCode() : 0); + result = 31 * result + (mFolderUri != null ? mFolderUri.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "InternalCriteria{" + + "mFolderUri='" + mFolderUri + '\'' + + ", mLimit=" + mLimit + + ", mOffset=" + mOffset + + ", mResourceMask=" + mResourceMask + + ", mRecursive=" + mRecursive + + ", mForceFullPage=" + mForceFullPage + + ", mForceTotalCount=" + mForceTotalCount + + ", mQuery='" + mQuery + '\'' + + ", mSortBy='" + mSortBy + '\'' + + '}'; + } + public static class Builder { private int limit = DEFAULT_LIMIT; private int offset = DEFAULT_OFFSET; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java deleted file mode 100644 index 2f6ead29..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapper.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; -import com.jaspersoft.android.sdk.service.data.repository.SearchResult; - -import java.text.SimpleDateFormat; -import java.util.Collection; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class SearchResultMapper { - - private final GenericResourceMapper mGenericResourceMapper; - - SearchResultMapper(GenericResourceMapper genericResourceMapper) { - mGenericResourceMapper = genericResourceMapper; - } - - public SearchResult transform(ResourceSearchResult result, SimpleDateFormat dateTimeFormat) { - SearchResult searchResult = new SearchResult(); - searchResult.setNextOffset(result.getNextOffset()); - - Collection resources = mGenericResourceMapper.transform(result.getResources(), dateTimeFormat); - searchResult.setResources(resources); - return searchResult; - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 21c6a587..76b1068f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -25,8 +25,9 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.util.Collection; @@ -36,18 +37,26 @@ * @since 2.0 */ interface SearchStrategy { - Collection searchNext(); + Collection searchNext(); boolean hasNext(); class Factory { - public static SearchStrategy get(ServerVersion version, InternalCriteria criteria, RepositoryRestApi repositoryRestApi, TokenProvider tokenProvider) { + public static SearchStrategy get(InternalCriteria criteria, + RepositoryRestApi repositoryRestApi, + InfoProvider infoProvider, + TokenProvider tokenProvider) { + ServerVersion version = infoProvider.provideVersion(); + GenericResourceMapper resourceMapper = new GenericResourceMapper(); + SearchUseCase searchUseCase = new SearchUseCase(resourceMapper, repositoryRestApi, tokenProvider, infoProvider); + if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { - return new EmeraldMR2SearchStrategy(criteria, repositoryRestApi, tokenProvider); + return new EmeraldMR2SearchStrategy(criteria, searchUseCase); } if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { - return new EmeraldMR3SearchStrategy(criteria, repositoryRestApi, tokenProvider); + return new EmeraldMR3SearchStrategy(criteria, searchUseCase); } throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + version.getRawValue()); } + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 02c5092c..92e87f35 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -25,7 +25,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; import java.util.Collection; @@ -35,6 +35,6 @@ */ public interface SearchTask { @NonNull - Collection nextLookup(); + Collection nextLookup(); boolean hasNext(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 12005e44..a4813a0a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -28,10 +28,9 @@ import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; import java.util.Collection; @@ -60,7 +59,7 @@ final class SearchTaskImpl implements SearchTask { @NonNull @Override - public Collection nextLookup() { + public Collection nextLookup() { return defineSearchStrategy().searchNext(); } @@ -78,8 +77,7 @@ public boolean hasNext() { private SearchStrategy defineSearchStrategy() { if (strategy == null) { - ServerVersion version = mInfoProvider.provideVersion(); - strategy = SearchStrategy.Factory.get(version, mCriteria, mRepositoryRestApi, mTokenProvider); + strategy = SearchStrategy.Factory.get(mCriteria, mRepositoryRestApi, mInfoProvider, mTokenProvider); } return strategy; } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 5dc35ad1..2f361d57 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -27,9 +27,13 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import java.text.SimpleDateFormat; +import java.util.Collection; /** * @author Tom Koptel @@ -37,17 +41,30 @@ */ final class SearchUseCase { private final RepositoryRestApi mRestApi; - private final SearchResultMapper mDataMapper; + private final TokenProvider mTokenProvider; + private final InfoProvider mInfoProvider; + private final GenericResourceMapper mDataMapper; - public SearchUseCase(RepositoryRestApi restApi, SearchResultMapper dataMapper) { + public SearchUseCase( + GenericResourceMapper dataMapper, RepositoryRestApi restApi, + TokenProvider tokenProvider, InfoProvider infoProvider) { mRestApi = restApi; + mTokenProvider = tokenProvider; + mInfoProvider = infoProvider; mDataMapper = dataMapper; } @NonNull - public SearchResult performSearch(@NonNull InternalCriteria criteria, - @NonNull SimpleDateFormat dateTimeFormat) { - ResourceSearchResult response = mRestApi.searchResources(criteria.toMap()); - return mDataMapper.transform(response, dateTimeFormat); + public SearchResult performSearch(@NonNull InternalCriteria criteria) { + ResourceSearchResult response = mRestApi.searchResources(mTokenProvider.provideToken(), criteria.toMap()); + SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); + + SearchResult searchResult = new SearchResult(); + searchResult.setNextOffset(response.getNextOffset()); + + Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); + searchResult.setResources(resources); + + return searchResult; } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index 847ab998..a3c34eee 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -1,13 +1,12 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; @@ -18,16 +17,11 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -39,76 +33,68 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ResourceSearchResult.class}) +@PrepareForTest({SearchUseCase.class}) public class EmeraldMR2SearchStrategyTest { @Mock - RepositoryRestApi mApi; + SearchUseCase mSearchUseCase; @Mock - ResourceSearchResult mResponse; - @Mock - TokenProvider mTokenProvider; + SearchResult mResponse; + /** * Objects under test */ private EmeraldMR2SearchStrategy search10itemsStrategy; private EmeraldMR2SearchStrategy search10itemsStrategyWithUserOffset5; - public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); + public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); @Before public void setupMocks() { MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn("cookie"); - - when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); - - List stubLookup = Collections.singletonList(new ResourceLookup()); - when(mResponse.getResources()).thenReturn(stubLookup); + when(mSearchUseCase.performSearch(Matchers.any(InternalCriteria.class))).thenReturn(mResponse); InternalCriteria criteria = InternalCriteria.builder().limit(10).create(); - search10itemsStrategy = new EmeraldMR2SearchStrategy(criteria, mApi, mTokenProvider); + search10itemsStrategy = new EmeraldMR2SearchStrategy(criteria, mSearchUseCase); InternalCriteria userCriteria = criteria.newBuilder().offset(5).create(); - search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(userCriteria, mApi, mTokenProvider); + search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(userCriteria, mSearchUseCase); } @Test public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(10)); - Map params = new HashMap<>(); - params.put("limit", "10"); - verify(mApi).searchResources("cookie", params); + InternalCriteria criteria1 = InternalCriteria.builder().limit(10).create(); + verify(mSearchUseCase).performSearch(criteria1); - params = new HashMap<>(); - params.put("limit", "10"); - params.put("offset", "10"); - verify(mApi).searchResources("cookie", params); + InternalCriteria criteria2 = InternalCriteria.builder() + .offset(10).limit(10).create(); + verify(mSearchUseCase).performSearch(criteria2); } @Test public void willRetry5timesIfApiReturnsNoElements() throws Exception { - when(mResponse.getResources()).thenReturn(Collections.emptyList()); + when(mResponse.getResources()).thenReturn(Collections.emptyList()); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); - verify(mApi, times(6)).searchResources( eq("cookie"), anyMap()); + verify(mSearchUseCase, times(6)).performSearch(Matchers.any(InternalCriteria.class)); } @Test public void willReturnAsMuchElementsAsLeftIfEndReached() throws Exception { when(mResponse.getResources()).then(OnlyTwoItems.INSTANCE); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(2)); - verify(mApi, times(6)).searchResources( eq("cookie"), anyMap()); + verify(mSearchUseCase, times(6)).performSearch(Matchers.any(InternalCriteria.class)); } @Test @@ -117,45 +103,45 @@ public void forCustomOffsetShouldCalculateServerDisposition() throws Exception { search10itemsStrategyWithUserOffset5.searchNext(); - Map params1 = new HashMap<>(); - params1.put("limit", "5"); - verify(mApi).searchResources("cookie", params1); - Map params2 = new HashMap<>(); - params2.put("limit", "10"); - params2.put("offset", "5"); - verify(mApi).searchResources("cookie", params2); + InternalCriteria criteria1 = InternalCriteria.builder() + .limit(5).create(); + verify(mSearchUseCase).performSearch(criteria1); + + + InternalCriteria criteria2 = InternalCriteria.builder() + .limit(10).offset(5).create(); + verify(mSearchUseCase).performSearch(criteria2); - Map params3 = new HashMap<>(); - params3.put("limit", "10"); - params3.put("offset", "15"); - verify(mApi).searchResources("cookie", params3); + InternalCriteria criteria3 = InternalCriteria.builder() + .limit(10).offset(15).create(); + verify(mSearchUseCase).performSearch(criteria3); - verify(mApi, times(3)).searchResources(eq("cookie"), anyMap()); - verifyNoMoreInteractions(mApi); + verify(mSearchUseCase, times(3)).performSearch(Matchers.any(InternalCriteria.class)); + verifyNoMoreInteractions(mSearchUseCase); } @Test public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(userCriteria, mApi, mTokenProvider); + EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(userCriteria, mSearchUseCase); - Collection result = strategy.searchNext(); + Collection result = strategy.searchNext(); assertThat(result, is(empty())); - verifyZeroInteractions(mApi); + verifyZeroInteractions(mSearchUseCase); } - private static class OnlyTwoItems implements Answer> { + private static class OnlyTwoItems implements Answer> { public static final OnlyTwoItems INSTANCE = new OnlyTwoItems(); - private final List twoItems = Arrays.asList(null, null); - private final List zeroItems = Collections.emptyList(); + private final List twoItems = Arrays.asList(null, null); + private final List zeroItems = Collections.emptyList(); private int count = 0; @Override - public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { + public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { if (count == 0) { count++; return twoItems; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index a8283826..b92ef7bd 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -1,9 +1,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import org.hamcrest.Matchers; import org.junit.Before; @@ -16,16 +14,12 @@ import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; @@ -36,62 +30,57 @@ * @since 2.0 */ @RunWith(PowerMockRunner.class) -@PrepareForTest(ResourceSearchResult.class) +@PrepareForTest(SearchUseCase.class) public class EmeraldMR3SearchStrategyTest { private static final InternalCriteria NO_CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock - RepositoryRestApi mApi; + SearchUseCase mSearchUseCase; @Mock - ResourceSearchResult mResponse; - @Mock - TokenProvider mTokenProvider; + SearchResult mResponse; @Before public void setupMocks() { MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn("cookie"); - - when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); + when(mSearchUseCase.performSearch(any(InternalCriteria.class))).thenReturn(mResponse); - List stubLookup = Collections.singletonList(new ResourceLookup()); + List stubLookup = Collections.singletonList(null); when(mResponse.getResources()).thenReturn(stubLookup); } @Test public void shouldMakeImmediateCallOnApiForUserOffsetZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mApi, mTokenProvider); - - when(mApi.searchResources(anyString(), anyMap())).thenReturn(mResponse); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); strategy.searchNext(); - Map params = new HashMap<>(); - params.put("forceFullPage", "true"); - - verify(mApi, times(1)).searchResources(eq("cookie"), eq(params)); + InternalCriteria internalCriteria = InternalCriteria.builder() + .offset(0) + .forceFullPage(true) + .create(); + verify(mSearchUseCase).performSearch(internalCriteria); } @Test public void makesAdditionalCallOnApiIfUserOffsetNotZero() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mApi, mTokenProvider); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); strategy.searchNext(); - Map params = new HashMap<>(); - params.put("forceFullPage", "true"); - params.put("limit", "5"); - - verify(mApi, times(1)).searchResources(eq("cookie"), eq(params)); + InternalCriteria internalCriteria = InternalCriteria.builder() + .limit(5) + .forceFullPage(true) + .create(); + verify(mSearchUseCase).performSearch(internalCriteria); } @Test public void secondSearchLookupShouldUseNextOffset() { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mApi, mTokenProvider); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); when(mResponse.getNextOffset()).thenReturn(133); strategy.searchNext(); @@ -100,17 +89,19 @@ public void secondSearchLookupShouldUseNextOffset() { strategy.searchNext(); - Map params = new HashMap<>(); - params.put("forceFullPage", "true"); - params.put("offset", "133"); + InternalCriteria internalCriteria = InternalCriteria.builder() + .offset(133) + .limit(100) + .forceFullPage(true) + .create(); verify(mResponse, times(2)).getNextOffset(); - verify(mApi).searchResources(eq("cookie"), eq(params)); + verify(mSearchUseCase).performSearch(internalCriteria); } @Test public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(NO_CRITERIA, mApi, mTokenProvider); + EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(NO_CRITERIA, mSearchUseCase); when(mResponse.getNextOffset()).thenReturn(133); strategy.searchNext(); @@ -118,22 +109,22 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { when(mResponse.getNextOffset()).thenReturn(0); strategy.searchNext(); - Collection response = strategy.searchNext(); + Collection response = strategy.searchNext(); assertThat(response, is(empty())); assertThat(strategy.hasNext(), is(false)); verify(mResponse, times(2)).getNextOffset(); - verify(mApi, times(2)).searchResources(eq("cookie"), anyMap()); + verify(mSearchUseCase, times(2)).performSearch(any(InternalCriteria.class)); } @Test public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - SearchStrategy strategy = new EmeraldMR3SearchStrategy(userCriteria, mApi, mTokenProvider); + SearchStrategy strategy = new EmeraldMR3SearchStrategy(userCriteria, mSearchUseCase); - Collection result = strategy.searchNext(); + Collection result = strategy.searchNext(); assertThat(result, Matchers.is(Matchers.empty())); - verifyZeroInteractions(mApi); + verifyZeroInteractions(mSearchUseCase); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java deleted file mode 100644 index 882369d3..00000000 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchResultMapperTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; -import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyList; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class SearchResultMapperTest { - - public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat(); - @Mock - GenericResourceMapper mGenericResourceMapper; - @Mock - GenericResource mGenericResource; - - @Mock - ResourceSearchResult mSearchResult; - @Mock - ServerInfo mServerInfo; - @Mock - ResourceLookup mLookup; - - private SearchResultMapper objectUnderTest; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchResultMapper(mGenericResourceMapper); - } - - @Test - public void testTransform() throws Exception { - List resources = Collections.singletonList(mLookup); - when(mSearchResult.getNextOffset()).thenReturn(100); - when(mSearchResult.getResources()).thenReturn(resources); - - Collection genericResources = Collections.singletonList(mGenericResource); - when(mGenericResourceMapper.transform(anyList(), any(SimpleDateFormat.class))).thenReturn(genericResources); - SearchResult searchResult = objectUnderTest.transform(mSearchResult, DATE_TIME_FORMAT); - - assertThat(searchResult.getNextOffset(), is(100)); - assertThat(searchResult.getResources(), contains(mGenericResource)); - - verify(mGenericResourceMapper).transform(resources, DATE_TIME_FORMAT); - verify(mSearchResult).getNextOffset(); - verify(mSearchResult).getResources(); - } -} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index 2b32c290..59f01f27 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -40,6 +40,7 @@ import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertThat; +import static org.powermock.api.mockito.PowerMockito.when; /** * @author Tom Koptel @@ -68,7 +69,9 @@ public void before() { }) public void factoryCreatesEmeraldMR2Strategy(String version) { ServerVersion serverVersion = ServerVersion.defaultParser().parse(version); - SearchStrategy searchStrategy = SearchStrategy.Factory.get(serverVersion, CRITERIA, mRepoApi, mTokenProvider); + when(mInfoProvider.provideVersion()).thenReturn(serverVersion); + + SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); } @@ -79,7 +82,9 @@ public void factoryCreatesEmeraldMR2Strategy(String version) { }) public void factoryCreatesEmeraldMR3Strategy(String version) { ServerVersion serverVersion = ServerVersion.defaultParser().parse(version); - SearchStrategy searchStrategy = SearchStrategy.Factory.get(serverVersion, CRITERIA, mRepoApi, mTokenProvider); + when(mInfoProvider.provideVersion()).thenReturn(serverVersion); + + SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index 5fdca3f2..8e5aaa9d 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -27,7 +27,6 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; @@ -72,33 +71,36 @@ public void setup() { when(mSearchStrategy.searchNext()).thenReturn(null); PowerMockito.mockStatic(SearchStrategy.Factory.class); - PowerMockito.when(SearchStrategy.Factory.get(any(ServerVersion.class), any(InternalCriteria.class), - any(RepositoryRestApi.class), any(TokenProvider.class))).thenReturn(mSearchStrategy); + + + PowerMockito.when( + SearchStrategy.Factory.get( + any(InternalCriteria.class), + any(RepositoryRestApi.class), + any(InfoProvider.class), + any(TokenProvider.class) + ) + ).thenReturn(mSearchStrategy); } @Test public void nextLookupShouldDefineSearchStrategy() { - when(mInfoProvider.provideVersion()).thenReturn(ServerVersion.EMERALD_MR2); objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq(ServerVersion.EMERALD_MR2), eq(CRITERIA), eq(mRepoApi), eq(mTokenProvider)); + SearchStrategy.Factory.get(eq(CRITERIA), eq(mRepoApi), eq(mInfoProvider), eq(mTokenProvider)); - verify(mInfoProvider).provideVersion(); - verify(mSearchStrategy, times(1)).searchNext(); + verify(mSearchStrategy).searchNext(); } @Test public void secondLookupShouldUseCachedStrategy() { - when(mInfoProvider.provideVersion()).thenReturn(ServerVersion.EMERALD_MR2); - objectUnderTest.nextLookup(); objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq(ServerVersion.EMERALD_MR2), eq(CRITERIA), eq(mRepoApi), eq(mTokenProvider)); + SearchStrategy.Factory.get(eq(CRITERIA), eq(mRepoApi), eq(mInfoProvider), eq(mTokenProvider)); - verify(mInfoProvider).provideVersion(); verify(mSearchStrategy, times(2)).searchNext(); } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 7ef949de..20a900e8 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -3,6 +3,9 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.GenericResource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -12,11 +15,17 @@ import org.mockito.MockitoAnnotations; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; import java.util.Map; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyCollection; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -30,12 +39,14 @@ public class SearchUseCaseTest { @Mock RepositoryRestApi mRepositoryRestApi; @Mock - SearchResultMapper mDataMapper; + GenericResourceMapper mDataMapper; + @Mock + TokenProvider mTokenProvider; + @Mock + InfoProvider mInfoProvider; @Mock ResourceLookup mResourceLookup; - @Mock - SearchResult mAdaptedSearchResult; @Mock InternalCriteria mCriteria; @@ -50,18 +61,23 @@ public class SearchUseCaseTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchUseCase(mRepositoryRestApi, mDataMapper); + objectUnderTest = new SearchUseCase(mDataMapper, mRepositoryRestApi, mTokenProvider, mInfoProvider); } @Test public void shouldProvideAndAdaptSearchResult() { - when(mRepositoryRestApi.searchResources(any(Map.class))).thenReturn(mResult); - when(mDataMapper.transform(any(ResourceSearchResult.class), any(SimpleDateFormat.class))).thenReturn(mAdaptedSearchResult); + when(mResult.getNextOffset()).thenReturn(100); + when(mRepositoryRestApi.searchResources(anyString(), any(Map.class))).thenReturn(mResult); + when(mInfoProvider.provideDateTimeFormat()).thenReturn(DATE_TIME_FORMAT); + + Collection resources = new ArrayList(); + when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); - SearchResult result = objectUnderTest.performSearch(mCriteria, DATE_TIME_FORMAT); - assertThat(result, is(mAdaptedSearchResult)); + SearchResult result = objectUnderTest.performSearch(mCriteria); + assertThat(result, is(not(nullValue()))); + assertThat(result.getNextOffset(), is(100)); + assertThat(result.getResources(), is(resources)); - verify(mRepositoryRestApi).searchResources(any(Map.class)); - verify(mDataMapper).transform(mResult, DATE_TIME_FORMAT); + verify(mRepositoryRestApi).searchResources(anyString(), any(Map.class)); } } \ No newline at end of file From 18f27366d603956d0ae649dd51cb8697c2a9b0a9 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 26 Oct 2015 17:44:48 +0200 Subject: [PATCH 235/457] Refactoring GenericResource -> Resource --- .../{GenericResource.java => Resource.java} | 178 +++++++++--------- .../service/data/repository/SearchResult.java | 6 +- .../repository/EmeraldMR2SearchStrategy.java | 12 +- .../repository/EmeraldMR3SearchStrategy.java | 8 +- ...esourceMapper.java => ResourceMapper.java} | 160 ++++++++-------- .../service/repository/SearchStrategy.java | 6 +- .../sdk/service/repository/SearchTask.java | 4 +- .../service/repository/SearchTaskImpl.java | 4 +- .../sdk/service/repository/SearchUseCase.java | 8 +- .../EmeraldMR2SearchStrategyTest.java | 22 +-- .../EmeraldMR3SearchStrategyTest.java | 8 +- ...apperTest.java => ResourceMapperTest.java} | 158 ++++++++-------- .../service/repository/SearchUseCaseTest.java | 6 +- 13 files changed, 290 insertions(+), 290 deletions(-) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/{GenericResource.java => Resource.java} (95%) rename client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/{GenericResourceMapper.java => ResourceMapper.java} (82%) rename client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/{GenericResourceMapperTest.java => ResourceMapperTest.java} (82%) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/GenericResource.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java similarity index 95% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/GenericResource.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java index ce22a2ce..47c4d94a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/GenericResource.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java @@ -1,89 +1,89 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.data.repository; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import java.util.Date; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class GenericResource { - @Nullable - private Date mCreationDate; - @Nullable - private Date mUpdateDate; - - private ResourceType mResourceType; - private String mLabel; - private String mDescription; - - @Nullable - public Date getCreationDate() { - return mCreationDate; - } - - public void setCreationDate(@Nullable Date creationDate) { - mCreationDate = creationDate; - } - - @Nullable - public Date getUpdateDate() { - return mUpdateDate; - } - - public void setUpdateDate(@Nullable Date updateDate) { - mUpdateDate = updateDate; - } - - @NonNull - public ResourceType getResourceType() { - return mResourceType; - } - - public void setResourceType(@NonNull ResourceType resourceType) { - mResourceType = resourceType; - } - - @NonNull - public String getLabel() { - return mLabel; - } - - public void setLabel(@NonNull String label) { - mLabel = label; - } - - @NonNull - public String getDescription() { - return mDescription; - } - - public void setDescription(@NonNull String description) { - mDescription = description; - } -} +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.data.repository; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import java.util.Date; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class Resource { + @Nullable + private Date mCreationDate; + @Nullable + private Date mUpdateDate; + + private ResourceType mResourceType; + private String mLabel; + private String mDescription; + + @Nullable + public Date getCreationDate() { + return mCreationDate; + } + + public void setCreationDate(@Nullable Date creationDate) { + mCreationDate = creationDate; + } + + @Nullable + public Date getUpdateDate() { + return mUpdateDate; + } + + public void setUpdateDate(@Nullable Date updateDate) { + mUpdateDate = updateDate; + } + + @NonNull + public ResourceType getResourceType() { + return mResourceType; + } + + public void setResourceType(@NonNull ResourceType resourceType) { + mResourceType = resourceType; + } + + @NonNull + public String getLabel() { + return mLabel; + } + + public void setLabel(@NonNull String label) { + mLabel = label; + } + + @NonNull + public String getDescription() { + return mDescription; + } + + public void setDescription(@NonNull String description) { + mDescription = description; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java index b337b4d2..e11938a2 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java @@ -30,14 +30,14 @@ * @since 2.0 */ public class SearchResult { - private Collection mResources; + private Collection mResources; private int mNextOffset; - public Collection getResources() { + public Collection getResources() { return mResources; } - public void setResources(Collection resources) { + public void setResources(Collection resources) { mResources = resources; } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 576e4803..598c12e0 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import java.util.Collection; @@ -39,13 +39,13 @@ * @since 2.0 */ final class EmeraldMR2SearchStrategy implements SearchStrategy { - private static final Collection EMPTY_RESPONSE = Collections.emptyList(); + private static final Collection EMPTY_RESPONSE = Collections.emptyList(); private static final int MAX_RETRY_COUNT = 5; private final InternalCriteria mInitialCriteria; private final SearchUseCase mSearchUserCase; - private List mBuffer = new LinkedList<>(); + private List mBuffer = new LinkedList<>(); private int mServerDisposition; private boolean mEndReached; @@ -58,7 +58,7 @@ public EmeraldMR2SearchStrategy(InternalCriteria criteria, } @Override - public Collection searchNext() { + public Collection searchNext() { int limit = mInitialCriteria.getLimit(); int offset = mInitialCriteria.getOffset(); @@ -82,7 +82,7 @@ private void calculateDisposition(int offset) { } @NonNull - private Collection internalSearch(int limit) { + private Collection internalSearch(int limit) { int count = 0; while (mBuffer.size() < limit && hasNext()) { SearchResult response = performSearch(limit); @@ -104,7 +104,7 @@ private Collection internalSearch(int limit) { } int median = Math.min(limit, mBuffer.size()); - Collection result = mBuffer.subList(0, median); + Collection result = mBuffer.subList(0, median); mBuffer = mBuffer.subList(median, mBuffer.size()); return result; } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 8294bcfb..1c1da89e 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import java.util.Collection; @@ -37,7 +37,7 @@ * @since 2.0 */ final class EmeraldMR3SearchStrategy implements SearchStrategy { - public static final Collection EMPTY_RESPONSE = Collections.emptyList(); + public static final Collection EMPTY_RESPONSE = Collections.emptyList(); private final static int UNDEFINED = -1; private final InternalCriteria mInitialCriteria; @@ -58,7 +58,7 @@ public EmeraldMR3SearchStrategy(InternalCriteria criteria, SearchUseCase searchU } @Override - public Collection searchNext() { + public Collection searchNext() { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } @@ -75,7 +75,7 @@ public boolean hasNext() { } @NonNull - private Collection performLookup() { + private Collection performLookup() { InternalCriteria newSearchCriteria = createNextCriteria(); SearchResult result = performApiCall(newSearchCriteria); updateInternalOffset(result); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java similarity index 82% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapper.java rename to client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java index f740a3ab..6f20fe49 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java @@ -1,80 +1,80 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.repository; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; -import com.jaspersoft.android.sdk.service.data.repository.ResourceType; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; -import java.util.LinkedList; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class GenericResourceMapper { - - @NonNull - public Collection transform(Collection resources, SimpleDateFormat dateTimeFormat) { - Collection result = new LinkedList<>(); - for (ResourceLookup lookup : resources) { - if (lookup != null) { - result.add(transform(lookup, dateTimeFormat)); - } - } - return result; - } - - @NonNull - public GenericResource transform(ResourceLookup lookup, SimpleDateFormat dateTimeFormat) { - GenericResource resource = new GenericResource(); - resource.setCreationDate(toDate(lookup.getCreationDate(), dateTimeFormat)); - resource.setUpdateDate(toDate(lookup.getUpdateDate(), dateTimeFormat)); - resource.setDescription(lookup.getDescription()); - resource.setLabel(lookup.getLabel()); - resource.setResourceType(toType(lookup.getResourceType())); - return resource; - } - - @Nullable - private Date toDate(String creationDate, SimpleDateFormat dateTimeFormat) { - try { - return dateTimeFormat.parse(String.valueOf(creationDate)); - } catch (ParseException e) { - return null; - } - } - - @NonNull - private ResourceType toType(String resourceType) { - return ResourceType.defaultParser().parse(String.valueOf(resourceType)); - } -} +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of Jaspersoft Mobile for Android. + * + * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Jaspersoft Mobile for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.repository; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.ResourceType; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedList; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class ResourceMapper { + + @NonNull + public Collection transform(Collection resources, SimpleDateFormat dateTimeFormat) { + Collection result = new LinkedList<>(); + for (ResourceLookup lookup : resources) { + if (lookup != null) { + result.add(transform(lookup, dateTimeFormat)); + } + } + return result; + } + + @NonNull + public Resource transform(ResourceLookup lookup, SimpleDateFormat dateTimeFormat) { + Resource resource = new Resource(); + resource.setCreationDate(toDate(lookup.getCreationDate(), dateTimeFormat)); + resource.setUpdateDate(toDate(lookup.getUpdateDate(), dateTimeFormat)); + resource.setDescription(lookup.getDescription()); + resource.setLabel(lookup.getLabel()); + resource.setResourceType(toType(lookup.getResourceType())); + return resource; + } + + @Nullable + private Date toDate(String creationDate, SimpleDateFormat dateTimeFormat) { + try { + return dateTimeFormat.parse(String.valueOf(creationDate)); + } catch (ParseException e) { + return null; + } + } + + @NonNull + private ResourceType toType(String resourceType) { + return ResourceType.defaultParser().parse(String.valueOf(resourceType)); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 76b1068f..d362989f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.util.Collection; @@ -37,7 +37,7 @@ * @since 2.0 */ interface SearchStrategy { - Collection searchNext(); + Collection searchNext(); boolean hasNext(); class Factory { @@ -46,7 +46,7 @@ public static SearchStrategy get(InternalCriteria criteria, InfoProvider infoProvider, TokenProvider tokenProvider) { ServerVersion version = infoProvider.provideVersion(); - GenericResourceMapper resourceMapper = new GenericResourceMapper(); + ResourceMapper resourceMapper = new ResourceMapper(); SearchUseCase searchUseCase = new SearchUseCase(resourceMapper, repositoryRestApi, tokenProvider, infoProvider); if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 92e87f35..e1af72f9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -25,7 +25,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import java.util.Collection; @@ -35,6 +35,6 @@ */ public interface SearchTask { @NonNull - Collection nextLookup(); + Collection nextLookup(); boolean hasNext(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index a4813a0a..20f81556 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -30,7 +30,7 @@ import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import java.util.Collection; @@ -59,7 +59,7 @@ final class SearchTaskImpl implements SearchTask { @NonNull @Override - public Collection nextLookup() { + public Collection nextLookup() { return defineSearchStrategy().searchNext(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 2f361d57..c8374fd5 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -29,7 +29,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import java.text.SimpleDateFormat; @@ -43,10 +43,10 @@ final class SearchUseCase { private final RepositoryRestApi mRestApi; private final TokenProvider mTokenProvider; private final InfoProvider mInfoProvider; - private final GenericResourceMapper mDataMapper; + private final ResourceMapper mDataMapper; public SearchUseCase( - GenericResourceMapper dataMapper, RepositoryRestApi restApi, + ResourceMapper dataMapper, RepositoryRestApi restApi, TokenProvider tokenProvider, InfoProvider infoProvider) { mRestApi = restApi; mTokenProvider = tokenProvider; @@ -62,7 +62,7 @@ public SearchResult performSearch(@NonNull InternalCriteria criteria) { SearchResult searchResult = new SearchResult(); searchResult.setNextOffset(response.getNextOffset()); - Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); + Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); searchResult.setResources(resources); return searchResult; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index a3c34eee..de1820ed 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import org.junit.Before; @@ -46,7 +46,7 @@ public class EmeraldMR2SearchStrategyTest { */ private EmeraldMR2SearchStrategy search10itemsStrategy; private EmeraldMR2SearchStrategy search10itemsStrategyWithUserOffset5; - public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); + public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); @Before public void setupMocks() { @@ -65,7 +65,7 @@ public void setupMocks() { public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(10)); InternalCriteria criteria1 = InternalCriteria.builder().limit(10).create(); @@ -78,9 +78,9 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce @Test public void willRetry5timesIfApiReturnsNoElements() throws Exception { - when(mResponse.getResources()).thenReturn(Collections.emptyList()); + when(mResponse.getResources()).thenReturn(Collections.emptyList()); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); @@ -91,7 +91,7 @@ public void willRetry5timesIfApiReturnsNoElements() throws Exception { public void willReturnAsMuchElementsAsLeftIfEndReached() throws Exception { when(mResponse.getResources()).then(OnlyTwoItems.INSTANCE); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.searchNext(); assertThat(result.size(), is(2)); verify(mSearchUseCase, times(6)).performSearch(Matchers.any(InternalCriteria.class)); @@ -126,22 +126,22 @@ public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(userCriteria, mSearchUseCase); - Collection result = strategy.searchNext(); + Collection result = strategy.searchNext(); assertThat(result, is(empty())); verifyZeroInteractions(mSearchUseCase); } - private static class OnlyTwoItems implements Answer> { + private static class OnlyTwoItems implements Answer> { public static final OnlyTwoItems INSTANCE = new OnlyTwoItems(); - private final List twoItems = Arrays.asList(null, null); - private final List zeroItems = Collections.emptyList(); + private final List twoItems = Arrays.asList(null, null); + private final List zeroItems = Collections.emptyList(); private int count = 0; @Override - public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { + public Collection answer(InvocationOnMock invocationOnMock) throws Throwable { if (count == 0) { count++; return twoItems; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index b92ef7bd..90fb5623 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import org.hamcrest.Matchers; @@ -45,7 +45,7 @@ public void setupMocks() { when(mSearchUseCase.performSearch(any(InternalCriteria.class))).thenReturn(mResponse); - List stubLookup = Collections.singletonList(null); + List stubLookup = Collections.singletonList(null); when(mResponse.getResources()).thenReturn(stubLookup); } @@ -109,7 +109,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { when(mResponse.getNextOffset()).thenReturn(0); strategy.searchNext(); - Collection response = strategy.searchNext(); + Collection response = strategy.searchNext(); assertThat(response, is(empty())); assertThat(strategy.hasNext(), is(false)); @@ -122,7 +122,7 @@ public void shouldReturnEmptyCollectionForZeroLimit() { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); SearchStrategy strategy = new EmeraldMR3SearchStrategy(userCriteria, mSearchUseCase); - Collection result = strategy.searchNext(); + Collection result = strategy.searchNext(); assertThat(result, Matchers.is(Matchers.empty())); verifyZeroInteractions(mSearchUseCase); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java similarity index 82% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapperTest.java rename to client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java index 22cb18ac..cd3ba82b 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/GenericResourceMapperTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java @@ -1,80 +1,80 @@ -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; -import com.jaspersoft.android.sdk.service.data.repository.ResourceType; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Locale; - -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class GenericResourceMapperTest { - public static final String FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss"; - public static final SimpleDateFormat DATE_FORMAT = - new SimpleDateFormat(FORMAT_PATTERN, Locale.getDefault()); - @Mock - ServerInfo mServerInfo; - @Mock - ResourceLookup mResourceLookup; - - private GenericResourceMapper objectUnderTest; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - objectUnderTest = new GenericResourceMapper(); - - when(mResourceLookup.getCreationDate()).thenReturn("2013-10-03 16:32:05"); - when(mResourceLookup.getUpdateDate()).thenReturn("2013-11-03 16:32:05"); - when(mResourceLookup.getResourceType()).thenReturn("reportUnit"); - when(mResourceLookup.getDescription()).thenReturn("description"); - when(mResourceLookup.getLabel()).thenReturn("label"); - } - - @Test - public void testTransform() throws Exception { - long creationTime = DATE_FORMAT.parse("2013-10-03 16:32:05").getTime(); - long updateTime = DATE_FORMAT.parse("2013-11-03 16:32:05").getTime(); - - GenericResource resource = objectUnderTest.transform(mResourceLookup, DATE_FORMAT); - assertThat(resource.getCreationDate().getTime(), is(creationTime)); - assertThat(resource.getUpdateDate().getTime(), is(updateTime)); - assertThat(resource.getDescription(), is("description")); - assertThat(resource.getLabel(), is("label")); - assertThat(resource.getResourceType(), is(ResourceType.reportUnit)); - } - - @Test - public void testTransformResourceLookupCollection() { - ResourceLookup mockResourceLookupOne = mock(ResourceLookup.class); - ResourceLookup mockResourceLookupTwo = mock(ResourceLookup.class); - - List lookups = new ArrayList(5); - lookups.add(mockResourceLookupOne); - lookups.add(mockResourceLookupTwo); - - Collection resourcesCollection = objectUnderTest.transform(lookups, DATE_FORMAT); - - assertThat(resourcesCollection.toArray()[0], is(instanceOf(GenericResource.class))); - assertThat(resourcesCollection.toArray()[1], is(instanceOf(GenericResource.class))); - assertThat(resourcesCollection.size(), is(2)); - } +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.ResourceType; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; + +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ResourceMapperTest { + public static final String FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss"; + public static final SimpleDateFormat DATE_FORMAT = + new SimpleDateFormat(FORMAT_PATTERN, Locale.getDefault()); + @Mock + ServerInfo mServerInfo; + @Mock + ResourceLookup mResourceLookup; + + private ResourceMapper objectUnderTest; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + objectUnderTest = new ResourceMapper(); + + when(mResourceLookup.getCreationDate()).thenReturn("2013-10-03 16:32:05"); + when(mResourceLookup.getUpdateDate()).thenReturn("2013-11-03 16:32:05"); + when(mResourceLookup.getResourceType()).thenReturn("reportUnit"); + when(mResourceLookup.getDescription()).thenReturn("description"); + when(mResourceLookup.getLabel()).thenReturn("label"); + } + + @Test + public void testTransform() throws Exception { + long creationTime = DATE_FORMAT.parse("2013-10-03 16:32:05").getTime(); + long updateTime = DATE_FORMAT.parse("2013-11-03 16:32:05").getTime(); + + Resource resource = objectUnderTest.transform(mResourceLookup, DATE_FORMAT); + assertThat(resource.getCreationDate().getTime(), is(creationTime)); + assertThat(resource.getUpdateDate().getTime(), is(updateTime)); + assertThat(resource.getDescription(), is("description")); + assertThat(resource.getLabel(), is("label")); + assertThat(resource.getResourceType(), is(ResourceType.reportUnit)); + } + + @Test + public void testTransformResourceLookupCollection() { + ResourceLookup mockResourceLookupOne = mock(ResourceLookup.class); + ResourceLookup mockResourceLookupTwo = mock(ResourceLookup.class); + + List lookups = new ArrayList(5); + lookups.add(mockResourceLookupOne); + lookups.add(mockResourceLookupTwo); + + Collection resourcesCollection = objectUnderTest.transform(lookups, DATE_FORMAT); + + assertThat(resourcesCollection.toArray()[0], is(instanceOf(Resource.class))); + assertThat(resourcesCollection.toArray()[1], is(instanceOf(Resource.class))); + assertThat(resourcesCollection.size(), is(2)); + } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 20a900e8..46fb8a50 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -5,7 +5,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.repository.GenericResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -39,7 +39,7 @@ public class SearchUseCaseTest { @Mock RepositoryRestApi mRepositoryRestApi; @Mock - GenericResourceMapper mDataMapper; + ResourceMapper mDataMapper; @Mock TokenProvider mTokenProvider; @Mock @@ -70,7 +70,7 @@ public void shouldProvideAndAdaptSearchResult() { when(mRepositoryRestApi.searchResources(anyString(), any(Map.class))).thenReturn(mResult); when(mInfoProvider.provideDateTimeFormat()).thenReturn(DATE_TIME_FORMAT); - Collection resources = new ArrayList(); + Collection resources = new ArrayList(); when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); SearchResult result = objectUnderTest.performSearch(mCriteria); From 166719e8855efe0a337f4a9f3de1fcb2c7db4ffd Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 26 Oct 2015 18:04:25 +0200 Subject: [PATCH 236/457] Introduce Criteria mapper --- .../service/repository/CriteriaMapper.java | 109 ++++++++++ .../service/repository/InternalCriteria.java | 66 ------ .../sdk/service/repository/SearchUseCase.java | 2 +- .../repository/CriteriaMapperTest.java | 199 ++++++++++++++++++ .../InternalSearchCriteriaTest.java | 142 ------------- 5 files changed, 309 insertions(+), 209 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java new file mode 100644 index 00000000..f29e6491 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import android.support.annotation.NonNull; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.ALL; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DASHBOARD; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_LIMIT; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_OFFSET; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.LEGACY_DASHBOARD; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.REPORT; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class CriteriaMapper { + private CriteriaMapper() { + } + + @NonNull + public static Map map(InternalCriteria criteria) { + Map params = new HashMap<>(); + + if (criteria.getLimit() != DEFAULT_LIMIT) { + params.put("limit", String.valueOf(criteria.getLimit())); + } + if (criteria.getOffset() != DEFAULT_OFFSET) { + params.put("offset", String.valueOf(criteria.getOffset())); + } + if (criteria.getRecursive() != null) { + params.put("recursive", String.valueOf(criteria.getRecursive())); + } + if (criteria.getForceFullPage() != null) { + params.put("forceFullPage", String.valueOf(criteria.getForceFullPage())); + } + if (criteria.getForceTotalCount() != null) { + params.put("forceTotalCount", String.valueOf(criteria.getForceTotalCount())); + } + + String query = criteria.getQuery(); + if (query != null && query.length() > 0) { + params.put("q", query); + } + if (criteria.getSortBy() != null) { + params.put("sortBy", criteria.getSortBy()); + } + if (criteria.getFolderUri() != null) { + params.put("folderUri", criteria.getFolderUri()); + } + + populateTypes(criteria, params); + + return params; + } + + private static void populateTypes(InternalCriteria criteria, Map params) { + Set types = new HashSet<>(); + + int resourceMask = criteria.getResourceMask(); + boolean includeReport = + (resourceMask & REPORT) == REPORT || (resourceMask & ALL) == ALL; + if (includeReport) { + types.add("reportUnit"); + } + boolean includeDashboard = + (resourceMask & DASHBOARD) == DASHBOARD || (resourceMask & ALL) == ALL; + if (includeDashboard) { + types.add("dashboard"); + } + boolean includeLegacyDashboard = + (resourceMask & LEGACY_DASHBOARD) == LEGACY_DASHBOARD || (resourceMask & ALL) == ALL; + if (includeLegacyDashboard) { + types.add("legacyDashboard"); + } + + if (!types.isEmpty()) { + params.put("type", types); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index 649af1c6..a60fe46c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -26,17 +26,8 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.ALL; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DASHBOARD; import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_LIMIT; import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_OFFSET; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.LEGACY_DASHBOARD; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.REPORT; /** * @author Tom Koptel @@ -154,63 +145,6 @@ public InternalCriteria.Builder newBuilder() { return builder; } - @NonNull - public Map toMap() { - Map params = new HashMap<>(); - - if (mLimit != DEFAULT_LIMIT) { - params.put("limit", String.valueOf(mLimit)); - } - if (mOffset != DEFAULT_OFFSET) { - params.put("offset", String.valueOf(mOffset)); - } - if (mRecursive != null) { - params.put("recursive", String.valueOf(mRecursive)); - } - if (mForceFullPage != null) { - params.put("forceFullPage", String.valueOf(mForceFullPage)); - } - if (mForceTotalCount != null) { - params.put("forceTotalCount", String.valueOf(mForceTotalCount)); - } - if (mQuery != null && mQuery.length() > 0) { - params.put("q", mQuery); - } - if (mSortBy != null) { - params.put("sortBy", mSortBy); - } - if (mFolderUri != null) { - params.put("folderUri", mFolderUri); - } - - populateTypes(params); - return params; - } - - private void populateTypes(Map params) { - Set types = new HashSet<>(); - - boolean includeReport = - (mResourceMask & REPORT) == REPORT || (mResourceMask & ALL) == ALL; - if (includeReport) { - types.add("reportUnit"); - } - boolean includeDashboard = - (mResourceMask & DASHBOARD) == DASHBOARD || (mResourceMask & ALL) == ALL; - if (includeDashboard) { - types.add("dashboard"); - } - boolean includeLegacyDashboard = - (mResourceMask & LEGACY_DASHBOARD) == LEGACY_DASHBOARD || (mResourceMask & ALL) == ALL; - if (includeLegacyDashboard) { - types.add("legacyDashboard"); - } - - if (!types.isEmpty()) { - params.put("type", types); - } - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index c8374fd5..4af9f61b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -56,7 +56,7 @@ public SearchUseCase( @NonNull public SearchResult performSearch(@NonNull InternalCriteria criteria) { - ResourceSearchResult response = mRestApi.searchResources(mTokenProvider.provideToken(), criteria.toMap()); + ResourceSearchResult response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); SearchResult searchResult = new SearchResult(); diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java new file mode 100644 index 00000000..a5b0e829 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java @@ -0,0 +1,199 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class CriteriaMapperTest { + + @Test + public void shouldIncludeCountInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .limit(101) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("limit", "101"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIncludeOffsetInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .offset(100) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("offset", "100"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIncludeRecursiveInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .recursive(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("recursive", "true"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIncludeForceFullPageInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .forceFullPage(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("forceFullPage", "true"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIncludeForceTotalCountPageInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .forceTotalCount(true) + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("forceTotalCount", "true"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIncludeQueryPageInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .query("any") + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("q", "any"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIncludeFolderUriInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .folderUri("/") + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("folderUri", "/"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIncludeSortByInParams() { + InternalCriteria criteria = InternalCriteria.builder() + .sortBy("description") + .create(); + + Map resultMap = new HashMap<>(); + resultMap.put("sortBy", "description"); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldIgnoreEmptyQuery() { + InternalCriteria criteria = InternalCriteria.builder() + .query("") + .create(); + + Map emptytMap = new HashMap<>(); + assertThat(toMap(criteria), is(emptytMap)); + } + + @Test + @Parameters({ + "REPORT|reportUnit", + "DASHBOARD|dashboard", + "LEGACY_DASHBOARD|legacyDashboard", + "ALL|reportUnit:dashboard:legacyDashboard", + "REPORT:DASHBOARD|reportUnit:dashboard", + }) + public void criteriaShouldIncludeTypeInParams(String flags, String types) throws Exception { + int mask = 0; + if (flags.contains(":")) { + for (String flag : flags.split(":")) { + mask |= (Integer) SearchCriteria.class.getField(flag).get(null); + } + } else { + mask = (Integer) SearchCriteria.class.getField(flags).get(null); + } + + InternalCriteria criteria = InternalCriteria.builder() + .resourceMask(mask) + .create(); + + Map resultMap = new HashMap<>(); + Set typeSet = new HashSet<>(); + if (types.contains(":")) { + typeSet.addAll(Arrays.asList(types.split(":"))); + } else { + typeSet.add(types); + } + resultMap.put("type", typeSet); + + assertThat(toMap(criteria), is(resultMap)); + } + + @Test + public void shouldReturnEmptyParamsIfNoSupplied() { + InternalCriteria criteria = InternalCriteria.builder().create(); + Map resultMap = new HashMap<>(); + assertThat(toMap(criteria), is(resultMap)); + } + + private Map toMap(InternalCriteria criteria) { + return CriteriaMapper.map(criteria); + } +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java index 1fc5ea35..e514fd0d 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java @@ -27,14 +27,7 @@ import org.junit.Test; import org.junit.runner.RunWith; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - import junitparams.JUnitParamsRunner; -import junitparams.Parameters; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -46,141 +39,6 @@ @RunWith(JUnitParamsRunner.class) public class InternalSearchCriteriaTest { - @Test - public void shouldIncludeCountInParams() { - InternalCriteria criteria = InternalCriteria.builder() - .limit(101) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("limit", "101"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeOffsetInParams() { - InternalCriteria criteria = InternalCriteria.builder() - .offset(100) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("offset", "100"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeRecursiveInParams() { - InternalCriteria criteria = InternalCriteria.builder() - .recursive(true) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("recursive", "true"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeForceFullPageInParams() { - InternalCriteria criteria = InternalCriteria.builder() - .forceFullPage(true) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("forceFullPage", "true"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeForceTotalCountPageInParams() { - InternalCriteria criteria = InternalCriteria.builder() - .forceTotalCount(true) - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("forceTotalCount", "true"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeQueryPageInParams() { - InternalCriteria criteria = InternalCriteria.builder() - .query("any") - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("q", "any"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIncludeFolderUriInParams() { - InternalCriteria criteria = InternalCriteria.builder() - .folderUri("/") - .create(); - - Map resultMap = new HashMap<>(); - resultMap.put("folderUri", "/"); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldIgnoreEmptyQuery() { - InternalCriteria criteria = InternalCriteria.builder() - .query("") - .create(); - - Map emptytMap = new HashMap<>(); - assertThat(criteria.toMap(), is(emptytMap)); - } - - @Test - @Parameters({ - "REPORT|reportUnit", - "DASHBOARD|dashboard", - "LEGACY_DASHBOARD|legacyDashboard", - "ALL|reportUnit:dashboard:legacyDashboard", - "REPORT:DASHBOARD|reportUnit:dashboard", - }) - public void criteriaShouldIncludeTypeInParams(String flags, String types) throws Exception { - int mask = 0; - if (flags.contains(":")) { - for (String flag : flags.split(":")) { - mask |= (Integer) SearchCriteria.class.getField(flag).get(null); - } - } else { - mask = (Integer) SearchCriteria.class.getField(flags).get(null); - } - - InternalCriteria criteria = InternalCriteria.builder() - .resourceMask(mask) - .create(); - - Map resultMap = new HashMap<>(); - Set typeSet = new HashSet<>(); - if (types.contains(":")) { - typeSet.addAll(Arrays.asList(types.split(":"))); - } else { - typeSet.add(types); - } - resultMap.put("type", typeSet); - - assertThat(criteria.toMap(), is(resultMap)); - } - - @Test - public void shouldReturnEmptyParamsIfNoSupplied() { - InternalCriteria criteria = InternalCriteria.builder().create(); - Map resultMap = new HashMap<>(); - assertThat(criteria.toMap(), is(resultMap)); - } - @Test public void newBuilderShouldCopyCount() { InternalCriteria searchCriteria = InternalCriteria.builder() From e5d27ba9bb1dd76cce86fd978bd79304c673e63b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 26 Oct 2015 18:08:59 +0200 Subject: [PATCH 237/457] Make explicit mutation of search criteria params --- .../sdk/service/repository/CriteriaMapper.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java index f29e6491..5fdcedcb 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java @@ -53,15 +53,19 @@ public static Map map(InternalCriteria criteria) { if (criteria.getLimit() != DEFAULT_LIMIT) { params.put("limit", String.valueOf(criteria.getLimit())); } + if (criteria.getOffset() != DEFAULT_OFFSET) { params.put("offset", String.valueOf(criteria.getOffset())); } + if (criteria.getRecursive() != null) { params.put("recursive", String.valueOf(criteria.getRecursive())); } + if (criteria.getForceFullPage() != null) { params.put("forceFullPage", String.valueOf(criteria.getForceFullPage())); } + if (criteria.getForceTotalCount() != null) { params.put("forceTotalCount", String.valueOf(criteria.getForceTotalCount())); } @@ -70,19 +74,25 @@ public static Map map(InternalCriteria criteria) { if (query != null && query.length() > 0) { params.put("q", query); } + if (criteria.getSortBy() != null) { params.put("sortBy", criteria.getSortBy()); } + if (criteria.getFolderUri() != null) { params.put("folderUri", criteria.getFolderUri()); } - populateTypes(criteria, params); + Set types = populateTypes(criteria); + if (!types.isEmpty()) { + + params.put("type", types); + } return params; } - private static void populateTypes(InternalCriteria criteria, Map params) { + private static Set populateTypes(InternalCriteria criteria) { Set types = new HashSet<>(); int resourceMask = criteria.getResourceMask(); @@ -102,8 +112,6 @@ private static void populateTypes(InternalCriteria criteria, Map types.add("legacyDashboard"); } - if (!types.isEmpty()) { - params.put("type", types); - } + return types; } } From 21581f80608ddeb499c4c0db89e77f2eee947ee0 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 27 Oct 2015 13:29:20 +0200 Subject: [PATCH 238/457] Introduce report execution and export interactors --- .../sdk/service/report/ReportAttachment.java | 15 +--- .../sdk/service/report/ReportExecution.java | 83 ++++++++----------- .../report/ReportExecutionUseCase.java | 68 +++++++++++++++ .../sdk/service/report/ReportExport.java | 15 +--- .../service/report/ReportExportUseCase.java | 77 +++++++++++++++++ .../sdk/service/report/ReportService.java | 49 +++++------ .../service/report/ReportAttachmentTest.java | 6 +- .../service/report/ReportExecutionTest.java | 14 ++-- .../sdk/service/report/ReportExportTest.java | 4 +- .../sdk/service/report/ReportServiceTest.java | 17 ++-- 10 files changed, 227 insertions(+), 121 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index 7e0ce19b..c69ac4ab 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -25,9 +25,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; /** * @author Tom Koptel @@ -38,26 +36,21 @@ public final class ReportAttachment { private final String mExecutionId; private final String mExportId; - private final ReportExportRestApi mExportApi; - private final TokenProvider mTokenProvider; + private final ReportExportUseCase mExportUseCase; ReportAttachment(String fileName, String executionId, String exportId, - TokenProvider tokenProvider, - ReportExportRestApi exportApi) { + ReportExportUseCase exportUseCase) { mFileName = fileName; mExecutionId = executionId; mExportId = exportId; - - mTokenProvider = tokenProvider; - mExportApi = exportApi; + mExportUseCase = exportUseCase; } @NonNull public OutputResource download() { - return mExportApi.requestExportAttachment( - mTokenProvider.provideToken(), + return mExportUseCase.requestExportAttachmentOutput( mExecutionId, mExportId, mFileName); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 82c5154e..b60a3cf7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -25,16 +25,12 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; -import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.AttachmentDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import java.util.ArrayList; @@ -47,26 +43,25 @@ */ public final class ReportExecution { private final long mDelay; - private final ReportExecutionRestApi mExecutionApi; - private final ReportExportRestApi mExportApi; - private final TokenProvider mTokenProvider; - private final ReportExecutionDescriptor mState; - private final ExecutionOptionsDataMapper mExecutionOptionsMapper; - - public ReportExecution(long delay, - ReportExecutionRestApi executionApi, - ReportExportRestApi exportApi, - TokenProvider tokenProvider, - ExecutionOptionsDataMapper executionOptionsMapper, - ReportExecutionDescriptor state) { + + private final ReportExecutionUseCase mExecutionUseCase; + private final ReportExportUseCase mExportUseCase; + + private final String mExecutionId; + private final String mReportUri; + + @VisibleForTesting + ReportExecution(long delay, + ReportExecutionUseCase executionUseCase, + ReportExportUseCase exportUseCase, + ReportExecutionDescriptor state) { mDelay = delay; - mExecutionApi = executionApi; - mExportApi = exportApi; - mTokenProvider = tokenProvider; - mExecutionOptionsMapper = executionOptionsMapper; - mState = state; - } + mExecutionUseCase = executionUseCase; + mExportUseCase = exportUseCase; + mExecutionId = state.getExecutionId(); + mReportUri = state.getReportURI(); + } @NonNull public ReportMetadata waitForReportCompletion() { @@ -102,37 +97,28 @@ private ReportExport performExport(RunExportCriteria criteria) { ExportExecutionDescriptor exportDetails = runExport(criteria); waitForExportReadyStatus(exportDetails); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); - return createExport(currentDetails, exportDetails); } - @NonNull - private ReportExecutionDescriptor requestExecutionDetails() { - return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), mState.getExecutionId()); - } private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) { final String exportId = exportDetails.getExportId(); - final String executionId = mState.getExecutionId(); - final String reportUri = mState.getReportURI(); Status status = Status.wrap(exportDetails.getStatus()); while (!status.isReady()) { if (status.isCancelled()) { - throw ExecutionException.exportCancelled(reportUri); + throw ExecutionException.exportCancelled(mReportUri); } if (status.isFailed()) { - throw ExecutionException.exportFailed(reportUri); + throw ExecutionException.exportFailed(mReportUri); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw ExecutionException.exportFailed(reportUri, ex); + throw ExecutionException.exportFailed(mReportUri, ex); } - ExecutionStatus exportStatus = mExportApi - .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); - status = Status.wrap(exportStatus.getStatus()); + status = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); } } @@ -141,23 +127,23 @@ private ReportExport createExport(ReportExecutionDescriptor currentDetails, ExportExecutionDescriptor exportDetails) { ExportDescriptor export = findExportDescriptor(currentDetails, exportDetails.getExportId()); if (export == null) { - throw ExecutionException.exportFailed(mState.getReportURI()); + throw ExecutionException.exportFailed(mReportUri); } String executionId = currentDetails.getExecutionId(); String exportId = exportDetails.getExportId(); Collection attachments = adaptAttachments(export); - return new ReportExport(executionId, exportId, attachments, mTokenProvider, mExportApi); + return new ReportExport(executionId, exportId, attachments, mExportUseCase); } + @NonNull private Collection adaptAttachments(ExportDescriptor export) { - String executionId = mState.getExecutionId(); String exportId = export.getId(); Set rawAttachments = export.getAttachments(); Collection attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { ReportAttachment reportAttachment = new ReportAttachment( - attachment.getFileName(), executionId, exportId, mTokenProvider, mExportApi); + attachment.getFileName(), mExecutionId, exportId, mExportUseCase); attachments.add(reportAttachment); } return attachments; @@ -175,39 +161,42 @@ private ExportDescriptor findExportDescriptor(ReportExecutionDescriptor currentD @NonNull private ExportExecutionDescriptor runExport(RunExportCriteria criteria) { - ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); - return mExportApi.runExportExecution(mTokenProvider.provideToken(), mState.getExecutionId(), options); + return mExportUseCase.runExport(mExecutionId, criteria); } @NonNull private ReportMetadata performAwaitFoReport() { ReportExecutionDescriptor details = requestExecutionDetails(); ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); - return new ReportMetadata(completeDetails.getReportURI(), + return new ReportMetadata(mReportUri, completeDetails.getTotalPages()); } @NonNull private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) { - String reportUri = details.getReportURI(); Status status = Status.wrap(details.getStatus()); ReportExecutionDescriptor resultDetails = details; while (!status.isReady()) { if (status.isCancelled()) { - throw ExecutionException.reportCancelled(reportUri); + throw ExecutionException.reportCancelled(mReportUri); } if (status.isFailed()) { - throw ExecutionException.reportFailed(reportUri); + throw ExecutionException.reportFailed(mReportUri); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw ExecutionException.reportFailed(reportUri, ex); + throw ExecutionException.reportFailed(mReportUri, ex); } resultDetails = requestExecutionDetails(); status = Status.wrap(details.getStatus()); } return resultDetails; } + + @NonNull + private ReportExecutionDescriptor requestExecutionDetails() { + return mExecutionUseCase.requestExecutionDetails(mExecutionId); + } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java new file mode 100644 index 00000000..2f095e9f --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExecutionUseCase { + private final ReportExecutionRestApi mExecutionApi; + private final TokenProvider mTokenProvider; + private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + + ReportExecutionUseCase(ReportExecutionRestApi executionApi, + TokenProvider tokenProvider, + ExecutionOptionsDataMapper executionOptionsMapper) { + mExecutionApi = executionApi; + mTokenProvider = tokenProvider; + mExecutionOptionsMapper = executionOptionsMapper; + } + + @NonNull + public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) { + ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); + return mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); + } + + @NonNull + public Status requestStatus(String executionId) { + ExecutionStatus executionStatus = mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); + return Status.wrap(executionStatus.getStatus()); + } + + @NonNull + public ReportExecutionDescriptor requestExecutionDetails(String executionId) { + return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), executionId); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 153ad690..5adea865 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -25,9 +25,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import java.util.Collection; @@ -39,21 +37,16 @@ public final class ReportExport { private final Collection mAttachments; private final String mExecutionId; private final String mExportId; - - private final ReportExportRestApi mExportApi; - private final TokenProvider mTokenProvider; + private final ReportExportUseCase mExportUseCase; ReportExport(String executionId, String exportId, Collection attachments, - TokenProvider tokenProvider, - ReportExportRestApi exportApi) { + ReportExportUseCase exportUseCase) { mExecutionId = executionId; mExportId = exportId; mAttachments = attachments; - - mTokenProvider = tokenProvider; - mExportApi = exportApi; + mExportUseCase = exportUseCase; } @NonNull @@ -63,6 +56,6 @@ public Collection getAttachments() { @NonNull public ExportOutputResource download() { - return mExportApi.requestExportOutput(mTokenProvider.provideToken(), mExecutionId, mExportId); + return mExportUseCase.requestExportOutput(mExecutionId, mExportId); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java new file mode 100644 index 00000000..95ffae1e --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; + +import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExportUseCase { + private final ReportExportRestApi mExportApi; + private final TokenProvider mTokenProvider; + private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + + ReportExportUseCase(ReportExportRestApi exportApi, TokenProvider tokenProvider, + ExecutionOptionsDataMapper executionOptionsMapper) { + mExportApi = exportApi; + mTokenProvider = tokenProvider; + mExecutionOptionsMapper = executionOptionsMapper; + } + + @NonNull + public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) { + ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); + return mExportApi.runExportExecution(mTokenProvider.provideToken(), executionId, options); + } + + @NonNull + public Status checkExportExecutionStatus(String executionId, String exportId) { + ExecutionStatus exportStatus = mExportApi + .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); + return Status.wrap(exportStatus.getStatus()); + } + + @NonNull + public ExportOutputResource requestExportOutput(String executionId, String exportId) { + return mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); + } + + @NonNull + public OutputResource requestExportAttachmentOutput(String executionId, String exportId, String fileName) { + return mExportApi.requestExportAttachment( + mTokenProvider.provideToken(), + executionId, exportId, fileName); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index be023134..2c871cb5 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -28,9 +28,7 @@ import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; @@ -41,24 +39,19 @@ * @since 2.0 */ public class ReportService { - private final ReportExecutionRestApi mExecutionApi; - private final ReportExportRestApi mExportApi; - private final TokenProvider mTokenProvider; - private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + + private final ReportExecutionUseCase mExecutionUseCase; + private final ReportExportUseCase mExportUseCase; private final long mDelay; @VisibleForTesting ReportService( - long delay, - ReportExecutionRestApi executionApi, - ReportExportRestApi exportApi, - TokenProvider tokenProvider, - ExecutionOptionsDataMapper executionOptionsMapper) { + long delay, + ReportExecutionUseCase executionUseCase, + ReportExportUseCase exportUseCase) { mDelay = delay; - mExecutionApi = executionApi; - mExportApi = exportApi; - mTokenProvider = tokenProvider; - mExecutionOptionsMapper = executionOptionsMapper; + mExecutionUseCase = executionUseCase; + mExportUseCase = exportUseCase; } public static ReportService create(TokenProvider tokenProvider, InfoProvider infoProvider) { @@ -71,12 +64,15 @@ public static ReportService create(TokenProvider tokenProvider, InfoProvider inf .build(); ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(baseUrl); + ReportExecutionUseCase reportExecutionUseCase = + new ReportExecutionUseCase(executionApi, tokenProvider, executionOptionsMapper); + ReportExportUseCase reportExportUseCase = + new ReportExportUseCase(exportApi, tokenProvider, executionOptionsMapper); + return new ReportService( TimeUnit.SECONDS.toMillis(1), - executionApi, - exportApi, - tokenProvider, - executionOptionsMapper); + reportExecutionUseCase, + reportExportUseCase); } public ReportExecution run(String reportUri, RunReportCriteria criteria) { @@ -89,17 +85,14 @@ public ReportExecution run(String reportUri, RunReportCriteria criteria) { @NonNull private ReportExecution performRun(String reportUri, RunReportCriteria criteria) { - ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); - ReportExecutionDescriptor details = mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); + ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); waitForReportExecutionStart(reportUri, details); return new ReportExecution( TimeUnit.SECONDS.toMillis(2), - mExecutionApi, - mExportApi, - mTokenProvider, - mExecutionOptionsMapper, + mExecutionUseCase, + mExportUseCase, details); } @@ -119,11 +112,7 @@ private void waitForReportExecutionStart(String reportUri, ReportExecutionDescri } catch (InterruptedException ex) { throw ExecutionException.reportFailed(reportUri, ex); } - status = Status.wrap(requestStatus(executionId).getStatus()); + status = mExecutionUseCase.requestStatus(executionId); } } - - private ExecutionStatus requestStatus(String executionId) { - return mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); - } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 44eb0323..fae60750 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -40,9 +40,11 @@ public class ReportAttachmentTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn("cookie"); - objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", mTokenProvider, mExportRestApi); + + ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); + objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", exportUseCase); } @Test diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 91da3b38..9c3d6ddc 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -68,10 +68,6 @@ public class ReportExecutionTest { @Mock TokenProvider mTokenProvider; - @Mock - ExecutionOptionsDataMapper mapper; - - private ReportExecution objectUnderTest; @@ -86,12 +82,13 @@ public void setUp() throws Exception { when(mExecDetails.getExecutionId()).thenReturn("execution_id"); when(mExecDetails.getReportURI()).thenReturn("/report/uri"); + ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); + ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(mExecutionRestApi, mTokenProvider, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); objectUnderTest = new ReportExecution( TimeUnit.SECONDS.toMillis(0), - mExecutionRestApi, - mExportRestApi, - mTokenProvider, - mapper, + reportExecutionUseCase, + exportUseCase, mExecDetails); } @@ -102,7 +99,6 @@ public void testRequestExportIdealCase() throws Exception { objectUnderTest.export(exportCriteria); - verify(mapper).transformExportOptions(exportCriteria); verify(mExportRestApi).runExportExecution(eq("cookie"), eq("execution_id"), any(ExecutionRequestOptions.class)); verify(mExecutionRestApi).requestReportExecutionDetails(eq("cookie"), eq("execution_id")); } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 1129859c..17785cf4 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -31,7 +31,9 @@ public class ReportExportTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), mTokenProvider, mExportRestApi); + ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); + objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), exportUseCase); } @Test diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index daf31623..4a2b2cf3 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -61,20 +61,18 @@ public class ReportServiceTest { @Rule public ExpectedException mException = ExpectedException.none(); - @Mock - ExecutionOptionsDataMapper mapper; - @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); + + ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); + ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, mTokenProvider, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(exportApi, mTokenProvider, executionOptionsDataMapper); + objectUnderTest = new ReportService( TimeUnit.MILLISECONDS.toMillis(0), - executionApi, - exportApi, - mTokenProvider, - mapper - ); - + reportExecutionUseCase, + exportUseCase); } @Test @@ -85,7 +83,6 @@ public void testRunShouldCreateActiveSession() { ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); - verify(mapper).transformRunReportOptions("/report/uri", configuration); verify(executionApi).runReportExecution(anyString(), any(ReportExecutionRequestOptions.class)); verifyNoMoreInteractions(executionApi); } From e68636dcd13e76c2f9f1725645fba36d4ff5c0e1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 27 Oct 2015 13:44:27 +0200 Subject: [PATCH 239/457] Introduce ExportFactory --- .../sdk/service/report/ExportFactory.java | 89 +++++++++++++++++++ .../sdk/service/report/ReportExecution.java | 76 ++++------------ 2 files changed, 106 insertions(+), 59 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java new file mode 100644 index 00000000..35109ad7 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.jaspersoft.android.sdk.network.entity.execution.AttachmentDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ExportFactory { + private final ReportExportUseCase mExportUseCase; + + private final String mExecutionId; + private final String mReportUri; + + ExportFactory(ReportExportUseCase exportUseCase, String executionId, String reportUri) { + mExportUseCase = exportUseCase; + mExecutionId = executionId; + mReportUri = reportUri; + } + + @NonNull + public ReportExport create(ReportExecutionDescriptor executionDetails, + ExportExecutionDescriptor exportExecutionDetails) { + String exportId = exportExecutionDetails.getExportId(); + ExportDescriptor export = findExportDescriptor(executionDetails, exportId); + if (export == null) { + throw ExecutionException.exportFailed(mReportUri); + } + Collection attachments = adaptAttachments(export); + return new ReportExport(mExecutionId, exportId, attachments, mExportUseCase); + } + + @NonNull + private Collection adaptAttachments(ExportDescriptor export) { + String exportId = export.getId(); + Set rawAttachments = export.getAttachments(); + Collection attachments = new ArrayList<>(rawAttachments.size()); + for (AttachmentDescriptor attachment : rawAttachments) { + ReportAttachment reportAttachment = new ReportAttachment( + attachment.getFileName(), mExecutionId, exportId, mExportUseCase); + attachments.add(reportAttachment); + } + return attachments; + } + + @Nullable + private ExportDescriptor findExportDescriptor(ReportExecutionDescriptor executionDetails, String exportId) { + for (ExportDescriptor export : executionDetails.getExports()) { + if (exportId.equals(export.getId())) { + return export; + } + } + return null; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index b60a3cf7..5ac0278f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -24,19 +24,12 @@ package com.jaspersoft.android.sdk.service.report; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; -import com.jaspersoft.android.sdk.network.entity.execution.AttachmentDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; - /** * @author Tom Koptel * @since 2.0 @@ -49,6 +42,7 @@ public final class ReportExecution { private final String mExecutionId; private final String mReportUri; + private final ExportFactory mExportFactory; @VisibleForTesting ReportExecution(long delay, @@ -61,6 +55,8 @@ public final class ReportExecution { mExecutionId = state.getExecutionId(); mReportUri = state.getReportURI(); + + mExportFactory = new ExportFactory(exportUseCase, mExecutionId, mReportUri); } @NonNull @@ -92,15 +88,22 @@ public ReportExport export(RunExportCriteria criteria) { } } + @NonNull + private ReportMetadata performAwaitFoReport() { + ReportExecutionDescriptor details = requestExecutionDetails(); + ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); + return new ReportMetadata(mReportUri, + completeDetails.getTotalPages()); + } + @NonNull private ReportExport performExport(RunExportCriteria criteria) { ExportExecutionDescriptor exportDetails = runExport(criteria); waitForExportReadyStatus(exportDetails); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); - return createExport(currentDetails, exportDetails); + return mExportFactory.create(currentDetails, exportDetails); } - private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) { final String exportId = exportDetails.getExportId(); @@ -122,56 +125,6 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) { } } - @NonNull - private ReportExport createExport(ReportExecutionDescriptor currentDetails, - ExportExecutionDescriptor exportDetails) { - ExportDescriptor export = findExportDescriptor(currentDetails, exportDetails.getExportId()); - if (export == null) { - throw ExecutionException.exportFailed(mReportUri); - } - - String executionId = currentDetails.getExecutionId(); - String exportId = exportDetails.getExportId(); - Collection attachments = adaptAttachments(export); - return new ReportExport(executionId, exportId, attachments, mExportUseCase); - } - - @NonNull - private Collection adaptAttachments(ExportDescriptor export) { - String exportId = export.getId(); - Set rawAttachments = export.getAttachments(); - Collection attachments = new ArrayList<>(rawAttachments.size()); - for (AttachmentDescriptor attachment : rawAttachments) { - ReportAttachment reportAttachment = new ReportAttachment( - attachment.getFileName(), mExecutionId, exportId, mExportUseCase); - attachments.add(reportAttachment); - } - return attachments; - } - - @Nullable - private ExportDescriptor findExportDescriptor(ReportExecutionDescriptor currentDetails, String exportId) { - for (ExportDescriptor export : currentDetails.getExports()) { - if (exportId.equals(export.getId())) { - return export; - } - } - return null; - } - - @NonNull - private ExportExecutionDescriptor runExport(RunExportCriteria criteria) { - return mExportUseCase.runExport(mExecutionId, criteria); - } - - @NonNull - private ReportMetadata performAwaitFoReport() { - ReportExecutionDescriptor details = requestExecutionDetails(); - ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); - return new ReportMetadata(mReportUri, - completeDetails.getTotalPages()); - } - @NonNull private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) { Status status = Status.wrap(details.getStatus()); @@ -195,6 +148,11 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD return resultDetails; } + @NonNull + private ExportExecutionDescriptor runExport(RunExportCriteria criteria) { + return mExportUseCase.runExport(mExecutionId, criteria); + } + @NonNull private ReportExecutionDescriptor requestExecutionDetails() { return mExecutionUseCase.requestExecutionDetails(mExecutionId); From 84e458bd0e12a2713959684f00098826399f56e8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 27 Oct 2015 14:55:21 +0200 Subject: [PATCH 240/457] Introducing ResourceOutput/ResourceOutput --- .../sdk/service/data/report/ReportOutput.java | 34 ++++++++++ .../service/data/report/ResourceOutput.java | 36 ++++++++++ .../sdk/service/report/OutputDataMapper.java | 67 +++++++++++++++++++ .../sdk/service/report/ReportAttachment.java | 4 +- .../sdk/service/report/ReportExport.java | 4 +- .../service/report/ReportExportUseCase.java | 12 ++-- .../service/report/ReportAttachmentTest.java | 3 +- 7 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java new file mode 100644 index 00000000..4e8ac5bd --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ReportOutput extends ResourceOutput { + boolean isFinal(); + String getPages(); +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java new file mode 100644 index 00000000..3be0ce34 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.report; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface ResourceOutput { + InputStream getStream() throws IOException; +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java new file mode 100644 index 00000000..d1804c5f --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.ReportOutput; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class OutputDataMapper { + public static ReportOutput transform(final ExportOutputResource outputResource) { + return new ReportOutput() { + @Override + public boolean isFinal() { + return outputResource.isFinal(); + } + + @Override + public String getPages() { + return outputResource.getPages(); + } + + @Override + public InputStream getStream() throws IOException { + return outputResource.getOutputResource().getStream(); + } + }; + } + + public static ResourceOutput transform(final OutputResource resource) { + return new ResourceOutput() { + @Override + public InputStream getStream() throws IOException { + return resource.getStream(); + } + }; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index c69ac4ab..d4c04f91 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -25,7 +25,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; /** * @author Tom Koptel @@ -49,7 +49,7 @@ public final class ReportAttachment { } @NonNull - public OutputResource download() { + public ResourceOutput download() { return mExportUseCase.requestExportAttachmentOutput( mExecutionId, mExportId, mFileName); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 5adea865..8a6f7474 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -25,7 +25,7 @@ import android.support.annotation.NonNull; -import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import java.util.Collection; @@ -55,7 +55,7 @@ public Collection getAttachments() { } @NonNull - public ExportOutputResource download() { + public ReportOutput download() { return mExportUseCase.requestExportOutput(mExecutionId, mExportId); } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 95ffae1e..0a93c74d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -33,6 +33,8 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.report.ReportOutput; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; /** * @author Tom Koptel @@ -64,14 +66,16 @@ public Status checkExportExecutionStatus(String executionId, String exportId) { } @NonNull - public ExportOutputResource requestExportOutput(String executionId, String exportId) { - return mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); + public ReportOutput requestExportOutput(String executionId, String exportId) { + ExportOutputResource result = mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); + return OutputDataMapper.transform(result); } @NonNull - public OutputResource requestExportAttachmentOutput(String executionId, String exportId, String fileName) { - return mExportApi.requestExportAttachment( + public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, String fileName) { + OutputResource result = mExportApi.requestExportAttachment( mTokenProvider.provideToken(), executionId, exportId, fileName); + return OutputDataMapper.transform(result); } } diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index fae60750..0f6eb8c6 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -3,6 +3,7 @@ import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import org.junit.Before; import org.junit.Test; @@ -51,7 +52,7 @@ public void setUp() throws Exception { public void testDownload() throws Exception { when(mExportRestApi.requestExportAttachment(anyString(), anyString(), anyString(), anyString())).thenReturn(input); - OutputResource result = objectUnderTest.download(); + ResourceOutput result = objectUnderTest.download(); assertThat(result, is(notNullValue())); verify(mExportRestApi).requestExportAttachment(eq("cookie"), eq("exec_id"), eq("export_id"), eq("1.jpg")); From 473856e3bd8f77dd3bb680a1aa95f4619b47d831 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 27 Oct 2015 15:00:59 +0200 Subject: [PATCH 241/457] Enforcing final keyword on report module --- .../android/sdk/service/data/report/ReportMetadata.java | 2 +- .../jaspersoft/android/sdk/service/report/ReportService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java index 1cd57afc..c899056a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public class ReportMetadata { +public final class ReportMetadata { private final String uri; private final int totalPages; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 2c871cb5..4f62313e 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -38,7 +38,7 @@ * @author Tom Koptel * @since 2.0 */ -public class ReportService { +public final class ReportService { private final ReportExecutionUseCase mExecutionUseCase; private final ReportExportUseCase mExportUseCase; From 30810669060b1a2854e252fd29710921e342c36c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 27 Oct 2015 15:16:01 +0200 Subject: [PATCH 242/457] Removed explicit dependency on execution details --- .../android/sdk/service/report/ReportExecution.java | 7 ++++--- .../android/sdk/service/report/ReportService.java | 5 +++-- .../android/sdk/service/report/ReportExecutionTest.java | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 5ac0278f..422de4fc 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -48,13 +48,14 @@ public final class ReportExecution { ReportExecution(long delay, ReportExecutionUseCase executionUseCase, ReportExportUseCase exportUseCase, - ReportExecutionDescriptor state) { + String executionId, + String reportUri) { mDelay = delay; mExecutionUseCase = executionUseCase; mExportUseCase = exportUseCase; - mExecutionId = state.getExecutionId(); - mReportUri = state.getReportURI(); + mExecutionId = executionId; + mReportUri = reportUri; mExportFactory = new ExportFactory(exportUseCase, mExecutionId, mReportUri); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 4f62313e..2468eac8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -90,10 +90,11 @@ private ReportExecution performRun(String reportUri, RunReportCriteria criteria) waitForReportExecutionStart(reportUri, details); return new ReportExecution( - TimeUnit.SECONDS.toMillis(2), + mDelay, mExecutionUseCase, mExportUseCase, - details); + details.getExecutionId(), + details.getReportURI()); } private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) { diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 9c3d6ddc..712d9f97 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -82,14 +82,15 @@ public void setUp() throws Exception { when(mExecDetails.getExecutionId()).thenReturn("execution_id"); when(mExecDetails.getReportURI()).thenReturn("/report/uri"); - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); + ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/report/uri"); ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(mExecutionRestApi, mTokenProvider, executionOptionsDataMapper); ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); objectUnderTest = new ReportExecution( TimeUnit.SECONDS.toMillis(0), reportExecutionUseCase, exportUseCase, - mExecDetails); + "execution_id", + "/report/uri"); } @Test @@ -170,7 +171,6 @@ public void ensureThatExportCancelledEventWillBeResolved() { @Test public void testAwaitCompleteReport() throws Exception { - when(mExecDetails.getReportURI()).thenReturn("/report/uri"); when(mExecDetails.getTotalPages()).thenReturn(100); mockReportExecutionDetails("ready"); From 7af9ca16d30323f876b408793a7806a1d68b95b4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 28 Oct 2015 14:26:06 +0200 Subject: [PATCH 243/457] Introducing PageRange for ReportOutput API --- .../sdk/service/data/report/PageRange.java | 65 +++++++++++++++ .../sdk/service/data/report/ReportOutput.java | 2 +- .../sdk/service/report/OutputDataMapper.java | 5 +- .../sdk/service/data/PageRangeTest.java | 82 +++++++++++++++++++ 4 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java create mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java new file mode 100644 index 00000000..6bb66aa6 --- /dev/null +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class PageRange { + private final int mLowerBound; + private final int mUpperBound; + + public PageRange(String rawRange) { + mLowerBound = parseLowerBound(rawRange); + mUpperBound = parseUpperBound(rawRange); + } + + public int getLowerBound() { + return mLowerBound; + } + + public int getUpperBound() { + return mUpperBound; + } + + public boolean isRange() { + return mUpperBound != Integer.MAX_VALUE; + } + + private int parseLowerBound(String rawRange) { + String[] split = rawRange.split("-"); + return Integer.parseInt(split[0]); + } + + private int parseUpperBound(String rawRange) { + String[] split = rawRange.split("-"); + if (split.length == 1) { + return Integer.MAX_VALUE; + } + + return Integer.parseInt(split[1]); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java index 4e8ac5bd..0a66007c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java @@ -30,5 +30,5 @@ */ public interface ReportOutput extends ResourceOutput { boolean isFinal(); - String getPages(); + PageRange getPages(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java index d1804c5f..923861fb 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.PageRange; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; @@ -45,8 +46,8 @@ public boolean isFinal() { } @Override - public String getPages() { - return outputResource.getPages(); + public PageRange getPages() { + return new PageRange(outputResource.getPages()); } @Override diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java new file mode 100644 index 00000000..bfad7f78 --- /dev/null +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data; + +import com.jaspersoft.android.sdk.service.data.report.PageRange; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class PageRangeTest { + @Rule + public ExpectedException mExpectedException = ExpectedException.none(); + + @Test + public void shouldParseRange() { + PageRange pageRange = new PageRange("1-10"); + assertThat(pageRange.getLowerBound(), is(1)); + assertThat(pageRange.getUpperBound(), is(10)); + } + + @Test + public void upperBoundUndefinedIfMissing() { + PageRange pageRange = new PageRange("1"); + assertThat(pageRange.getLowerBound(), is(1)); + assertThat(pageRange.getUpperBound(), is(Integer.MAX_VALUE)); + } + + @Test + public void shouldNotBeRangeIfUpperBoundIsMissing() { + PageRange pageRange = new PageRange("1"); + assertThat(pageRange.isRange(), is(false)); + } + + @Test + public void shouldNotBeRangeIfHasUpperBound() { + PageRange pageRange = new PageRange("1-10"); + assertThat(pageRange.isRange(), is(true)); + } + + @Test + public void throwsNumberFormatExceptionIfLowerBoundNotANumber() { + mExpectedException.expect(NumberFormatException.class); + new PageRange("q"); + } + + @Test + public void throwsNumberFormatExceptionIfUpperBoundNotANumber() { + mExpectedException.expect(NumberFormatException.class); + new PageRange("1-q"); + } +} \ No newline at end of file From 5ef58e89fe7cb0ff60cadcebbe26e1c5ab9a5aaa Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 12:47:24 +0200 Subject: [PATCH 244/457] Replace android annotations with jetbrains counterpart --- client-network/build.gradle | 2 +- .../network/api/AuthenticationRestApi.java | 17 +++---- .../api/AuthenticationRestApiImpl.java | 26 +++++------ .../sdk/network/api/InputControlRestApi.java | 28 +++++------- .../network/api/InputControlRestApiImpl.java | 27 ++++++------ .../network/api/ReportExecutionRestApi.java | 35 ++++++--------- .../api/ReportExecutionRestApiImpl.java | 38 ++++++++-------- .../sdk/network/api/ReportExportRestApi.java | 42 ++++++++---------- .../network/api/ReportExportRestApiImpl.java | 40 ++++++++--------- .../sdk/network/api/ReportOptionRestApi.java | 35 +++++++-------- .../network/api/ReportOptionRestApiImpl.java | 36 +++++++-------- .../sdk/network/api/RepositoryRestApi.java | 21 ++++----- .../network/api/RepositoryRestApiImpl.java | 22 +++++----- .../android/sdk/network/api/RestError.java | 3 +- .../sdk/network/api/ServerRestApi.java | 44 +++++++++---------- .../sdk/network/api/ServerRestApiImpl.java | 26 +++++------ .../entity/report/option/ReportOption.java | 12 ++--- .../entity/report/option/ReportOptionSet.java | 8 ++-- .../network/entity/server/EncryptionKey.java | 10 ++--- .../api/ReportExecutionRestApiTest.java | 7 ++- .../api/ReportExportRestApiTest.java | 7 ++- .../api/utils/DummyTokenProvider.java | 6 +-- client-service/build.gradle | 2 +- .../sdk/service/GreedyInfoProvider.java | 18 ++++---- .../android/sdk/service/InfoProvider.java | 12 ++--- .../android/sdk/service/Preconditions.java | 3 +- .../sdk/service/ServerInfoService.java | 6 +-- .../android/sdk/service/auth/AuthService.java | 5 +-- .../sdk/service/auth/SpringAuthService.java | 43 +++++++++--------- .../sdk/service/data/repository/Resource.java | 17 +++---- .../sdk/service/report/ExecutionCriteria.java | 4 +- .../report/ExecutionOptionsDataMapper.java | 10 ++--- .../sdk/service/report/ExportFactory.java | 10 ++--- .../sdk/service/report/ReportAttachment.java | 6 +-- .../sdk/service/report/ReportExecution.java | 21 ++++----- .../report/ReportExecutionUseCase.java | 10 ++--- .../sdk/service/report/ReportExport.java | 8 ++-- .../service/report/ReportExportUseCase.java | 12 ++--- .../sdk/service/report/ReportService.java | 10 ++--- .../sdk/service/report/RunExportCriteria.java | 6 +-- .../sdk/service/report/RunReportCriteria.java | 6 +-- .../service/repository/CriteriaMapper.java | 4 +- .../repository/EmeraldMR2SearchStrategy.java | 7 +-- .../repository/EmeraldMR3SearchStrategy.java | 10 ++--- .../service/repository/InternalCriteria.java | 10 ++--- .../service/repository/ResourceMapper.java | 11 ++--- .../service/repository/SearchCriteria.java | 8 ++-- .../sdk/service/repository/SearchTask.java | 6 +-- .../service/repository/SearchTaskImpl.java | 8 ++-- .../sdk/service/repository/SearchUseCase.java | 8 ++-- 50 files changed, 372 insertions(+), 401 deletions(-) diff --git a/client-network/build.gradle b/client-network/build.gradle index 091ab6bd..6f1328b2 100644 --- a/client-network/build.gradle +++ b/client-network/build.gradle @@ -33,7 +33,7 @@ android { } dependencies { - compile 'com.android.support:support-annotations:22.2.0' + compile 'com.intellij:annotations:12.0' compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java index 4c726ce4..52863dac 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java @@ -24,14 +24,13 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.WorkerThread; - import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Map; /** @@ -39,15 +38,13 @@ * @since 2.0 */ public interface AuthenticationRestApi { - @NonNull - @WorkerThread - String authenticate(@NonNull String username, - @NonNull String password, + @NotNull + String authenticate(@NotNull String username, + @NotNull String password, @Nullable String organization, @Nullable Map params); - @NonNull - @WorkerThread + @NotNull EncryptionKey requestEncryptionMetadata(); final class Builder extends GenericBuilder { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java index 3ce0a78b..a29b1f2b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; - import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.Call; @@ -34,6 +32,8 @@ import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; +import org.jetbrains.annotations.NotNull; + import java.io.IOException; import java.util.Map; import java.util.Set; @@ -61,12 +61,12 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { mRestAdapterBuilder = retrofit; } - @NonNull + @NotNull @Override - public String authenticate(@NonNull final String username, - @NonNull final String password, - final String organization, - final Map params) { + public String authenticate(@NotNull final String username, + @NotNull final String password, + final String organization, + final Map params) { Request request = createAuthRequest(username, password, organization, params); Call call = mClient.newCall(request); try { @@ -101,7 +101,7 @@ public String authenticate(@NonNull final String username, } } - @NonNull + @NotNull @Override public EncryptionKey requestEncryptionMetadata() { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); @@ -123,8 +123,8 @@ public EncryptionKey requestEncryptionMetadata() { } private Request createAuthRequest( - @NonNull final String username, - @NonNull final String password, + @NotNull final String username, + @NotNull final String password, final String organization, final Map params) { @@ -155,13 +155,13 @@ private Request createAuthRequest( } private interface RestApi { - @NonNull + @NotNull @Headers("Accept: text/plain") @GET("rest_v2/serverInfo/edition") retrofit.Call requestAnonymousCookie(); - @NonNull + @NotNull @GET("GetEncryptionKey") - retrofit.Call requestEncryptionMetadata(@NonNull @Header("Cookie") String cookie); + retrofit.Call requestEncryptionMetadata(@NotNull @Header("Cookie") String cookie); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java index 7e445c7b..af2e254d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java @@ -24,12 +24,11 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.WorkerThread; - import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Map; import java.util.Set; @@ -50,16 +49,14 @@ public interface InputControlRestApi { * @param excludeState exclude field state which incorporates options values for control * @return unmodifiable list of {@link InputControl} */ - @NonNull - @WorkerThread - Collection requestInputControls(@NonNull String token, - @NonNull String reportUri, + @NotNull + Collection requestInputControls(@NotNull String token, + @NotNull String reportUri, boolean excludeState); - @NonNull - @WorkerThread - Collection requestInputControlsInitialStates(@NonNull String token, - @NonNull String reportUri, + @NotNull + Collection requestInputControlsInitialStates(@NotNull String token, + @NotNull String reportUri, boolean freshData); /** @@ -71,11 +68,10 @@ Collection requestInputControlsInitialStates(@NonNull String * @param freshData whether data should be retrieved from cache or not * @return unmodifiable list of {@link InputControlState} */ - @NonNull - @WorkerThread - Collection requestInputControlsStates(@NonNull String token, - @NonNull String reportUri, - @NonNull Map> controlsValues, + @NotNull + Collection requestInputControlsStates(@NotNull String token, + @NotNull String reportUri, + @NotNull Map> controlsValues, boolean freshData); final class Builder extends GenericBuilder { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java index e2b80a90..976ec689 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java @@ -24,14 +24,15 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Collection; import java.util.Map; import java.util.Set; @@ -59,7 +60,7 @@ final class InputControlRestApiImpl implements InputControlRestApi { mRestApi = restAdapter.create(RestApi.class); } - @NonNull + @NotNull @Override public Collection requestInputControls(@Nullable String token, @Nullable String reportUri, @@ -73,7 +74,7 @@ public Collection requestInputControls(@Nullable String token, return response.get(); } - @NonNull + @NotNull @Override public Collection requestInputControlsInitialStates(@Nullable String token, @Nullable String reportUri, @@ -86,7 +87,7 @@ public Collection requestInputControlsInitialStates(@Nullable return response.get(); } - @NonNull + @NotNull @Override public Collection requestInputControlsStates(@Nullable String token, @Nullable String reportUri, @@ -103,29 +104,29 @@ public Collection requestInputControlsStates(@Nullable String } private interface RestApi { - @NonNull + @NotNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls") Call requestInputControls( - @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("exclude") String state, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls/values") Call requestInputControlsInitialValues( - @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @Query("freshData") boolean freshData, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @POST("rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") Call requestInputControlsValues( - @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @NonNull @Path(value = "controlsId", encoded = true) String ids, - @NonNull @Body Map> controlsValues, + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, + @NotNull @Path(value = "controlsId", encoded = true) String ids, + @NotNull @Body Map> controlsValues, @Query("freshData") boolean freshData, @Header("Cookie") String cookie); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java index b3997c8f..407f68ea 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java @@ -24,14 +24,13 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.WorkerThread; - import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Map; import java.util.Set; @@ -42,32 +41,26 @@ */ public interface ReportExecutionRestApi { - @NonNull - @WorkerThread - ReportExecutionDescriptor runReportExecution(@NonNull String token, @NonNull ReportExecutionRequestOptions executionOptions); + @NotNull + ReportExecutionDescriptor runReportExecution(@NotNull String token, @NotNull ReportExecutionRequestOptions executionOptions); - @NonNull - @WorkerThread - ReportExecutionDescriptor requestReportExecutionDetails(@NonNull String token, @NonNull String executionId); + @NotNull + ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String token, @NotNull String executionId); - @NonNull - @WorkerThread - ExecutionStatus requestReportExecutionStatus(@NonNull String token, @NonNull String executionId); + @NotNull + ExecutionStatus requestReportExecutionStatus(@NotNull String token, @NotNull String executionId); - @WorkerThread - boolean cancelReportExecution(@NonNull String token, @NonNull String executionId); + boolean cancelReportExecution(@NotNull String token, @NotNull String executionId); - @WorkerThread - boolean updateReportExecution(@NonNull String token, - @NonNull String executionId, - @NonNull Collection>> params); + boolean updateReportExecution(@NotNull String token, + @NotNull String executionId, + @NotNull Collection>> params); /** * TODO: API is broken requires investigation before release */ - @NonNull - @WorkerThread - ReportExecutionSearchResponse searchReportExecution(@NonNull String token, Map params); + @NotNull + ReportExecutionSearchResponse searchReportExecution(@NotNull String token, Map params); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java index d4d08d5d..e693433d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Collection; import java.util.Map; import java.util.Set; @@ -63,7 +63,7 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { mRestApi = restAdapter.create(RestApi.class); } - @NonNull + @NotNull @Override public ReportExecutionDescriptor runReportExecution(@Nullable String token, @Nullable ReportExecutionRequestOptions executionOptions) { checkNotNull(executionOptions, "Execution options should not be null"); @@ -73,7 +73,7 @@ public ReportExecutionDescriptor runReportExecution(@Nullable String token, @Nul return CallWrapper.wrap(call).body(); } - @NonNull + @NotNull @Override public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String token, @Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); @@ -83,7 +83,7 @@ public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String return CallWrapper.wrap(call).body(); } - @NonNull + @NotNull @Override public ExecutionStatus requestReportExecutionStatus(@Nullable String token, @Nullable String executionId) { checkNotNull(executionId, "Execution id should not be null"); @@ -119,7 +119,7 @@ public boolean updateReportExecution(@Nullable String token, return status == 204; } - @NonNull + @NotNull @Override public ReportExecutionSearchResponse searchReportExecution(@Nullable String token, @Nullable Map params) { checkNotNull(params, "Search params should not be null"); @@ -135,36 +135,36 @@ public ReportExecutionSearchResponse searchReportExecution(@Nullable String toke } interface RestApi { - @NonNull + @NotNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions") - Call runReportExecution(@NonNull @Body ReportExecutionRequestOptions executionOptions, + Call runReportExecution(@NotNull @Body ReportExecutionRequestOptions executionOptions, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}") - Call requestReportExecutionDetails(@NonNull @Path(value = "executionId", encoded = true) String executionId, + Call requestReportExecutionDetails(@NotNull @Path(value = "executionId", encoded = true) String executionId, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/status") - Call requestReportExecutionStatus(@NonNull @Path(value = "executionId", encoded = true) String executionId, + Call requestReportExecutionStatus(@NotNull @Path(value = "executionId", encoded = true) String executionId, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/parameters") - Call updateReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body Collection>> params, + Call updateReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, + @NotNull @Body Collection>> params, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @PUT("rest_v2/reportExecutions/{executionId}/status") - Call cancelReportExecution(@NonNull @Path(value = "executionId", encoded = true) String executionId, - @NonNull @Body ExecutionStatus statusResponse, + Call cancelReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, + @NotNull @Body ExecutionStatus statusResponse, @Header("Cookie") String cookie); @Headers("Accept: application/json") diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java index 561d1e6f..d648325a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -33,36 +31,34 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 */ public interface ReportExportRestApi { - @NonNull - @WorkerThread - ExportExecutionDescriptor runExportExecution(@NonNull String token, - @NonNull String executionId, - @NonNull ExecutionRequestOptions executionOptions); + @NotNull + ExportExecutionDescriptor runExportExecution(@NotNull String token, + @NotNull String executionId, + @NotNull ExecutionRequestOptions executionOptions); - @NonNull - @WorkerThread - ExecutionStatus checkExportExecutionStatus(@NonNull String token, - @NonNull String executionId, - @NonNull String exportId); + @NotNull + ExecutionStatus checkExportExecutionStatus(@NotNull String token, + @NotNull String executionId, + @NotNull String exportId); - @NonNull - @WorkerThread - ExportOutputResource requestExportOutput(@NonNull String token, - @NonNull String executionId, - @NonNull String exportId); + @NotNull + ExportOutputResource requestExportOutput(@NotNull String token, + @NotNull String executionId, + @NotNull String exportId); - @NonNull - @WorkerThread - OutputResource requestExportAttachment(@NonNull String token, - @NonNull String executionId, - @NonNull String exportId, - @NonNull String attachmentId); + @NotNull + OutputResource requestExportAttachment(@NotNull String token, + @NotNull String executionId, + @NotNull String exportId, + @NotNull String attachmentId); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java index 445f93a5..9387b19b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java @@ -24,9 +24,6 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; @@ -34,6 +31,9 @@ import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.squareup.okhttp.ResponseBody; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; @@ -57,7 +57,7 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { mRestApi = restAdapter.create(RestApi.class); } - @NonNull + @NotNull @Override public ExportExecutionDescriptor runExportExecution(@Nullable String token, @Nullable String executionId, @@ -70,7 +70,7 @@ public ExportExecutionDescriptor runExportExecution(@Nullable String token, return CallWrapper.wrap(call).body(); } - @NonNull + @NotNull @Override public ExecutionStatus checkExportExecutionStatus(@Nullable String token, @Nullable String executionId, @@ -83,7 +83,7 @@ public ExecutionStatus checkExportExecutionStatus(@Nullable String token, return CallWrapper.wrap(call).body(); } - @NonNull + @NotNull @Override public ExportOutputResource requestExportOutput(@Nullable String token, @Nullable String executionId, @@ -103,7 +103,7 @@ public ExportOutputResource requestExportOutput(@Nullable String token, return ExportOutputResource.create(exportInput, pages, isFinal); } - @NonNull + @NotNull @Override public OutputResource requestExportAttachment(@Nullable String token, @Nullable String executionId, @@ -121,34 +121,34 @@ public OutputResource requestExportAttachment(@Nullable String token, } private interface RestApi { - @NonNull + @NotNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/exports") - Call runReportExportExecution(@NonNull @Path("executionId") String executionId, - @NonNull @Body ExecutionRequestOptions executionOptions, + Call runReportExportExecution(@NotNull @Path("executionId") String executionId, + @NotNull @Body ExecutionRequestOptions executionOptions, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") - Call checkReportExportStatus(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId, + Call checkReportExportStatus(@NotNull @Path("executionId") String executionId, + @NotNull @Path("exportId") String exportId, @Header("Cookie") String cookie); /** * 'suppressContentDisposition' used due to security implications this header has */ - @NonNull + @NotNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") - Call requestReportExportOutput(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId, + Call requestReportExportOutput(@NotNull @Path("executionId") String executionId, + @NotNull @Path("exportId") String exportId, @Header("Cookie") String cookie); - @NonNull + @NotNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") - Call requestReportExportAttachmentOutput(@NonNull @Path("executionId") String executionId, - @NonNull @Path("exportId") String exportId, - @NonNull @Path("attachmentId") String attachmentId, + Call requestReportExportAttachmentOutput(@NotNull @Path("executionId") String executionId, + @NotNull @Path("exportId") String exportId, + @NotNull @Path("attachmentId") String attachmentId, @Header("Cookie") String cookie); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java index d2aeb420..1256ebfe 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java @@ -24,11 +24,10 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.WorkerThread; - import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import org.jetbrains.annotations.NotNull; + import java.util.Map; import java.util.Set; @@ -38,27 +37,23 @@ */ public interface ReportOptionRestApi { - @NonNull - @WorkerThread - Set requestReportOptionsList(@NonNull String reportUnitUri, @NonNull String token); + @NotNull + Set requestReportOptionsList(@NotNull String reportUnitUri, @NotNull String token); - @NonNull - @WorkerThread - ReportOption createReportOption(@NonNull String token, @NonNull String reportUnitUri, - @NonNull String optionLabel, - @NonNull Map> controlsValues, + @NotNull + ReportOption createReportOption(@NotNull String token, @NotNull String reportUnitUri, + @NotNull String optionLabel, + @NotNull Map> controlsValues, boolean overwrite); - @WorkerThread - void updateReportOption(@NonNull String token, - @NonNull String reportUnitUri, - @NonNull String optionId, - @NonNull Map> controlsValues); + void updateReportOption(@NotNull String token, + @NotNull String reportUnitUri, + @NotNull String optionId, + @NotNull Map> controlsValues); - @WorkerThread - void deleteReportOption(@NonNull String token, - @NonNull String reportUnitUri, - @NonNull String optionId); + void deleteReportOption(@NotNull String token, + @NotNull String reportUnitUri, + @NotNull String optionId); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java index 3dbdc4ab..a258e3a3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import com.squareup.okhttp.Response; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Collections; import java.util.Map; import java.util.Set; @@ -61,7 +61,7 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { mRestApi = retrofit.create(RestApi.class); } - @NonNull + @NotNull @Override public Set requestReportOptionsList(@Nullable String token, @Nullable String reportUnitUri) { @@ -82,7 +82,7 @@ public Set requestReportOptionsList(@Nullable String token, } } - @NonNull + @NotNull @Override public ReportOption createReportOption(@Nullable String token, @Nullable String reportUnitUri, @@ -125,38 +125,38 @@ public void deleteReportOption(@Nullable String token, } private interface RestApi { - @NonNull + @NotNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitUri}/options") Call requestReportOptionsList( - @NonNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, + @NotNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @POST("rest_v2/reports{reportUnitURI}/options") Call createReportOption( - @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NonNull @Query("label") String optionLabel, - @NonNull @Body Map> controlsValues, + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, + @NotNull @Query("label") String optionLabel, + @NotNull @Body Map> controlsValues, @Query("overwrite") boolean overwrite, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @PUT("rest_v2/reports{reportUnitURI}/options/{optionId}") Call updateReportOption( - @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NonNull @Path(value = "optionId", encoded = true) String optionId, - @NonNull @Body Map> controlsValues, + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, + @NotNull @Path(value = "optionId", encoded = true) String optionId, + @NotNull @Body Map> controlsValues, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/json") @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") Call deleteReportOption( - @NonNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NonNull @Path(value = "optionId", encoded = true) String optionId, + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, + @NotNull @Path(value = "optionId", encoded = true) String optionId, @Header("Cookie") String cookie); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java index deaa758e..d09e805d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.WorkerThread; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Map; /** @@ -39,17 +39,14 @@ * @since 2.0 */ public interface RepositoryRestApi { - @NonNull - @WorkerThread - ResourceSearchResult searchResources(@NonNull String token, @Nullable Map searchParams); + @NotNull + ResourceSearchResult searchResources(@NotNull String token, @Nullable Map searchParams); - @NonNull - @WorkerThread - ReportLookup requestReportResource( @NonNull String token, @NonNull String resourceUri); + @NotNull + ReportLookup requestReportResource( @NotNull String token, @NotNull String resourceUri); - @NonNull - @WorkerThread - FolderLookup requestFolderResource(@NonNull String token, @NonNull String resourceUri); + @NotNull + FolderLookup requestFolderResource(@NotNull String token, @NotNull String resourceUri); final class Builder extends GenericBuilder { @Override diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java index 687ee6f8..c1b8521a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java @@ -24,13 +24,13 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.HashMap; import java.util.Map; @@ -58,7 +58,7 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { mRestApi = restAdapter.create(RestApi.class); } - @NonNull + @NotNull @Override public ResourceSearchResult searchResources(@Nullable String token, @Nullable Map searchParams) { checkNotNull(token, "Request token should not be null"); @@ -106,7 +106,7 @@ public ResourceSearchResult searchResources(@Nullable String token, @Nullable Ma return entity; } - @NonNull + @NotNull @Override public ReportLookup requestReportResource(@Nullable String token, @Nullable String resourceUri) { checkNotNull(resourceUri, "Report uri should not be null"); @@ -116,7 +116,7 @@ public ReportLookup requestReportResource(@Nullable String token, @Nullable Stri return CallWrapper.wrap(call).body(); } - @NonNull + @NotNull @Override public FolderLookup requestFolderResource(@Nullable String token, @Nullable String resourceUri) { checkNotNull(resourceUri, "Folder uri should not be null"); @@ -127,7 +127,7 @@ public FolderLookup requestFolderResource(@Nullable String token, @Nullable Stri } private interface RestApi { - @NonNull + @NotNull @Headers("Accept: application/json") @GET("rest_v2/resources") Call searchResources( @@ -135,18 +135,18 @@ Call searchResources( @Nullable @Query("type") Iterable types, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/repository.reportUnit+json") @GET("rest_v2/resources{resourceUri}") Call requestReportResource( - @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri, + @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri, @Header("Cookie") String cookie); - @NonNull + @NotNull @Headers("Accept: application/repository.folder+json") @GET("rest_v2/resources{resourceUri}") Call requestFolderResource( - @NonNull @Path(value = "resourceUri", encoded = true) String resourceUri, + @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri, @Header("Cookie") String cookie); } } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java index 3b44c6c7..e8bc68fc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -77,7 +77,6 @@ public String message() { return response.message(); } - @Nullable public String errorBody() { return Utils.bodyToString(response.body()); } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java index 349573c7..d282ae2c 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java @@ -24,46 +24,44 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; -import android.support.annotation.WorkerThread; - import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 */ public interface ServerRestApi { - @NonNull - @WorkerThread + @NotNull ServerInfoData requestServerInfo(); - @NonNull - @WorkerThread + + @NotNull String requestBuild(); - @NonNull - @WorkerThread + + @NotNull String requestDateFormatPattern(); - @NonNull - @WorkerThread + + @NotNull String requestDateTimeFormatPattern(); - @NonNull - @WorkerThread + + @NotNull String requestEdition(); - @NonNull - @WorkerThread + + @NotNull String requestEditionName(); - @NonNull - @WorkerThread + + @NotNull String requestVersion(); - @NonNull - @WorkerThread + + @NotNull String requestFeatures(); - @NonNull - @WorkerThread + + @NotNull String requestLicenseType(); - @NonNull - @WorkerThread + + @NotNull String requestExpiration(); final class Builder extends GenericBuilder { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java index 235f2055..294488f1 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java @@ -24,10 +24,10 @@ package com.jaspersoft.android.sdk.network.api; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import org.jetbrains.annotations.NotNull; + import retrofit.Call; import retrofit.Retrofit; import retrofit.http.GET; @@ -45,69 +45,69 @@ public ServerRestApiImpl(Retrofit retrofit) { mApi = retrofit.create(RestApi.class); } - @NonNull + @NotNull @Override public ServerInfoData requestServerInfo() { Call call = mApi.requestServerInfo(); return CallWrapper.wrap(call).body(); } - @NonNull + @NotNull @Override public String requestEdition() { return CallWrapper.wrap(mApi.requestEdition()).body(); } - @NonNull + @NotNull @Override public String requestVersion() { return CallWrapper.wrap(mApi.requestVersion()).body(); } - @NonNull + @NotNull @Override public String requestBuild() { return CallWrapper.wrap(mApi.requestBuild()).body(); } - @NonNull + @NotNull @Override public String requestFeatures() { return CallWrapper.wrap(mApi.requestFeatures()).body(); } - @NonNull + @NotNull @Override public String requestEditionName() { return CallWrapper.wrap(mApi.requestEditionName()).body(); } - @NonNull + @NotNull @Override public String requestLicenseType() { return CallWrapper.wrap(mApi.requestLicenseType()).body(); } - @NonNull + @NotNull @Override public String requestExpiration() { return CallWrapper.wrap(mApi.requestExpiration()).body(); } - @NonNull + @NotNull @Override public String requestDateFormatPattern() { return CallWrapper.wrap(mApi.requestDateFormatPattern()).body(); } - @NonNull + @NotNull @Override public String requestDateTimeFormatPattern() { return CallWrapper.wrap(mApi.requestDateTimeFormatPattern()).body(); } private interface RestApi { - @NonNull + @NotNull @Headers("Accept: application/json") @GET(value = "rest_v2/serverInfo") Call requestServerInfo(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java index 18d99619..ff186862 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,10 +24,10 @@ package com.jaspersoft.android.sdk.network.entity.report.option; -import android.support.annotation.NonNull; - import com.google.gson.annotations.Expose; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -41,17 +41,17 @@ public final class ReportOption { @Expose private String label; - @NonNull + @NotNull public String getId() { return id; } - @NonNull + @NotNull public String getLabel() { return label; } - @NonNull + @NotNull public String getUri() { return uri; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java index 6cd9cb7f..324d924d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,11 +24,11 @@ package com.jaspersoft.android.sdk.network.entity.report.option; -import android.support.annotation.NonNull; - import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import org.jetbrains.annotations.NotNull; + import java.util.Collections; import java.util.Set; @@ -44,7 +44,7 @@ private ReportOptionSet() {} @SerializedName("reportOptionsSummary") private Set mOptions = Collections.emptySet(); - @NonNull + @NotNull public Set get() { return mOptions; } diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java index bdb86613..a07abaca 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java @@ -24,11 +24,11 @@ package com.jaspersoft.android.sdk.network.entity.server; -import android.support.annotation.NonNull; - import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -49,17 +49,17 @@ public final class EncryptionKey { private EncryptionKey() { } - @NonNull + @NotNull public String getExponent() { return exponent; } - @NonNull + @NotNull public int getMaxdigits() { return maxdigits; } - @NonNull + @NotNull public String getModulus() { return modulus; } diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 6a644a04..a82062fd 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.test.integration.api; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; @@ -35,6 +33,7 @@ import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import org.jetbrains.annotations.NotNull; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -141,12 +140,12 @@ public void updateOfParametersForExecutionShouldReturnResult() { /** * Helper methods */ - @NonNull + @NotNull private ReportExecutionDescriptor startExecution() { return startExecution(REPORT_URI); } - @NonNull + @NotNull private ReportExecutionDescriptor startExecution(String uri) { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); Map> params = new HashMap<>(); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 7e6a8d3c..1a3edf82 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.test.integration.api; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; @@ -38,6 +36,7 @@ import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import org.jetbrains.annotations.NotNull; import org.junit.Before; import org.junit.Test; @@ -106,7 +105,7 @@ public void requestExportOutputShouldReturnResult() { /** * Helper methods */ - @NonNull + @NotNull private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor exec) { ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") @@ -114,7 +113,7 @@ private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor return apiUnderTest.runExportExecution(mAuthenticator.token(), exec.getExecutionId(), options); } - @NonNull + @NotNull private ReportExecutionDescriptor startExecution() { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); return mExecApi.runReportExecution(mAuthenticator.token(), executionRequestOptions); diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index ea4df183..46665302 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -24,10 +24,10 @@ package com.jaspersoft.android.sdk.test.integration.api.utils; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -45,7 +45,7 @@ public static DummyTokenProvider create(JrsMetadata metadata) { return new DummyTokenProvider(metadata); } - @NonNull + @NotNull public String provideToken() { if (mToken == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() diff --git a/client-service/build.gradle b/client-service/build.gradle index 7d97e8c1..e352c00c 100644 --- a/client-service/build.gradle +++ b/client-service/build.gradle @@ -34,7 +34,7 @@ android { dependencies { compile project(':js-android-sdk-client-network') - compile 'com.android.support:support-annotations:22.2.0' + compile 'com.intellij:annotations:12.0' testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java index 1b01dfd5..f4b313da 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java @@ -24,13 +24,12 @@ package com.jaspersoft.android.sdk.service; -import android.support.annotation.NonNull; -import android.support.annotation.VisibleForTesting; -import android.support.annotation.WorkerThread; - import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + import java.text.SimpleDateFormat; /** @@ -43,7 +42,7 @@ final class GreedyInfoProvider implements InfoProvider { private final ServerInfoService mServerInfoService; private final String mBaseUrl; - @VisibleForTesting + @TestOnly GreedyInfoProvider(ServerInfoService serverInfoService, String serverUrl) { mServerInfoService = serverInfoService; mBaseUrl = serverUrl; @@ -54,26 +53,25 @@ public static InfoProvider newInstance(String serverUrl) { return new GreedyInfoProvider(service, serverUrl); } - @NonNull + @NotNull @Override public String getBaseUrl() { return mBaseUrl; } @Override - @NonNull - @WorkerThread + @NotNull public ServerInfo provideInfo() { return mServerInfoService.requestServerInfo(); } - @NonNull + @NotNull @Override public ServerVersion provideVersion() { return mServerInfoService.requestServerVersion(); } - @NonNull + @NotNull @Override public SimpleDateFormat provideDateTimeFormat() { return mServerInfoService.requestServerDateTimeFormat(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java index ab60e029..486f477f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java @@ -24,11 +24,11 @@ package com.jaspersoft.android.sdk.service; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import org.jetbrains.annotations.NotNull; + import java.text.SimpleDateFormat; /** @@ -38,12 +38,12 @@ * @since 2.0 */ public interface InfoProvider { - @NonNull + @NotNull String getBaseUrl(); - @NonNull + @NotNull ServerInfo provideInfo(); - @NonNull + @NotNull ServerVersion provideVersion(); - @NonNull + @NotNull SimpleDateFormat provideDateTimeFormat(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java index f317e0f4..1c5d4808 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java @@ -16,7 +16,8 @@ package com.jaspersoft.android.sdk.service; -import android.support.annotation.Nullable; + +import org.jetbrains.annotations.Nullable; /** * @author Kevin Bourrillion diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index 2d65f203..af55256c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -1,12 +1,12 @@ package com.jaspersoft.android.sdk.service; -import android.support.annotation.VisibleForTesting; - import com.jaspersoft.android.sdk.network.api.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import org.jetbrains.annotations.TestOnly; + import java.text.SimpleDateFormat; /** @@ -17,7 +17,7 @@ public final class ServerInfoService { private final ServerRestApi mRestApi; private final ServerInfoTransformer mTransformer; - @VisibleForTesting + @TestOnly ServerInfoService(ServerRestApi restApi, ServerInfoTransformer transformer) { mRestApi = restApi; mTransformer = transformer; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 17851748..8cc1379e 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -24,14 +24,13 @@ package com.jaspersoft.android.sdk.service.auth; -import android.support.annotation.NonNull; - +import org.jetbrains.annotations.NotNull; /** * @author Tom Koptel * @since 2.0 */ public interface AuthService { - @NonNull + @NotNull String authenticate(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 770d0c09..4026b790 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.service.auth; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; - import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -52,16 +52,15 @@ public final class SpringAuthService implements AuthService { private final Locale mLocale; private final TimeZone mTimeZone; - @VisibleForTesting + @TestOnly SpringAuthService( - @NonNull JSEncryptionAlgorithm generator, - @NonNull AuthenticationRestApi restApi, - @NonNull String username, - @NonNull String password, - @NonNull String organization, - @NonNull Locale locale, - @NonNull TimeZone timeZone - ) { + @NotNull JSEncryptionAlgorithm generator, + @NotNull AuthenticationRestApi restApi, + @NotNull String username, + @NotNull String password, + @NotNull String organization, + @NotNull Locale locale, + @NotNull TimeZone timeZone) { mEncryptionAlgorithm = generator; mRestApi = restApi; mUsername = username; @@ -71,7 +70,7 @@ public final class SpringAuthService implements AuthService { mTimeZone = timeZone; } - @NonNull + @NotNull @Override public String authenticate() { String password = mPassword; @@ -99,7 +98,7 @@ private Map prepareOptionals() { return params; } - @NonNull + @NotNull private String encryptPassword(String password, EncryptionKey key) { return mEncryptionAlgorithm.encrypt(key.getModulus(), key.getExponent(), password); } @@ -114,17 +113,17 @@ public static class Builder { private Locale mLocale; private TimeZone mTimeZone; - public Builder username(@NonNull String username) { + public Builder username(@NotNull String username) { mUsername = checkNotNull(username, "username == null"); return this; } - public Builder password(@NonNull String password) { + public Builder password(@NotNull String password) { mPassword = checkNotNull(password, "password == null"); return this; } - public Builder restApi(@NonNull AuthenticationRestApi restApi) { + public Builder restApi(@NotNull AuthenticationRestApi restApi) { mRestApi = checkNotNull(restApi, "restApi == null"); return this; } @@ -134,12 +133,12 @@ public Builder organization(@Nullable String organization) { return this; } - public Builder timeZone(@NonNull TimeZone timeZone) { + public Builder timeZone(@NotNull TimeZone timeZone) { mTimeZone = checkNotNull(timeZone, "timeZone == null"); return this; } - public Builder locale(@NonNull Locale locale) { + public Builder locale(@NotNull Locale locale) { mLocale = checkNotNull(locale, "locale == null"); return this; } @@ -147,14 +146,14 @@ public Builder locale(@NonNull Locale locale) { /** * TODO experimental API consider before release */ - public Builder withDefaultApiProvider(@NonNull String serverUrl) { + public Builder withDefaultApiProvider(@NotNull String serverUrl) { mRestApi = new AuthenticationRestApi.Builder() .baseUrl(serverUrl) .build(); return this; } - @NonNull + @NotNull public SpringAuthService build() { ensureValidState(); ensureDefaults(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java index 47c4d94a..c1377b97 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java @@ -23,8 +23,9 @@ */ package com.jaspersoft.android.sdk.service.data.repository; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Date; @@ -60,30 +61,30 @@ public void setUpdateDate(@Nullable Date updateDate) { mUpdateDate = updateDate; } - @NonNull + @NotNull public ResourceType getResourceType() { return mResourceType; } - public void setResourceType(@NonNull ResourceType resourceType) { + public void setResourceType(@NotNull ResourceType resourceType) { mResourceType = resourceType; } - @NonNull + @NotNull public String getLabel() { return mLabel; } - public void setLabel(@NonNull String label) { + public void setLabel(@NotNull String label) { mLabel = label; } - @NonNull + @NotNull public String getDescription() { return mDescription; } - public void setDescription(@NonNull String description) { + public void setDescription(@NotNull String description) { mDescription = description; } } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java index 03fc9f50..4b2a75a5 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -23,7 +23,7 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.Nullable; +import org.jetbrains.annotations.Nullable; /** * @author Tom Koptel diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 17a9cee1..92f72ba7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -23,11 +23,11 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import org.jetbrains.annotations.NotNull; + import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -43,7 +43,7 @@ public ExecutionOptionsDataMapper(String mBaseUrl) { this.mBaseUrl = mBaseUrl; } - public ReportExecutionRequestOptions transformRunReportOptions(@NonNull String reportUri, @NonNull RunReportCriteria criteria) { + public ReportExecutionRequestOptions transformRunReportOptions(@NotNull String reportUri, @NotNull RunReportCriteria criteria) { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); mapCommonCriterion(criteria, options); options.withAsync(true); @@ -51,13 +51,13 @@ public ReportExecutionRequestOptions transformRunReportOptions(@NonNull String r return options; } - public ExecutionRequestOptions transformExportOptions(@NonNull RunExportCriteria configuration) { + public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria configuration) { ExecutionRequestOptions options = ExecutionRequestOptions.create(); mapCommonCriterion(configuration, options); return options; } - private void mapCommonCriterion(@NonNull ExecutionCriteria criteria, ExecutionRequestOptions options) { + private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, ExecutionRequestOptions options) { options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index 35109ad7..1360e748 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - import com.jaspersoft.android.sdk.network.entity.execution.AttachmentDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.ArrayList; import java.util.Collection; import java.util.Set; @@ -52,7 +52,7 @@ final class ExportFactory { mReportUri = reportUri; } - @NonNull + @NotNull public ReportExport create(ReportExecutionDescriptor executionDetails, ExportExecutionDescriptor exportExecutionDetails) { String exportId = exportExecutionDetails.getExportId(); @@ -64,7 +64,7 @@ public ReportExport create(ReportExecutionDescriptor executionDetails, return new ReportExport(mExecutionId, exportId, attachments, mExportUseCase); } - @NonNull + @NotNull private Collection adaptAttachments(ExportDescriptor export) { String exportId = export.getId(); Set rawAttachments = export.getAttachments(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index d4c04f91..1c7100af 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -23,10 +23,10 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -48,7 +48,7 @@ public final class ReportAttachment { mExportUseCase = exportUseCase; } - @NonNull + @NotNull public ResourceOutput download() { return mExportUseCase.requestExportAttachmentOutput( mExecutionId, mExportId, mFileName); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 422de4fc..0fb5657e 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -23,13 +23,14 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; -import android.support.annotation.VisibleForTesting; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + /** * @author Tom Koptel * @since 2.0 @@ -44,7 +45,7 @@ public final class ReportExecution { private final String mReportUri; private final ExportFactory mExportFactory; - @VisibleForTesting + @TestOnly ReportExecution(long delay, ReportExecutionUseCase executionUseCase, ReportExportUseCase exportUseCase, @@ -60,7 +61,7 @@ public final class ReportExecution { mExportFactory = new ExportFactory(exportUseCase, mExecutionId, mReportUri); } - @NonNull + @NotNull public ReportMetadata waitForReportCompletion() { try { return performAwaitFoReport(); @@ -69,7 +70,7 @@ public ReportMetadata waitForReportCompletion() { } } - @NonNull + @NotNull public ReportExport export(RunExportCriteria criteria) { try { return performExport(criteria); @@ -89,7 +90,7 @@ public ReportExport export(RunExportCriteria criteria) { } } - @NonNull + @NotNull private ReportMetadata performAwaitFoReport() { ReportExecutionDescriptor details = requestExecutionDetails(); ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); @@ -97,7 +98,7 @@ private ReportMetadata performAwaitFoReport() { completeDetails.getTotalPages()); } - @NonNull + @NotNull private ReportExport performExport(RunExportCriteria criteria) { ExportExecutionDescriptor exportDetails = runExport(criteria); waitForExportReadyStatus(exportDetails); @@ -126,7 +127,7 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) { } } - @NonNull + @NotNull private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) { Status status = Status.wrap(details.getStatus()); @@ -149,12 +150,12 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD return resultDetails; } - @NonNull + @NotNull private ExportExecutionDescriptor runExport(RunExportCriteria criteria) { return mExportUseCase.runExport(mExecutionId, criteria); } - @NonNull + @NotNull private ReportExecutionDescriptor requestExecutionDetails() { return mExecutionUseCase.requestExecutionDetails(mExecutionId); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 2f095e9f..158cb667 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -49,19 +49,19 @@ final class ReportExecutionUseCase { mExecutionOptionsMapper = executionOptionsMapper; } - @NonNull + @NotNull public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); return mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); } - @NonNull + @NotNull public Status requestStatus(String executionId) { ExecutionStatus executionStatus = mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); return Status.wrap(executionStatus.getStatus()); } - @NonNull + @NotNull public ReportExecutionDescriptor requestExecutionDetails(String executionId) { return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), executionId); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 8a6f7474..703ad6cf 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -23,10 +23,10 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.service.data.report.ReportOutput; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; /** @@ -49,12 +49,12 @@ public final class ReportExport { mExportUseCase = exportUseCase; } - @NonNull + @NotNull public Collection getAttachments() { return mAttachments; } - @NonNull + @NotNull public ReportOutput download() { return mExportUseCase.requestExportOutput(mExecutionId, mExportId); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 0a93c74d..7a8dd95c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -36,6 +34,8 @@ import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -52,26 +52,26 @@ final class ReportExportUseCase { mExecutionOptionsMapper = executionOptionsMapper; } - @NonNull + @NotNull public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); return mExportApi.runExportExecution(mTokenProvider.provideToken(), executionId, options); } - @NonNull + @NotNull public Status checkExportExecutionStatus(String executionId, String exportId) { ExecutionStatus exportStatus = mExportApi .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); return Status.wrap(exportStatus.getStatus()); } - @NonNull + @NotNull public ReportOutput requestExportOutput(String executionId, String exportId) { ExportOutputResource result = mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); return OutputDataMapper.transform(result); } - @NonNull + @NotNull public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, String fileName) { OutputResource result = mExportApi.requestExportAttachment( mTokenProvider.provideToken(), diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 2468eac8..dc95fedc 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -23,15 +23,15 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; -import android.support.annotation.VisibleForTesting; - import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + import java.util.concurrent.TimeUnit; /** @@ -44,7 +44,7 @@ public final class ReportService { private final ReportExportUseCase mExportUseCase; private final long mDelay; - @VisibleForTesting + @TestOnly ReportService( long delay, ReportExecutionUseCase executionUseCase, @@ -83,7 +83,7 @@ public ReportExecution run(String reportUri, RunReportCriteria criteria) { } } - @NonNull + @NotNull private ReportExecution performRun(String reportUri, RunReportCriteria criteria) { ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index 1b2c58c4..0d2d10f1 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -23,8 +23,8 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Tom Koptel @@ -35,7 +35,7 @@ private RunExportCriteria(boolean freshData, boolean interactive, boolean saveSn super(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); } - @NonNull + @NotNull public static Builder builder() { return new Builder(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index 95dff958..6fe69752 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -23,8 +23,8 @@ */ package com.jaspersoft.android.sdk.service.report; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.Set; @@ -48,7 +48,7 @@ private RunReportCriteria(boolean freshData, mParams = params; } - @NonNull + @NotNull public static Builder builder() { return new Builder(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java index 5fdcedcb..8ad8c16d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.HashSet; @@ -46,7 +46,7 @@ final class CriteriaMapper { private CriteriaMapper() { } - @NonNull + @NotNull public static Map map(InternalCriteria criteria) { Map params = new HashMap<>(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 598c12e0..9b918d17 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -24,11 +24,12 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Collections; import java.util.LinkedList; @@ -81,7 +82,7 @@ private void calculateDisposition(int offset) { } } - @NonNull + @NotNull private Collection internalSearch(int limit) { int count = 0; while (mBuffer.size() < limit && hasNext()) { @@ -109,7 +110,7 @@ private Collection internalSearch(int limit) { return result; } - @NonNull + @NotNull private SearchResult performSearch(int limit) { InternalCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 1c1da89e..93948204 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -24,11 +24,11 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; import java.util.Collections; @@ -74,7 +74,7 @@ public boolean hasNext() { return !mEndReached; } - @NonNull + @NotNull private Collection performLookup() { InternalCriteria newSearchCriteria = createNextCriteria(); SearchResult result = performApiCall(newSearchCriteria); @@ -82,7 +82,7 @@ private Collection performLookup() { return result.getResources(); } - @NonNull + @NotNull private SearchResult performApiCall(InternalCriteria newSearchCriteria) { return mSearchUseCase.performSearch(newSearchCriteria); } @@ -109,7 +109,7 @@ private void updateInternalOffset(SearchResult result) { } } - @NonNull + @NotNull private InternalCriteria createNextCriteria() { InternalCriteria.Builder newCriteriaBuilder = mInitialCriteria.newBuilder(); newCriteriaBuilder.offset(mInternalOffset); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index a60fe46c..20e75def 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -23,8 +23,8 @@ */ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_LIMIT; import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_OFFSET; @@ -56,12 +56,12 @@ private InternalCriteria(Builder builder) { mFolderUri = builder.folderUri; } - @NonNull + @NotNull public static InternalCriteria.Builder builder() { return new InternalCriteria.Builder(); } - @NonNull + @NotNull public static InternalCriteria from(SearchCriteria criteria) { return InternalCriteria.builder() .limit(criteria.getLimit()) @@ -115,7 +115,7 @@ public String getSortBy() { return mSortBy; } - @NonNull + @NotNull public InternalCriteria.Builder newBuilder() { InternalCriteria.Builder builder = builder(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java index 6f20fe49..85b732f8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java @@ -23,13 +23,14 @@ */ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.ResourceType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collection; @@ -42,7 +43,7 @@ */ class ResourceMapper { - @NonNull + @NotNull public Collection transform(Collection resources, SimpleDateFormat dateTimeFormat) { Collection result = new LinkedList<>(); for (ResourceLookup lookup : resources) { @@ -53,7 +54,7 @@ public Collection transform(Collection resources, Simp return result; } - @NonNull + @NotNull public Resource transform(ResourceLookup lookup, SimpleDateFormat dateTimeFormat) { Resource resource = new Resource(); resource.setCreationDate(toDate(lookup.getCreationDate(), dateTimeFormat)); @@ -73,7 +74,7 @@ private Date toDate(String creationDate, SimpleDateFormat dateTimeFormat) { } } - @NonNull + @NotNull private ResourceType toType(String resourceType) { return ResourceType.defaultParser().parse(String.valueOf(resourceType)); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index c6ee0a1e..519066a7 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -24,8 +24,8 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import static com.jaspersoft.android.sdk.service.Preconditions.checkArgument; @@ -61,12 +61,12 @@ private SearchCriteria(Builder builder) { mFolderUri = builder.folderUri; } - @NonNull + @NotNull public static SearchCriteria.Builder builder() { return new SearchCriteria.Builder(); } - @NonNull + @NotNull public static SearchCriteria none() { return builder().create(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index e1af72f9..3bb056af 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -23,10 +23,10 @@ */ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.service.data.repository.Resource; +import org.jetbrains.annotations.NotNull; + import java.util.Collection; /** @@ -34,7 +34,7 @@ * @since 2.0 */ public interface SearchTask { - @NonNull + @NotNull Collection nextLookup(); boolean hasNext(); } diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 20f81556..1d3e2b32 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -24,14 +24,14 @@ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.util.Collection; /** @@ -57,7 +57,7 @@ final class SearchTaskImpl implements SearchTask { mInfoProvider = infoProvider; } - @NonNull + @NotNull @Override public Collection nextLookup() { return defineSearchStrategy().searchNext(); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 4af9f61b..bf8008fe 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -23,8 +23,6 @@ */ package com.jaspersoft.android.sdk.service.repository; -import android.support.annotation.NonNull; - import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.service.InfoProvider; @@ -32,6 +30,8 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import org.jetbrains.annotations.NotNull; + import java.text.SimpleDateFormat; import java.util.Collection; @@ -54,8 +54,8 @@ public SearchUseCase( mDataMapper = dataMapper; } - @NonNull - public SearchResult performSearch(@NonNull InternalCriteria criteria) { + @NotNull + public SearchResult performSearch(@NotNull InternalCriteria criteria) { ResourceSearchResult response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); From f4a9d5104b5eb3f999ae51c7110cf067191edbd6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 12:57:06 +0200 Subject: [PATCH 245/457] Drop legacy code --- client/build.gradle | 77 +- client/src/main/AndroidManifest.xml | 31 - .../sdk/client/DataTypeConverterCreator.java | 14 - .../client/GSONDataTypeConverterCreator.java | 60 - .../android/sdk/client/JsRestClient.java | 1461 --- .../android/sdk/client/JsServerProfile.java | 234 - .../sdk/client/MessageConvertersFactory.java | 86 - .../client/XMLDataTypeConverterCreator.java | 47 - .../sdk/client/api/v2/ConverterFactory.java | 70 - .../android/sdk/client/api/v2/DataType.java | 9 - .../api/v2/JsonHttpRequestInterceptor.java | 39 - .../sdk/client/api/v2/ServerRestApi.java | 79 - .../api/v2/XmlHttpRequestInterceptor.java | 39 - .../sdk/client/async/JsAsyncTaskManager.java | 244 - .../async/JsOnTaskCallbackListener.java | 57 - .../sdk/client/async/JsProgressTracker.java | 69 - .../sdk/client/async/JsXmlSpiceService.java | 53 - .../sdk/client/async/request/BaseRequest.java | 68 - .../request/CheckReportStatusRequest.java | 41 - .../async/request/DeleteResourceRequest.java | 62 - .../async/request/GetExportOutputRequest.java | 63 - .../request/GetReportResourceRequest.java | 68 - .../request/GetRootFolderDataRequest.java | 26 - .../async/request/ModifyResourceRequest.java | 63 - .../async/request/ReportDetailsRequest.java | 26 - .../request/RunReportExecutionRequest.java | 81 - .../request/RunReportExportOutputRequest.java | 44 - .../request/RunReportExportsRequest.java | 51 - .../request/SaveExportAttachmentRequest.java | 77 - .../request/SaveExportOutputRequest.java | 70 - .../request/SaveReportAttachmentRequest.java | 80 - .../request/SaveReportAttachmentsRequest.java | 86 - .../cacheable/BaseInputControlsRequest.java | 101 - .../request/cacheable/CacheableRequest.java | 61 - .../cacheable/GetInputControlsRequest.java | 69 - .../GetInputControlsValuesRequest.java | 84 - .../request/cacheable/GetReportRequest.java | 87 - .../cacheable/GetResourceLookupsRequest.java | 149 - .../request/cacheable/GetResourceRequest.java | 67 - .../cacheable/GetResourcesRequest.java | 68 - .../cacheable/GetServerInfoRequest.java | 55 - .../cacheable/SearchResourcesRequest.java | 119 - .../ValidateInputControlsValuesRequest.java | 76 - .../async/task/DeleteResourceAsyncTask.java | 109 - .../async/task/GetInputControlsAsyncTask.java | 111 - .../client/async/task/GetReportAsyncTask.java | 124 - .../async/task/GetResourceAsyncTask.java | 111 - .../async/task/GetResourcesListAsyncTask.java | 111 - .../async/task/GetServerInfoAsyncTask.java | 93 - .../sdk/client/async/task/JsAsyncTask.java | 217 - .../client/async/task/JsRestAsyncTask.java | 90 - .../async/task/ModifyResourceAsyncTask.java | 112 - .../task/SaveReportAttachmentAsyncTask.java | 150 - .../task/SaveReportAttachmentsAsyncTask.java | 148 - .../async/task/SearchResourcesAsyncTask.java | 229 - .../sdk/client/ic/InputControlWrapper.java | 338 - .../sdk/client/oxm/ReportAttachment.java | 64 - .../sdk/client/oxm/ReportDescriptor.java | 111 - .../sdk/client/oxm/ResourceDescriptor.java | 396 - .../sdk/client/oxm/ResourceParameter.java | 92 - .../sdk/client/oxm/ResourceProperty.java | 86 - .../android/sdk/client/oxm/ResourcesList.java | 52 - .../sdk/client/oxm/control/InputControl.java | 332 - .../oxm/control/InputControlOption.java | 129 - .../client/oxm/control/InputControlState.java | 147 - .../oxm/control/InputControlStatesList.java | 52 - .../client/oxm/control/InputControlsList.java | 53 - .../DateTimeFormatValidationRule.java | 73 - .../validation/MandatoryValidationRule.java | 50 - .../control/validation/ValidationRule.java | 99 - .../validation/ValidationRulesList.java | 98 - .../oxm/converter/ReportStatusConverter.java | 23 - .../client/oxm/report/ErrorDescriptor.java | 69 - .../client/oxm/report/ExecutionRequest.java | 192 - .../client/oxm/report/ExportExecution.java | 104 - .../sdk/client/oxm/report/ExportsRequest.java | 11 - .../client/oxm/report/FolderDataResponse.java | 20 - .../client/oxm/report/ReportDataResponse.java | 23 - .../oxm/report/ReportExecutionRequest.java | 36 - .../oxm/report/ReportExecutionResponse.java | 134 - .../oxm/report/ReportOutputResource.java | 64 - .../client/oxm/report/ReportParameter.java | 122 - .../oxm/report/ReportParametersList.java | 54 - .../sdk/client/oxm/report/ReportStatus.java | 9 - .../oxm/report/ReportStatusResponse.java | 45 - .../adapter/ExecutionRequestAdapter.java | 64 - .../ReportParametersListDeserializer.java | 74 - .../ReportParametersListSerializer.java | 64 - .../ValidationRulesListTypeAdapter.java | 81 - .../sdk/client/oxm/resource/ReportUnit.java | 35 - .../client/oxm/resource/ResourceLookup.java | 200 - .../ResourceLookupSearchCriteria.java | 259 - .../oxm/resource/ResourceLookupsList.java | 128 - .../sdk/client/oxm/server/ServerInfo.java | 176 - .../util/CookieHttpRequestInterceptor.java | 68 - .../android/sdk/util/FileUtils.java | 132 - .../util/KeepAliveHttpRequestInterceptor.java | 28 - .../util/LocalesHttpRequestInterceptor.java | 63 - .../android/sdk/util/StaticCacheHelper.java | 117 - .../client/ExecutionRequestAdapterTest.java | 107 - .../GSONDataTypeConverterCreatorTest.java | 45 - .../client/InputControlStatesListTest.java | 71 - .../sdk/client/JsRestClientBuilderTest.java | 61 - .../client/MessageConvertersFactoryTest.java | 87 - .../client/ReportExecutionResponseTest.java | 54 - .../sdk/client/ReportParametersTest.java | 73 - .../sdk/client/ReportStatusResponseTest.java | 54 - .../sdk/client/ResourceLookupsListTest.java | 53 - .../android/sdk/client/ServerInfoTest.java | 93 - .../sdk/client/ValidationRuleAdapterTest.java | 60 - .../XMLDataTypeConverterCreatorTest.java | 45 - .../client/api/v2/ConverterFactoryTest.java | 53 - .../sdk/client/api/v2/ServerRestApiTest.java | 79 - .../CheckReportStatusRequestTest.java | 56 - .../GetReportResourceRequestTest.java | 52 - .../GetRootFolderDataRequestTest.java | 58 - .../client/integration/JsRestClientTest.java | 50 - .../client/integration/ParametrizedTest.java | 73 - .../integration/ReportDetailsRequestTest.java | 57 - .../ResourceLookupRequestTest.java | 75 - .../RootFolderLookupRequestTest.java | 79 - .../RunReportExportsRequestTest.java | 72 - .../integration/ServerInfoRequestTest.java | 75 - .../ValidateInputControlsRequestTest.java | 87 - .../android/sdk/client/util/FactoryGirl.java | 118 - .../client/util/JsServerProfileAdapter.java | 25 - .../android/sdk/client/util/RealHttpRule.java | 50 - .../sdk/client/util/ResourceUnderTest.java | 10 - .../sdk/client/util/ResourceUnderTest5_5.java | 44 - .../client/util/ResourceUnderTestFactory.java | 51 - .../util/ResourceUnderTestGreater5_5.java | 44 - .../sdk/client/util/ServerCollection.java | 147 - .../sdk/client/util/ServerUnderTest.java | 217 - .../sdk/client/util/ServerVersion.java | 47 - .../sdk/client/util/TargetDataType.java | 16 - .../android/sdk/client/util/TestResource.java | 111 - client/src/test/resources/controls_01.json | 7891 ----------------- client/src/test/resources/controls_04.json | 41 - client/src/test/resources/controls_06.json | 44 - client/src/test/resources/controls_07.json | 44 - .../resources/input_control_states_list.json | 7847 ---------------- .../test/resources/input_controls_date.json | 62 - .../test/resources/report_execution_data.json | 40 - .../src/test/resources/report_parameters.json | 14 - .../src/test/resources/resource_lookup.json | 64 - .../test/resources/servers_under_test.json | 3 - 146 files changed, 2 insertions(+), 29280 deletions(-) delete mode 100644 client/src/main/AndroidManifest.xml delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/DataTypeConverterCreator.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreator.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/JsRestClient.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/JsServerProfile.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/MessageConvertersFactory.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreator.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/JsAsyncTaskManager.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/JsOnTaskCallbackListener.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/JsProgressTracker.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/JsXmlSpiceService.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/BaseRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/CheckReportStatusRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/DeleteResourceRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetExportOutputRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetReportResourceRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetRootFolderDataRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ModifyResourceRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ReportDetailsRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExecutionRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportOutputRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportsRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportAttachmentRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportOutputRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentsRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/BaseInputControlsRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/CacheableRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsValuesRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetReportRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceLookupsRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourcesRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetServerInfoRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/SearchResourcesRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/ValidateInputControlsValuesRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/DeleteResourceAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetInputControlsAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetReportAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourceAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourcesListAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetServerInfoAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsRestAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/ModifyResourceAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentsAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SearchResourcesAsyncTask.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/ic/InputControlWrapper.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportAttachment.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportDescriptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceDescriptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceParameter.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceProperty.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourcesList.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControl.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlOption.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlState.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlStatesList.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlsList.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/DateTimeFormatValidationRule.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/MandatoryValidationRule.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRule.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRulesList.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/converter/ReportStatusConverter.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ErrorDescriptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportExecution.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportsRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/FolderDataResponse.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportDataResponse.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionRequest.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionResponse.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportOutputResource.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParameter.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParametersList.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatus.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatusResponse.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ExecutionRequestAdapter.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListDeserializer.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListSerializer.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ValidationRulesListTypeAdapter.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ReportUnit.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookup.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupSearchCriteria.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupsList.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/client/oxm/server/ServerInfo.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/util/CookieHttpRequestInterceptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/util/FileUtils.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/util/KeepAliveHttpRequestInterceptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/util/LocalesHttpRequestInterceptor.java delete mode 100644 client/src/main/java/com/jaspersoft/android/sdk/util/StaticCacheHelper.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/ExecutionRequestAdapterTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreatorTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/InputControlStatesListTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/JsRestClientBuilderTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/MessageConvertersFactoryTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/ReportExecutionResponseTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/ReportParametersTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/ReportStatusResponseTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/ResourceLookupsListTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/ServerInfoTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/ValidationRuleAdapterTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreatorTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/CheckReportStatusRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetReportResourceRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetRootFolderDataRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/JsRestClientTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/ParametrizedTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/ReportDetailsRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/ResourceLookupRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/RootFolderLookupRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/RunReportExportsRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/ServerInfoRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/integration/ValidateInputControlsRequestTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/FactoryGirl.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/JsServerProfileAdapter.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/RealHttpRule.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest5_5.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestFactory.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestGreater5_5.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerCollection.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerUnderTest.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerVersion.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/TargetDataType.java delete mode 100644 client/src/test/java/com/jaspersoft/android/sdk/client/util/TestResource.java delete mode 100644 client/src/test/resources/controls_01.json delete mode 100644 client/src/test/resources/controls_04.json delete mode 100644 client/src/test/resources/controls_06.json delete mode 100644 client/src/test/resources/controls_07.json delete mode 100644 client/src/test/resources/input_control_states_list.json delete mode 100644 client/src/test/resources/input_controls_date.json delete mode 100644 client/src/test/resources/report_execution_data.json delete mode 100644 client/src/test/resources/report_parameters.json delete mode 100644 client/src/test/resources/resource_lookup.json delete mode 100644 client/src/test/resources/servers_under_test.json diff --git a/client/build.gradle b/client/build.gradle index e173501b..8e719477 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -1,5 +1,4 @@ -apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'java' description = 'js-android-sdk-client' version = clientModuleVersion @@ -10,78 +9,6 @@ ext { PUBLISH_VERSION = clientModuleVersion } -android { - compileSdkVersion androidCompileSdkVersion - buildToolsVersion androidBuildToolsVersion - - defaultConfig { - minSdkVersion androidMinSdkVersion - targetSdkVersion androidTargetSdkVersion - versionCode clientModuleVersionCode - versionName version - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - encoding 'ISO-8859-1' - } - packagingOptions { - exclude 'META-INF/notice.txt' - exclude 'META-INF/license.txt' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/NOTICE.txt' - } - lintOptions { - abortOnError false - } - - buildTypes { - debug { - minifyEnabled false - } - } -} - dependencies { - compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0' - compile 'com.squareup.retrofit:retrofit:1.9.0' - compile('com.squareup.retrofit:converter-simplexml:1.9.0') { - transitive = false - } - - compile 'com.android.support:support-annotations:22.2.0' - compile 'com.google.code.gson:gson:2.3.1' - compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE' - compile 'com.octo.android.robospice:robospice:1.4.14' - compile 'com.octo.android.robospice:robospice-spring-android:1.4.14' - compile('org.simpleframework:simple-xml:2.7') { - exclude group: 'stax', module: 'stax' - exclude group: 'stax', module: 'stax-api' - exclude group: 'xpp3', module: 'xpp3' - } - // Junit - testCompile('junit:junit:4.12') { - exclude group: 'org.hamcrest' - } - // JunitParams - testCompile('pl.pragmatists:JUnitParams:1.0.4') { - exclude group: 'org.hamcrest' - } - // Hamcrest Matchers for Junit - testCompile 'org.hamcrest:hamcrest-integration:1.3' - // Mockito - testCompile "org.mockito:mockito-core:1.10.19" - // Robolectric + Support v4 - testCompile('org.robolectric:shadows-support-v4:3.0-rc3') { - exclude group: 'commons-logging', module: 'commons-logging' - exclude group: 'org.apache.httpcomponents', module: 'httpclient' - } - testCompile 'org.robolectric:shadows-httpclient:3.0-rc3' - - testCompile('com.squareup.okhttp:mockwebserver:2.1.0') { - transitive = false - } - -} -apply from: '../scripts/android-release-aar.gradle' \ No newline at end of file +} \ No newline at end of file diff --git a/client/src/main/AndroidManifest.xml b/client/src/main/AndroidManifest.xml deleted file mode 100644 index 622790da..00000000 --- a/client/src/main/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/DataTypeConverterCreator.java b/client/src/main/java/com/jaspersoft/android/sdk/client/DataTypeConverterCreator.java deleted file mode 100644 index 6bee4ce8..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/DataTypeConverterCreator.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.jaspersoft.android.sdk.client; - -import android.support.annotation.NonNull; - -import org.springframework.http.converter.HttpMessageConverter; - -/** - * @author Tom Koptel - * @since 1.10 - */ -interface DataTypeConverterCreator> { - @NonNull - T create(); -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreator.java b/client/src/main/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreator.java deleted file mode 100644 index 6e013b76..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import android.support.annotation.NonNull; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ReportParametersListDeserializer; - -import org.springframework.http.MediaType; -import org.springframework.http.converter.json.GsonHttpMessageConverter; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Tom Koptel - * @since 1.10 - */ -class GSONDataTypeConverterCreator implements DataTypeConverterCreator { - @NonNull - @Override - public GsonHttpMessageConverter create() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(ReportParametersList.class, new ReportParametersListDeserializer()); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - - GsonHttpMessageConverter converter = new GsonHttpMessageConverter(gson); - List supportedMediaTypes = new ArrayList<>(3); - supportedMediaTypes.add(new MediaType("application", "json", GsonHttpMessageConverter.DEFAULT_CHARSET)); - supportedMediaTypes.add(new MediaType("application", "*+json", GsonHttpMessageConverter.DEFAULT_CHARSET)); - converter.setSupportedMediaTypes(supportedMediaTypes); - - return converter; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/JsRestClient.java b/client/src/main/java/com/jaspersoft/android/sdk/client/JsRestClient.java deleted file mode 100644 index 94e316f2..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/JsRestClient.java +++ /dev/null @@ -1,1461 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import com.jaspersoft.android.sdk.client.oxm.ReportDescriptor; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; -import com.jaspersoft.android.sdk.client.oxm.ResourceParameter; -import com.jaspersoft.android.sdk.client.oxm.ResourceProperty; -import com.jaspersoft.android.sdk.client.oxm.ResourcesList; -import com.jaspersoft.android.sdk.client.oxm.control.InputControl; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlState; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlStatesList; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlsList; -import com.jaspersoft.android.sdk.client.oxm.report.ExportExecution; -import com.jaspersoft.android.sdk.client.oxm.report.ExportsRequest; -import com.jaspersoft.android.sdk.client.oxm.report.FolderDataResponse; -import com.jaspersoft.android.sdk.client.oxm.report.ReportDataResponse; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; -import com.jaspersoft.android.sdk.client.oxm.report.ReportStatusResponse; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ExecutionRequestAdapter; -import com.jaspersoft.android.sdk.client.oxm.resource.ReportUnit; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupSearchCriteria; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupsList; -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; -import com.jaspersoft.android.sdk.util.CookieHttpRequestInterceptor; -import com.jaspersoft.android.sdk.util.KeepAliveHttpRequestInterceptor; -import com.jaspersoft.android.sdk.util.LocalesHttpRequestInterceptor; -import com.jaspersoft.android.sdk.util.StaticCacheHelper; - -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.ClientHttpRequest; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.util.FileCopyUtils; -import org.springframework.web.client.HttpStatusCodeException; -import org.springframework.web.client.ResourceAccessException; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriTemplate; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static java.util.Collections.singletonList; - -/** - * The central class that provides a set of convenient methods to interact with the JasperReports Server REST API - * and does mapping of the returned data to object model. - * - * @author Ivan Gadzhega - * @since 1.0 - */ -public class JsRestClient { - - public static final String REST_SERVICES_URI = "/rest"; - public static final String REST_SERVICES_V2_URI = "/rest_v2"; - public static final String REST_RESOURCE_URI = "/resource"; - public static final String REST_RESOURCES_URI = "/resources"; - public static final String REST_REPORT_URI = "/report"; - public static final String REST_REPORTS_URI = "/reports"; - public static final String REST_INPUT_CONTROLS_URI = "/inputControls"; - public static final String REST_VALUES_URI = "/values"; - public static final String REST_SERVER_INFO_URI = "/serverInfo"; - public static final String REST_REPORT_EXECUTIONS = "/reportExecutions"; - public static final String REST_REPORT_EXPORTS = "/exports"; - public static final String REST_REPORT_STATUS = "/status"; - public static final String REST_THUMBNAILS = "/thumbnails"; - - - // the timeout in milliseconds until a connection is established - private int connectTimeout = 15 * 1000; - // the socket timeout in milliseconds for waiting for data - private int readTimeout = 120 * 1000; - - private JsServerProfile jsServerProfile; - private String restServicesUrl; - private ServerInfo serverInfo; - - private final RestTemplate restTemplate; - private final SimpleClientHttpRequestFactory requestFactory; - private final DataType dataType; - - //--------------------------------------------------------------------- - // Factory methods - //--------------------------------------------------------------------- - - public static Builder builder() { - return new Builder(); - } - - //--------------------------------------------------------------------- - // Constructors - //--------------------------------------------------------------------- - - public JsRestClient() { - this(new RestTemplate(false), new SimpleClientHttpRequestFactory()); - } - - public JsRestClient(RestTemplate restTemplate) { - this(restTemplate, new SimpleClientHttpRequestFactory()); - } - - public JsRestClient(RestTemplate restTemplate, - SimpleClientHttpRequestFactory factory) { - this(restTemplate, factory, DataType.XML); - } - - private JsRestClient(Builder builder) { - this(builder.restTemplate, new SimpleClientHttpRequestFactory(), builder.dataType); - } - - private JsRestClient(RestTemplate restTemplate, - SimpleClientHttpRequestFactory factory, DataType dataType) { - this.restTemplate = restTemplate; - this.requestFactory = factory; - this.dataType = dataType; - configureMessageConverters(); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public RestTemplate getRestTemplate() { - return restTemplate; - } - - public String getRestServicesUrl() { - return restServicesUrl; - } - - public JsServerProfile getServerProfile() { - return jsServerProfile; - } - - public DataType getDataType() { - return dataType; - } - - public SimpleClientHttpRequestFactory getRequestFactory() { - return requestFactory; - } - - //--------------------------------------------------------------------- - // Timeouts - //--------------------------------------------------------------------- - - /** - * Set the underlying URLConnection's connect timeout. A timeout value of 0 specifies an infinite timeout. - * - * @param timeout the timeout value in milliseconds - * @since 1.5 - */ - public void setConnectTimeout(int timeout) { - connectTimeout = timeout; - updateConnectTimeout(); - } - - /** - * Set the underlying URLConnection's read timeout. A timeout value of 0 specifies an infinite timeout. - * - * @param timeout the timeout value in milliseconds - * @since 1.5 - */ - public void setReadTimeout(int timeout) { - readTimeout = timeout; - updateReadTimeout(); - } - - //--------------------------------------------------------------------- - // Server Profiles & Info - //--------------------------------------------------------------------- - - /** - * Alternative way to change server profile. - * This method mutates request factory. - * This method doesn't mutates interceptors collection. - * - * @param serverProfile store of user auth credentials - */ - public void updateServerProfile(final JsServerProfile serverProfile) { - this.serverInfo = null; - this.jsServerProfile = serverProfile; - - // We allow user to set profile to null value - if (jsServerProfile != null) { - this.restServicesUrl = serverProfile.getServerUrl() + REST_SERVICES_URI; - updateRequestFactoryTimeouts(); - restTemplate.setRequestFactory(requestFactory); - } - } - - /** - * Legacy way to change server profile. - * This method mutates request factory. - * This method mutates interceptors collection. - * - * @param serverProfile store of user auth credentials - */ - @Deprecated - public void setServerProfile(final JsServerProfile serverProfile) { - this.serverInfo = null; - this.jsServerProfile = serverProfile; - - // We allow user to set profile to null value - if (jsServerProfile != null) { - this.restServicesUrl = serverProfile.getServerUrl() + REST_SERVICES_URI; - - updateRequestFactoryTimeouts(); - restTemplate.setRequestFactory(requestFactory); - - List interceptors = new ArrayList(); - interceptors.add(new LocalesHttpRequestInterceptor()); - interceptors.add(new CookieHttpRequestInterceptor(jsServerProfile)); - interceptors.add(new KeepAliveHttpRequestInterceptor()); - restTemplate.setInterceptors(interceptors); - } - } - - /** - * Allows to mutate list of request request interceptors. - * - * @param interceptors list of new request interceptors. - */ - public void setRequestInterceptors(List interceptors) { - restTemplate.setInterceptors(interceptors); - } - - /** - * Gets server information details - * - * @return the ServerInfo value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.4 - */ - public ServerInfo getServerInfo() throws RestClientException { - return getServerInfo(false); - } - - /** - * Gets server information details - * - * @param forceUpdate set to true to force update of the server info - * @return the ServerInfo value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.4 - */ - public ServerInfo getServerInfo(boolean forceUpdate) throws RestClientException { - if (forceUpdate || serverInfo == null) { - String uri = getServerProfile().getServerUrl() + REST_SERVICES_V2_URI + REST_SERVER_INFO_URI; - try { - serverInfo = restTemplate.getForObject(uri, ServerInfo.class); - } catch (HttpStatusCodeException ex) { - HttpStatus statusCode = ex.getStatusCode(); - if (statusCode == HttpStatus.NOT_FOUND) { - serverInfo = new ServerInfo(); - } else { - throw ex; - } - } - } - - return serverInfo; - } - - //--------------------------------------------------------------------- - // The Resource Service - //--------------------------------------------------------------------- - - /** - * Gets the single resource lookup for the specified URI. - * - * @param uri resource URI (e.g. /reports/samples/) - * @return the ResourceDescriptor value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourceLookup getReportResource(String uri) throws RestClientException { - String fullUri = jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_RESOURCES_URI + uri; - - HttpHeaders headers = new HttpHeaders(); - if (dataType == DataType.JSON) { - headers.add("Accept", "application/repository.reportUnit+json"); - headers.add("Content-Type", "application/json"); - } else if (dataType == DataType.XML) { - headers.add("Accept", "application/repository.reportUnit+xml"); - headers.add("Content-Type", "application/xml"); - } - - HttpEntity httpEntity = new HttpEntity("", headers); - - ReportUnit resourceLookup = restTemplate.exchange(fullUri, - HttpMethod.GET, httpEntity, ReportUnit.class).getBody(); - resourceLookup.setResourceType(ResourceLookup.ResourceType.reportUnit); - - return resourceLookup; - } - - /** - * Gets the resource descriptor for the resource with specified URI. - * - * @param uri resource URI (e.g. /reports/samples/) - * @return the ResourceDescriptor value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourceDescriptor getResource(String uri) throws RestClientException { - String fullUri = restServicesUrl + REST_RESOURCE_URI + uri; - return restTemplate.getForObject(fullUri, ResourceDescriptor.class); - } - - /** - * Modifies the resource with specified ResourceDescriptor - * - * @param resourceDescriptor ResourceDescriptor of resource being modified - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public void modifyResource(ResourceDescriptor resourceDescriptor) throws RestClientException { - String fullUri = restServicesUrl + REST_RESOURCE_URI + resourceDescriptor.getUriString(); - restTemplate.postForLocation(fullUri, resourceDescriptor); - } - - /** - * Deletes the resource with the specified URI - * - * @param uri resource URI (e.g. /reports/samples/) - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public void deleteResource(String uri) throws RestClientException { - String fullUri = restServicesUrl + REST_RESOURCE_URI + uri; - restTemplate.delete(fullUri); - } - - //--------------------------------------------------------------------- - // The Resources Service - //--------------------------------------------------------------------- - - /** - * Gets the list of resource descriptors for all resources available in the folder specified in the URI. - * - * @param uri folder URI (e.g. /reports/samples/) - * @return the list of ResourceDescriptor values - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public List getResourcesList(String uri) throws RestClientException { - return getResources(uri).getResourceDescriptors(); - } - - /** - * Gets the list of resource descriptors for all resources available in the folder specified in the URI. - * - * @param uri folder URI (e.g. /reports/samples/) - * @return the ResourcesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourcesList getResources(String uri) throws RestClientException { - String fullUri = restServicesUrl + REST_RESOURCES_URI + uri; - return restTemplate.getForObject(fullUri, ResourcesList.class); - } - - /** - * Gets the list of resource descriptors for the resources available in the folder specified in the URI - * and matching the specified parameters. - * - * @param uri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - * @return the list of ResourceDescriptor values - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public List getResourcesList(String uri, String query, Boolean recursive, Integer limit) throws RestClientException { - return getResources(uri, query, recursive, limit).getResourceDescriptors(); - } - - /** - * Gets the list of resource descriptors for the resources available in the folder specified in the URI - * and matching the specified parameters. - * - * @param uri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - * @return the ResourcesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourcesList getResources(String uri, String query, Boolean recursive, Integer limit) throws RestClientException { - String uriVariablesTemplate = "?q={query}&recursive={recursive}&limit={limit}"; - String fullUri = restServicesUrl + REST_RESOURCES_URI + uri + uriVariablesTemplate; - return restTemplate.getForObject(fullUri, ResourcesList.class, query, recursive, limit); - } - - /** - * Gets the list of resource descriptors for the resources available in the folder specified in the URI - * and matching the specified parameters. - * - * @param uri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param type Match only resources of the given type - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - * @return the list of ResourceDescriptor values - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public List getResourcesList(String uri, String query, String type, Boolean recursive, - Integer limit) throws RestClientException { - return getResources(uri, query, type, recursive, limit).getResourceDescriptors(); - } - - /** - * Gets the list of resource descriptors for the resources available in the folder specified in the URI - * and matching the specified parameters. - * - * @param uri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param type Match only resources of the given type - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - * @return the ResourcesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourcesList getResources(String uri, String query, String type, Boolean recursive, Integer limit) throws RestClientException { - String uriVariablesTemplate = "?q={query}&type={type}&recursive={recursive}&limit={limit}"; - String fullUri = restServicesUrl + REST_RESOURCES_URI + uri + uriVariablesTemplate; - return restTemplate.getForObject(fullUri, ResourcesList.class, query, type, recursive, limit); - } - - /** - * Gets the list of resource descriptors for the resources available in the folder specified in the URI - * and matching the specified parameters. - * - * @param uri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param types Match only resources of the given types - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - * @return the list of ResourceDescriptor values - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public List getResourcesList(String uri, String query, List types, Boolean recursive, - Integer limit) throws RestClientException { - return getResources(uri, query, types, recursive, limit).getResourceDescriptors(); - } - - /** - * Gets the list of resource descriptors for the resources available in the folder specified in the URI - * and matching the specified parameters. - * - * @param uri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param types Match only resources of the given types - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - * @return the ResourcesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourcesList getResources(String uri, String query, List types, Boolean recursive, Integer limit) throws RestClientException { - StringBuilder fullUri = new StringBuilder(); - fullUri.append(restServicesUrl).append(REST_RESOURCES_URI).append(uri); - fullUri.append("?q={query}&recursive={recursive}&limit={limit}"); - if (types != null) { - for (String type : types) { - fullUri.append("&type=").append(type); - } - } - return restTemplate.getForObject(fullUri.toString(), ResourcesList.class, query, recursive, limit); - } - - //--------------------------------------------------------------------- - // The Resources Service v2 - //--------------------------------------------------------------------- - - /** - * Retrieves the list of resource lookup objects for the resources contained in the given parent folder - * and matching the specified parameters. - * - * @param folderUri parent folder URI (e.g. /reports/samples/) - * @param recursive Get resources recursively - * @param offset Pagination. Start index for requested page. - * @param limit Pagination. Resources count per page. - * @return the ResourceLookupsList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourceLookupsList getResourceLookups(String folderUri, boolean recursive, int offset, int limit) throws RestClientException { - return getResourceLookups(folderUri, null, null, recursive, offset, limit); - } - - /** - * Retrieves the list of resource lookup objects for the resources contained in the given parent folder - * and matching the specified parameters. - * - * @param folderUri parent folder URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description. - * (can be null) - * @param types Match only resources of the given types. Multiple resource types allowed. - * (can be null) - * @param recursive Get resources recursively - * @param offset Pagination. Start index for requested page. - * @param limit Pagination. Resources count per page. - * @return the ResourceLookupsList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourceLookupsList getResourceLookups(String folderUri, String query, List types, boolean recursive, - int offset, int limit) throws RestClientException { - return getResourceLookups(folderUri, query, types, null, recursive, offset, limit); - } - - /** - * Retrieves the list of resource lookup objects for the resources contained in the given parent folder - * and matching the specified parameters. - * - * @param folderUri parent folder URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description. - * (can be null) - * @param types Match only resources of the given types. Multiple resource types allowed. - * (can be null) - * @param sortBy Represents a field in the results to sort by: uri, label, description, type, creationDate, - * updateDate, accessTime, or popularity (based on access events). - * (can be null) - * @param recursive Get resources recursively - * @param offset Pagination. Start index for requested page. - * @param limit Pagination. Resources count per page. - * @return the ResourceLookupsList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourceLookupsList getResourceLookups(String folderUri, String query, List types, String sortBy, boolean recursive, - int offset, int limit) throws RestClientException { - ResourceLookupSearchCriteria criteria = new ResourceLookupSearchCriteria(); - criteria.setFolderUri(folderUri); - criteria.setQuery(query); - criteria.setTypes(types); - criteria.setSortBy(sortBy); - criteria.setRecursive(recursive); - criteria.setOffset(offset); - criteria.setLimit(limit); - return getResourceLookups(criteria); - } - - /** - * Retrieves the list of resource lookup objects matching the specified search criteria. - * - * @param searchCriteria the search criteria - * @return the ResourceLookupsList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourceLookupsList getResourceLookups(ResourceLookupSearchCriteria searchCriteria) throws RestClientException { - StringBuilder fullUri = new StringBuilder(); - fullUri.append(getServerProfile().getServerUrl()) - .append(REST_SERVICES_V2_URI) - .append(REST_RESOURCES_URI) - .append("?folderUri={folderUri}") - .append("&q={query}") - .append("&sortBy={sortBy}") - .append("&recursive={recursive}") - .append("&forceFullPage={forceFullPage}") - .append("&offset={offset}") - .append("&limit={limit}") - .append("&accessType={accessType}"); - - if (searchCriteria.getTypes() != null) { - for (String type : searchCriteria.getTypes()) { - fullUri.append("&type=").append(type); - } - } - - ResponseEntity responseEntity = restTemplate.exchange(fullUri.toString(), HttpMethod.GET, - null, ResourceLookupsList.class, searchCriteria.getFolderUri(), searchCriteria.getQuery(), - searchCriteria.getSortBy(), searchCriteria.isRecursive(), searchCriteria.isForceFullPage(), - searchCriteria.getOffset(), searchCriteria.getLimit(), searchCriteria.getAccessType()); - - if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) { - return new ResourceLookupsList(); - } else { - ResourceLookupsList resourceLookupsList = responseEntity.getBody(); - resourceLookupsList.setResultCount(responseEntity.getHeaders().getFirst("Result-Count")); - resourceLookupsList.setTotalCount(responseEntity.getHeaders().getFirst("Total-Count")); - resourceLookupsList.setStartIndex(responseEntity.getHeaders().getFirst("Start-Index")); - resourceLookupsList.setNextOffset(responseEntity.getHeaders().getFirst("Next-Offset")); - return resourceLookupsList; - } - } - - /** - * Retrives all data for the root folder - */ - public FolderDataResponse getRootFolderData() { - String fullUri = jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_RESOURCES_URI; - HttpHeaders headers = new HttpHeaders(); - if (dataType == DataType.JSON) { - headers.add("Accept", "application/repository.folder+json"); - headers.add("Content-Type", "application/json"); - } else if (dataType == DataType.XML) { - headers.add("Accept", "application/repository.folder+xml"); - headers.add("Content-Type", "application/xml"); - } - HttpEntity httpEntity = new HttpEntity("", headers); - - ResponseEntity responseEntity = restTemplate.exchange(fullUri, - HttpMethod.GET, httpEntity, FolderDataResponse.class); - - return responseEntity.getBody(); - } - - //--------------------------------------------------------------------- - // The Report Service - //--------------------------------------------------------------------- - - /** - * Runs the report and generates the specified output. The response contains report descriptor - * with the ID of the saved output for downloading later with a GET request. - * - * @param resourceDescriptor resource descriptor of this report - * @param format The format of the report output. Possible values: PDF, HTML, XLS, RTF, CSV, - * XML, JRPRINT. The Default is PDF. - * @return ReportDescriptor - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ReportDescriptor getReportDescriptor(ResourceDescriptor resourceDescriptor, String format) throws RestClientException { - String fullUri = restServicesUrl + REST_REPORT_URI + resourceDescriptor.getUriString() + "?IMAGES_URI=./&RUN_OUTPUT_FORMAT={format}"; - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.setAccept(singletonList(MediaType.TEXT_XML)); - HttpEntity requestEntity = new HttpEntity(resourceDescriptor, requestHeaders); - ResponseEntity entity = restTemplate.exchange(fullUri, HttpMethod.PUT, requestEntity, ReportDescriptor.class, format); - return entity.getBody(); - } - - /** - * Downloads specified report attachment, once a report has been generated, and keeps it in memory as a byte array. - * - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URI is visible only to the currently logged in user. - * @param name One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @return Attachment file as byte array stored in memory. - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public byte[] getReportAttachment(String uuid, String name) throws RestClientException { - String fullUri = restServicesUrl + REST_REPORT_URI + "/{uuid}?file={name}"; - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.setAccept(singletonList(MediaType.APPLICATION_OCTET_STREAM)); - ResponseEntity entity = restTemplate.exchange(fullUri, HttpMethod.GET, new HttpEntity(requestHeaders), byte[].class, uuid, name); - return entity.getBody(); - } - - /** - * Downloads specified report attachment, once a report has been generated and saves it in the specified file. - * - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URI is visible only to the currently logged in user. - * @param name One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @param file The file in which the attachment will be saved. - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public void saveReportAttachmentToFile(String uuid, String name, File file) throws RestClientException { - String fullUri = restServicesUrl + REST_REPORT_URI + "/{uuid}?file={name}"; - UriTemplate uriTemplate = new UriTemplate(fullUri); - URI expandedUri = uriTemplate.expand(uuid, name); - - downloadFile(expandedUri, file); - } - - //--------------------------------------------------------------------- - // The Report Service v2 - //--------------------------------------------------------------------- - - /** - * Generates the fully qualified report URL to receive all pages report output in HTML format. - * - * @param reportUri repository URI of the report - * @param parameters list of report parameter/input control values - * @return the fully qualified report URL - * @since 1.4 - */ - public String generateReportUrl(String reportUri, List parameters) { - return generateReportUrl(reportUri, parameters, 0, "HTML"); - } - - /** - * Generates the fully qualified report URL to receive all pages report output in specified format. - * - * @param reportUri repository URI of the report - * @param parameters list of report parameter/input control values - * @param format the format of the report output. Possible values: PDF, HTML, XLS, RTF, CSV, XML. - * @return the fully qualified report URL - * @since 1.4 - */ - public String generateReportUrl(String reportUri, List parameters, String format) { - return generateReportUrl(reportUri, parameters, 0, format); - } - - /** - * Generates the fully qualified report URL according to specified parameters. The new v2/reports service allows clients - * to receive report output in a single request-response using this url. - * - * @param reportUri repository URI of the report - * @param parameters list of report parameter/input control values - * @param page a positive integer value used to output a specific page or 0 to output all pages - * @param format the format of the report output. Possible values: PDF, HTML, XLS, RTF, CSV, XML. - * @return the fully qualified report URL - * @since 1.4 - */ - public String generateReportUrl(String reportUri, List parameters, int page, String format) { - StringBuilder reportUrl = new StringBuilder(); - reportUrl.append(getServerProfile().getServerUrl()).append(REST_SERVICES_V2_URI); - reportUrl.append(REST_REPORTS_URI).append(reportUri).append(".").append(format); - - if (parameters == null) parameters = new ArrayList(); - if (page > 0) parameters.add(new ReportParameter("page", Integer.toString(page))); - - if (!parameters.isEmpty()) { - reportUrl.append("?"); - Iterator paramIterator = parameters.iterator(); - while (paramIterator.hasNext()) { - ReportParameter parameter = paramIterator.next(); - Iterator valueIterator = parameter.getValues().iterator(); - while (valueIterator.hasNext()) { - try { - String value = URLEncoder.encode(valueIterator.next(), "UTF-8"); - reportUrl.append(parameter.getName()).append("=").append(value); - if (paramIterator.hasNext() || valueIterator.hasNext()) - reportUrl.append("&"); - } catch (UnsupportedEncodingException ex) { - throw new IllegalArgumentException(ex); - } - } - } - } - return reportUrl.toString(); - } - - /** - * Downloads report output, once it has been generated and saves it in the specified file. - * - * @param reportUrl the fully qualified report URL - * @param file The file in which the output will be saved - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.4 - */ - public void saveReportOutputToFile(String reportUrl, File file) throws RestClientException { - URI uri; - try { - uri = new URI(reportUrl); - } catch (URISyntaxException ex) { - throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex); - } - - downloadFile(uri, file); - } - - //--------------------------------------------------------------------- - // Report Execution Service - //--------------------------------------------------------------------- - - /** - * Forms and executes url "{server url}/rest_v2/reportExecutions" - * - * @param request we delegate to the restTemplate. - * @return report execution response. Includes executionId for later use. - * @throws RestClientException - */ - public ReportExecutionResponse runReportExecution(ReportExecutionRequest request) throws RestClientException { - checkForProfile(); - request = ExecutionRequestAdapter.newInstance(jsServerProfile.getVersionCode()).adapt(request); - String url = jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_REPORT_EXECUTIONS; - return restTemplate.postForObject(url, request, ReportExecutionResponse.class); - } - - /** - * Sends request with porpose to fetch current export datum. - * - * @param executionId Identifies current id of running report. - * @param request we delegate to the restTemplate. - * @return response with all exports datum associated with request. - * @throws RestClientException - */ - public ExportExecution runExportForReport(String executionId, ExportsRequest request) throws RestClientException { - checkForProfile(); - request = ExecutionRequestAdapter.newInstance(jsServerProfile.getVersionCode()).adapt(request); - URI uri = getExportForReportURI(executionId); - return restTemplate.postForObject(uri, request, ExportExecution.class); - } - - /** - * Generates link for requesting data on specified export resource. - * - * @param executionId Identifies current id of running report. - * @return "{server url}/rest_v2/reportExecutions/{executionId}/exports" - */ - public URI getExportForReportURI(String executionId) { - String outputResourceUri = "/{executionId}"; - String fullUri = jsServerProfile.getServerUrl() + - REST_SERVICES_V2_URI + REST_REPORT_EXECUTIONS + - outputResourceUri + REST_REPORT_EXPORTS; - - return new UriTemplate(fullUri).expand(executionId, executionId); - } - - /** - * Sends request for the current running report for the status check. - * - * @param executionId Identifies current id of running report. - * @return response which expose current report status. - */ - public ReportStatusResponse runReportStatusCheck(String executionId) { - return restTemplate.getForObject(getReportStatusCheckURI(executionId), ReportStatusResponse.class); - } - - /** - * Generates link for requesting report execution status. - * - * @param executionId Identifies current id of running report. - * @return "{server url}/rest_v2/reportExecutions/{executionId}/status" - */ - public URI getReportStatusCheckURI(String executionId) { - String outputResourceUri = "/{executionId}"; - - String fullUri = jsServerProfile.getServerUrl() + - REST_SERVICES_V2_URI + REST_REPORT_EXECUTIONS + - outputResourceUri + REST_REPORT_STATUS; - - return new UriTemplate(fullUri).expand(executionId); - } - - /** - * Sends request for the current running export for the status check. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @return response which expose current export status. - */ - public ReportStatusResponse runExportStatusCheck(String executionId, String exportOutput) { - return restTemplate.getForObject(getExportStatusCheckURI(executionId, exportOutput), ReportStatusResponse.class); - } - - /** - * Generates link for requesting report execution status. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @return "{server url}/rest_v2/reportExecutions/{executionId}/exports/{exportOutput}/status" - */ - public URI getExportStatusCheckURI(String executionId, String exportOutput) { - String outputResourceUri = "/{executionId}/exports/{exportOutput}/status"; - String fullUri = jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_REPORT_EXECUTIONS + outputResourceUri; - - UriTemplate uriTemplate = new UriTemplate(fullUri); - return uriTemplate.expand(executionId, exportOutput); - } - - /** - * Saves resource ouput in file. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @param file The file in which the output will be saved - * @throws RestClientException - */ - public void saveExportOutputToFile(String executionId, String exportOutput, File file) throws RestClientException { - URI outputResourceUri = getExportOutputResourceURI(executionId, exportOutput); - downloadFile(outputResourceUri, file); - } - - /** - * Returns response for export request in order to process InputStream directly. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @throws RestClientException - */ - public ClientHttpResponse getExportOutputResponse(String executionId, String exportOutput) throws RestClientException { - URI outputResourceUri = getExportOutputResourceURI(executionId, exportOutput); - return requestFile(outputResourceUri); - } - - /** - * Load output data for export on current request. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @return Basically it will be 3 cases HTML/JSON/XML types. - */ - public ReportDataResponse runExportOutputResource(String executionId, String exportOutput) { - ResponseEntity response = restTemplate.exchange( - getExportOutputResourceURI(executionId, exportOutput), HttpMethod.GET, null, String.class); - - boolean isFinal; - boolean hasOutputFinal = response.getHeaders().containsKey("output-final"); - String data = response.getBody(); - - if (hasOutputFinal) { - isFinal = Boolean.valueOf(response.getHeaders().getFirst("output-final")); - } else { - // "output-final" header is missing for JRS 5.5 and lower, - // so we consider request to be not final by default - isFinal = false; - } - return new ReportDataResponse(isFinal, data); - } - - /** - * Generates link for requesting report output resource datum. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @return "{server url}/rest_v2/reportExecutions/{executionId}/exports/{exportOutput}/outputResource" - */ - public URI getExportOutputResourceURI(String executionId, String exportOutput) { - String outputResourceUri = "/{executionId}/exports/{exportOutput}/outputResource"; - String fullUri = jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_REPORT_EXECUTIONS + outputResourceUri; - - UriTemplate uriTemplate = new UriTemplate(fullUri); - return uriTemplate.expand(executionId, exportOutput); - } - - /** - * Save report in file with specified name. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @param attachmentName Name of attachment we store on JRS side. - * @param file The file in which the output will be saved - * @throws RestClientException - */ - public void saveExportAttachmentToFile(String executionId, String exportOutput, - String attachmentName, File file) throws RestClientException { - URI attachmentUri = getExportAttachmentURI(executionId, exportOutput, attachmentName); - downloadFile(attachmentUri, file); - } - - /** - * Generates link for requesting of report export attachemnt data. - * - * @param executionId Identifies current id of running report. - * @param exportOutput Identifier which refers to current requested export. - * @param attachmentName Name of attachment we store on JRS side. - * @return "{server url}/rest_v2/reportExecutions/{executionId}/exports/{exportOutput}/attachments/{attachment}" - */ - public URI getExportAttachmentURI(String executionId, String exportOutput, String attachmentName) { - String attachmentUri = "/{executionId}/exports/{exportOutput}/attachments/{attachment}"; - String fullUri = jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_REPORT_EXECUTIONS + attachmentUri; - return new UriTemplate(fullUri).expand(executionId, exportOutput, attachmentName); - } - - /** - * Sends request for retrieving report details data. - * - * @param executionId Identifies current id of running report. - * @return response which expose current report details. - */ - public ReportExecutionResponse runReportDetailsRequest(String executionId) { - return restTemplate.getForObject(getReportDetailsURI(executionId), ReportExecutionResponse.class); - } - - /** - * Generates link for requesting details on specified report. - * - * @param executionId Identifies current id of running report. - * @return "{server url}/rest_v2/reportExecutions/{executionId}" - */ - public URI getReportDetailsURI(String executionId) { - String attachmentUri = "/{executionId}"; - String fullUri = jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_REPORT_EXECUTIONS + attachmentUri; - return new UriTemplate(fullUri).expand(executionId); - } - - //--------------------------------------------------------------------- - // Input Controls - //--------------------------------------------------------------------- - - /** - * Gets the resource descriptor of a query-based input control that contains query data - * according to specified parameters. - * - * @param uri repository URI of the input control - * @param datasourceUri repository URI of a datasource for the control - * @param params parameters for the input control (can be null) - * @return the ResourceDescriptor of a query-based input control that contains query data - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public ResourceDescriptor getInputControlWithQueryData(String uri, String datasourceUri, List params) throws RestClientException { - StringBuilder fullUri = new StringBuilder(); - fullUri.append(restServicesUrl).append(REST_RESOURCE_URI).append(uri); - fullUri.append("?IC_GET_QUERY_DATA=").append(datasourceUri); - if (params != null) { - for (ResourceParameter parameter : params) { - fullUri.append(parameter.isListItem() ? "&PL_" : "&P_"); - fullUri.append(parameter.getName()).append("=").append(parameter.getValue()); - } - } - return restTemplate.getForObject(fullUri.toString(), ResourceDescriptor.class); - } - - /** - * Gets the query data of a query-based input control, according to specified parameters. - * - * @param uri repository URI of the input control - * @param datasourceUri repository URI of a datasource for the control - * @param params parameters for the input control (can be null) - * @return The query data as list of ResourceProperty objects - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - */ - public List getInputControlQueryData(String uri, String datasourceUri, List params) throws RestClientException { - ResourceDescriptor descriptor = getInputControlWithQueryData(uri, datasourceUri, params); - ResourceProperty queryDataProperty = descriptor.getPropertyByName(ResourceDescriptor.PROP_QUERY_DATA); - - List listOfValues = new ArrayList(); - - if (queryDataProperty != null) { - List queryData = queryDataProperty.getProperties(); - // rows - for (ResourceProperty queryDataRow : queryData) { - ResourceProperty property = new ResourceProperty(); - property.setName(queryDataRow.getValue()); - //cols - StringBuilder value = new StringBuilder(); - for (ResourceProperty queryDataCol : queryDataRow.getProperties()) { - if (ResourceDescriptor.PROP_QUERY_DATA_ROW_COLUMN.equals(queryDataCol.getName())) { - if (value.length() > 0) value.append(" | "); - value.append(queryDataCol.getValue()); - } - } - property.setValue(value.toString()); - listOfValues.add(property); - } - } - - return listOfValues; - } - - //--------------------------------------------------------------------- - // Input Controls v2 - //--------------------------------------------------------------------- - - /** - * Gets the list of all input controls for the report with specified URI. - * - * @param reportUri repository URI of the report - * @return a list of input controls - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public List getInputControls(String reportUri) throws RestClientException { - return getInputControlsList(reportUri).getInputControls(); - } - - /** - * Deprecated due to the invalid selectedValues argument. Starting from 1.10 we are ignoring it. - * - * Gets the list of input controls with specified IDs for the report with specified URI - * and according to selected values. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs - * @param selectedValues list of selected values - * @return a list of input controls - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - @Deprecated - public List getInputControls(String reportUri, List controlsIds, - List selectedValues) throws RestClientException { - return getInputControlsList(reportUri, controlsIds, selectedValues).getInputControls(); - } - - /** - * Gets the list of all input controls for the report with specified URI. - * - * @param reportUri repository URI of the report - * @return the InputControlsList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public InputControlsList getInputControlsList(String reportUri) throws RestClientException { - return getInputControlsList(reportUri, new ArrayList(), new ArrayList()); - } - - /** - * Deprecated due to the invalid selectedValues argument. Starting from 1.10 we are ignoring it. - * - * Gets the list of input controls with specified IDs for the report with specified URI - * and according to selected values. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs - * @param selectedValues list of selected values - * @return the InputControlsList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - @Deprecated - public InputControlsList getInputControlsList(String reportUri, List controlsIds, - List selectedValues) throws RestClientException { - // generate full url - String url = generateInputControlsUrl(reportUri, controlsIds, false); - // execute POST request - InputControlsList controlsList = - restTemplate.getForObject(url, InputControlsList.class); - return (controlsList != null) ? controlsList : new InputControlsList(); - } - - /** - * Gets the list of states of all input controls for the report with specified URI. - * - * @param reportUri repository URI of the report - * @return the list of the input controls states - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public List getInputControlsValues(String reportUri) throws RestClientException { - return getInputControlsValuesList(reportUri).getInputControlStates(); - } - - /** - * Gets the list of states of input controls with specified IDs for the report with specified URI - * and according to selected values. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs - * @param selectedValues list of selected values - * @return the list of the input controls states - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public List getInputControlsValues(String reportUri, List controlsIds, - List selectedValues) throws RestClientException { - return getInputControlsValuesList(reportUri, controlsIds, selectedValues).getInputControlStates(); - } - - /** - * Gets the list of states of all input controls for the report with specified URI. - * - * @param reportUri repository URI of the report - * @return the InputControlStatesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public InputControlStatesList getInputControlsValuesList(String reportUri) throws RestClientException { - return getInputControlsValuesList(reportUri, new ArrayList(), new ArrayList()); - } - - /** - * Gets the list of states of input controls with specified IDs for the report with specified URI - * and according to selected values. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs - * @param selectedValues list of selected values - * @return the InputControlStatesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public InputControlStatesList getInputControlsValuesList(String reportUri, List controlsIds, - List selectedValues) throws RestClientException { - // generate full url - String url = generateInputControlsUrl(reportUri, controlsIds, true); - - Object request = null; - if (dataType == DataType.JSON) { - Map> map = new HashMap>(); - for (ReportParameter reportParameter : selectedValues) { - map.put(reportParameter.getName(), reportParameter.getValues()); - } - request = map; - } else if (dataType == DataType.XML) { - // add selected values to request - ReportParametersList parametersList = new ReportParametersList(); - parametersList.setReportParameters(selectedValues); - request = parametersList; - } - if (request == null) { - throw new IllegalStateException("Failed to create request object"); - } - // execute POST request - try { - return restTemplate.postForObject(url, request, InputControlStatesList.class); - } catch (HttpMessageNotReadableException exception) { - return new InputControlStatesList(); - } - } - - /** - * Validates the input controls values on the server side and returns states only for invalid controls. - * - * @param reportUri repository URI of the report - * @param inputControls list of input controls that should be validated - * @return the list of the input controls states - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.4 - */ - public List validateInputControlsValues(String reportUri, List inputControls) - throws RestClientException { - return validateInputControlsValuesList(reportUri, inputControls).getInputControlStates(); - } - - /** - * Validates the input controls values on the server side and returns states only for invalid controls. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs that should be validated - * @param selectedValues list of selected values for validation - * @return the list of the input controls states - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public List validateInputControlsValues(String reportUri, List controlsIds, - List selectedValues) throws RestClientException { - return validateInputControlsValuesList(reportUri, controlsIds, selectedValues).getInputControlStates(); - } - - /** - * Validates the input controls values on the server side and returns states only for invalid controls. - * - * @param reportUri repository URI of the report - * @param inputControls list of input controls that should be validated - * @return the InputControlStatesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public InputControlStatesList validateInputControlsValuesList(String reportUri, List inputControls) - throws RestClientException { - List controlsIds = new ArrayList(); - List selectedValues = new ArrayList(); - for (InputControl control : inputControls) { - controlsIds.add(control.getId()); - selectedValues.add(new ReportParameter(control.getId(), control.getSelectedValues())); - } - // execute validation request - return validateInputControlsValuesList(reportUri, controlsIds, selectedValues); - } - - /** - * Validates the input controls values on the server side and returns states only for invalid controls. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs that should be validated - * @param selectedValues list of selected values for validation - * @return the InputControlStatesList value - * @throws RestClientException thrown by RestTemplate whenever it encounters client-side HTTP errors - * @since 1.6 - */ - public InputControlStatesList validateInputControlsValuesList(String reportUri, List controlsIds, - List selectedValues) throws RestClientException { - InputControlStatesList statesList = getInputControlsValuesList(reportUri, controlsIds, selectedValues); - // remove states without validation errors - Iterator iterator = statesList.getInputControlStates().iterator(); - while (iterator.hasNext()) { - if (iterator.next().getError() == null) { - iterator.remove(); - } - } - return statesList; - } - - /** - * Method which flashes all stared cookies. - */ - public static void flushCookies() { - StaticCacheHelper.clearCache(); - } - - //--------------------------------------------------------------------- - // Thumbnails API - //--------------------------------------------------------------------- - - /** - * Returns thumbnail image or encoded image of the requested URI without placeholder - * - * @param resourceUri Uri of resource - * @return {serverUrl}/rest_v2/thumbnails/{resourceUri}?defaultAllowed=false - */ - public String generateThumbNailUri(String resourceUri) { - return generateThumbNailUri(resourceUri, false); - } - - /** - * Returns thumbnail image or encoded image of the requested URI - * - * @param resourceUri Uri of resource - * @param defaultAllowed If true, a placeholder thumbnail will be provided when no thumbnail is available (default: false) - * @return {serverUrl}/rest_v2/thumbnails/{resourceUri}?defaultAllowed={allowedFlag} - */ - public String generateThumbNailUri(String resourceUri, boolean defaultAllowed) { - return jsServerProfile.getServerUrl() + REST_SERVICES_V2_URI + REST_THUMBNAILS - + resourceUri + "?defaultAllowed=" + Boolean.toString(defaultAllowed); - } - - //--------------------------------------------------------------------- - // Helper methods - //--------------------------------------------------------------------- - - private void downloadFile(URI uri, File file) throws RestClientException { - ClientHttpResponse response = null; - try { - response = requestFile(uri); - copyResponseToFile(response, file); - } catch (IOException ex) { - throw new ResourceAccessException("I/O error: " + ex.getMessage(), ex); - } finally { - if (response != null) response.close(); - } - } - - private ClientHttpResponse requestFile(URI uri) throws RestClientException { - ClientHttpResponse response = null; - try { - ClientHttpRequest request = restTemplate.getRequestFactory().createRequest(uri, HttpMethod.GET); - response = request.execute(); - if (restTemplate.getErrorHandler().hasError(response)) { - restTemplate.getErrorHandler().handleError(response); - } - return response; - } catch (IOException ex) { - throw new ResourceAccessException("I/O error: " + ex.getMessage(), ex); - } - } - - protected int copyResponseToFile(ClientHttpResponse response, File file) throws IOException { - File parentFolder = file.getParentFile(); - if (parentFolder != null && !parentFolder.exists() && !parentFolder.mkdirs()) { - throw new IllegalStateException("Unable to create folder: " + parentFolder); - } - return FileCopyUtils.copy(response.getBody(), new FileOutputStream(file)); - } - - private void updateRequestFactoryTimeouts() { - updateConnectTimeout(); - updateReadTimeout(); - } - - private void updateConnectTimeout() { - requestFactory.setConnectTimeout(connectTimeout); - } - - private void updateReadTimeout() { - requestFactory.setReadTimeout(readTimeout); - } - - private String generateInputControlsUrl(String reportUri, List controlsIds, boolean valuesOnly) { - StringBuilder fullUri = new StringBuilder(); - fullUri.append(jsServerProfile.getServerUrl()) - .append(REST_SERVICES_V2_URI) - .append(REST_REPORTS_URI) - .append(reportUri) - .append(REST_INPUT_CONTROLS_URI); - // add ids to uri - if (!controlsIds.isEmpty()) { - fullUri.append("/"); - for (String id : controlsIds) { - fullUri.append(id).append(";"); - } - } - // add "values" suffix - if (valuesOnly) { - fullUri.append(REST_VALUES_URI); - } - return fullUri.toString(); - } - - private void configureMessageConverters() { - MessageConvertersFactory.newInstance(restTemplate, dataType).createMessageConverters(); - } - - private void checkForProfile() { - if (jsServerProfile == null) { - throw new IllegalStateException("Server profile is missing."); - } - } - - //--------------------------------------------------------------------- - // Inner classes - //--------------------------------------------------------------------- - - public enum DataType { - XML, JSON - } - - public static class Builder { - private RestTemplate restTemplate; - private JsRestClient.DataType dataType; - - public Builder setRestTemplate(RestTemplate restTemplate) { - this.restTemplate = restTemplate; - return this; - } - - public Builder setDataType(JsRestClient.DataType dataType) { - this.dataType = dataType; - return this; - } - - public JsRestClient build() { - ensureSaneDefaults(); - return new JsRestClient(this); - } - - private void ensureSaneDefaults() { - if (restTemplate == null) { - restTemplate = new RestTemplate(false); - } - if (dataType == null) { - dataType = DataType.XML; - } - } - } - -} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/JsServerProfile.java b/client/src/main/java/com/jaspersoft/android/sdk/client/JsServerProfile.java deleted file mode 100644 index ad684fb0..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/JsServerProfile.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import android.os.Parcel; -import android.os.Parcelable; - -/** - * The JsServerProfile object represents an instance of a JasperReports Server - * including authentication credentials. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ -public class JsServerProfile implements Parcelable { - private long id; - private String alias; - private String serverUrl; - private String organization; - private String username; - private String password; - private String versionCode; - private String serverEdition; - - /** - * Creates an empty JsServerProfile entity. - */ - public JsServerProfile() {} - - /** - * Creates a new JsServerProfile entity with the specified parameters. - * - * @param alias The name used to refer to this JsServerProfile. The alias is mainly used to display the name - * of this JsServerProfile in UI (e.g. when displaying a list of available servers). - * @param serverUrl The URL of JasperReports Server. The url does not include the /core/ portion of the uri, - * e.g. http://hostname:port/jasperserver - * @param organization The name of an organization (used in JasperReport Server Professional which supports multi-tenancy). - * May be null or empty. - * @param username The username, must be a valid account on JasperReports Server. - * @param password The account password - */ - public JsServerProfile(String alias, String serverUrl, String organization, String username, String password) { - this(0, alias, serverUrl, organization, username, password); - } - - /** - * Creates a new JsServerProfile entity with the specified parameters. - * - * @param id Unique identifier of this JsServerProfile. May be null. - * @param alias The name used to refer to this JsServerProfile. The alias is mainly used to display the name - * of this JsServerProfile in UI (e.g. when displaying a list of available servers). - * @param serverUrl The URL of JasperReports Server. The url does not include the /core/ portion of the uri, - * e.g. http://hostname:port/jasperserver - * @param organization The name of an organization (used in JasperReport Server Professional which supports multi-tenancy). - * May be null or empty. - * @param username The username, must be a valid account on JasperReports Server. - * @param password The account password - */ - public JsServerProfile(long id, String alias, String serverUrl, String organization, String username, String password) { - setId(id); - setAlias(alias); - setServerUrl(serverUrl); - setOrganization(organization); - setUsername(username); - setPassword(password); - } - - public String getUsernameWithOrgId() { - if (organization != null && organization.length() > 0) { - return username + "|" + organization; - } else { - return username; - } - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public String getServerUrl() { - return serverUrl; - } - - public void setServerUrl(String serverUrl) { - this.serverUrl = serverUrl; - } - - public String getOrganization() { - return organization; - } - - public void setOrganization(String organization) { - this.organization = organization; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getServerEdition() { - return serverEdition; - } - - public void setServerEdition(String serverEdition) { - this.serverEdition = serverEdition; - } - - public String getVersionCode() { - return versionCode; - } - - public void setVersionCode(String versionCode) { - this.versionCode = versionCode; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - JsServerProfile that = (JsServerProfile) o; - - if (id != that.id) return false; - if (!alias.equals(that.alias)) return false; - if (!serverUrl.equals(that.serverUrl)) return false; - if (organization != null ? !organization.equals(that.organization) : that.organization != null) - return false; - if (!username.equals(that.username)) return false; - if (!password.equals(that.password)) return false; - if (versionCode != null ? !versionCode.equals(that.versionCode) : that.versionCode != null) - return false; - return !(serverEdition != null ? !serverEdition.equals(that.serverEdition) : that.serverEdition != null); - - } - - @Override - public int hashCode() { - int result = (int) (id ^ (id >>> 32)); - result = 31 * result + alias.hashCode(); - result = 31 * result + serverUrl.hashCode(); - result = 31 * result + (organization != null ? organization.hashCode() : 0); - result = 31 * result + username.hashCode(); - result = 31 * result + password.hashCode(); - result = 31 * result + (versionCode != null ? versionCode.hashCode() : 0); - result = 31 * result + (serverEdition != null ? serverEdition.hashCode() : 0); - return result; - } - - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeLong(this.id); - dest.writeString(this.alias); - dest.writeString(this.serverUrl); - dest.writeString(this.organization); - dest.writeString(this.username); - dest.writeString(this.password); - dest.writeString(this.versionCode); - dest.writeString(this.serverEdition); - } - - protected JsServerProfile(Parcel in) { - this.id = in.readLong(); - this.alias = in.readString(); - this.serverUrl = in.readString(); - this.organization = in.readString(); - this.username = in.readString(); - this.password = in.readString(); - this.versionCode = in.readString(); - this.serverEdition = in.readString(); - } - - public static final Creator CREATOR = new Creator() { - public JsServerProfile createFromParcel(Parcel source) { - return new JsServerProfile(source); - } - - public JsServerProfile[] newArray(int size) { - return new JsServerProfile[size]; - } - }; -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/MessageConvertersFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/client/MessageConvertersFactory.java deleted file mode 100644 index 573636cb..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/MessageConvertersFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import android.support.annotation.Nullable; - -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.web.client.RestTemplate; - -import java.nio.charset.Charset; -import java.util.List; - -/** - * @author Tom Koptel - * @since 1.10 - */ -class MessageConvertersFactory { - private final RestTemplate restTemplate; - private final JsRestClient.DataType dataType; - - private MessageConvertersFactory(RestTemplate restTemplate, JsRestClient.DataType dataType) { - this.restTemplate = restTemplate; - this.dataType = dataType; - } - - public static MessageConvertersFactory newInstance(RestTemplate restTemplate, JsRestClient.DataType dataType) { - return new MessageConvertersFactory(restTemplate, dataType); - } - - public List> createMessageConverters() { - List> messageConverters = restTemplate.getMessageConverters(); - messageConverters.add(new ByteArrayHttpMessageConverter()); - messageConverters.add(new StringHttpMessageConverter(Charset.forName("UTF-8"))); - messageConverters.add(new ResourceHttpMessageConverter()); - messageConverters.add(new FormHttpMessageConverter()); - - createDataTypeConverter(messageConverters); - - return messageConverters; - } - - private void createDataTypeConverter(List> messageConverters) { - DataTypeConverterCreator dataTypeConverterCreator = resolveDataTypeConverter(); - if (dataTypeConverterCreator != null) { - HttpMessageConverter converter = dataTypeConverterCreator.create(); - messageConverters.add(converter); - } - } - - @Nullable - private DataTypeConverterCreator resolveDataTypeConverter() { - switch (dataType) { - case XML: - return new XMLDataTypeConverterCreator(); - case JSON: - return new GSONDataTypeConverterCreator(); - } - return null; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreator.java b/client/src/main/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreator.java deleted file mode 100644 index d0b36dd4..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreator.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import android.support.annotation.NonNull; - -import org.simpleframework.xml.Serializer; -import org.simpleframework.xml.convert.AnnotationStrategy; -import org.simpleframework.xml.core.Persister; -import org.simpleframework.xml.strategy.Strategy; -import org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter; - -/** - * @author Tom Koptel - * @since 1.10 - */ -class XMLDataTypeConverterCreator implements DataTypeConverterCreator { - @NonNull - @Override - public SimpleXmlHttpMessageConverter create() { - Strategy annotationStrategy = new AnnotationStrategy(); - Serializer serializer = new Persister(annotationStrategy); - return new SimpleXmlHttpMessageConverter(serializer); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java deleted file mode 100644 index 3d8fd372..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.api.v2; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ReportParametersListDeserializer; - -import org.simpleframework.xml.Serializer; -import org.simpleframework.xml.convert.AnnotationStrategy; -import org.simpleframework.xml.core.Persister; -import org.simpleframework.xml.strategy.Strategy; - -import retrofit.converter.Converter; -import retrofit.converter.GsonConverter; -import retrofit.converter.SimpleXMLConverter; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ConverterFactory { - - public static Converter create(DataType dataType) { - if (dataType == DataType.JSON) { - return createJsonConverter(); - } - if (dataType == DataType.XML) { - return createXmlConverter(); - } - throw new UnsupportedOperationException("Following DataType[ " + dataType + "] has no converter resolution."); - } - - private static Converter createXmlConverter() { - Strategy annotationStrategy = new AnnotationStrategy(); - Serializer serializer = new Persister(annotationStrategy); - return new SimpleXMLConverter(serializer); - } - - private static Converter createJsonConverter() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(ReportParametersList.class, new ReportParametersListDeserializer()); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - return new GsonConverter(gson); - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java deleted file mode 100644 index 8f9f5201..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/DataType.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jaspersoft.android.sdk.client.api.v2; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public enum DataType { - XML, JSON -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java deleted file mode 100644 index 58347fa7..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/JsonHttpRequestInterceptor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.api.v2; - -import retrofit.RequestInterceptor; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class JsonHttpRequestInterceptor implements RequestInterceptor { - @Override - public void intercept(RequestFacade request) { - request.addHeader("Accept", "application/json"); - request.addHeader("Accept", "application/*+json"); - } -} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java deleted file mode 100644 index f4fcf095..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApi.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.api.v2; - -import android.support.annotation.Nullable; - -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; - -import retrofit.Endpoint; -import retrofit.Endpoints; -import retrofit.RestAdapter; -import retrofit.http.GET; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface ServerRestApi { - - @GET(value = "/rest_v2/serverInfo") - ServerInfo getServerInfo(); - - class Builder { - private final String mBaseUrl; - private DataType mDataType = DataType.XML; - - Builder(@Nullable String baseUrl) { - mBaseUrl = baseUrl; - } - - public Builder setDataType(DataType dataType) { - mDataType = dataType; - return this; - } - - public Builder consumeJson() { - mDataType = DataType.JSON; - return this; - } - - public Builder consumeXml() { - mDataType = DataType.JSON; - return this; - } - - public ServerRestApi build() { - Endpoint endpoint = Endpoints.newFixedEndpoint(mBaseUrl); - - RestAdapter.Builder builder = new RestAdapter.Builder(); - builder.setConverter(ConverterFactory.create(mDataType)); - builder.setEndpoint(endpoint); - RestAdapter restAdapter = builder.build(); - - return restAdapter.create(ServerRestApi.class); - } - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java deleted file mode 100644 index e6b4cd3b..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/api/v2/XmlHttpRequestInterceptor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.api.v2; - -import retrofit.RequestInterceptor; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class XmlHttpRequestInterceptor implements RequestInterceptor { - @Override - public void intercept(RequestFacade request) { - request.addHeader("Accept", "application/xml"); - request.addHeader("Accept", "application/*+xml"); - } -} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsAsyncTaskManager.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsAsyncTaskManager.java deleted file mode 100644 index 94887031..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsAsyncTaskManager.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async; - -import android.app.AlertDialog; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.AsyncTask; -import android.os.Build; -import android.util.Log; -import android.view.WindowManager; - -import com.jaspersoft.android.sdk.client.async.task.JsAsyncTask; - -import java.util.ArrayList; -import java.util.List; - -/** - *

Declaration of Asynchronous Task Manager, - * used to manage Asynchronous Tasks. It responsible for the following:
- * 1) Creating a Progress dialog during it initialization;
- * 2) Executing the task when received into Asynchronous Task Manager control;
- * 3) Displaying the status of the target Asynchronous Task in the Progress dialog;
- * 4) Retaining/restoring the list of Asynchronous Tasks from state during - * Activity recovery
- * 5) Canceling the strong>Asynchronous task when Progress dialog is canceled.
- * 6) Closing the Progress dialog when all active Asynchronous Tasks are completed.
- * 7) Informing Activity about completion or cancellation of Asynchronous Tasks

.
- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @since 1.0 - * - * @deprecated Use {@link JsXmlSpiceService} instead. - */ - -@Deprecated -public class JsAsyncTaskManager implements JsProgressTracker, DialogInterface.OnCancelListener { - - private static final String TAG = "JsAsyncTaskManager"; - - private final JsOnTaskCallbackListener jsTaskCompleteListener; - private AlertDialog progressDialog; - private List jsAsyncTaskList = new ArrayList(); - - /** - * Creates a new Asynchronous Task Manager entity with the specified parameters. - * - * @param context Android context. - * @param jsTaskCompleteListener Asynchronous task callback listener. - */ - public JsAsyncTaskManager(Context context, JsOnTaskCallbackListener jsTaskCompleteListener) { - this(context, jsTaskCompleteListener, null); - } - - /** - * Creates a new Asynchronous Task Manager entity with the specified parameters. - * - * @param context Android context. - * @param jsTaskCompleteListener Asynchronous Task Callback Listener. - * @param progressDialog Progress dialog. - */ - public JsAsyncTaskManager(Context context, JsOnTaskCallbackListener jsTaskCompleteListener, AlertDialog progressDialog) { - // Save reference to complete listener (activity) - this.jsTaskCompleteListener = jsTaskCompleteListener; - - if (progressDialog == null) { - // Setup default progress dialog. - this.progressDialog = new ProgressDialog(context); - this.progressDialog.setCancelable(true); - this.progressDialog.setOnCancelListener(this); - this.progressDialog.dismiss(); - } else { - this.progressDialog = progressDialog; - } - } - - /** - * Executes target Asynchronous Task. - * - * @param jsAsyncTask Asynchronous Task. - */ - public void executeTask(JsAsyncTask jsAsyncTask) { - // Keep async tasks - jsAsyncTaskList.add(jsAsyncTask); - // Wire task to tracker (this) - jsAsyncTask.setProgressTracker(this); - // Start task - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - jsAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - else { - jsAsyncTask.execute(); - } - } - - /** - * {@inheritDoc} - */ - public void onProgress(JsAsyncTask jsAsyncTask, String message) { - if (jsAsyncTask.isShowProgressDialog()) { - // Show dialog if it wasn't shown yet or was removed on configuration (rotation) change - if (!progressDialog.isShowing()) { - try { - progressDialog.show(); - } catch (WindowManager.BadTokenException ex) { - jsAsyncTask.cancel(true); - jsAsyncTaskList.remove(jsAsyncTask); - Log.w(TAG, ex.getMessage()); - } - } - // Show current message in progress dialog - progressDialog.setMessage(message); - } - } - - /** - * {@inheritDoc} - */ - public void onCancel(DialogInterface dialog) { - if(!this.jsAsyncTaskList.isEmpty()) { - for (JsAsyncTask task : jsAsyncTaskList) { - task.cancel(true); - this.jsTaskCompleteListener.onTaskComplete(task); - jsAsyncTaskList.remove(task); - } - } - } - - /** - * {@inheritDoc} - */ - public void onComplete(JsAsyncTask asyncTask) { - // Notify activity about completion - jsTaskCompleteListener.onTaskComplete(asyncTask); - // Reset task - jsAsyncTaskList.remove(asyncTask); - - // Close progress dialog when all task is done - finishTaskHandler(asyncTask); - } - - /** - * {@inheritDoc} - */ - public void onException(JsAsyncTask asyncTask) { - // Notify activity about completion - jsTaskCompleteListener.onTaskException(asyncTask); - // Reset task - jsAsyncTaskList.remove(asyncTask); - - finishTaskHandler(asyncTask); - } - - /** - * Retains and detaches from progress tracker the list of Asynchronous Tasks in - * state during Activity destruction. - * - * @return list of Asynchronous tasks. - */ - public Object retainTasks() { - // Detach task from tracker (this) before retain - for (JsAsyncTask task : jsAsyncTaskList) { - task.setProgressTracker(null); - } - // Retains task - return jsAsyncTaskList; - } - - /** - * Restores the list of Asynchronous Tasks from state during - * Activity recovery. - * - * @param retainedTasksList list of Asynchronous Tasks. - */ - public void handleRetainedTasks(List retainedTasksList) { - if (retainedTasksList != null) { - jsAsyncTaskList.addAll(retainedTasksList); - for (JsAsyncTask task : jsAsyncTaskList) { - task.setProgressTracker(this); - } - } - } - - /** - * Closes progress dialog when all task is done and target progress dialog showing is required for target. - * Asynchronous task. - * - * @param asyncTask Asynchronous Task. - */ - private void finishTaskHandler(JsAsyncTask asyncTask) { - if (progressDialog.isShowing() && asyncTask.isShowProgressDialog() && jsAsyncTaskList.isEmpty()) { - try { - progressDialog.dismiss(); - } catch (IllegalArgumentException ex) { - Log.w(TAG, ex.getMessage()); - } - - } - } - - /** - * Tracks current status of Asynchronous Tasks. - * - * @return true if there are Asynchronous Tasks executing, otherwise - * false. - */ - public boolean isWorking() { - return !jsAsyncTaskList.isEmpty(); - } - - /** - * Tracks current status of the target Asynchronous Task. - * - * @return true if given Asynchronous Task is executing, otherwise - * false. - */ - public boolean isTaskWorking(JsAsyncTask asyncTask) { - return jsAsyncTaskList.contains(asyncTask); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsOnTaskCallbackListener.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsOnTaskCallbackListener.java deleted file mode 100644 index 950622bd..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsOnTaskCallbackListener.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async; - -import com.jaspersoft.android.sdk.client.async.task.JsAsyncTask; - -/** - *

Declaration of Asynchronous task callback listener, - * used to notify Activity about Asynchronous task execution results.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @since 1.0 - */ - -@Deprecated -public interface JsOnTaskCallbackListener { - - /** - * Notifies Activity about successful completion of an Asynchronous Task and contains - * the logic which will be executed on the UI thread. - * - * @param task Asynchronous Task which finished with exceptions. - */ - void onTaskComplete(JsAsyncTask task); - - /** - * Notifies Activity about Asynchronous Task execution errors and contains the - * logic which will be executed on the UI thread. - * - * @param task Asynchronous Task which finished with exceptions. - */ - void onTaskException(JsAsyncTask task); - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsProgressTracker.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsProgressTracker.java deleted file mode 100644 index 57b6d636..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsProgressTracker.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async; - -import com.jaspersoft.android.sdk.client.async.task.JsAsyncTask; - -/** - *

Declaration of Progress tracker, used for reducing of relating between Activity - * and Asynchronous task manager and notifies the last one about life cycles result of - * Asynchronous task executing.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @since 1.0 - */ - -@Deprecated -public interface JsProgressTracker { - - /** - * Updates progress message for target Asynchronous Task if showing progress - * dialog is required. - * - * @param asyncTask Asynchronous task. - * @param message message which will appear on progress dialog. - */ - void onProgress(JsAsyncTask asyncTask, String message); - - /** - * Notifies Asynchronous Task Manager about successful Asynchronous Task - * completion and is also responsible for removing the target task from active Asynchronous Task - * list and disconnecting the progress dialog. - * - * @param asyncTask Asynchronous task which finished successfully. - */ - void onComplete(JsAsyncTask asyncTask); - - /** - * Notifies Asynchronous Task Manager about Asynchronous Task errors and is - * responsible for removing the target task from active Asynchronous Task list and - * disconnecting the progress dialog. - * - * @param asyncTask Asynchronous task which finished with exceptions. - */ - void onException(JsAsyncTask asyncTask); - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsXmlSpiceService.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsXmlSpiceService.java deleted file mode 100644 index 38c243dc..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/JsXmlSpiceService.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async; - -import android.app.Application; - -import com.octo.android.robospice.SpiceService; -import com.octo.android.robospice.persistence.CacheManager; -import com.octo.android.robospice.persistence.exception.CacheCreationException; -import com.octo.android.robospice.persistence.springandroid.xml.SimpleSerializerObjectPersisterFactory; -import com.octo.android.robospice.persistence.string.InFileStringObjectPersister; - -/** - * This class offers a {@link SpiceService} dedicated to xml web services. Provides - * caching. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class JsXmlSpiceService extends SpiceService { - - @Override - public CacheManager createCacheManager(Application application) throws CacheCreationException { - CacheManager cacheManager = new CacheManager(); - // It is really important to keep proper persister order. - cacheManager.addPersister(new InFileStringObjectPersister(application)); - cacheManager.addPersister(new SimpleSerializerObjectPersisterFactory(application)); - return cacheManager; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/BaseRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/BaseRequest.java deleted file mode 100644 index e55fa8ef..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/BaseRequest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.octo.android.robospice.request.SpiceRequest; -import com.octo.android.robospice.retry.DefaultRetryPolicy; - -import roboguice.util.temp.Ln; - -/** - * Base class for writing requests using {@link JsRestClient}. - * Simply override {@link #loadDataFromNetwork()} to define the network operation of a request. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public abstract class BaseRequest extends SpiceRequest { - - private JsRestClient jsRestClient; - - public BaseRequest(JsRestClient jsRestClient, Class clazz) { - super(clazz); - this.setRetryPolicy(new DefaultRetryPolicy(0, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); - this.jsRestClient = jsRestClient; - } - - /** - * This method doesn't really work within the Spring Android module : once the request is - * loading data from network, there is no way to interrupt it. This is weakness of the spring android framework, - * and seems to come from even deeper. The IO operations on which it relies don't support the interrupt flag - * properly. - * Nevertheless, there are still some opportunities to cancel the request, basically during cache operations. - */ - @Override - public void cancel() { - super.cancel(); - Ln.w(BaseRequest.class.getName(), "Cancel can't be invoked directly on " - + BaseRequest.class.getName() + " requests. You must call SpiceManager.cancelAllRequests()."); - } - - public JsRestClient getJsRestClient() { - return jsRestClient; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/CheckReportStatusRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/CheckReportStatusRequest.java deleted file mode 100644 index 1151c995..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/CheckReportStatusRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.report.ReportStatusResponse; - -/** - * @author Tom Koptel - * @since 1.9 - * - * Check the status of export execution. - */ -public class CheckReportStatusRequest extends BaseRequest { - private String executionId; - - /** - * - * @param jsRestClient Rest client. Encapsulates call logic - * @param executionId Current report identifier. - */ - public CheckReportStatusRequest(JsRestClient jsRestClient, String executionId) { - super(jsRestClient, ReportStatusResponse.class); - this.executionId = executionId; - } - - public CheckReportStatusRequest(JsRestClient jsRestClient) { - super(jsRestClient, ReportStatusResponse.class); - } - - @Override - public ReportStatusResponse loadDataFromNetwork() throws Exception { - return getJsRestClient().runReportStatusCheck(executionId); - } - - public String getExportExecutionId() { - return executionId; - } - - public void setExportExecutionId(String exportExecutionId) { - this.executionId = exportExecutionId; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/DeleteResourceRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/DeleteResourceRequest.java deleted file mode 100644 index e3283651..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/DeleteResourceRequest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -/** - * Request that deletes the resource with the specified URI. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class DeleteResourceRequest extends BaseRequest { - - private String uri; - - /** - * Creates a new instance of {@link DeleteResourceRequest}. - * @param uri resource URI (e.g. /reports/samples/) - */ - public DeleteResourceRequest(JsRestClient jsRestClient, String uri) { - super(jsRestClient, Void.class); - this.uri = uri; - } - - @Override - public Void loadDataFromNetwork() throws Exception { - getJsRestClient().deleteResource(uri); - return null; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getUri() { - return uri; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetExportOutputRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetExportOutputRequest.java deleted file mode 100644 index f86eda57..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetExportOutputRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -import org.springframework.http.client.ClientHttpResponse; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class GetExportOutputRequest extends BaseRequest { - - private String executionId; - private String exportOutput; - - public GetExportOutputRequest(JsRestClient jsRestClient, String executionId, String exportOutput) { - super(jsRestClient, ClientHttpResponse.class); - this.executionId = executionId; - this.exportOutput = exportOutput; - } - - @Override - public ClientHttpResponse loadDataFromNetwork() throws Exception { - return getJsRestClient().getExportOutputResponse(executionId, exportOutput); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getExecutionId() { - return executionId; - } - - public String getExportOutput() { - return exportOutput; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetReportResourceRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetReportResourceRequest.java deleted file mode 100644 index 735e34a9..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetReportResourceRequest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.cacheable.CacheableRequest; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; - -/** - * Request that gets the report resource lookup for the specified URI. - * - * @author Ivan Gadzhega - * @since 1.10 - */ -public class GetReportResourceRequest extends CacheableRequest { - - private String uri; - - /** - * Creates a new instance of {@link GetReportResourceRequest}. - * @param uri resource URI (e.g. /reports/samples/) - */ - public GetReportResourceRequest(JsRestClient jsRestClient, String uri) { - super(jsRestClient, ResourceLookup.class); - this.uri = uri; - } - - @Override - public ResourceLookup loadDataFromNetwork() throws Exception { - return getJsRestClient().getReportResource(uri); - } - - @Override - protected String createCacheKeyString() { - return super.createCacheKeyString() + uri; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getUri() { - return uri; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetRootFolderDataRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetRootFolderDataRequest.java deleted file mode 100644 index 003bd697..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/GetRootFolderDataRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. - * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. - * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. - * Vestibulum commodo. Ut rhoncus gravida arcu. - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.cacheable.CacheableRequest; -import com.jaspersoft.android.sdk.client.oxm.report.FolderDataResponse; - -public class GetRootFolderDataRequest extends CacheableRequest { - - public GetRootFolderDataRequest(JsRestClient jsRestClient) { - super(jsRestClient, FolderDataResponse.class); - } - - @Override - public FolderDataResponse loadDataFromNetwork() throws Exception { - return getJsRestClient().getRootFolderData(); - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ModifyResourceRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ModifyResourceRequest.java deleted file mode 100644 index cd8423f8..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ModifyResourceRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -/** - * Request that modifies the resource with specified ResourceDescriptor. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class ModifyResourceRequest extends BaseRequest { - - private ResourceDescriptor resourceDescriptor; - - /** - * Creates a new instance of {@link ModifyResourceRequest}. - * @param resourceDescriptor descriptor of resource being modified - */ - public ModifyResourceRequest(JsRestClient jsRestClient, ResourceDescriptor resourceDescriptor) { - super(jsRestClient, Void.class); - this.resourceDescriptor = resourceDescriptor; - } - - @Override - public Void loadDataFromNetwork() throws Exception { - getJsRestClient().modifyResource(resourceDescriptor); - return null; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public ResourceDescriptor getResourceDescriptor() { - return resourceDescriptor; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ReportDetailsRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ReportDetailsRequest.java deleted file mode 100644 index 982e3c54..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/ReportDetailsRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class ReportDetailsRequest extends BaseRequest { - private String executionId; - - public ReportDetailsRequest(JsRestClient jsRestClient) { - super(jsRestClient, ReportExecutionResponse.class); - } - - public ReportDetailsRequest(JsRestClient jsRestClient, String executionId) { - super(jsRestClient, ReportExecutionResponse.class); - this.executionId = executionId; - } - - @Override - public ReportExecutionResponse loadDataFromNetwork() throws Exception { - return getJsRestClient().runReportDetailsRequest(executionId); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExecutionRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExecutionRequest.java deleted file mode 100644 index 297b3708..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExecutionRequest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; - -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ -public class RunReportExecutionRequest extends BaseRequest { - - private ReportExecutionRequest request; - - public RunReportExecutionRequest(JsRestClient jsRestClient, String reportUri, - String outputFormat, List parameters) { - this(jsRestClient, reportUri, outputFormat, parameters, true); - } - - public RunReportExecutionRequest(JsRestClient jsRestClient, String reportUri, String outputFormat, - List parameters, boolean interactive) { - this(jsRestClient, reportUri, outputFormat, parameters, interactive, null); - } - - public RunReportExecutionRequest(JsRestClient jsRestClient, String reportUri, String outputFormat, - List parameters, boolean interactive, String attachmentsPrefix) { - super(jsRestClient, ReportExecutionResponse.class); - request = new ReportExecutionRequest(); - request.setReportUnitUri(reportUri); - request.setOutputFormat(outputFormat); - request.setParameters(parameters); - request.setInteractive(interactive); - request.setAttachmentsPrefix(attachmentsPrefix); - } - - public RunReportExecutionRequest(JsRestClient jsRestClient, ReportExecutionRequest request) { - super(jsRestClient, ReportExecutionResponse.class); - this.request = request; - } - - @Override - public ReportExecutionResponse loadDataFromNetwork() throws Exception { - return getJsRestClient().runReportExecution(request); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public ReportExecutionRequest getRequest() { - return request; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportOutputRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportOutputRequest.java deleted file mode 100644 index 5a492681..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportOutputRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.report.ReportDataResponse; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class RunReportExportOutputRequest extends BaseRequest { - private String requestId; - private String executionId; - - public RunReportExportOutputRequest(JsRestClient jsRestClient) { - super(jsRestClient, ReportDataResponse.class); - } - - public RunReportExportOutputRequest(JsRestClient jsRestClient, String requestId, String executionId) { - super(jsRestClient, ReportDataResponse.class); - this.requestId = requestId; - this.executionId = executionId; - } - - @Override - public ReportDataResponse loadDataFromNetwork() throws Exception { - return getJsRestClient().runExportOutputResource(requestId, executionId); - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getExecutionId() { - return executionId; - } - - public void setExecutionId(String executionId) { - this.executionId = executionId; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportsRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportsRequest.java deleted file mode 100644 index f5171ecb..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/RunReportExportsRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.report.ExportExecution; -import com.jaspersoft.android.sdk.client.oxm.report.ExportsRequest; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class RunReportExportsRequest extends BaseRequest { - - private ExportsRequest request; - private String executionId; - - public RunReportExportsRequest(JsRestClient jsRestClient) { - super(jsRestClient, ExportExecution.class); - } - - public RunReportExportsRequest(JsRestClient jsRestClient, - ExportsRequest request, String executionId) { - super(jsRestClient, ExportExecution.class); - this.request = request; - this.executionId = executionId; - } - - @Override - public ExportExecution loadDataFromNetwork() throws Exception { - return getJsRestClient().runExportForReport(executionId, request); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public ExportsRequest getRequest() { - return request; - } - - public void setRequest(ExportsRequest request) { - this.request = request; - } - - public String getExecutionId() { - return executionId; - } - - public void setExecutionId(String executionId) { - this.executionId = executionId; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportAttachmentRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportAttachmentRequest.java deleted file mode 100644 index 3226fcf7..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportAttachmentRequest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -import java.io.File; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ -public class SaveExportAttachmentRequest extends BaseRequest { - - private String executionId; - private String exportOutput; - private String attachmentName; - private File outputFile; - - public SaveExportAttachmentRequest(JsRestClient jsRestClient, String executionId, - String exportOutput, String attachmentName, File outputFile) { - super(jsRestClient, File.class); - this.executionId = executionId; - this.exportOutput = exportOutput; - this.attachmentName = attachmentName; - this.outputFile = outputFile; - } - - @Override - public File loadDataFromNetwork() throws Exception { - getJsRestClient().saveExportAttachmentToFile(executionId, exportOutput, attachmentName, outputFile); - return outputFile; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getExecutionId() { - return executionId; - } - - public String getExportOutput() { - return exportOutput; - } - - public String getAttachmentName() { - return attachmentName; - } - - public File getOutputFile() { - return outputFile; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportOutputRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportOutputRequest.java deleted file mode 100644 index eb75b42b..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveExportOutputRequest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -import java.io.File; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ -public class SaveExportOutputRequest extends BaseRequest { - - private String executionId; - private String exportOutput; - private File outputFile; - - public SaveExportOutputRequest(JsRestClient jsRestClient, String executionId, String exportOutput, File outputFile) { - super(jsRestClient, File.class); - this.executionId = executionId; - this.exportOutput = exportOutput; - this.outputFile = outputFile; - } - - @Override - public File loadDataFromNetwork() throws Exception { - getJsRestClient().saveExportOutputToFile(executionId, exportOutput, outputFile); - return outputFile; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getExecutionId() { - return executionId; - } - - public String getExportOutput() { - return exportOutput; - } - - public File getOutputFile() { - return outputFile; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentRequest.java deleted file mode 100644 index 54a9236d..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentRequest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -import java.io.File; - -/** - * Request that downloads specified report attachment, once a report - * has been generated and saves it in the specified file. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class SaveReportAttachmentRequest extends BaseRequest { - - private String uuid; - private String attachmentName; - private File outputFile; - - /** - * Creates a new instance of {@link SaveReportAttachmentRequest}. - * - * @param uuid Universally Unique Identifier. - * @param attachmentName One of the file names specified in the report descriptor. - * @param outputFile The file in which the attachment will be saved. - */ - public SaveReportAttachmentRequest(JsRestClient jsRestClient, String uuid, String attachmentName, File outputFile) { - super(jsRestClient, File.class); - this.uuid = uuid; - this.attachmentName = attachmentName; - this.outputFile = outputFile; - } - - @Override - public File loadDataFromNetwork() throws Exception { - getJsRestClient().saveReportAttachmentToFile(uuid, attachmentName, outputFile); - return outputFile; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getUuid() { - return uuid; - } - - public String getAttachmentName() { - return attachmentName; - } - - public File getOutputFile() { - return outputFile; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentsRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentsRequest.java deleted file mode 100644 index bc435915..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/SaveReportAttachmentsRequest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ReportAttachment; - -import java.io.File; -import java.util.List; - -/** - * Request that downloads specified list of report attachments, once a report - * has been generated and saves them in the specified directory. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class SaveReportAttachmentsRequest extends BaseRequest { - - private String uuid; - private List reportAttachments; - private File outputDir; - - /** - * Creates a new instance of {@link SaveReportAttachmentsRequest}. - * - * @param uuid Universally Unique Identifier. - * @param reportAttachments List of the file names specified in the report descriptor. - * @param outputDir The directory in which these attachments will be saved. - */ - public SaveReportAttachmentsRequest(JsRestClient jsRestClient, String uuid, List reportAttachments, File outputDir) { - super(jsRestClient, File.class); - this.uuid = uuid; - this.reportAttachments = reportAttachments; - this.outputDir = outputDir; - } - - @Override - public File loadDataFromNetwork() throws Exception { - for (ReportAttachment attachment : reportAttachments) { - String attachmentName = attachment.getName(); - File outputFile = new File(outputDir, attachmentName); - getJsRestClient().saveReportAttachmentToFile(uuid, attachmentName, outputFile); - } - return outputDir; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getUuid() { - return uuid; - } - - public List getReportAttachments() { - return reportAttachments; - } - - public File getOutputDir() { - return outputDir; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/BaseInputControlsRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/BaseInputControlsRequest.java deleted file mode 100644 index 1c5a7c00..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/BaseInputControlsRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.control.InputControl; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.6 - */ -abstract class BaseInputControlsRequest extends CacheableRequest { - - protected static final String TAG_IC_VALUES = "INPUT_CONTROLS_VALUES"; - - private String reportUri; - private List controlsIds; - private List selectedValues; - - - BaseInputControlsRequest(JsRestClient jsRestClient, String reportUri, Class clazz) { - this(jsRestClient, reportUri, new ArrayList(), new ArrayList(), clazz); - } - - BaseInputControlsRequest(JsRestClient jsRestClient, String reportUri, List inputControls, Class clazz) { - this(jsRestClient, reportUri, clazz); - for(InputControl control : inputControls) { - controlsIds.add(control.getId()); - selectedValues.add(new ReportParameter(control.getId(), control.getSelectedValues())); - } - } - - BaseInputControlsRequest(JsRestClient jsRestClient, String reportUri, List controlsIds, - List selectedValues, Class clazz) { - super(jsRestClient, clazz); - this.reportUri = reportUri; - this.controlsIds = controlsIds; - this.selectedValues = selectedValues; - } - - - @Override - public abstract T loadDataFromNetwork() throws Exception; - - @Override - protected String createCacheKeyString() { - StringBuilder keyBuilder = new StringBuilder(); - keyBuilder.append(super.createCacheKeyString()); - keyBuilder.append(reportUri); - for (String id : controlsIds) keyBuilder.append(id); - for (ReportParameter parameter : selectedValues) { - keyBuilder.append(parameter.getName()); - for (String value : parameter.getValues()) { - keyBuilder.append(value); - } - } - return keyBuilder.toString(); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getReportUri() { - return reportUri; - } - - public List getControlsIds() { - return controlsIds; - } - - public List getSelectedValues() { - return selectedValues; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/CacheableRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/CacheableRequest.java deleted file mode 100644 index 7194ad44..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/CacheableRequest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.JsServerProfile; -import com.jaspersoft.android.sdk.client.async.request.BaseRequest; - -/** - * A request that contains results that may be cached. - * Provides additional functionality for cache key generation. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public abstract class CacheableRequest extends BaseRequest { - - public CacheableRequest(JsRestClient jsRestClient, Class clazz) { - super(jsRestClient, clazz); - } - - public int createCacheKey() { - return createCacheKeyString().hashCode(); - } - - protected String createCacheKeyString() { - JsServerProfile profile = getJsRestClient().getServerProfile(); - if (profile == null) { - return createCacheKeyTag(); - } else { - return createCacheKeyTag() + profile.getServerUrl() + profile.getOrganization() + profile.getUsername(); - } - } - - protected String createCacheKeyTag() { - return getClass().getName(); - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsRequest.java deleted file mode 100644 index 0755fd76..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsRequest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlsList; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; - -import java.util.List; - -/** - * Request that gets the list of input controls for the report with specified URI - * and according to specified parameters. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class GetInputControlsRequest extends BaseInputControlsRequest { - - /** - * Creates a new instance of {@link GetInputControlsRequest}. - * - * @param reportUri repository URI of the report. - */ - public GetInputControlsRequest(JsRestClient jsRestClient, String reportUri) { - super(jsRestClient, reportUri, InputControlsList.class); - } - - /** - * Creates a new instance of {@link GetInputControlsRequest}. - * - * @param reportUri repository URI of the report. - * @param controlsIds list of input controls IDs. - * @param selectedValues list of selected values. - */ - public GetInputControlsRequest(JsRestClient jsRestClient, String reportUri, - List controlsIds, List selectedValues) { - super(jsRestClient, reportUri, controlsIds, selectedValues, InputControlsList.class); - } - - - @Override - public InputControlsList loadDataFromNetwork() throws Exception { - return getJsRestClient().getInputControlsList(getReportUri(), getControlsIds(), getSelectedValues()); - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsValuesRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsValuesRequest.java deleted file mode 100644 index f61c201e..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetInputControlsValuesRequest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.control.InputControl; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlStatesList; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; - -import java.util.List; - -/** - * Request that gets the list of states of input controls for the report with specified URI - * and according to specified parameters. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class GetInputControlsValuesRequest extends BaseInputControlsRequest { - - /** - * Creates a new instance of {@link GetInputControlsValuesRequest}. - * - * @param reportUri repository URI of the report - */ - public GetInputControlsValuesRequest(JsRestClient jsRestClient, String reportUri) { - super(jsRestClient, reportUri, InputControlStatesList.class); - } - - /** - * Creates a new instance of {@link GetInputControlsValuesRequest}. - * - * @param reportUri repository URI of the report - * @param inputControls list of input controls - */ - public GetInputControlsValuesRequest(JsRestClient jsRestClient, String reportUri, List inputControls) { - super(jsRestClient, reportUri, inputControls, InputControlStatesList.class); - } - - /** - * Creates a new instance of {@link GetInputControlsValuesRequest}. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs - * @param selectedValues list of selected values - */ - public GetInputControlsValuesRequest(JsRestClient jsRestClient, String reportUri, - List controlsIds, List selectedValues) { - super(jsRestClient, reportUri, controlsIds, selectedValues, InputControlStatesList.class); - } - - - @Override - public InputControlStatesList loadDataFromNetwork() throws Exception { - return getJsRestClient().getInputControlsValuesList(getReportUri(), getControlsIds(), getSelectedValues()); - } - - @Override - protected String createCacheKeyTag() { - return TAG_IC_VALUES; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetReportRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetReportRequest.java deleted file mode 100644 index a35af590..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetReportRequest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ReportDescriptor; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; -import com.jaspersoft.android.sdk.client.oxm.ResourceParameter; - -/** - * Request that runs the report and generates the specified output. The response contains report descriptor - * with the ID of the saved output for downloading later with another GET request. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class GetReportRequest extends CacheableRequest { - - private ResourceDescriptor resourceDescriptor; - private String outputFormat; - - /** - * Creates a new instance of {@link GetReportRequest}. - * - * @param resourceDescriptor resource descriptor of this report - * @param outputFormat The format of the report output. Possible values: PDF, HTML, XLS, RTF, CSV, - * XML, JRPRINT. The Default is PDF. - */ - public GetReportRequest(JsRestClient jsRestClient, ResourceDescriptor resourceDescriptor, String outputFormat) { - super(jsRestClient, ReportDescriptor.class); - this.resourceDescriptor = resourceDescriptor; - this.outputFormat = outputFormat; - } - - @Override - public ReportDescriptor loadDataFromNetwork() throws Exception { - return getJsRestClient().getReportDescriptor(resourceDescriptor, outputFormat); - } - - @Override - protected String createCacheKeyString() { - StringBuilder keyBuilder = new StringBuilder(); - keyBuilder.append(super.createCacheKeyString()); - keyBuilder.append(resourceDescriptor.getUriString()); - keyBuilder.append(outputFormat); - for (ResourceParameter parameter : resourceDescriptor.getParameters()) { - keyBuilder.append(parameter.getName()); - keyBuilder.append(parameter.getValue()); - } - return keyBuilder.toString(); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public ResourceDescriptor getResourceDescriptor() { - return resourceDescriptor; - } - - public String getOutputFormat() { - return outputFormat; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceLookupsRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceLookupsRequest.java deleted file mode 100644 index 8b0e046c..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceLookupsRequest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupSearchCriteria; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupsList; - -import java.util.List; - -/** - * Request that retrieves the list of resource lookup objects for the resources - * contained in the given parent folder and matching the specified parameters. - * - * @author Ivan Gadzhega - * @since 1.7 - */ -public class GetResourceLookupsRequest extends CacheableRequest { - - private ResourceLookupSearchCriteria searchCriteria; - - /** - * Creates a new instance of {@link GetResourceLookupsRequest}. - * - * @param folderUri parent folder URI (e.g. /reports/samples/) - * @param recursive Get resources recursively - * @param offset Pagination. Start index for requested page. - * @param limit Pagination. Resources count per page. - */ - public GetResourceLookupsRequest(JsRestClient jsRestClient, String folderUri, boolean recursive, int offset, int limit) { - this(jsRestClient, folderUri, null, null, recursive, offset, limit); - } - - /** - * Creates a new instance of {@link GetResourceLookupsRequest}. - * - * @param folderUri parent folder URI (e.g. /reports/samples/) - * @param types Match only resources of the given types. Multiple resource types allowed. - * (can be null) - * @param offset Pagination. Start index for requested page. - * @param limit Pagination. Resources count per page. - */ - public GetResourceLookupsRequest(JsRestClient jsRestClient, String folderUri, List types, int offset, int limit) { - this(jsRestClient, folderUri, null, types, false, offset, limit); - } - - /** - * Creates a new instance of {@link GetResourceLookupsRequest}. - * - * @param folderUri parent folder URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description. - * (can be null) - * @param types Match only resources of the given types. Multiple resource types allowed. - * (can be null) - * @param recursive Get resources recursively - * @param offset Pagination. Start index for requested page. - * @param limit Pagination. Resources count per page. - */ - public GetResourceLookupsRequest(JsRestClient jsRestClient, String folderUri, String query, List types, - boolean recursive, int offset, int limit) { - this(jsRestClient, folderUri, query, types, null, recursive, offset, limit); - } - - /** - * Creates a new instance of {@link GetResourceLookupsRequest}. - * - * @param folderUri parent folder URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description. - * (can be null) - * @param types Match only resources of the given types. Multiple resource types allowed. - * (can be null) - * @param sortBy Represents a field in the results to sort by: uri, label, description, type, creationDate, - * updateDate, accessTime, or popularity (based on access events). - * (can be null) - * @param recursive Get resources recursively - * @param offset Pagination. Start index for requested page. - * @param limit Pagination. Resources count per page. - */ - public GetResourceLookupsRequest(JsRestClient jsRestClient, String folderUri, String query, List types, - String sortBy, boolean recursive, int offset, int limit) { - super(jsRestClient, ResourceLookupsList.class); - searchCriteria = new ResourceLookupSearchCriteria(); - searchCriteria.setFolderUri(folderUri); - searchCriteria.setQuery(query); - searchCriteria.setTypes(types); - searchCriteria.setSortBy(sortBy); - searchCriteria.setRecursive(recursive); - searchCriteria.setOffset(offset); - searchCriteria.setLimit(limit); - } - - /** - * Creates a new instance of {@link GetResourceLookupsRequest}. - * - * @param searchCriteria the search criteria - */ - public GetResourceLookupsRequest(JsRestClient jsRestClient, ResourceLookupSearchCriteria searchCriteria) { - super(jsRestClient, ResourceLookupsList.class); - this.searchCriteria = searchCriteria; - } - - @Override - public ResourceLookupsList loadDataFromNetwork() throws Exception { - return getJsRestClient().getResourceLookups(searchCriteria); - } - - @Override - protected String createCacheKeyString() { - return super.createCacheKeyString() - + searchCriteria.getFolderUri() - + searchCriteria.getQuery() - + searchCriteria.getTypes() - + searchCriteria.getSortBy() - + searchCriteria.isRecursive() - + searchCriteria.getOffset() - + searchCriteria.getLimit(); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public ResourceLookupSearchCriteria getSearchCriteria() { - return searchCriteria; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceRequest.java deleted file mode 100644 index d39dfc13..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourceRequest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -/** - * Request that gets the resource descriptor for the resource with specified URI. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class GetResourceRequest extends CacheableRequest { - - private String uri; - - /** - * Creates a new instance of {@link GetResourceRequest}. - * @param uri resource URI (e.g. /reports/samples/) - */ - public GetResourceRequest(JsRestClient jsRestClient, String uri) { - super(jsRestClient, ResourceDescriptor.class); - this.uri = uri; - } - - @Override - public ResourceDescriptor loadDataFromNetwork() throws Exception { - return getJsRestClient().getResource(uri); - } - - @Override - protected String createCacheKeyString() { - return super.createCacheKeyString() + uri; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getUri() { - return uri; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourcesRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourcesRequest.java deleted file mode 100644 index b5d7c48b..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetResourcesRequest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourcesList; - -/** - * Request that gets the list of resource descriptors for all resources - * available in the folder specified in the URI. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class GetResourcesRequest extends CacheableRequest { - - private String uri; - - /** - * Creates a new instance of {@link GetResourcesRequest}. - * @param uri folder URI (e.g. /reports/samples/) - */ - public GetResourcesRequest(JsRestClient jsRestClient, String uri) { - super(jsRestClient, ResourcesList.class); - this.uri = uri; - } - - @Override - public ResourcesList loadDataFromNetwork() throws Exception { - return getJsRestClient().getResources(uri); - } - - @Override - protected String createCacheKeyString() { - return super.createCacheKeyString() + uri; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getUri() { - return uri; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetServerInfoRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetServerInfoRequest.java deleted file mode 100644 index 44a9ffbc..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/GetServerInfoRequest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; - -/** - * Request that gets server information details. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class GetServerInfoRequest extends CacheableRequest { - - /** - * Creates a new instance of {@link GetServerInfoRequest}. - */ - public GetServerInfoRequest(JsRestClient jsRestClient) { - super(jsRestClient, ServerInfo.class); - } - - @Override - public ServerInfo loadDataFromNetwork() throws Exception { - return getJsRestClient().getServerInfo(); - } - - @Override - protected String createCacheKeyString() { - return super.createCacheKeyString() + JsRestClient.REST_SERVER_INFO_URI; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/SearchResourcesRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/SearchResourcesRequest.java deleted file mode 100644 index 3ef81c13..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/SearchResourcesRequest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourcesList; - -import java.util.Arrays; -import java.util.List; - -/** - * Gets the list of resource descriptors for the resources available - * in the folder specified in the URI and matching the specified parameters. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class SearchResourcesRequest extends CacheableRequest { - - private String uri; - private String query; - private List types; - private Boolean recursive; - private Integer limit; - - /** - * Creates a new instance of {@link SearchResourcesRequest}. - * - * @param uri folder URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param type Match only resources of the given type - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesRequest(JsRestClient jsRestClient, String uri, String query, String type, - Boolean recursive, Integer limit) { - this(jsRestClient, uri, query, Arrays.asList(type), recursive, limit); - } - - /** - * Creates a new instance of {@link SearchResourcesRequest}. - * - * @param uri folder URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param types Match only resources of the given types - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesRequest(JsRestClient jsRestClient, String uri, String query, List types, - Boolean recursive, Integer limit) { - super(jsRestClient, ResourcesList.class); - this.uri = uri; - this.query = query; - this.types = types; - this.recursive = recursive; - this.limit = limit; - } - - @Override - public ResourcesList loadDataFromNetwork() throws Exception { - return getJsRestClient().getResources(uri, query, types, recursive, limit); - } - - @Override - protected String createCacheKeyString() { - return super.createCacheKeyString() + uri + query + types + recursive + limit; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getUri() { - return uri; - } - - public String getQuery() { - return query; - } - - public List getTypes() { - return types; - } - - public Boolean getRecursive() { - return recursive; - } - - public Integer getLimit() { - return limit; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/ValidateInputControlsValuesRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/ValidateInputControlsValuesRequest.java deleted file mode 100644 index 4f748e41..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/request/cacheable/ValidateInputControlsValuesRequest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.request.cacheable; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.control.InputControl; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlStatesList; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; - -import java.util.List; - -/** - * Request that validates input controls values on the server side - * and returns states only for invalid controls. - * - * @author Ivan Gadzhega - * @since 1.6 - */ -public class ValidateInputControlsValuesRequest extends BaseInputControlsRequest { - - /** - * Creates a new instance of {@link ValidateInputControlsValuesRequest}. - * - * @param reportUri repository URI of the report - * @param inputControls list of input controls that should be validated - */ - public ValidateInputControlsValuesRequest(JsRestClient jsRestClient, String reportUri, List inputControls) { - super(jsRestClient, reportUri, inputControls, InputControlStatesList.class); - } - - /** - * Creates a new instance of {@link ValidateInputControlsValuesRequest}. - * - * @param reportUri repository URI of the report - * @param controlsIds list of input controls IDs that should be validated - * @param selectedValues list of selected values for validation - */ - public ValidateInputControlsValuesRequest(JsRestClient jsRestClient, String reportUri, List controlsIds, - List selectedValues) { - super(jsRestClient, reportUri, controlsIds, selectedValues, InputControlStatesList.class); - } - - - @Override - public InputControlStatesList loadDataFromNetwork() throws Exception { - return getJsRestClient().validateInputControlsValuesList(getReportUri(), getControlsIds(), getSelectedValues()); - } - - @Override - protected String createCacheKeyTag() { - return TAG_IC_VALUES; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/DeleteResourceAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/DeleteResourceAsyncTask.java deleted file mode 100644 index 2e149ac5..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/DeleteResourceAsyncTask.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -/** - *

Declaration of the DeleteResourceAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.DeleteResourceRequest DeleteResourceRequest} - * instead. - */ - -@Deprecated -public class DeleteResourceAsyncTask extends JsRestAsyncTask { - - private String resourceUri; - - /** - * Creates a new DeleteResourceAsyncTask entity with the specified parameters. - * - * @param id DeleteResourceAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public DeleteResourceAsyncTask(int id, JsRestClient jsRestClient, String resourceUri) { - super(id, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * Creates a new DeleteResourceAsyncTask entity with the specified parameters. - * - * @param id DeleteResourceAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public DeleteResourceAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, String resourceUri) { - super(id, progressMessage, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * - * @param id DeleteResourceAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public DeleteResourceAsyncTask(int id, String progressMessage, - long showDialogTimeout, JsRestClient jsRestClient, String resourceUri) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - this.resourceUri = resourceUri; - } - - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * deleteResource(String resourceUri) method. - * - * @param arg0 the parameters of the Asynchronous Task. Current implementation does not use these params. - * @return Resource descriptor by resource URI. - */ - @Override - protected Void doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - getJsRestClient().deleteResource(this.resourceUri); - } catch (Exception e) { - setTaskException(e); - } - return null; - } - - // Getters - - public String getResourceUri() { - return resourceUri; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetInputControlsAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetInputControlsAsyncTask.java deleted file mode 100644 index ff15a427..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetInputControlsAsyncTask.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.control.InputControl; - -import java.util.List; - -/** - *

Declaration of the GetInputControlsAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Ivan Gadzhega - * @since 1.4 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.cacheable.GetInputControlsRequest GetInputControlsRequest} - * instead. - */ - -@Deprecated -public class GetInputControlsAsyncTask extends JsRestAsyncTask> { - - private String reportUri; - - /** - * Creates a new GetInputControlsAsyncTask entity with the specified parameters. - * - * @param id GetInputControlsAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param reportUri Report Uri. - */ - public GetInputControlsAsyncTask(int id, JsRestClient jsRestClient, String reportUri) { - super(id, jsRestClient); - this.reportUri = reportUri; - } - - /** - * Creates a new GetInputControlsAsyncTask entity with the specified parameters. - * - * @param id GetInputControlsAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param reportUri Report Uri. - */ - public GetInputControlsAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, String reportUri) { - super(id, progressMessage, jsRestClient); - this.reportUri = reportUri; - } - - /** - * - * @param id GetInputControlsAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param reportUri Report Uri. - */ - public GetInputControlsAsyncTask(int id, String progressMessage, - long showDialogTimeout, JsRestClient jsRestClient, String reportUri) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - this.reportUri = reportUri; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * getInputControlsForReport(String reportUri) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return the list of input controls for the report with specified URI - */ - @Override - protected List doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - return getJsRestClient().getInputControls(reportUri); - } catch (Exception e) { - setTaskException(e); - return null; - } - } - - // Getters - - public String getReportUri() { - return reportUri; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetReportAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetReportAsyncTask.java deleted file mode 100644 index b9db27b2..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetReportAsyncTask.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ReportDescriptor; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -/** - *

Declaration of the GetReportAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method.

- * - * @author Ivan Gadzhega - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.cacheable.GetReportRequest GetReportRequest} - * instead. - */ - -@Deprecated -public class GetReportAsyncTask extends JsRestAsyncTask { - - private ResourceDescriptor resourceDescriptor; - private String outputFormat; - - /** - * Creates a new GetReportAsyncTask entity with the specified parameters. - * - * @param id GetReportAsyncTask identifier. - * @param jsRestClient JsRestClient. - */ - public GetReportAsyncTask(int id, JsRestClient jsRestClient, - ResourceDescriptor resourceDescriptor, String outputFormat) { - super(id, jsRestClient); - this.resourceDescriptor = resourceDescriptor; - this.outputFormat = outputFormat; - } - - /** - * Creates a new GetReportAsyncTask entity with the specified parameters. - * - * @param id GetReportAsyncTask identifier. - * @param progressMessage Progress dialog message. - * @param jsRestClient JsRestClient. - * @param resourceDescriptor resource descriptor of this report - * @param outputFormat The format of the report output. Possible values: PDF, HTML, XLS, RTF, CSV, - * XML, JRPRINT. The Default is PDF. - */ - public GetReportAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, - ResourceDescriptor resourceDescriptor, String outputFormat) { - super(id, progressMessage, jsRestClient); - this.resourceDescriptor = resourceDescriptor; - this.outputFormat = outputFormat; - } - - /** - * Creates a new GetReportAsyncTask entity with the specified parameters. - * - * @param id GetReportAsyncTask identifier. - * @param progressMessage Progress dialog message. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param resourceDescriptor resource descriptor of this report - * @param outputFormat The format of the report output. Possible values: PDF, HTML, XLS, RTF, CSV, - * XML, JRPRINT. The Default is PDF. - */ - public GetReportAsyncTask(int id, String progressMessage, long showDialogTimeout, JsRestClient jsRestClient, - ResourceDescriptor resourceDescriptor, String outputFormat) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - this.resourceDescriptor = resourceDescriptor; - this.outputFormat = outputFormat; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * getReportDescriptor(String resourceUri, String outputFormat) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return Resource descriptor by resource URI. - */ - @Override - protected ReportDescriptor doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - return getJsRestClient().getReportDescriptor(this.resourceDescriptor, outputFormat); - } catch (Exception e) { - setTaskException(e); - return null; - } - } - - // Getters - - public ResourceDescriptor getResourceDescriptor() { - return resourceDescriptor; - } - - public String getOutputFormat() { - return outputFormat; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourceAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourceAsyncTask.java deleted file mode 100644 index 8a0e6609..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourceAsyncTask.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -/** - *

Declaration of the GetResourceAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.cacheable.GetResourceRequest GetResourceRequest} - * instead. - */ - -@Deprecated -public class GetResourceAsyncTask extends JsRestAsyncTask { - - private String resourceUri; - - /** - * Creates a new GetResourceAsyncTask entity with the specified parameters. - * - * @param id GetResourceAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public GetResourceAsyncTask(int id, JsRestClient jsRestClient, String resourceUri) { - super(id, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * Creates a new GetResourceAsyncTask entity with the specified parameters. - * - * @param id GetResourceAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public GetResourceAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, String resourceUri) { - super(id, progressMessage, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * Creates a new GetResourceAsyncTask entity with the specified parameters. - * - * @param id GetResourceAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public GetResourceAsyncTask(int id, String progressMessage, - long showDialogTimeout, JsRestClient jsRestClient, String resourceUri) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * getResource(String resourceUri) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return Resource descriptor by resource URI. - */ - @Override - protected ResourceDescriptor doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - return getJsRestClient().getResource(resourceUri); - } catch (Exception e) { - setTaskException(e); - return null; - } - } - - // Getters - - public String getResourceUri() { - return resourceUri; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourcesListAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourcesListAsyncTask.java deleted file mode 100644 index 46f3956a..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetResourcesListAsyncTask.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -import java.util.List; - -/** - *

Declaration of the GetResourcesListAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.cacheable.GetResourcesRequest GetResourcesRequest} instead. - */ - -@Deprecated -public class GetResourcesListAsyncTask extends JsRestAsyncTask> { - - private String resourceUri; - - /** - * Creates a new GetResourcesListAsyncTask entity with the specified parameters. - * - * @param id GetResourcesListAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public GetResourcesListAsyncTask(int id, JsRestClient jsRestClient, String resourceUri) { - super(id, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * Creates a new GetResourcesListAsyncTask entity with the specified parameters. - * - * @param id GetResourcesListAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public GetResourcesListAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, String resourceUri) { - super(id, progressMessage, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * - * @param id GetResourcesListAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param resourceUri Resource Uri. - */ - public GetResourcesListAsyncTask(int id, String progressMessage, - long showDialogTimeout, JsRestClient jsRestClient, String resourceUri) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - this.resourceUri = resourceUri; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * getResourcesList(String resourceUri) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return Resource descriptor by resource URI. - */ - @Override - protected List doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - return getJsRestClient().getResourcesList(resourceUri); - } catch (Exception e) { - setTaskException(e); - return null; - } - } - - // Getters - - public String getResourceUri() { - return resourceUri; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetServerInfoAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetServerInfoAsyncTask.java deleted file mode 100644 index 006a1ff1..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/GetServerInfoAsyncTask.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; - -/** - * @author Ivan Gadzhega - * @since 1.4 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.cacheable.GetServerInfoRequest GetResourcesRequest} - * instead. - */ - -@Deprecated -public class GetServerInfoAsyncTask extends JsRestAsyncTask{ - - /** - * Creates a new GetServerInfoAsyncTask entity with the specified parameters. - * - * @param id GetServerInfoAsyncTask identifier. - * @param jsRestClient JsRestClient. - */ - public GetServerInfoAsyncTask(int id, JsRestClient jsRestClient) { - super(id, jsRestClient); - } - - /** - * Creates a new GetServerInfoAsyncTask entity with the specified parameters. - * - * @param id GetServerInfoAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - */ - public GetServerInfoAsyncTask(int id, String progressMessage, JsRestClient jsRestClient) { - super(id, progressMessage, SHOW_DIALOG_DEFAULT_TIMEOUT, jsRestClient); - } - - /** - * Creates a new GetServerInfoAsyncTask entity with the specified parameters. - * - * @param id GetServerInfoAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param progressDialogAppearAfter the time interval (in milliseconds) Progress dialog should be - * appear. - * @param jsRestClient JsRestClient. - */ - public GetServerInfoAsyncTask(int id, String progressMessage, long progressDialogAppearAfter, JsRestClient jsRestClient) { - super(id, progressMessage, progressDialogAppearAfter, jsRestClient); - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * getServerInfo() method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return the ServerInfo value - */ - @Override - protected ServerInfo doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - return getJsRestClient().getServerInfo(); - } catch (Exception e) { - setTaskException(e); - return null; - } - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsAsyncTask.java deleted file mode 100644 index 53fc8bf3..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsAsyncTask.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import android.os.AsyncTask; - -import com.jaspersoft.android.sdk.client.async.JsProgressTracker; - -import java.util.Timer; -import java.util.TimerTask; - -/** - *

Declaration of the JsAsyncTask which is subclass of Android core AsyncTask - * abstract class that enables proper and easy use of the Android UI thread. - * JsAsyncTask enables of Progress dialog integration due of encapsulating of - * Progress tracker.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.BaseRequest BaseRequest} - * instead. - */ - -@Deprecated -public abstract class JsAsyncTask extends AsyncTask { - - // constant for dialog showing default timeout (1 second). - public static final long SHOW_DIALOG_DEFAULT_TIMEOUT = 1000; - - private int id; - private Result result; - private Exception taskException; - private JsProgressTracker progressTracker; - private boolean showProgressDialog; - private long showDialogTimeout; - private String progressMessage; - - /** - * Creates a new JsAsyncTask entity with the specified parameters. - * - * @param id Asynchronous task identifier. - */ - public JsAsyncTask(int id) { - this.id = id; - } - - /** - * Creates a new JsAsyncTask entity with the specified parameters. - * - * @param id Asynchronous task identifier. - * @param progressMessage Progress dialog message. - */ - public JsAsyncTask(int id, String progressMessage) { - this(id, progressMessage, SHOW_DIALOG_DEFAULT_TIMEOUT); - showProgressDialog = true; - } - - /** - * Creates a new JsAsyncTask entity with the specified parameters. - * - * @param id Asynchronous task identifier. - * @param progressMessage Progress dialog message. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - */ - public JsAsyncTask(int id, String progressMessage, long showDialogTimeout) { - this.id = id; - showProgressDialog = true; - this.showDialogTimeout = showDialogTimeout; - this.progressMessage = progressMessage; - } - - /** - * Attaches Progress tracker for target Asynchronous task. - * - * @param progressTracker Progress tracker. - */ - public void setProgressTracker(JsProgressTracker progressTracker) { - // Attach to progress tracker - this.progressTracker = progressTracker; - // Initialise progress tracker with current task state - if (this.progressTracker != null) { - //this.progressTracker.onProgress(progressMessage); - if (result != null) { - this.progressTracker.onComplete(this); - } - } - } - - /** - * Overrides the android core AsyncTask method which runs on the UI thread after - * cancel(boolean) is invoked and doInBackground(Object[]) has finished. Overriding method - * detaches from progress tracker. - */ - @Override - protected void onCancelled() { - // Detach from progress tracker - this.progressTracker = null; - } - - /** - * Overrides the android core AsyncTask method which invokes on the UI thread after a - * publishProgress(Progress...) calling. Overriding method update progress message and sent it to - * progress tracker. - * - * @param values the values indicating progress - progress dialog message in current implementation. - */ - @Override - protected void onProgressUpdate(String... values) { - // Update progress message - this.progressMessage = values[0]; - // And send it to progress tracker - if (this.progressTracker != null) { - this.progressTracker.onProgress(this, this.progressMessage); - } - } - - /** - * Overrides the android core AsyncTask method which runs on the UI thread after - * doInBackground(Params...). This method won't be invoked if the task was cancelled. - * - * @param result the specified result is the value returned by doInBackground(Params...). - */ - @Override - protected void onPostExecute(Result result) { - // Update result - this.result = result; - // And send it to progress tracker - if (taskException == null) { - progressTracker.onComplete(this); - } else { - progressTracker.onException(this); - } - // Detach from progress tracker - progressTracker = null; - } - - /** - * Overrides the android core AsyncTask method which performs a computation on a background thread. - * Overriding is done by scheduling of progress dialog if it required for target - * Asynchronous task. - * - * @param params the parameters of the Asynchronous task. - * @return a result, defined by the subclass of this class. - */ - protected Result doInBackground(Params... params) { - if (showProgressDialog) { - //Init starting time of execution show progress dialog. - Timer timer = new Timer(); - TimerTask showProgressDialogTask = new ShowProgressDialogTask(); - //Show progress dialog after showDialogTimeout milliseconds . - timer.schedule(showProgressDialogTask, showDialogTimeout); - } - return null; - } - - /** - * Declaration of runnable ShowProgressDialogTask which publishes updates on the UI thread while the - * background computation is still running. - */ - private class ShowProgressDialogTask extends TimerTask { - @Override - public void run() { - publishProgress(progressMessage); - } - } - - /** - * Tracks whether to show Progress dialog for target Asynchronous task. - * - * @return true if Asynchronous task required of Progress dialog - * showing, otherwise false. - */ - public boolean isShowProgressDialog() { - return showProgressDialog; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public Exception getTaskException() { - return taskException; - } - - public void setTaskException(Exception taskException) { - this.taskException = taskException; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsRestAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsRestAsyncTask.java deleted file mode 100644 index 5bd076e6..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/JsRestAsyncTask.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -/** - *

Declaration of the JsRestAsyncTask which is subclass of JsAsyncTask - * abstract class and encapsulates JsRestClient.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.BaseRequest BaseRequest} - * instead. - */ - -@Deprecated -public abstract class JsRestAsyncTask extends JsAsyncTask { - - private JsRestClient jsRestClient; - - /** - * Creates a new JsRestAsyncTask entity with the specified parameters. - * - * @param id JsRestAsyncTask identifier. - * @param jsRestClient JsRestClient. - */ - public JsRestAsyncTask(int id, JsRestClient jsRestClient) { - super(id); - this.jsRestClient = jsRestClient; - } - - /** - * Creates a new JsRestAsyncTask entity with the specified parameters. - * - * @param id JsRestAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - */ - public JsRestAsyncTask(int id, String progressMessage, JsRestClient jsRestClient) { - super(id, progressMessage, SHOW_DIALOG_DEFAULT_TIMEOUT); - this.jsRestClient = jsRestClient; - } - - /** - * Creates a new JsRestAsyncTask entity with the specified parameters. - * - * @param id JsRestAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param progressDialogAppearAfter the time interval (in milliseconds) Progress dialog should be - * appear. - * @param jsRestClient JsRestClient. - */ - public JsRestAsyncTask(int id, String progressMessage, long progressDialogAppearAfter, JsRestClient jsRestClient) { - super(id, progressMessage, progressDialogAppearAfter); - this.jsRestClient = jsRestClient; - } - - - public JsRestClient getJsRestClient() { - return jsRestClient; - } - - public void setJsRestClient(JsRestClient jsRestClient) { - this.jsRestClient = jsRestClient; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/ModifyResourceAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/ModifyResourceAsyncTask.java deleted file mode 100644 index b7aca7ab..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/ModifyResourceAsyncTask.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -/** - *

Declaration of the ModifyResourceAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.ModifyResourceRequest ModifyResourceRequest} - * instead. - */ - -@Deprecated -public class ModifyResourceAsyncTask extends JsRestAsyncTask { - - private ResourceDescriptor resourceDescriptor; - - /** - * Creates a new ModifyResourceAsyncTask entity with the specified parameters. - * - * @param id ModifyResourceAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param resourceDescriptor Resource descriptor. - */ - public ModifyResourceAsyncTask(int id, JsRestClient jsRestClient, ResourceDescriptor resourceDescriptor) { - super(id, jsRestClient); - this.resourceDescriptor = resourceDescriptor; - } - - /** - * Creates a new ModifyResourceAsyncTask entity with the specified parameters. - * - * @param id ModifyResourceAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param resourceDescriptor Resource descriptor. - */ - public ModifyResourceAsyncTask(int id, String progressMessage, - JsRestClient jsRestClient, ResourceDescriptor resourceDescriptor) { - super(id, progressMessage, jsRestClient); - this.resourceDescriptor = resourceDescriptor; - } - - /** - * - * @param id ModifyResourceAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param resourceDescriptor Resource descriptor. - */ - public ModifyResourceAsyncTask(int id, String progressMessage, - JsRestClient jsRestClient, long showDialogTimeout, ResourceDescriptor resourceDescriptor) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - this.resourceDescriptor = resourceDescriptor; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * modifyResource(ResourceDescriptor resourceDescriptor) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return nothing. - */ - @Override - protected Void doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - getJsRestClient().modifyResource(this.resourceDescriptor); - } catch (Exception e) { - setTaskException(e); - } - return null; - } - - // Getters - - public ResourceDescriptor getResourceDescriptor() { - return resourceDescriptor; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentAsyncTask.java deleted file mode 100644 index f0955a4b..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentAsyncTask.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; - -import java.io.File; - -/** - *

Declaration of the SaveReportAttachmentAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.SaveReportAttachmentRequest SaveReportAttachmentRequest} - * instead. - */ - -@Deprecated -public class SaveReportAttachmentAsyncTask extends JsRestAsyncTask { - - private String uuid; - private String attachmentName; - private File outputFile; - private String contentType; - - /** - * Creates a new SaveReportAttachmentAsyncTask entity with the specified parameters. - * - * @param id SaveReportAttachmentAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URL is visible only to the currently logged user. - * @param attachmentName One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @param outputFile The file in which the attachment will be saved. - */ - public SaveReportAttachmentAsyncTask(int id, JsRestClient jsRestClient, String uuid, String attachmentName, File outputFile) { - super(id, jsRestClient); - init(uuid, attachmentName, outputFile); - } - - /** - * Creates a new SaveReportAttachmentAsyncTask entity with the specified parameters. - * - * @param id SaveReportAttachmentAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URL is visible only to the currently logged user. - * @param attachmentName One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @param outputFile The file in which the attachment will be saved. - */ - public SaveReportAttachmentAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, - String uuid, String attachmentName, File outputFile) { - super(id, progressMessage, jsRestClient); - init(uuid, attachmentName, outputFile); - } - - /** - * Creates a new SaveReportAttachmentAsyncTask entity with the specified parameters. - * - * @param id SaveReportAttachmentAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URL is visible only to the currently logged user. - * @param attachmentName One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @param outputFile The file in which the attachment will be saved. - */ - public SaveReportAttachmentAsyncTask(int id, String progressMessage, long showDialogTimeout, - JsRestClient jsRestClient, String uuid, String attachmentName, File outputFile) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - init(uuid, attachmentName, outputFile); - } - - private void init(String uuid, String attachmentName, File outputFile) { - this.uuid = uuid; - this.attachmentName = attachmentName; - this.outputFile = outputFile; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * saveReportAttachmentToFile(...) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return nothing. - */ - @Override - protected Void doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - getJsRestClient().saveReportAttachmentToFile(uuid, attachmentName, outputFile); - } catch (Exception e) { - setTaskException(e); - } - return null; - } - - // Getters - - public String getUuid() { - return uuid; - } - - public String getAttachmentName() { - return attachmentName; - } - - public File getOutputFile() { - return outputFile; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentsAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentsAsyncTask.java deleted file mode 100644 index 897e2b97..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SaveReportAttachmentsAsyncTask.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ReportAttachment; - -import java.io.File; -import java.util.List; - -/** - *

Declaration of the SaveReportAttachmentsAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.SaveReportAttachmentsRequest SaveReportAttachmentsRequest} - * instead. - */ - -@Deprecated -public class SaveReportAttachmentsAsyncTask extends JsRestAsyncTask { - - private String uuid; - private List reportAttachments; - private File outputDir; - - /** - * Creates a new SaveReportAttachmentsAsyncTask entity with the specified parameters. - * - * @param id SaveReportAttachmentsAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URL is visible only to the currently logged user. - * @param reportAttachments One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @param outputDir The file in which the attachment will be saved. - */ - public SaveReportAttachmentsAsyncTask(int id, JsRestClient jsRestClient, - String uuid, List reportAttachments, File outputDir) { - super(id, jsRestClient); - init(uuid, reportAttachments, outputDir); - } - - /** - * Creates a new SaveReportAttachmentsAsyncTask entity with the specified parameters. - * - * @param id SaveReportAttachmentsAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URL is visible only to the currently logged user. - * @param reportAttachments One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @param outputDir The file in which the attachment will be saved. - */ - public SaveReportAttachmentsAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, - String uuid, List reportAttachments, File outputDir) { - super(id, progressMessage, jsRestClient); - init(uuid, reportAttachments, outputDir); - } - - /** - * Creates a new SaveReportAttachmentsAsyncTask entity with the specified parameters. - * - * @param id SaveReportAttachmentsAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param uuid Universally Unique Identifier. As a side effect of storing the report output in the user session, - * the UUID in the URL is visible only to the currently logged user. - * @param reportAttachments One of the file names specified in the report xml. If the file parameter is not specified, - * the service returns the report descriptor. - * @param outputDir The file in which the attachment will be saved. - */ - public SaveReportAttachmentsAsyncTask(int id, String progressMessage, long showDialogTimeout, - JsRestClient jsRestClient, String uuid, List reportAttachments, File outputDir) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - init(uuid, reportAttachments, outputDir); - } - - private void init(String uuid, List reportAttachments, File outputDir) { - this.uuid = uuid; - this.reportAttachments = reportAttachments; - this.outputDir = outputDir; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * saveReportAttachmentToFile(...) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return nothing. - */ - @Override - protected Void doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - for (ReportAttachment attachment : reportAttachments) { - String attachmentName = attachment.getName(); - File outputFile = new File(outputDir, attachmentName); - getJsRestClient().saveReportAttachmentToFile(uuid, attachmentName, outputFile); - } - } catch (Exception e) { - setTaskException(e); - } - return null; - } - - // Getters - - public String getUuid() { - return uuid; - } - - public List getReportAttachments() { - return reportAttachments; - } - - public File getOutputDir() { - return outputDir; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SearchResourcesAsyncTask.java b/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SearchResourcesAsyncTask.java deleted file mode 100644 index 93dd57df..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/async/task/SearchResourcesAsyncTask.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.async.task; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -import java.util.ArrayList; -import java.util.List; - -/** - *

Declaration of the SearchResourcesAsyncTask which is subclass of JsRestAsyncTask - * abstract class and overrides doInBackground(Object... arg0) method from it.

- * - * @author Volodya Sabadosh (vsabadosh@jaspersoft.com) - * @author Ivan Gadzhega - * @since 1.0 - * - * @deprecated Use {@link com.jaspersoft.android.sdk.client.async.request.cacheable.SearchResourcesRequest SearchResourcesRequest} - * instead. - */ - -@Deprecated -public class SearchResourcesAsyncTask extends JsRestAsyncTask> { - - private String resourceUri; - private String query; - private List types; - private Boolean recursive; - private Integer limit; - - /** - * Creates a new SearchResourcesAsyncTask entity with the specified parameters. - * - * @param id SearchResourcesAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param resourceUri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param type Match only resources of the given type - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesAsyncTask(int id, JsRestClient jsRestClient, String resourceUri, String query, String type, - Boolean recursive, Integer limit) { - super(id, jsRestClient); - init(resourceUri, query, type, recursive, limit); - } - - /** - * Creates a new SearchResourcesAsyncTask entity with the specified parameters. - * - * @param id SearchResourcesAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param resourceUri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param type Match only resources of the given type - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, String resourceUri, - String query, String type, Boolean recursive, Integer limit) { - super(id, progressMessage, jsRestClient); - init(resourceUri, query, type, recursive, limit); - } - - /** - * Creates a new SearchResourcesAsyncTask entity with the specified parameters. - * - * @param id SearchResourcesAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param resourceUri resource URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param type Match only resources of the given type - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesAsyncTask(int id, String progressMessage, long showDialogTimeout, JsRestClient jsRestClient, - String resourceUri, String query, String type, Boolean recursive, Integer limit) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - init(resourceUri, query, type, recursive, limit); - } - - /** - * Creates a new SearchResourcesAsyncTask entity with the specified parameters. - * - * @param id SearchResourcesAsyncTask identifier. - * @param jsRestClient JsRestClient. - * @param resourceUri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param types Match only resources of the given types - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesAsyncTask(int id, JsRestClient jsRestClient, String resourceUri, String query, List types, - Boolean recursive, Integer limit) { - super(id, jsRestClient); - init(resourceUri, query, types, recursive, limit); - } - - /** - * Creates a new SearchResourcesAsyncTask entity with the specified parameters. - * - * @param id SearchResourcesAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param jsRestClient JsRestClient. - * @param resourceUri repository URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param types Match only resources of the given types - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesAsyncTask(int id, String progressMessage, JsRestClient jsRestClient, String resourceUri, - String query, List types, Boolean recursive, Integer limit) { - super(id, progressMessage, jsRestClient); - init(resourceUri, query, types, recursive, limit); - } - - /** - * Creates a new SearchResourcesAsyncTask entity with the specified parameters. - * - * @param id SearchResourcesAsyncTask identifier. - * @param progressMessage message of Progress dialog. - * @param showDialogTimeout the time interval (in milliseconds) Progress dialog should be appear - * after. - * @param jsRestClient JsRestClient. - * @param resourceUri resource URI (e.g. /reports/samples/) - * @param query Match only resources having the specified text in the name or description (can be null) - * @param types Match only resources of the given type - * @param recursive Get resources recursively and not only in the specified URI. Used only when a search criteria - * is specified, either query or type. (can be null) - * @param limit Maximum number of items returned to the client. The default is 0 (can be null), - * meaning no limit. - */ - public SearchResourcesAsyncTask(int id, String progressMessage, long showDialogTimeout, JsRestClient jsRestClient, - String resourceUri, String query, List types, Boolean recursive, Integer limit) { - super(id, progressMessage, showDialogTimeout, jsRestClient); - init(resourceUri, query, types, recursive, limit); - } - - private void init(String resourceUri, String query, String type, Boolean recursive, Integer limit) { - List types = new ArrayList(); - types.add(type); - init(resourceUri, query, types, recursive, limit); - } - - private void init(String resourceUri, String query, List types, Boolean recursive, Integer limit) { - this.resourceUri = resourceUri; - this.query = query; - this.types = types; - this.recursive = recursive; - this.limit = limit; - } - - /** - * Overrides the doInBackground(Object... arg0) method by calling JsRestClient - * getResourcesList(...) method. - * - * @param arg0 the parameters of the Asynchronous task. Current implementation does not use this params. - * @return the list of ResourceDescriptors. - */ - @Override - protected List doInBackground(Object... arg0) { - super.doInBackground(arg0); - try { - return getJsRestClient().getResourcesList(resourceUri, query, types, recursive, limit); - } catch (Exception e) { - setTaskException(e); - return null; - } - } - - // Getters - - public String getResourceUri() { - return resourceUri; - } - - public String getQuery() { - return query; - } - - public List getTypes() { - return types; - } - - public Boolean getRecursive() { - return recursive; - } - - public Integer getLimit() { - return limit; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/ic/InputControlWrapper.java b/client/src/main/java/com/jaspersoft/android/sdk/client/ic/InputControlWrapper.java deleted file mode 100644 index c010bb42..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/ic/InputControlWrapper.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.ic; - -import android.view.View; - -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; -import com.jaspersoft.android.sdk.client.oxm.ResourceParameter; -import com.jaspersoft.android.sdk.client.oxm.ResourceProperty; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * This is a helper class for working with input control entities, independent of type and UI appearance. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ -@Deprecated -public class InputControlWrapper { - - public static final String NULL_SUBSTITUTE = "~NULL~"; - public static final String NULL_SUBSTITUTE_LABEL = "[Null]"; - public static final String NOTHING_SUBSTITUTE = "~NOTHING~"; - public static final String NOTHING_SUBSTITUTE_LABEL = "---"; - - private String name; - private String label; - private String uri; - private byte type; - private byte dataType; - private String dataTypeUri; - private boolean isMandatory = false; - private boolean isReadOnly = false; - private boolean isVisible= true; - - private String query; - private String dataSourceUri; - private List parameterDependencies = new ArrayList(); - - private List masterDependencies = new ArrayList(); - private List slaveDependencies = new ArrayList(); - - private List listOfValues = new ArrayList(); - private List listOfSelectedValues = new ArrayList(); - - private View inputView; - private View errorView; - - - public InputControlWrapper(ResourceDescriptor resourceDescriptor){ - name = resourceDescriptor.getName(); - label = resourceDescriptor.getLabel(); - uri = resourceDescriptor.getUriString(); - - // init fields from resource properties - for (ResourceProperty property : resourceDescriptor.getProperties()){ - String name = property.getName(); - if (ResourceDescriptor.PROP_INPUTCONTROL_TYPE.equals(name)) { - type = Byte.parseByte(property.getValue()); - } else if (ResourceDescriptor.PROP_INPUTCONTROL_IS_MANDATORY.equals(name)) { - isMandatory = Boolean.parseBoolean(property.getValue()); - } else if (ResourceDescriptor.PROP_INPUTCONTROL_IS_READONLY.equals(name)) { - isReadOnly = Boolean.parseBoolean(property.getValue()); - } else if (ResourceDescriptor.PROP_INPUTCONTROL_IS_VISIBLE.equals(name)) { - isVisible = Boolean.parseBoolean(property.getValue()); - } - } - - // get query and datasource uri if exist - for(ResourceDescriptor internalResource : resourceDescriptor.getInternalResources()) { - if(internalResource.getWsType() == ResourceDescriptor.WsType.query) { - ResourceProperty queryProperty = internalResource.getPropertyByName(ResourceDescriptor.PROP_QUERY); - this.query = queryProperty.getValue(); - this.dataSourceUri = internalResource.getDataSourceUri(); - break; - } - } - - // resolve data type for single value input control - if (this.getType() == ResourceDescriptor.IC_TYPE_SINGLE_VALUE) { - for(ResourceDescriptor internalResource : resourceDescriptor.getInternalResources()) { - if(internalResource.getWsType() == ResourceDescriptor.WsType.dataType) { - ResourceProperty dataTypeProperty = internalResource.getPropertyByName(ResourceDescriptor.PROP_DATATYPE_TYPE); - this.dataType = Byte.parseByte(dataTypeProperty.getValue()); - break; - } else if (internalResource.getWsType() == ResourceDescriptor.WsType.reference) { - ResourceProperty referenceUri = internalResource.getPropertyByName(ResourceDescriptor.PROP_FILERESOURCE_REFERENCE_URI); - this.dataTypeUri = referenceUri.getValue(); - break; - } - } - } - - // get parameters that input control depends on - if (query != null) { - // standard parameter - Pattern sp = Pattern.compile("\\$P\\{\\s*([\\w]*)\\s*\\}"); - - Matcher m = sp.matcher(query); - while (m.find()) parameterDependencies.add(m.group(1)); - - // include parameter - Pattern ip = Pattern.compile("\\$P!\\{\\s*([\\w]*)\\s*\\}"); - - m = ip.matcher(query); - while (m.find()) parameterDependencies.add(m.group(1)); - - // dynamic query parameter - Pattern dqp = Pattern.compile("\\$X\\{[^{}]*,\\s*([\\w]*)\\s*\\}"); - - m = dqp.matcher(query); - while (m.find()) parameterDependencies.add(m.group(1)); - } - - // init input control values list - switch (getType()) { - case ResourceDescriptor.IC_TYPE_BOOLEAN: - case ResourceDescriptor.IC_TYPE_SINGLE_VALUE: - break; - - case ResourceDescriptor.IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES: - case ResourceDescriptor.IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES_RADIO: - case ResourceDescriptor.IC_TYPE_MULTI_SELECT_LIST_OF_VALUES: - case ResourceDescriptor.IC_TYPE_MULTI_SELECT_LIST_OF_VALUES_CHECKBOX: - - for (ResourceDescriptor internalResource : resourceDescriptor.getInternalResources()) { - if (internalResource.getWsType() == ResourceDescriptor.WsType.lov) { - ResourceProperty propLov = internalResource.getPropertyByName(ResourceDescriptor.PROP_LOV); - listOfValues = propLov.getProperties(); - break; - } - } - break; - - case ResourceDescriptor.IC_TYPE_SINGLE_SELECT_QUERY: - case ResourceDescriptor.IC_TYPE_SINGLE_SELECT_QUERY_RADIO: - case ResourceDescriptor.IC_TYPE_MULTI_SELECT_QUERY: - case ResourceDescriptor.IC_TYPE_MULTI_SELECT_QUERY_CHECKBOX: - - ResourceProperty queryDataProperty = resourceDescriptor.getPropertyByName(ResourceDescriptor.PROP_QUERY_DATA); - - if (queryDataProperty != null) { - List queryData = queryDataProperty.getProperties(); - // rows - for (ResourceProperty queryDataRow : queryData) { - ResourceProperty property = new ResourceProperty(); - property.setName(queryDataRow.getValue()); - - //cols - StringBuilder value = new StringBuilder(); - for(ResourceProperty queryDataCol : queryDataRow.getProperties()) { - if(ResourceDescriptor.PROP_QUERY_DATA_ROW_COLUMN.equals(queryDataCol.getName())) { - if (value.length() > 0) value.append(" | "); - value.append(queryDataCol.getValue()); - } - } - - property.setValue(value.toString()); - listOfValues.add(property); - } - } - break; - } - - } - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public byte getType() { - return type; - } - - public void setType(byte type) { - this.type = type; - } - - public byte getDataType() { - return dataType; - } - - public void setDataType(byte dataType) { - this.dataType = dataType; - } - - public String getDataTypeUri() { - return dataTypeUri; - } - - public void setDataTypeUri(String dataTypeUri) { - this.dataTypeUri = dataTypeUri; - } - - public boolean isMandatory() { - return isMandatory; - } - - public void setMandatory(boolean mandatory) { - isMandatory = mandatory; - } - - public boolean isReadOnly() { - return isReadOnly; - } - - public void setReadOnly(boolean readOnly) { - isReadOnly = readOnly; - } - - public boolean isVisible() { - return isVisible; - } - - public void setVisible(boolean visible) { - isVisible = visible; - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public String getDataSourceUri() { - return dataSourceUri; - } - - public void setDataSourceUri(String dataSourceUri) { - this.dataSourceUri = dataSourceUri; - } - - public List getParameterDependencies() { - return parameterDependencies; - } - - public void setParameterDependencies(List parameterDependencies) { - this.parameterDependencies = parameterDependencies; - } - - public List getMasterDependencies() { - return masterDependencies; - } - - public void setMasterDependencies(List masterDependencies) { - this.masterDependencies = masterDependencies; - } - - public List getSlaveDependencies() { - return slaveDependencies; - } - - public void setSlaveDependencies(List slaveDependencies) { - this.slaveDependencies = slaveDependencies; - } - - public List getListOfValues() { - return listOfValues; - } - - public void setListOfValues(List listOfValues) { - this.listOfValues = listOfValues; - } - - public List getListOfSelectedValues() { - return listOfSelectedValues; - } - - public void setListOfSelectedValues(List listOfSelectedValues) { - this.listOfSelectedValues = listOfSelectedValues; - } - - public View getInputView() { - return inputView; - } - - public void setInputView(View inputView) { - this.inputView = inputView; - } - - public View getErrorView() { - return errorView; - } - - public void setErrorView(View errorView) { - this.errorView = errorView; - } -} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportAttachment.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportAttachment.java deleted file mode 100644 index d0746b1d..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportAttachment.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Root; -import org.simpleframework.xml.Text; - -/** - * This class represents a report attachment entity for convenient XML serialization process. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ -@Root(name="file") -public class ReportAttachment { - - @Expose - @Attribute - private String type; - - @Expose - @Text - private String name; - - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportDescriptor.java deleted file mode 100644 index f74d8182..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ReportDescriptor.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class represents a report descriptor entity for convenient XML serialization process. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ - -@Root(name="report", strict=false) -public class ReportDescriptor { - - @Expose - @Element - private String uuid; - @Expose - @Element - private String originalUri; - @Expose - @Element - private Integer totalPages; - @Expose - @Element - private Integer startPage; - @Expose - @Element - private Integer endPage; - - @ElementList(entry="file", inline=true, empty=false) - private List attachments = new ArrayList(); - - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getOriginalUri() { - return originalUri; - } - - public void setOriginalUri(String originalUri) { - this.originalUri = originalUri; - } - - public Integer getTotalPages() { - return totalPages; - } - - public void setTotalPages(Integer totalPages) { - this.totalPages = totalPages; - } - - public Integer getStartPage() { - return startPage; - } - - public void setStartPage(Integer startPage) { - this.startPage = startPage; - } - - public Integer getEndPage() { - return endPage; - } - - public void setEndPage(Integer endPage) { - this.endPage = endPage; - } - - public List getAttachments() { - return attachments; - } - - public void setAttachments(List attachments) { - this.attachments = attachments; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceDescriptor.java deleted file mode 100644 index c5a611ad..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceDescriptor.java +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm; - -import android.util.Log; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class represents a resource descriptor entity for convenient XML serialization process. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ - -@Root(strict=false) -public class ResourceDescriptor { - - /** - * These constants are copied here from DataType for facility - */ - public static final byte DT_TYPE_TEXT = 1; - public static final byte DT_TYPE_NUMBER = 2; - public static final byte DT_TYPE_DATE = 3; - public static final byte DT_TYPE_DATE_TIME = 4; - - /** - * These constants are copied here from InputControl for facility - */ - public static final byte IC_TYPE_BOOLEAN = 1; - public static final byte IC_TYPE_SINGLE_VALUE = 2; - public static final byte IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES = 3; - public static final byte IC_TYPE_SINGLE_SELECT_QUERY = 4; - public static final byte IC_TYPE_MULTI_VALUE = 5; - public static final byte IC_TYPE_MULTI_SELECT_LIST_OF_VALUES = 6; - public static final byte IC_TYPE_MULTI_SELECT_QUERY = 7; - - public static final byte IC_TYPE_SINGLE_SELECT_LIST_OF_VALUES_RADIO = 8; - public static final byte IC_TYPE_SINGLE_SELECT_QUERY_RADIO = 9; - public static final byte IC_TYPE_MULTI_SELECT_LIST_OF_VALUES_CHECKBOX = 10; - public static final byte IC_TYPE_MULTI_SELECT_QUERY_CHECKBOX = 11; - - public static final String PROP_VERSION = "PROP_VERSION"; - public static final String PROP_PARENT_FOLDER = "PROP_PARENT_FOLDER"; - public static final String PROP_RESOURCE_TYPE = "PROP_RESOURCE_TYPE"; - public static final String PROP_CREATION_DATE = "PROP_CREATION_DATE"; - - // File resource properties - public static final String PROP_FILERESOURCE_HAS_DATA = "PROP_HAS_DATA"; - public static final String PROP_FILERESOURCE_IS_REFERENCE = "PROP_IS_REFERENCE"; - public static final String PROP_FILERESOURCE_REFERENCE_URI = "PROP_REFERENCE_URI"; - public static final String PROP_FILERESOURCE_WSTYPE = "PROP_WSTYPE"; - public static final String PROP_DATA = "PROP_DATA"; - public static final String PROP_DATASOURCE_MAPPING = "DATASOURCE_MAPPING"; - - // Datasource properties - public static final String PROP_DATASOURCE_DRIVER_CLASS = "PROP_DATASOURCE_DRIVER_CLASS"; - public static final String PROP_DATASOURCE_CONNECTION_URL = "PROP_DATASOURCE_CONNECTION_URL"; - public static final String PROP_DATASOURCE_USERNAME = "PROP_DATASOURCE_USERNAME"; - public static final String PROP_DATASOURCE_PASSWORD = "PROP_DATASOURCE_PASSWORD"; - public static final String PROP_DATASOURCE_JNDI_NAME = "PROP_DATASOURCE_JNDI_NAME"; - public static final String PROP_DATASOURCE_BEAN_NAME = "PROP_DATASOURCE_BEAN_NAME"; - public static final String PROP_DATASOURCE_BEAN_METHOD = "PROP_DATASOURCE_BEAN_METHOD"; - // - public static final String PROP_DATASOURCE_CUSTOM_SERVICE_CLASS = "PROP_DATASOURCE_CUSTOM_SERVICE_CLASS"; - public static final String PROP_DATASOURCE_CUSTOM_PROPERTY_MAP = "PROP_DATASOURCE_CUSTOM_PROPERTY_MAP"; - - - // ReportUnit resource properties - public static final String PROP_RU_DATASOURCE_TYPE = "PROP_RU_DATASOURCE_TYPE"; - public static final String PROP_RU_IS_MAIN_REPORT = "PROP_RU_IS_MAIN_REPORT"; - public static final String PROP_RU_INPUTCONTROL_RENDERING_VIEW = "PROP_RU_INPUTCONTROL_RENDERING_VIEW"; - public static final String PROP_RU_REPORT_RENDERING_VIEW = "PROP_RU_REPORT_RENDERING_VIEW"; - public static final String PROP_RU_ALWAYS_PROPMT_CONTROLS = "PROP_RU_ALWAYS_PROPMT_CONTROLS"; - public static final String PROP_RU_CONTROLS_LAYOUT = "PROP_RU_CONTROLS_LAYOUT"; - - public static final byte RU_CONTROLS_LAYOUT_POPUP_SCREEN = 1; - public static final byte RU_CONTROLS_LAYOUT_SEPARATE_PAGE = 2; - public static final byte RU_CONTROLS_LAYOUT_TOP_OF_PAGE = 3; - public static final byte RU_CONTROLS_LAYOUT_IN_PAGE = 4; - - // DataType resource properties - public static final String PROP_DATATYPE_STRICT_MAX = "PROP_DATATYPE_STRICT_MAX"; - public static final String PROP_DATATYPE_STRICT_MIN = "PROP_DATATYPE_STRICT_MIN"; - public static final String PROP_DATATYPE_MIN_VALUE = "PROP_DATATYPE_MIN_VALUE"; - public static final String PROP_DATATYPE_MAX_VALUE = "PROP_DATATYPE_MAX_VALUE"; - public static final String PROP_DATATYPE_PATTERN = "PROP_DATATYPE_PATTERN"; - public static final String PROP_DATATYPE_TYPE = "PROP_DATATYPE_TYPE"; - - // ListOfValues resource properties - public static final String PROP_LOV = "PROP_LOV"; - public static final String PROP_LOV_LABEL = "PROP_LOV_LABEL"; - public static final String PROP_LOV_VALUE = "PROP_LOV_VALUE"; - - - // InputControl resource properties - public static final String PROP_INPUTCONTROL_TYPE = "PROP_INPUTCONTROL_TYPE"; - public static final String PROP_INPUTCONTROL_IS_MANDATORY = "PROP_INPUTCONTROL_IS_MANDATORY"; - public static final String PROP_INPUTCONTROL_IS_READONLY = "PROP_INPUTCONTROL_IS_READONLY"; - public static final String PROP_INPUTCONTROL_IS_VISIBLE = "PROP_INPUTCONTROL_IS_VISIBLE"; - - // SQL resource properties - public static final String PROP_QUERY = "PROP_QUERY"; - public static final String PROP_QUERY_VISIBLE_COLUMNS = "PROP_QUERY_VISIBLE_COLUMNS"; - public static final String PROP_QUERY_VISIBLE_COLUMN_NAME = "PROP_QUERY_VISIBLE_COLUMN_NAME"; - public static final String PROP_QUERY_VALUE_COLUMN = "PROP_QUERY_VALUE_COLUMN"; - public static final String PROP_QUERY_LANGUAGE = "PROP_QUERY_LANGUAGE"; - - - // SQL resource properties - public static final String PROP_QUERY_DATA = "PROP_QUERY_DATA"; - public static final String PROP_QUERY_DATA_ROW = "PROP_QUERY_DATA_ROW"; - public static final String PROP_QUERY_DATA_ROW_COLUMN = "PROP_QUERY_DATA_ROW_COLUMN"; - - - // OLAP XMLA Connection - public static final String PROP_XMLA_URI = "PROP_XMLA_URI"; - public static final String PROP_XMLA_CATALOG = "PROP_XMLA_CATALOG"; - public static final String PROP_XMLA_DATASOURCE = "PROP_XMLA_DATASOURCE"; - public static final String PROP_XMLA_USERNAME = "PROP_XMLA_USERNAME"; - public static final String PROP_XMLA_PASSWORD = "PROP_XMLA_PASSWORD"; - - // OLAP Unit - public static final String PROP_MDX_QUERY = "PROP_MDX_QUERY"; - - public enum WsType { - accessGrantSchema, - adhocDataView, - adhocReport, - aws, - bean, - contentResource, - css, - custom, - datasource, - dataType, - dashboard, - dashboardState, - domain, - domainTopic, - folder, - font, - img, - inputControl, - jar, - jdbc, - jndi, - jrxml, - lov, - olapMondrianCon, - olapMondrianSchema, - olapUnit, - olapXmlaCon, - prop, - query, - reference, - reportOptions, - reportUnit, - virtual, - xml, - xmlaConnection, - unknow - } - - // Convenient TAG for logging purposes - private static final String TAG = "ResourceDescriptor"; - - @Expose - @Attribute(required=false) - private String name; - @Expose - @Attribute - private String wsType; - @Expose - @Attribute(required=false) - private String uriString; - @Expose - @Attribute(required=false) - private Boolean isNew; - - @Expose - @Element(required=false) - private String label; - @Element(required=false) - @Expose - private String description; - @Expose - @Element(required=false) - private String creationDate; - - @Expose - @ElementList(entry="resourceProperty", inline=true, required=false, empty=false) - private List properties = new ArrayList(); - - @Expose - @ElementList(entry="resourceDescriptor", inline=true, required=false, empty=false) - private List internalResources = new ArrayList(); - - @Expose - @ElementList(entry="parameter", inline=true, required=false, empty=false) - private List parameters = new ArrayList(); - - - /** - * Looks the wsType of the resource descriptor and return true - * if it is one of the following: datasource, jdbc, jndi, bean, custom. - * @return true if it is data source, false otherwise. - */ - public boolean isDataSource() { - switch (getWsType()) { - case datasource: - case jdbc: - case jndi: - case bean: - case custom: - return true; - default: - return false; - } - } - - /** - * Gets a valid data source resource from a resource descriptor - * @return the data source resource, or null if no data source is found. - */ - public ResourceDescriptor getDataSource() { - for (ResourceDescriptor internalResource : getInternalResources()) { - if (internalResource.isDataSource()) { - return internalResource; - } - } - return null; - } - - /** - * Gets a valid data source uri from a resource descriptor - * @return the data source uri, or null if no data source is found. - */ - public String getDataSourceUri() { - for (ResourceDescriptor internalResource : getInternalResources()) { - switch (internalResource.getWsType()) { - case datasource: - return internalResource.getPropertyByName(PROP_FILERESOURCE_REFERENCE_URI).getValue(); - case jdbc: - case jndi: - case bean: - case custom: - return internalResource.getUriString(); - } - } - // TODO: data source references - return null; - } - - /** - * Gets the property with the specified name - * @param name the property name - * @return property with the specified name, or null if the property is not found - */ - public ResourceProperty getPropertyByName(String name) { - for (ResourceProperty property : getProperties()) { - if (name.equals(property.getName())) { - return property; - } - } - return null; - } - - /** - * Gets the list of internal resources with the specified type - * @param type the resource type - * @return the list of resources that have the specified type - */ - public List getInternalResourcesByType(WsType type) { - List resourcesByType = new ArrayList(); - for(ResourceDescriptor resource : this.getInternalResources()) { - if(this.getWsType() == type) { - resourcesByType.add(resource); - } - } - return resourcesByType; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public WsType getWsType() { - try { - return WsType.valueOf(wsType); - } catch (IllegalArgumentException ex) { - Log.w(TAG, wsType + " is not a constant in WsType enum"); - return WsType.unknow; - } - } - - public void setWsType(WsType wsType) { - this.wsType = wsType.toString(); - } - - public String getUriString() { - return uriString; - } - - public void setUriString(String uriString) { - this.uriString = uriString; - } - - public Boolean getNew() { - return isNew; - } - - public void setNew(Boolean aNew) { - isNew = aNew; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCreationDate() { - return creationDate; - } - - public void setCreationDate(String creationDate) { - this.creationDate = creationDate; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public List getInternalResources() { - return internalResources; - } - - public void setInternalResources(List internalResources) { - this.internalResources = internalResources; - } - - public List getParameters() { - return parameters; - } - - public void setParameters(List parameters) { - this.parameters = parameters; - } -} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceParameter.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceParameter.java deleted file mode 100644 index a6054c9b..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceParameter.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Root; -import org.simpleframework.xml.Text; - -/** - * This class represents a resource parameter entity for convenient XML serialization process. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ -@Root(name="parameter") -public class ResourceParameter { - - @Expose - @Attribute - private String name; - - @Expose - @Attribute(required=false) - private boolean isListItem; - - @Expose - @Text - private String value; - - public ResourceParameter() { } - - public ResourceParameter(String name, String value) { - this(name, value, false); - } - - public ResourceParameter(String name, boolean value, boolean isListItem) { - this(name, Boolean.toString(value), isListItem); - } - - public ResourceParameter(String name, String value, boolean isListItem) { - setName(name); - setValue(value); - isListItem(isListItem); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean isListItem() { - return isListItem; - } - - public void isListItem(boolean listItem) { - isListItem = listItem; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceProperty.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceProperty.java deleted file mode 100644 index fa66682d..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourceProperty.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; -import org.simpleframework.xml.util.Entry; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class represents a resource property entity for convenient XML serialization process. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ - -@Root(strict=false) -public class ResourceProperty implements Entry { - - @Expose - @Attribute - private String name; - - @Expose - @Element(required=false) - private String value; - - @Expose - @ElementList(entry="resourceProperty", inline=true, required=false, empty=false) - private List properties = new ArrayList(); - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public List getProperties() { - return properties; - } - - public void setProperties(List properties) { - this.properties = properties; - } - - public String toString() { - return value; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourcesList.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourcesList.java deleted file mode 100644 index c914235c..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/ResourcesList.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ - -@Root(name = "resourceDescriptors") -public class ResourcesList { - - @Expose - @ElementList(entry = "resourceDescriptor", inline = true, required = false, empty = false) - private List resourceDescriptors = new ArrayList(); - - public List getResourceDescriptors() { - return resourceDescriptors; - } - - public void setResourceDescriptors(List resourceDescriptors) { - this.resourceDescriptors = resourceDescriptors; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControl.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControl.java deleted file mode 100644 index c100020c..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControl.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control; - -import android.os.Parcel; -import android.os.Parcelable; -import android.view.View; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.JsonAdapter; -import com.jaspersoft.android.sdk.client.oxm.control.validation.ValidationRule; -import com.jaspersoft.android.sdk.client.oxm.control.validation.ValidationRulesList; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ValidationRulesListTypeAdapter; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ - -@Root(name="inputControl", strict=false) -public class InputControl implements Parcelable { - - public enum Type { - bool, - singleValueText, - singleValueNumber, - singleValueTime, - singleValueDate, - singleValueDatetime, - singleSelect, - singleSelectRadio, - multiSelect, - multiSelectCheckbox, - } - - @Expose - @Element - private String id; - @Expose - @Element - private String label; - @Expose - @Element - private String uri; - - @Expose - @Element - private boolean mandatory; - @Expose - @Element - private boolean readOnly; - @Expose - @Element - private boolean visible; - - @Expose - @Element - private Type type; - - @Expose - @Element - private InputControlState state; - - @Element(required=false) - @Expose - @JsonAdapter(ValidationRulesListTypeAdapter.class) - private ValidationRulesList validationRules; - - @Expose - @ElementList(entry="controlId", empty=false) - private List masterDependencies = new ArrayList(); - - @Expose - @ElementList(entry="controlId", empty=false) - private List slaveDependencies = new ArrayList(); - - private View inputView; - private View errorView; - - public InputControl() {} - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public InputControl(Parcel source) { - this.id = source.readString(); - this.label = source.readString(); - this.uri = source.readString(); - - this.mandatory = source.readByte() != 0; - this.readOnly = source.readByte() != 0; - this.visible = source.readByte() != 0; - - this.type = Type.values()[source.readInt()]; - this.state = source.readParcelable(InputControlState.class.getClassLoader()); - this.validationRules = source.readParcelable(ValidationRulesList.class.getClassLoader()); - - this.masterDependencies= source.createStringArrayList(); - this.slaveDependencies = source.createStringArrayList(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public InputControl createFromParcel(Parcel source) { - return new InputControl(source); - } - - public InputControl[] newArray(int size) { - return new InputControl[size]; - } - }; - - @Override - public int describeContents(){ - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(id); - dest.writeString(label); - dest.writeString(uri); - - dest.writeByte((byte) (mandatory ? 1 : 0)); - dest.writeByte((byte) (readOnly ? 1 : 0)); - dest.writeByte((byte) (visible ? 1 : 0)); - - dest.writeInt(type.ordinal()); - dest.writeParcelable(state, flags); - dest.writeParcelable(validationRules, flags); - - dest.writeStringList(masterDependencies); - dest.writeStringList(slaveDependencies); - } - - //--------------------------------------------------------------------- - // Public - //--------------------------------------------------------------------- - - public Set getSelectedValues() { - Set values = new HashSet(); - switch (getType()) { - case bool: - case singleValueText: - case singleValueNumber: - case singleValueTime: - case singleValueDate: - case singleValueDatetime: - if (getState().getValue() != null) { - values.add(getState().getValue()); - } - break; - case singleSelect: - case singleSelectRadio: - for (InputControlOption option : getState().getOptions()) { - if (option.isSelected()) { - values.add(option.getValue()); - break; - } - } - case multiSelect: - case multiSelectCheckbox: - for (InputControlOption option : getState().getOptions()) { - if (option.isSelected()) { - values.add(option.getValue()); - } - } - break; - } - return values; - } - - public void setValidationRules(List rulesList) { - if (validationRules == null) { - validationRules = new ValidationRulesList(); - } - validationRules.setValidationRules(rulesList); - } - - public List getValidationRules() { - if (validationRules == null) { - List rules = new ArrayList(); - validationRules = new ValidationRulesList(rules); - } - return validationRules.getValidationRules(); - } - - @SuppressWarnings("unchecked") - public List getValidationRules(Class concreteRuleType){ - List rules = getValidationRules(); - List result = new ArrayList(); - if(!rules.isEmpty()){ - for(ValidationRule currentRule : rules){ - if(concreteRuleType.isAssignableFrom(currentRule.getClass())){ - result.add((T) currentRule); - } - } - } - return result; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public boolean isMandatory() { - return mandatory; - } - - public List getMasterDependencies() { - return masterDependencies; - } - - public void setMasterDependencies(List masterDependencies) { - this.masterDependencies = masterDependencies; - } - - public List getSlaveDependencies() { - return slaveDependencies; - } - - public void setSlaveDependencies(List slaveDependencies) { - this.slaveDependencies = slaveDependencies; - } - - public void setMandatory(boolean mandatory) { - this.mandatory = mandatory; - } - - public InputControlState getState() { - return state; - } - - public void setState(InputControlState state) { - this.state = state; - } - - public boolean isReadOnly() { - return readOnly; - } - - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public boolean isVisible() { - return visible; - } - - public void setVisible(boolean visible) { - this.visible = visible; - } - - public View getInputView() { - return inputView; - } - - public void setInputView(View inputView) { - this.inputView = inputView; - } - - public View getErrorView() { - return errorView; - } - - public void setErrorView(View errorView) { - this.errorView = errorView; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlOption.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlOption.java deleted file mode 100644 index ac88572e..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlOption.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -@Root(name="option", strict=false) -public class InputControlOption implements Parcelable { - - @Expose - @Element - private String label; - - @Expose - @Element - private String value; - - @Expose - @Element - private boolean selected; - - public InputControlOption() { } - - public InputControlOption(String label, String value) { - this(label, value, false); - } - - public InputControlOption(String label, String value, boolean selected) { - this.label = label; - this.value = value; - this.selected = selected; - } - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public InputControlOption(Parcel source) { - this.label = source.readString(); - this.value = source.readString(); - this.selected = source.readByte() != 0; - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public InputControlOption createFromParcel(Parcel source) { - return new InputControlOption(source); - } - - public InputControlOption[] newArray(int size) { - return new InputControlOption[size]; - } - }; - - @Override - public int describeContents(){ - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(label); - dest.writeString(value); - dest.writeByte((byte) (selected ? 1 : 0)); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public boolean isSelected() { - return selected; - } - - public void setSelected(boolean selected) { - this.selected = selected; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String toString() { - return label; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlState.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlState.java deleted file mode 100644 index e4c23854..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlState.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -@Root(name="state", strict=false) -public class InputControlState implements Parcelable { - - @Expose - @Element - private String id; - - @Expose - @Element - private String uri; - - @Expose - @Element(required=false) - private String value; - - @Expose - @Element(required=false) - private String error; - - @Expose - @ElementList(required=false, empty=false) - private List options = new ArrayList(); - - public InputControlState() {} - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public InputControlState(Parcel source) { - this.id = source.readString(); - this.uri = source.readString(); - this.value = source.readString(); - this.error = source.readString(); - this.options = source.createTypedArrayList(InputControlOption.CREATOR); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public InputControlState createFromParcel(Parcel source) { - return new InputControlState(source); - } - - public InputControlState[] newArray(int size) { - return new InputControlState[size]; - } - }; - - @Override - public int describeContents(){ - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(id); - dest.writeString(uri); - dest.writeString(value); - dest.writeString(error); - dest.writeTypedList(options); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public List getOptions() { - return options; - } - - public void setOptions(List options) { - this.options = options; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlStatesList.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlStatesList.java deleted file mode 100644 index 8244b166..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlStatesList.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import org.simpleframework.xml.ElementList; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -public class InputControlStatesList { - @Expose - @SerializedName("inputControlState") - @ElementList(entry="inputControlState", inline=true, empty=false) - private List inputControlStates = new ArrayList(); - - public List getInputControlStates() { - return inputControlStates; - } - - public void setInputControlStates(List inputControlStates) { - this.inputControlStates = inputControlStates; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlsList.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlsList.java deleted file mode 100644 index 090d5779..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/InputControlsList.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm.control; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ - -@Root(name="inputControls") -public class InputControlsList { - - @Expose - @SerializedName("inputControl") - @ElementList(entry="inputControl", inline=true, empty=false) - private List inputControls = new ArrayList(); - - public List getInputControls() { - return inputControls; - } - - public void setInputControls(List inputControls) { - this.inputControls = inputControls; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/DateTimeFormatValidationRule.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/DateTimeFormatValidationRule.java deleted file mode 100644 index 0b67b731..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/DateTimeFormatValidationRule.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control.validation; - -import android.os.Parcel; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -@Root(strict=false) -public class DateTimeFormatValidationRule extends ValidationRule { - - @Expose - @Element - private String format; - - public DateTimeFormatValidationRule() { } - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public DateTimeFormatValidationRule(Parcel source) { - super(source); - this.format = source.readString(); - } - - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeString(format); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/MandatoryValidationRule.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/MandatoryValidationRule.java deleted file mode 100644 index a4f1a841..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/MandatoryValidationRule.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control.validation; - -import android.os.Parcel; - -import org.simpleframework.xml.Root; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -@Root(strict=false) -public class MandatoryValidationRule extends ValidationRule { - - // currently it's enough to have super class's fields only, i.e. errorMessage. - - public MandatoryValidationRule() { } - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public MandatoryValidationRule(Parcel source) { - super(source); - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRule.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRule.java deleted file mode 100644 index 5dc7ff68..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRule.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control.validation; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -import java.lang.reflect.Constructor; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -@Root(strict=false) -public class ValidationRule implements Parcelable { - - @Expose - @Element - private String errorMessage; - - public ValidationRule() {} - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public ValidationRule(Parcel source) { - this.errorMessage = source.readString(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public ValidationRule createFromParcel(Parcel source) { - try { - String className = source.readString(); - Class clazz = Class.forName(className); - Constructor constructor = clazz.getConstructor(Parcel.class); - return (ValidationRule) constructor.newInstance(source); - } catch (RuntimeException ex) { - throw ex; - } catch (Exception ex) { - return new ValidationRule(source); - } - } - - public ValidationRule[] newArray(int size) { - return new ValidationRule[size]; - } - }; - - @Override - public int describeContents(){ - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(getClass().getName()); - dest.writeString(errorMessage); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRulesList.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRulesList.java deleted file mode 100644 index 7cfc2dcc..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/control/validation/ValidationRulesList.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.control.validation; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.ElementListUnion; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -@Root(name="validationRules", strict=false) -public class ValidationRulesList implements Parcelable { - - @Expose - @ElementListUnion({ - @ElementList(entry="dateTimeFormatValidationRule", inline=true, type=DateTimeFormatValidationRule.class), - @ElementList(entry="mandatoryValidationRule", inline=true, type=MandatoryValidationRule.class) - }) - private List validationRules = new ArrayList(); - - public ValidationRulesList() {} - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public ValidationRulesList(List validationRules) { - this.validationRules = validationRules; - } - - public ValidationRulesList(Parcel source) { - validationRules = source.createTypedArrayList(ValidationRule.CREATOR); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public ValidationRulesList createFromParcel(Parcel source) { - return new ValidationRulesList(source); - } - - public ValidationRulesList[] newArray(int size) { - return new ValidationRulesList[size]; - } - }; - - @Override - public int describeContents(){ - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeTypedList(validationRules); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public List getValidationRules() { - return validationRules; - } - - public void setValidationRules(List validationRules) { - this.validationRules = validationRules; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/converter/ReportStatusConverter.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/converter/ReportStatusConverter.java deleted file mode 100644 index baa74b47..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/converter/ReportStatusConverter.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.jaspersoft.android.sdk.client.oxm.converter; - -import com.jaspersoft.android.sdk.client.oxm.report.ReportStatusResponse; - -import org.simpleframework.xml.convert.Converter; -import org.simpleframework.xml.stream.InputNode; -import org.simpleframework.xml.stream.OutputNode; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class ReportStatusConverter implements Converter { - @Override - public ReportStatusResponse read(InputNode node) throws Exception { - return new ReportStatusResponse(node.getValue()); - } - - @Override - public void write(OutputNode node, ReportStatusResponse value) throws Exception { - // Do nothing - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ErrorDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ErrorDescriptor.java deleted file mode 100644 index c53c0ea8..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ErrorDescriptor.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; -import org.simpleframework.xml.Serializer; -import org.simpleframework.xml.core.Persister; -import org.springframework.web.client.HttpStatusCodeException; - -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Tom Koptel - * @since 1.9 - */ -@Root(strict = false) -public class ErrorDescriptor { - @Expose - @Element - private String errorCode; - @Expose - @Element(required = false) - private String message; - - @Expose - @ElementList(name = "parameters", entry = "parameter", required = false) - private List parameters = new ArrayList(); - - public static ErrorDescriptor valueOf(HttpStatusCodeException exception) { - String response = exception.getResponseBodyAsString(); - Serializer serializer = new Persister(); - StringWriter stringWriter = new StringWriter(); - stringWriter.append(response); - try { - return serializer.read(ErrorDescriptor.class, response); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public List getParameters() { - return parameters; - } - - public void setParameters(List parameters) { - this.parameters = parameters; - } - -} \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java deleted file mode 100644 index ab7301a6..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExecutionRequest.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class ExecutionRequest { - public static final String DEFAULT_ATTACHMENT_PREFIX = "/reportExecutions/{reportExecutionId}/exports/{exportExecutionId}/attachments/"; - public static final String MARKUP_TYPE_EMBEDDABLE = "embeddable"; - public static final String MARKUP_TYPE_FULL = "full"; - - @Expose - @Element(required = false) - protected String reportUnitUri; - - @Expose - @Element(required = false) - protected String markupType; - - @Element(required = false) - protected String baseUrl; - - @Expose - @Element(required = false) - protected Boolean async; - - @Expose - @Element(required = false) - protected Boolean freshData; - - @Expose - @Element(required = false) - protected Boolean saveDataSnapshot; - - @Expose - @Element - protected String outputFormat; - - @Expose - @Element(required = false) - protected Boolean interactive; - - @Expose - @Element(required = false) - protected Boolean ignorePagination; - - @Expose - @Element(required = false) - protected Boolean allowInlineScripts; - - @Expose - @Element(required = false) - protected String pages; - - @Expose - @Element(required = false) - protected String attachmentsPrefix; - - @ElementList(required = false) - protected List parameters = new ArrayList(); - - @Expose - @SerializedName("parameters") - protected ReportParametersList reportParameters; - - public void setAttachmentsPrefix(String attachmentsPrefix) { - this.attachmentsPrefix = attachmentsPrefix; - } - - public void setEscapedAttachmentsPrefix(String attachmentsPrefix) { - try { - this.attachmentsPrefix = URLEncoder.encode(attachmentsPrefix, "UTF-8"); - } catch (UnsupportedEncodingException exception) { - this.attachmentsPrefix = attachmentsPrefix; - } - } - - public String getAttachmentsPrefix() { - return attachmentsPrefix; - } - - public String getReportUnitUri() { - return reportUnitUri; - } - - public void setReportUnitUri(String reportUnitUri) { - this.reportUnitUri = reportUnitUri; - } - - public boolean isAsync() { - return async; - } - - public void setAsync(boolean async) { - this.async = async; - } - - public boolean isFreshData() { - return freshData; - } - - public void setFreshData(boolean freshData) { - this.freshData = freshData; - } - - public boolean isSaveDataSnapshot() { - return saveDataSnapshot; - } - - public void setSaveDataSnapshot(boolean saveDataSnapshot) { - this.saveDataSnapshot = saveDataSnapshot; - } - - public String getOutputFormat() { - return outputFormat; - } - - public void setOutputFormat(String outputFormat) { - this.outputFormat = outputFormat; - } - - public boolean isInteractive() { - return interactive; - } - - public void setInteractive(boolean interactive) { - this.interactive = interactive; - } - - public boolean isIgnorePagination() { - return ignorePagination; - } - - public void setIgnorePagination(boolean ignorePagination) { - this.ignorePagination = ignorePagination; - } - - public String getPages() { - return pages; - } - - public void setPages(String pages) { - this.pages = pages; - } - - public List getParameters() { - return parameters; - } - - public void setParameters(List parameters) { - this.parameters = parameters; - ReportParametersList reportParametersList = new ReportParametersList(); - reportParametersList.setReportParameters(parameters); - this.reportParameters = reportParametersList; - } - - public String getBaseUrl() { - return baseUrl; - } - - public void setBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - } - - public String getMarkupType() { - return markupType; - } - - public void setMarkupType(String markupType) { - this.markupType = markupType; - } - - public Boolean getAllowInlineScripts() { - return allowInlineScripts; - } - - public void setAllowInlineScripts(Boolean allowInlineScripts) { - this.allowInlineScripts = allowInlineScripts; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportExecution.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportExecution.java deleted file mode 100644 index 513b084a..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportExecution.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ - -@Root(strict=false) -public class ExportExecution { - - @Expose - @Element - private String id; - - @Expose - @Element - private String status; - - @Expose - @Element(required=false) - private ReportOutputResource outputResource; - - @Expose - @ElementList(empty=false, entry="attachment", required=false) - private List attachments = new ArrayList(); - - @Expose - @Element(required=false) - private ErrorDescriptor errorDescriptor; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public ReportOutputResource getOutputResource() { - return outputResource; - } - - public void setOutputResource(ReportOutputResource outputResource) { - this.outputResource = outputResource; - } - - public List getAttachments() { - return attachments; - } - - public void setAttachments(List attachments) { - this.attachments = attachments; - } - - public ErrorDescriptor getErrorDescriptor() { - return errorDescriptor; - } - - public void setErrorDescriptor(ErrorDescriptor errorDescriptor) { - this.errorDescriptor = errorDescriptor; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportsRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportsRequest.java deleted file mode 100644 index 8801e530..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ExportsRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.jaspersoft.android.sdk.client.oxm.report; - -import org.simpleframework.xml.Root; - -/** - * @author Tom Koptel - * @since 1.9 - */ -@Root(name="export") -public class ExportsRequest extends ExecutionRequest { -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/FolderDataResponse.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/FolderDataResponse.java deleted file mode 100644 index 86693034..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/FolderDataResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. - * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. - * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. - * Vestibulum commodo. Ut rhoncus gravida arcu. - */ - -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; - -import org.simpleframework.xml.Root; - -@Root(name = "folder") -public class FolderDataResponse extends ResourceLookup { - public FolderDataResponse() { - this.resourceType = ResourceType.folder.toString(); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportDataResponse.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportDataResponse.java deleted file mode 100644 index 11a11834..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportDataResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.jaspersoft.android.sdk.client.oxm.report; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class ReportDataResponse { - private final boolean isFinal; - private final String data; - - public ReportDataResponse(boolean isFinal, String data) { - this.isFinal = isFinal; - this.data = data; - } - - public boolean isFinal() { - return isFinal; - } - - public String getData() { - return data; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionRequest.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionRequest.java deleted file mode 100644 index 600d31ed..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report; - -import org.simpleframework.xml.Root; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ - -@Root -public class ReportExecutionRequest extends ExecutionRequest { -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionResponse.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionResponse.java deleted file mode 100644 index b5e9b3b8..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportExecutionResponse.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - - -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ - -@Root(name = "reportExecution", strict = false) -public class ReportExecutionResponse { - - @Expose - @Element - private String requestId; - - @Expose - @Element - private String reportURI; - - @Expose - @Element - private String status; - - @Expose - @ElementList(empty = false) - private List exports = new ArrayList(); - - @Expose - @Element(required = false) - private int currentPage; - - @Expose - @Element(required = false) - private int totalPages; - - @Expose - @Element(required = false) - ErrorDescriptor errorDescriptor; - - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getReportURI() { - return reportURI; - } - - public void setReportURI(String reportURI) { - this.reportURI = reportURI; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public List getExports() { - return exports; - } - - public void setExports(List exports) { - this.exports = exports; - } - - public int getCurrentPage() { - return currentPage; - } - - public void setCurrentPage(int currentPage) { - this.currentPage = currentPage; - } - - public int getTotalPages() { - return totalPages; - } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public ReportStatus getReportStatus() { - return ReportStatus.valueOf(status); - } - - public ErrorDescriptor getErrorDescriptor() { - return errorDescriptor; - } - - public void setErrorDescriptor(ErrorDescriptor errorDescriptor) { - this.errorDescriptor = errorDescriptor; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportOutputResource.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportOutputResource.java deleted file mode 100644 index d7bbc0a5..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportOutputResource.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ - -@Root(strict=false) -public class ReportOutputResource { - - @Expose - @Element - private String contentType; - - @Expose - @Element(required=false) - private String fileName; - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParameter.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParameter.java deleted file mode 100644 index 7ada2f87..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParameter.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import org.simpleframework.xml.Attribute; -import org.simpleframework.xml.ElementList; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -public class ReportParameter implements Parcelable { - - @Expose - @Attribute - private String name; - - @Expose - @SerializedName("value") - @ElementList(entry="value", inline=true, empty=false) - private Set values = new HashSet(); - - public ReportParameter() {} - - public ReportParameter(String name, Set values) { - this.name = name; - this.values = values; - } - - public ReportParameter(String name, String value) { - this.name = name; - this.values = new HashSet(); - this.values.add(value); - } - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public ReportParameter(Parcel source) { - this.name = source.readString(); - this.values = new HashSet(source.createStringArrayList()); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public ReportParameter createFromParcel(Parcel source) { - return new ReportParameter(source); - } - - public ReportParameter[] newArray(int size) { - return new ReportParameter[size]; - } - }; - - @Override - public int describeContents(){ - return 0; - } - - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(name); - dest.writeStringList(new ArrayList(values)); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void setValue(String value) { - this.values = new HashSet(); - this.values.add(value); - } - - public Set getValues() { - return values; - } - - public void setValues(Set values) { - this.values = values; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParametersList.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParametersList.java deleted file mode 100644 index 454e09ed..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportParametersList.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2005 - 2012 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.4 - */ -@Root(name="reportParameters") -public class ReportParametersList { - - @Expose - @SerializedName("reportParameter") - @ElementList(inline=true, empty=false) - private List reportParameters = new ArrayList(); - - public List getReportParameters() { - return reportParameters; - } - - public void setReportParameters(List reportParameters) { - this.reportParameters = reportParameters; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatus.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatus.java deleted file mode 100644 index 66ca9adc..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatus.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jaspersoft.android.sdk.client.oxm.report; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public enum ReportStatus { - execution, ready, cancelled, failed, queued -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatusResponse.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatusResponse.java deleted file mode 100644 index b84ea52a..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/ReportStatusResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jaspersoft.android.sdk.client.oxm.report; - -import com.google.gson.annotations.Expose; -import com.jaspersoft.android.sdk.client.oxm.converter.ReportStatusConverter; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; -import org.simpleframework.xml.convert.Convert; - -/** - * @author Tom Koptel - * @since 1.9 - */ -@Root(name = "status") -@Convert(ReportStatusConverter.class) -public class ReportStatusResponse { - - @Expose - @Element(required = false) - private String value; - - /** - * Otherwise, the framework cannot instantiate the class for deserialization. - * - * http://stackoverflow.com/questions/7470992/exception-with-simple-xml-framework-deserialization - */ - public ReportStatusResponse() { - } - - public ReportStatusResponse(String status) { - value = status; - } - - public ReportStatus getReportStatus() { - return ReportStatus.valueOf(value); - } - - public String getStatus() { - return value; - } - - public void setStatus(String status) { - this.value = status; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ExecutionRequestAdapter.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ExecutionRequestAdapter.java deleted file mode 100644 index 8663f2ea..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ExecutionRequestAdapter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report.adapter; - -import com.jaspersoft.android.sdk.client.oxm.report.ExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ExecutionRequestAdapter { - - private final String versionCode; - - private ExecutionRequestAdapter(String versionCode) { - this.versionCode = versionCode; - } - - public static ExecutionRequestAdapter newInstance(String versionCode) { - if (versionCode == null) { - throw new IllegalArgumentException("VersionCode should not be null"); - } - if (versionCode.trim().length() == 0) { - throw new IllegalArgumentException("VersionCode should not be empty"); - } - return new ExecutionRequestAdapter(versionCode); - } - - public T adapt(T adaptee) { - if (isAmberMR2()) { - adaptee.setAllowInlineScripts(null); - adaptee.setBaseUrl(null); - adaptee.setMarkupType(null); - } - return adaptee; - } - - private boolean isAmberMR2() { - return String.valueOf(ServerInfo.VERSION_CODES.EMERALD_TWO).equals(versionCode); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListDeserializer.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListDeserializer.java deleted file mode 100644 index b0bbafab..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListDeserializer.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report.adapter; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; - -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ReportParametersListDeserializer implements JsonDeserializer { - private final Gson gson; - private final Type mType; - - public ReportParametersListDeserializer() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - mType = new TypeToken>>() { - }.getType(); - } - - @Override - public ReportParametersList deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - Type type = new TypeToken>>() { - }.getType(); - - Map> response = gson.fromJson(json, type); - - ReportParametersList reportParametersList = new ReportParametersList(); - ReportParameter reportParameter; - for (Map.Entry> entry : response.entrySet()) { - reportParameter = new ReportParameter(); - reportParameter.setName(entry.getKey()); - reportParameter.setValues(entry.getValue()); - reportParametersList.getReportParameters().add(reportParameter); - } - - return reportParametersList; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListSerializer.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListSerializer.java deleted file mode 100644 index 2cac4a76..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ReportParametersListSerializer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report.adapter; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ReportParametersListSerializer implements JsonSerializer { - private final Gson gson; - private final Type mType; - - public ReportParametersListSerializer() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - mType = new TypeToken>>() { - }.getType(); - } - - @Override - public JsonElement serialize(ReportParametersList reportParametersList, Type typeOfSrc, JsonSerializationContext context) { - Map> response = new HashMap>(); - for (ReportParameter reportParameter : reportParametersList.getReportParameters()) { - response.put(reportParameter.getName(), reportParameter.getValues()); - } - return gson.toJsonTree(response, mType); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ValidationRulesListTypeAdapter.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ValidationRulesListTypeAdapter.java deleted file mode 100644 index 3ce1b415..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/report/adapter/ValidationRulesListTypeAdapter.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.report.adapter; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.jaspersoft.android.sdk.client.oxm.control.validation.DateTimeFormatValidationRule; -import com.jaspersoft.android.sdk.client.oxm.control.validation.MandatoryValidationRule; -import com.jaspersoft.android.sdk.client.oxm.control.validation.ValidationRule; -import com.jaspersoft.android.sdk.client.oxm.control.validation.ValidationRulesList; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ValidationRulesListTypeAdapter extends TypeAdapter { - private final Gson gson; - - public ValidationRulesListTypeAdapter() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - } - - @Override - public ValidationRulesList read(JsonReader in) throws IOException { - ValidationRulesList ruleList = new ValidationRulesList(); - List rules = new ArrayList(); - - in.beginArray(); - while (in.hasNext()) { - in.beginObject(); - while (in.hasNext()) { - ValidationRule rule; - if (in.nextName().equals("dateTimeFormatValidationRule")) { - rule = gson.fromJson(in, DateTimeFormatValidationRule.class); - } else { - rule = gson.fromJson(in, MandatoryValidationRule.class); - } - rules.add(rule); - } - in.endObject(); - } - in.endArray(); - - ruleList.setValidationRules(rules); - return ruleList; - } - - @Override - public void write(JsonWriter out, ValidationRulesList value) throws IOException { - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ReportUnit.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ReportUnit.java deleted file mode 100644 index 6b9688c0..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ReportUnit.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.resource; - -import org.simpleframework.xml.Root; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@Root(strict=false, name = "reportUnit") -public class ReportUnit extends ResourceLookup { -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookup.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookup.java deleted file mode 100644 index b39163d1..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookup.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.oxm.resource; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; - -/** - * This class represents a resource lookup entity for convenient XML serialization process. - * - * @author Ivan Gadzhega - * @since 1.7 - */ -public class ResourceLookup implements Parcelable { - - @Expose - @Element(required=false) - protected String label; - @Expose - @Element(required=false) - protected String description; - @Expose - @Element - protected String uri; - @Expose - @Element(required=false) - protected String resourceType; - - @Expose - @Element(required=false) - protected int version; - @Expose - @Element(required=false) - protected int permissionMask; - @Expose - @Element(required=false) - protected String creationDate; - @Expose - @Element(required=false) - protected String updateDate; - - public ResourceLookup() { } - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public ResourceLookup(Parcel source) { - this.label = source.readString(); - this.description = source.readString(); - this.uri = source.readString(); - this.resourceType = source.readString(); - this.creationDate = source.readString(); - this.updateDate = source.readString(); - this.version = source.readInt(); - this.permissionMask = source.readInt(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public ResourceLookup createFromParcel(Parcel source) { - return new ResourceLookup(source); - } - - public ResourceLookup[] newArray(int size) { - return new ResourceLookup[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(label); - dest.writeString(description); - dest.writeString(uri); - dest.writeString(resourceType); - dest.writeString(creationDate); - dest.writeString(updateDate); - dest.writeInt(version); - dest.writeInt(permissionMask); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public ResourceType getResourceType() { - try { - return ResourceType.valueOf(resourceType); - } catch (IllegalArgumentException ex) { - return ResourceType.unknown; - } - } - - public void setResourceType(ResourceType resourceType) { - this.resourceType = resourceType.toString(); - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public int getPermissionMask() { - return permissionMask; - } - - public void setPermissionMask(int permissionMask) { - this.permissionMask = permissionMask; - } - - public String getCreationDate() { - return creationDate; - } - - public void setCreationDate(String creationDate) { - this.creationDate = creationDate; - } - - public String getUpdateDate() { - return updateDate; - } - - public void setUpdateDate(String updateDate) { - this.updateDate = updateDate; - } - - //--------------------------------------------------------------------- - // Nested Classes - //--------------------------------------------------------------------- - - public enum ResourceType { - folder, - reportUnit, - dashboard, - legacyDashboard, - unknown - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupSearchCriteria.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupSearchCriteria.java deleted file mode 100644 index 8c15e23f..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupSearchCriteria.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm.resource; - -import android.os.Parcel; -import android.os.Parcelable; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 2.0 - */ -public class ResourceLookupSearchCriteria implements Parcelable { - - private String folderUri; - private String query; - private List types; - private String sortBy; - private String accessType; - - private boolean recursive = true; - private boolean forceFullPage; - private int offset = 0; - private int limit = 100; - - public ResourceLookupSearchCriteria() { - } - - public ResourceLookupSearchCriteria(ResourceLookupSearchCriteria oldCriteria) { - this.folderUri = oldCriteria.getFolderUri(); - this.query = oldCriteria.getQuery(); - this.types = new ArrayList(oldCriteria.getTypes()); - this.sortBy = oldCriteria.getSortBy(); - this.recursive = oldCriteria.isRecursive(); - this.forceFullPage = oldCriteria.isForceFullPage(); - this.offset = oldCriteria.getOffset(); - this.limit = oldCriteria.getLimit(); - this.accessType = oldCriteria.getAccessType(); - } - - //--------------------------------------------------------------------- - // Parcelable - //--------------------------------------------------------------------- - - public ResourceLookupSearchCriteria(Parcel source) { - this.folderUri = source.readString(); - this.query = source.readString(); - this.types = source.createStringArrayList(); - this.sortBy = source.readString(); - this.recursive = source.readByte() != 0; - this.forceFullPage = source.readByte() != 0; - this.offset = source.readInt(); - this.limit = source.readInt(); - this.accessType = source.readString(); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public ResourceLookupSearchCriteria createFromParcel(Parcel source) { - return new ResourceLookupSearchCriteria(source); - } - - public ResourceLookupSearchCriteria[] newArray(int size) { - return new ResourceLookupSearchCriteria[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(folderUri); - dest.writeString(query); - dest.writeStringList(types); - dest.writeString(sortBy); - dest.writeByte((byte) (recursive ? 1 : 0)); - dest.writeByte((byte) (forceFullPage ? 1 : 0)); - dest.writeInt(offset); - dest.writeInt(limit); - dest.writeString(accessType); - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - /** - * {@link ResourceLookupSearchCriteria#setFolderUri} - */ - public String getFolderUri() { - return folderUri; - } - - /** - * The path of the base folder for the search. - */ - public void setFolderUri(String folderUri) { - this.folderUri = folderUri; - } - - /** - * {@link ResourceLookupSearchCriteria#setQuery} - */ - public String getQuery() { - return query; - } - - /** - * Search for resources having the specified text in the name or description. - * Note that the search string does not match in the ID of resources. - */ - public void setQuery(String query) { - this.query = query; - } - - /** - * {@link ResourceLookupSearchCriteria#setTypes} - */ - public List getTypes() { - return types; - } - - /** - * Match only resources of the given type. Multiple type parameters are allowed. - * Wrong values are ignored. - */ - public void setTypes(List types) { - this.types = types; - } - - /** - * {@link ResourceLookupSearchCriteria#setSortBy} - */ - public String getSortBy() { - return sortBy; - } - - /** - * Filtering by access events. Can be viewed or modified. - */ - public String getAccessType() { - return accessType; - } - - /** - * Filtering by access events. Can be viewed or modified. - */ - public void setAccessType(String accessType) { - this.accessType = accessType; - } - - /** - * One of the following strings representing a field in the results to sort by: uri, - * label, description, type, creationDate, updateDate, accessTime, or popularity - * (based on access events). - */ - public void setSortBy(String sortBy) { - this.sortBy = sortBy; - } - - /** - * {@link ResourceLookupSearchCriteria#setRecursive} - */ - public boolean isRecursive() { - return recursive; - } - - /** - * Indicates whether search should include all sub-folders recursively. When - * omitted, the default behavior is recursive (true). - */ - public void setRecursive(boolean recursive) { - this.recursive = recursive; - } - - /** - * {@link ResourceLookupSearchCriteria#setOffset} - */ - public int getOffset() { - return offset; - } - - /** - * Used for pagination to request an offset in the set of results. This is - * equivalent to a specific page number. The default offset is 1 (first page). - */ - public void setOffset(int offset) { - this.offset = offset; - } - - /** - * {@link ResourceLookupSearchCriteria#setLimit} - */ - public int getLimit() { - return limit; - } - - /** - * Used for pagination to specify the maximum number of resources to return in - * each response. This is equivalent to the number of results per page. The - * default limit is 100. - */ - public void setLimit(int limit) { - this.limit = limit; - } - - /** - * {@link ResourceLookupSearchCriteria#setForceFullPage} - */ - public boolean isForceFullPage() { - return forceFullPage; - } - - /** - * With forceFullPage=false, - * This is the offset to request the next page. The Next-Offset is equivalent to Start-Index+limit, except on the last page. - * On the the last page, the Next-Offset is omitted to indicate there are no further pages. - * {@link ResourceLookupSearchCriteria#setLimit} - */ - - /** - * With forceFullPage=false we receive different pagination experience. Considering header - * for response Next-Offset which is the offset to request the next page. The Next-Offset - * is equivalent to Start-Index+limit, except on the last page. - * On the the last page, the Next-Offset is omitted to indicate there are no further pages. - *
- *
- * With forceFullPage=true enables full page pagination. Depending on the type of search and - * user permissions, this parameter can cause significant performance delays. - * - * @param forceFullPage accepts boolean value - */ - public void setForceFullPage(boolean forceFullPage) { - this.forceFullPage = forceFullPage; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupsList.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupsList.java deleted file mode 100644 index a50b26c2..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/resource/ResourceLookupsList.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm.resource; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.ElementList; -import org.simpleframework.xml.Root; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Ivan Gadzhega - * @since 1.7 - */ - -@Root(name = "resources") -public class ResourceLookupsList { - public static int NO_OFFSET = -1; - - @Expose - @SerializedName("resourceLookup") - @ElementList(entry = "resourceLookup", inline = true, required = false, empty = false) - private List resourceLookups = new ArrayList(); - - @Expose - @Element(required = false) - private int resultCount; - - @Expose - @Element(required = false) - private int totalCount; - - @Expose - @Element(required = false) - private int nextOffset; - - @Expose - @Element(required = false) - private int startIndex; - - public ResourceLookupsList() { - this.resultCount = 0; - this.totalCount = 0; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public List getResourceLookups() { - return resourceLookups; - } - - public void setResourceLookups(List resourceLookups) { - this.resourceLookups = resourceLookups; - } - - public int getResultCount() { - return resultCount; - } - - public void setResultCount(int resultCount) { - this.resultCount = resultCount; - } - - public void setResultCount(String resultCount) { - this.resultCount = (resultCount != null) ? Integer.parseInt(resultCount) : 0; - } - - public int getTotalCount() { - return totalCount; - } - - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - public void setTotalCount(String totalCount) { - this.totalCount = (totalCount != null) ? Integer.parseInt(totalCount) : 0; - } - - public int getStartIndex() { - return startIndex; - } - - public void setStartIndex(String startIndex) { - this.startIndex = (startIndex != null) ? Integer.parseInt(startIndex) : 0; - } - - public void setStartIndex(int startIndex) { - this.startIndex = startIndex; - } - - public int getNextOffset() { - return nextOffset; - } - - public void setNextOffset(String nextOffset) { - this.nextOffset = (nextOffset != null) ? Integer.parseInt(nextOffset) : NO_OFFSET; - } - - public void setNextOffset(int nextOffset) { - this.nextOffset = nextOffset; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/server/ServerInfo.java b/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/server/ServerInfo.java deleted file mode 100644 index c8076560..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/client/oxm/server/ServerInfo.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.jaspersoft.android.sdk.client.oxm.server; - -import com.google.gson.annotations.Expose; - -import org.simpleframework.xml.Element; -import org.simpleframework.xml.Root; - -import java.math.BigDecimal; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -@Root(strict=false) -public class ServerInfo { - - public static class VERSION_CODES { - public static final int UNKNOWN = 0; - public static final double EMERALD = 5.0; - public static final double EMERALD_MR1 = 5.2; - public static final double EMERALD_TWO = 5.5; - public static final double EMERALD_THREE = 5.6; - public static final double AMBER = 6.0; - } - - public static class EDITIONS { - public static final String CE = "CE"; - public static final String PRO = "PRO"; - } - - @Expose - @Element(required=false) - private String build; - - @Expose - @Element - private String edition; - - @Expose - @Element(required=false) - private String editionName; - - @Expose - @Element(required=false) - private String expiration; - - @Expose - @Element(required=false) - private String features; - - @Expose - @Element(required=false) - private String licenseType; - - private String version; - - private double versionCode; - - - public ServerInfo() { - edition = EDITIONS.CE; - version = String.valueOf(VERSION_CODES.UNKNOWN); - } - - @Element - public void setVersion(String version) { - this.version = version; - this.versionCode = 0; - // update version code - if (version != null) { - String[] subs = version.split("\\."); - - BigDecimal decimalSubVersion, decimalFactor, decimalResult; - BigDecimal decimalVersion = new BigDecimal("0"); - for (int i = 0; i < subs.length; i++) { - try { - decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); - } catch (NumberFormatException ex) { - decimalSubVersion = new BigDecimal("0"); - } - - decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); - decimalResult = decimalSubVersion.multiply(decimalFactor); - decimalVersion = decimalVersion.add(decimalResult); - } - versionCode = decimalVersion.doubleValue(); - } - } - - @Element - public String getVersion() { - return version; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public String getBuild() { - return build; - } - - public void setBuild(String build) { - this.build = build; - } - - public String getEdition() { - return edition; - } - - public void setEdition(String edition) { - this.edition = edition; - } - - public String getEditionName() { - return editionName; - } - - public void setEditionName(String editionName) { - this.editionName = editionName; - } - - public String getExpiration() { - return expiration; - } - - public void setExpiration(String expiration) { - this.expiration = expiration; - } - - public String getFeatures() { - return features; - } - - public void setFeatures(String features) { - this.features = features; - } - - public String getLicenseType() { - return licenseType; - } - - public void setLicenseType(String licenseType) { - this.licenseType = licenseType; - } - - public double getVersionCode() { - return versionCode; - } - - public void setVersionCode(double versionCode) { - this.versionCode = versionCode; - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/util/CookieHttpRequestInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/util/CookieHttpRequestInterceptor.java deleted file mode 100644 index 0a114b3b..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/util/CookieHttpRequestInterceptor.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.jaspersoft.android.sdk.util; - -import android.util.Base64; -import android.util.Log; - -import com.jaspersoft.android.sdk.client.JsServerProfile; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; - -import java.io.IOException; -import java.util.List; - -/** - * @author Tom Koptel - * @since 1.9 - */ -@Deprecated -public class CookieHttpRequestInterceptor implements ClientHttpRequestInterceptor { - private static final String SET_COOKIE = "set-cookie"; - private static final String COOKIE = "Cookie"; - private static final String COOKIE_STORE = "cookieStore"; - private final JsServerProfile jsServerProfile; - - public CookieHttpRequestInterceptor(JsServerProfile jsServerProfile) { - this.jsServerProfile = jsServerProfile; - } - - @Override - public ClientHttpResponse intercept(HttpRequest request, byte[] byteArray, - ClientHttpRequestExecution execution) throws IOException { - - Log.d(getClass().getSimpleName(), ">>> entering intercept"); - List cookies = request.getHeaders().get(COOKIE); - // if the header doesn't exist, add any existing, saved cookies - if (cookies == null) { - List cookieStore = (List) StaticCacheHelper.retrieveObjectFromCache(COOKIE_STORE); - // if we have stored cookies, add them to the headers - if (cookieStore != null) { - request.getHeaders().add(COOKIE, StringUtils.join(cookieStore, ";")); - } else { - Log.d(getClass().getSimpleName(), "Setting basic auth"); - // Basic Authentication - String authorisation = jsServerProfile.getUsernameWithOrgId() + ":" + jsServerProfile.getPassword(); - byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes(), Base64.NO_WRAP); - request.getHeaders().set("Authorization", "Basic " + new String(encodedAuthorisation)); - // disable buggy keep-alive - request.getHeaders().set("Connection", "close"); - } - } - - // execute the request - ClientHttpResponse response = execution.execute(request, byteArray); - // pull any cookies off and store them - cookies = response.getHeaders().get(SET_COOKIE); - if (cookies != null) { - for (String cookie : cookies) { - Log.d(getClass().getSimpleName(), ">>> response cookie = " + cookie); - } - StaticCacheHelper.storeObjectInCache(COOKIE_STORE, cookies); - } - Log.d(getClass().getSimpleName(), ">>> leaving intercept"); - return response; - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/util/FileUtils.java b/client/src/main/java/com/jaspersoft/android/sdk/util/FileUtils.java deleted file mode 100644 index 136695e2..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/util/FileUtils.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.util; - -import android.os.Environment; -import android.util.Log; - -import java.io.File; - -/** - * @author Ivan Gadzhega - * @since 1.8 - */ -public final class FileUtils { - - public static final char EXTENSION_SEPARATOR = '.'; - - private static final String TAG = "FileUtils"; - - // This class cannot be instantiated - private FileUtils() {} - - /** - * Helper Method to Test if external Storage is Available - * @return true if storage is writable, false otherwise - */ - public static boolean isExternalStorageWritable() { - String extStorageState = Environment.getExternalStorageState(); - return Environment.MEDIA_MOUNTED.equals(extStorageState); - } - - /** - * Recursively delete files in the specified folder. - * @param directory directory file - * @return {@code true} if these files were deleted, {@code false} otherwise. - */ - public static boolean deleteFilesInDirectory(File directory) { - if(directory.exists()) { - File[] childFiles = directory.listFiles(); - if (childFiles != null) { - for (File childFile : childFiles) { - if (childFile.isDirectory()) { - deleteFilesInDirectory(childFile); - } - // http://stackoverflow.com/questions/13948890/android-mkdirs-creates-a-zero-byte-file-instead-of-a-folder - File tmpFile = new File(childFile.getAbsolutePath() + System.currentTimeMillis()); - boolean deleted = childFile.renameTo(tmpFile) && tmpFile.delete(); - if (!deleted) { - Log.e(TAG, "Unable to delete " + childFile); - return false; - } - } - } - } - return true; - } - - public static long calculateFileSize(File file) { - long result = 0; - - if (file.isDirectory()) { - // Recursive call if it's a directory - File[] childFiles = file.listFiles(); - if (childFiles != null) { - for (File childFile : childFiles) { - result += calculateFileSize(childFile); - } - } - } else { - result += file.length(); - } - - return result; - } - - public static String getHumanReadableByteCount(long bytes) { - int unit = 1024; - if (bytes < unit) return bytes + " B"; - int exp = (int) (Math.log(bytes) / Math.log(unit)); - char pre = ("kMGTPE").charAt(exp-1); - return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); - } - - /** - * Check if name contains any of the following characters: - * * \ / " ' : ? | < > + [ ] - */ - public static boolean nameContainsReservedChars(String fileName) { - return fileName.matches(".*[\\Q*/\\\"':?|<>+[]\\E].*"); - } - - /** - * Gets the base name, minus extension, from a filename. - */ - public static String getBaseName(String fileName) { - if (fileName == null) return null; - int index = fileName.lastIndexOf(EXTENSION_SEPARATOR); - return (index == -1) ? fileName : fileName.substring(0, index); - } - - /** - * Gets the extension of a filename. - */ - public static String getExtension(String fileName) { - if (fileName == null) return null; - int index = fileName.lastIndexOf(EXTENSION_SEPARATOR); - return (index == -1) ? "" : fileName.substring(index + 1); - } - -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/util/KeepAliveHttpRequestInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/util/KeepAliveHttpRequestInterceptor.java deleted file mode 100644 index 2e7567b1..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/util/KeepAliveHttpRequestInterceptor.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. - * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. - * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. - * Vestibulum commodo. Ut rhoncus gravida arcu. - */ - -package com.jaspersoft.android.sdk.util; - -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class KeepAliveHttpRequestInterceptor implements ClientHttpRequestInterceptor { - @Override - public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { - request.getHeaders().add("Connection", "close"); - return execution.execute(request, body); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/util/LocalesHttpRequestInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/util/LocalesHttpRequestInterceptor.java deleted file mode 100644 index 275aea1a..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/util/LocalesHttpRequestInterceptor.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. - * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. - * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. - * Vestibulum commodo. Ut rhoncus gravida arcu. - */ - -package com.jaspersoft.android.sdk.util; - -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; - -import java.io.IOException; -import java.util.Locale; -import java.util.TimeZone; - -public class LocalesHttpRequestInterceptor implements ClientHttpRequestInterceptor { - private static final String ACCEPT_TIMEZONE = "Accept-Timezone"; - - @Override - public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { - String timeZone = createGmtOffsetString(true, true, TimeZone.getDefault().getRawOffset()); - // Because of HTTP accepts this type separator '-' we replace default one - String locale = Locale.getDefault().toString().replaceAll("_", "-"); - - request.getHeaders().setAcceptLanguage(locale); - request.getHeaders().add(ACCEPT_TIMEZONE, timeZone); - - return execution.execute(request, body); - } - - private String createGmtOffsetString(boolean includeGmt, - boolean includeMinuteSeparator, int offsetMillis) { - int offsetMinutes = offsetMillis / 60000; - char sign = '+'; - if (offsetMinutes < 0) { - sign = '-'; - offsetMinutes = -offsetMinutes; - } - StringBuilder builder = new StringBuilder(9); - if (includeGmt) { - builder.append("GMT"); - } - builder.append(sign); - appendNumber(builder, 2, offsetMinutes / 60); - if (includeMinuteSeparator) { - builder.append(':'); - } - appendNumber(builder, 2, offsetMinutes % 60); - return builder.toString(); - } - - private void appendNumber(StringBuilder builder, int count, int value) { - String string = Integer.toString(value); - for (int i = 0; i < count - string.length(); i++) { - builder.append('0'); - } - builder.append(string); - } -} diff --git a/client/src/main/java/com/jaspersoft/android/sdk/util/StaticCacheHelper.java b/client/src/main/java/com/jaspersoft/android/sdk/util/StaticCacheHelper.java deleted file mode 100644 index a1e495c8..00000000 --- a/client/src/main/java/com/jaspersoft/android/sdk/util/StaticCacheHelper.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.jaspersoft.android.sdk.util; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class StaticCacheHelper { - - private static final long TIME_TO_LIVE = TimeUnit.MINUTES.toMillis(20); - - private static final Map cacheMap = new HashMap(); - - /** - * Retrieves an item from the cache. If found, the method compares - * the object's expiration date to the current time and only returns - * the object if the expiration date has not passed. - * - * @param cacheKey - * @return - */ - public static Object retrieveObjectFromCache(String cacheKey) { - Element e = cacheMap.get(cacheKey); - Object o = null; - if (e != null) { - Date now = new Date(); - if (e.getExpirationDate().after(now)) { - o = e.getObject(); - } else { - removeCacheItem(cacheKey); - } - } - return o; - } - - /** - * Stores an object in the cache, wrapped by an Element object. - * The Element object has an expiration date, which will be set to - * now + this class' TIME_TO_LIVE setting. - * - * @param cacheKey - * @param object - */ - public static void storeObjectInCache(String cacheKey, Object object) { - Date expirationDate = new Date(System.currentTimeMillis() + TIME_TO_LIVE); - Element e = new Element(object, expirationDate); - cacheMap.put(cacheKey, e); - } - - /** - * Stores an object in the cache, wrapped by an Element object. - * The Element object has an expiration date, which will be set to - * now + the timeToLiveInMilliseconds value that is passed into the method. - * - * @param cacheKey - * @param object - * @param timeToLiveInMilliseconds - */ - public static void storeObjectInCache(String cacheKey, Object object, int timeToLiveInMilliseconds) { - Date expirationDate = new Date(System.currentTimeMillis() + timeToLiveInMilliseconds); - Element e = new Element(object, expirationDate); - cacheMap.put(cacheKey, e); - } - - public static void removeCacheItem(String cacheKey) { - cacheMap.remove(cacheKey); - } - - public static void clearCache() { - cacheMap.clear(); - } - - static class Element { - - private Object object; - private Date expirationDate; - - /** - * @param object - * @param key - * @param expirationDate - */ - private Element(Object object, Date expirationDate) { - super(); - this.object = object; - this.expirationDate = expirationDate; - } - /** - * @return the object - */ - public Object getObject() { - return object; - } - /** - * @param object the object to set - */ - public void setObject(Object object) { - this.object = object; - } - /** - * @return the expirationDate - */ - public Date getExpirationDate() { - return expirationDate; - } - /** - * @param expirationDate the expirationDate to set - */ - public void setExpirationDate(Date expirationDate) { - this.expirationDate = expirationDate; - } - } -} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/ExecutionRequestAdapterTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/ExecutionRequestAdapterTest.java deleted file mode 100644 index 77103beb..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/ExecutionRequestAdapterTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ExecutionRequestAdapter; -import com.jaspersoft.android.sdk.client.util.ServerVersion; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(JUnitParamsRunner.class) -public class ExecutionRequestAdapterTest { - private static final String EMPTY_JSON = "{}"; - private Gson gson; - - @Parameters(method = "getNullVersionCodes") - @Test(expected = IllegalArgumentException.class) - public void shouldNotAcceptInvalidVersionCode(String versionCode) { - ExecutionRequestAdapter.newInstance(versionCode); - } - - @Before - public void setup() { - gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); - } - - @Test - public void shouldExcludeInlineScriptsForEMERALD_MR2() { - ExecutionRequestAdapter adapter = - ExecutionRequestAdapter.newInstance(ServerVersion.V5_5.get()); - - ReportExecutionRequest request = new ReportExecutionRequest(); - request.setAllowInlineScripts(true); - - request = adapter.adapt(request); - String json = gson.toJson(request); - assertThat(json, is(EMPTY_JSON)); - } - - @Test - public void shouldExcludeBaseUrlForEMERALD_MR2() { - ExecutionRequestAdapter adapter = - ExecutionRequestAdapter.newInstance(ServerVersion.V5_5.get()); - - ReportExecutionRequest request = new ReportExecutionRequest(); - request.setBaseUrl("some_base_url"); - - request = adapter.adapt(request); - String json = gson.toJson(request); - assertThat(json, is(EMPTY_JSON)); - } - - @Test - public void shouldExcludeMarkupTypeForEMERALD_MR2() { - ExecutionRequestAdapter adapter = - ExecutionRequestAdapter.newInstance(ServerVersion.V5_5.get()); - - ReportExecutionRequest request = new ReportExecutionRequest(); - request.setMarkupType("some_type"); - - request = adapter.adapt(request); - String json = gson.toJson(request); - assertThat(json, is(EMPTY_JSON)); - } - - public Object[] getNullVersionCodes() { - return new Object[] { - null, "", " " - }; - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreatorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreatorTest.java deleted file mode 100644 index 31b3b7d2..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/GSONDataTypeConverterCreatorTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import org.junit.Test; -import org.springframework.http.converter.json.GsonHttpMessageConverter; - -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class GSONDataTypeConverterCreatorTest { - @Test - public void shouldCreateJSONConverter() { - GSONDataTypeConverterCreator xmlDataTypeConverterCreator = new GSONDataTypeConverterCreator(); - GsonHttpMessageConverter converter = xmlDataTypeConverterCreator.create(); - assertThat(converter, is(notNullValue())); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/InputControlStatesListTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/InputControlStatesListTest.java deleted file mode 100644 index 4dd9ea92..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/InputControlStatesListTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.oxm.control.InputControl; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlStatesList; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlsList; -import com.jaspersoft.android.sdk.client.oxm.control.validation.DateTimeFormatValidationRule; -import com.jaspersoft.android.sdk.client.oxm.control.validation.MandatoryValidationRule; -import com.jaspersoft.android.sdk.client.util.TestResource; - -import org.junit.Assert; -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class InputControlStatesListTest { - @Test - public void shouldDeserializeControlStateList() { - GsonBuilder gsonBuilder = new GsonBuilder(); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - - String json = TestResource.getJson().rawData("input_control_states_list"); - InputControlStatesList controlsList = gson.fromJson(json, InputControlStatesList.class); - assertThat(controlsList.getInputControlStates(), is(not(empty()))); - assertThat(controlsList.getInputControlStates().get(0).getOptions(), is(not(empty()))); - } - - @Test - public void shouldAssignValidClassForSpecificValidationRule() { - GsonBuilder gsonBuilder = new GsonBuilder(); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - - String json = TestResource.getJson().rawData("input_controls_date"); - InputControlsList controlsList = gson.fromJson(json, InputControlsList.class); - InputControl inputControl = controlsList.getInputControls().get(0); - Assert.assertThat(inputControl.getValidationRules(DateTimeFormatValidationRule.class), is(not(empty()))); - Assert.assertThat(inputControl.getValidationRules(MandatoryValidationRule.class), is(not(empty()))); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/JsRestClientBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/JsRestClientBuilderTest.java deleted file mode 100644 index 6e952e53..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/JsRestClientBuilderTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import org.junit.Test; -import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.web.client.RestTemplate; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class JsRestClientBuilderTest { - @Test - public void shouldCreateClientInstanceWithRestTemplate() { - JsRestClient jsRestClient = JsRestClient.builder().build(); - assertThat(jsRestClient.getRestTemplate(), is(notNullValue())); - assertThat(jsRestClient.getRestTemplate(), instanceOf(RestTemplate.class)); - } - - @Test - public void shouldCreateClientInstanceWithDataType() { - JsRestClient jsRestClient = JsRestClient.builder().build(); - assertThat(jsRestClient.getDataType(), is(notNullValue())); - assertThat(jsRestClient.getDataType(), instanceOf(JsRestClient.DataType.class)); - } - - @Test - public void shouldCreateClientInstanceWithRequestFactory() { - JsRestClient jsRestClient = JsRestClient.builder().build(); - assertThat(jsRestClient.getRequestFactory(), is(notNullValue())); - assertThat(jsRestClient.getRequestFactory(), instanceOf(SimpleClientHttpRequestFactory.class)); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/MessageConvertersFactoryTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/MessageConvertersFactoryTest.java deleted file mode 100644 index 12c96cac..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/MessageConvertersFactoryTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.FormHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.http.converter.json.GsonHttpMessageConverter; -import org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter; -import org.springframework.web.client.RestTemplate; - -import java.util.List; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.core.Is.isA; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(JUnitParamsRunner.class) -public class MessageConvertersFactoryTest { - - private RestTemplate restTemplate; - - @Before - public void setup() { - restTemplate = new RestTemplate(false); - } - - @Parameters({"XML", "JSON"}) - @Test - public void shouldCreateCommonConvertersForAnyDataType(String type) { - MessageConvertersFactory factory = MessageConvertersFactory.newInstance(restTemplate, JsRestClient.DataType.valueOf(type)); - List> converters = factory.createMessageConverters(); - assertThat(converters, hasItem(isA(ByteArrayHttpMessageConverter.class))); - assertThat(converters, hasItem(isA(StringHttpMessageConverter.class))); - assertThat(converters, hasItem(isA(ResourceHttpMessageConverter.class))); - assertThat(converters, hasItem(isA(FormHttpMessageConverter.class))); - } - - @Test - public void shouldCreateConvertersForXMLDataType() { - MessageConvertersFactory factory = MessageConvertersFactory.newInstance(restTemplate, JsRestClient.DataType.XML); - List> converters = factory.createMessageConverters(); - assertThat(converters, hasItem(isA(SimpleXmlHttpMessageConverter.class))); - } - - @Test - public void shouldCreateConvertersForJSONDataType() { - MessageConvertersFactory factory = MessageConvertersFactory.newInstance(restTemplate, JsRestClient.DataType.JSON); - List> converters = factory.createMessageConverters(); - assertThat(converters, hasItem(isA(GsonHttpMessageConverter.class))); - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/ReportExecutionResponseTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/ReportExecutionResponseTest.java deleted file mode 100644 index a29ecbcc..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/ReportExecutionResponseTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.jaspersoft.android.sdk.client; - -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse; -import com.jaspersoft.android.sdk.client.oxm.report.ReportStatus; - -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class ReportExecutionResponseTest { - private ReportExecutionResponse reportExecutionResponse; - - @Before - public void setUp() { - reportExecutionResponse = new ReportExecutionResponse(); - } - - @Test - public void test_getReportStatus_for_queued() { - reportExecutionResponse.setStatus("queued"); - assertThat(reportExecutionResponse.getReportStatus(), is(ReportStatus.queued)); - } - - @Test - public void test_getReportStatus_for_ready() { - reportExecutionResponse.setStatus("ready"); - assertThat(reportExecutionResponse.getReportStatus(), is(ReportStatus.ready)); - } - - @Test - public void test_getReportStatus_for_failed() { - reportExecutionResponse.setStatus("failed"); - assertThat(reportExecutionResponse.getReportStatus(), is(ReportStatus.failed)); - } - - @Test - public void test_getReportStatus_for_execution() { - reportExecutionResponse.setStatus("execution"); - assertThat(reportExecutionResponse.getReportStatus(), is(ReportStatus.execution)); - } - - @Test - public void test_getReportStatus_for_cancelled() { - reportExecutionResponse.setStatus("cancelled"); - assertThat(reportExecutionResponse.getReportStatus(), is(ReportStatus.cancelled)); - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/ReportParametersTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/ReportParametersTest.java deleted file mode 100644 index dc66c710..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/ReportParametersTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParameter; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ReportParametersListDeserializer; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ReportParametersListSerializer; -import com.jaspersoft.android.sdk.client.util.TestResource; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ReportParametersTest { - @Test - public void shouldDeserializeJson() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(ReportParametersList.class, new ReportParametersListDeserializer()); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - - String json = TestResource.getJson().rawData("report_parameters"); - ReportParametersList reportParameter = gson.fromJson(json, ReportParametersList.class); - assertThat(reportParameter.getReportParameters(), is(not(empty()))); - } - - @Test - public void shouldSerializeJson() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(ReportParametersList.class, new ReportParametersListSerializer()); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - ReportParameter reportParameter = new ReportParameter(); - reportParameter.setName("key"); - reportParameter.setValue("value"); - - ReportParametersList reportParametersList = new ReportParametersList(); - reportParametersList.getReportParameters().add(reportParameter); - - String json = gson.toJson(reportParametersList, ReportParametersList.class); - assertThat(json, is("{\"key\":[\"value\"]}")); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/ReportStatusResponseTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/ReportStatusResponseTest.java deleted file mode 100644 index ad0ee7c5..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/ReportStatusResponseTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.jaspersoft.android.sdk.client; - -import com.jaspersoft.android.sdk.client.oxm.report.ReportStatus; -import com.jaspersoft.android.sdk.client.oxm.report.ReportStatusResponse; - -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class ReportStatusResponseTest { - private ReportStatusResponse reportStatusResponse; - - @Before - public void setUp() { - reportStatusResponse = new ReportStatusResponse(); - } - - @Test - public void test_getReportStatus_for_queued() { - reportStatusResponse.setStatus("queued"); - assertThat(reportStatusResponse.getReportStatus(), is(ReportStatus.queued)); - } - - @Test - public void test_getReportStatus_for_ready() { - reportStatusResponse.setStatus("ready"); - assertThat(reportStatusResponse.getReportStatus(), is(ReportStatus.ready)); - } - - @Test - public void test_getReportStatus_for_failed() { - reportStatusResponse.setStatus("failed"); - assertThat(reportStatusResponse.getReportStatus(), is(ReportStatus.failed)); - } - - @Test - public void test_getReportStatus_for_execution() { - reportStatusResponse.setStatus("execution"); - assertThat(reportStatusResponse.getReportStatus(), is(ReportStatus.execution)); - } - - @Test - public void test_getReportStatus_for_cancelled() { - reportStatusResponse.setStatus("cancelled"); - assertThat(reportStatusResponse.getReportStatus(), is(ReportStatus.cancelled)); - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/ResourceLookupsListTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/ResourceLookupsListTest.java deleted file mode 100644 index d1358926..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/ResourceLookupsListTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupsList; -import com.jaspersoft.android.sdk.client.util.TestResource; - -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ResourceLookupsListTest { - @Test - public void shouldSerializeJson() { - GsonBuilder gsonBuilder = new GsonBuilder(); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - - String json = TestResource.getJson().rawData("resource_lookup"); - ResourceLookupsList lookupsList = gson.fromJson(json, ResourceLookupsList.class); - assertThat(lookupsList.getResourceLookups(), is(not(empty()))); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/ServerInfoTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/ServerInfoTest.java deleted file mode 100644 index 6a4f561c..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/ServerInfoTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright © 2014 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; - -import org.junit.Before; -import org.junit.Test; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 1.9 - */ -public class ServerInfoTest { - private ServerInfo mockServerInfo; - - @Before - public void setMocks() { - mockServerInfo = new ServerInfo(); - } - - @Test - public void shouldParseSemanticVersioning() { - Map doubleMap = new HashMap(); - doubleMap.put("5.0.0", new BigDecimal("5").doubleValue()); - doubleMap.put("5.1.0", new BigDecimal("5.1").doubleValue()); - doubleMap.put("5.2.0", new BigDecimal("5.2").doubleValue()); - doubleMap.put("5.5.0", new BigDecimal("5.5").doubleValue()); - doubleMap.put("5.6.0", new BigDecimal("5.6").doubleValue()); - doubleMap.put("5.6.1", new BigDecimal("5.61").doubleValue()); - doubleMap.put("6.0", new BigDecimal("6").doubleValue()); - - for (Map.Entry entry : doubleMap.entrySet()) { - mockServerInfo.setVersion(entry.getKey()); - assertThat(mockServerInfo.getVersionCode(), is(entry.getValue())) ; - } - } - - @Test - public void shouldParseNonSemanticVersioning() { - String[] nonSemanticOne = {"5.6.0 Preview", "5.6.0-BETA"}; - for (String nonSemanticVersion : nonSemanticOne) { - mockServerInfo.setVersion(nonSemanticVersion); - assertThat(mockServerInfo.getVersionCode(), is(ServerInfo.VERSION_CODES.EMERALD_THREE)); - } - } - - @Test - public void shouldParseLongSemanticVersioning() { - Map doubleMap = new HashMap(); - doubleMap.put("5.6.1.2", new BigDecimal("5.612").doubleValue()); - doubleMap.put("5.6.1.2.0", new BigDecimal("5.612").doubleValue()); - doubleMap.put("5.5.6.1.2", new BigDecimal("5.5612").doubleValue()); - doubleMap.put("5.5.6.1.2.0", new BigDecimal("5.5612").doubleValue()); - doubleMap.put("5.5.6.1.2.3", new BigDecimal("5.56123").doubleValue()); - doubleMap.put("5.5.6.1.2.3.0", new BigDecimal("5.56123").doubleValue()); - - for (Map.Entry entry : doubleMap.entrySet()) { - mockServerInfo.setVersion(entry.getKey()); - assertThat(mockServerInfo.getVersionCode(), is(entry.getValue())) ; - } - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/ValidationRuleAdapterTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/ValidationRuleAdapterTest.java deleted file mode 100644 index f90ee43c..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/ValidationRuleAdapterTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlsList; -import com.jaspersoft.android.sdk.client.util.TestResource; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(JUnitParamsRunner.class) -public class ValidationRuleAdapterTest { - - @Parameters({"controls_01", "controls_04", "controls_06", "controls_07"}) - @Test - public void shouldSerialize(String jsonSourceFileName) { - GsonBuilder gsonBuilder = new GsonBuilder(); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - - String json = TestResource.getJson().rawData(jsonSourceFileName); - InputControlsList controlsList = gson.fromJson(json, InputControlsList.class); - assertThat(controlsList.getInputControls().get(0).getValidationRules(), is(notNullValue())); - } - -} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreatorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreatorTest.java deleted file mode 100644 index 3849bcca..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/XMLDataTypeConverterCreatorTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client; - -import org.junit.Test; -import org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter; - -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class XMLDataTypeConverterCreatorTest { - @Test - public void shouldCreateXMLConverter() { - XMLDataTypeConverterCreator xmlDataTypeConverterCreator = new XMLDataTypeConverterCreator(); - SimpleXmlHttpMessageConverter converter = xmlDataTypeConverterCreator.create(); - assertThat(converter, is(notNullValue())); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java deleted file mode 100644 index 922caf62..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ConverterFactoryTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.api.v2; - -import org.junit.Test; - -import retrofit.converter.GsonConverter; -import retrofit.converter.SimpleXMLConverter; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ConverterFactoryTest { - - @Test - public void shouldCreateJsonConverter() { - GsonConverter converter = (GsonConverter) ConverterFactory.create(DataType.JSON); - assertThat(converter, notNullValue()); - } - - @Test - public void shouldCreateXmlConverter() { - SimpleXMLConverter converter = (SimpleXMLConverter) ConverterFactory.create(DataType.XML); - assertThat(converter, notNullValue()); - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java deleted file mode 100644 index 6aaeb494..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/api/v2/ServerRestApiTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.api.v2; - -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.FakeHttp; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) -public class ServerRestApiTest { - - @Before - public void setup() { - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - } - - @Test - public void shouldRequestInfoForXml() { - ServerRestApi restApi = new ServerRestApi.Builder("http://mobiledemo.jaspersoft.com/jasperserver-pro") - .consumeJson() - .build(); - - ServerInfo serverInfo = restApi.getServerInfo(); - serverInfo.setVersion(serverInfo.getVersion()); - - double version = serverInfo.getVersionCode(); - assertThat(version, is(not(0d))); - } - - @Test - public void shouldRequestInfoForJson() { - ServerRestApi restApi = new ServerRestApi.Builder("http://mobiledemo.jaspersoft.com/jasperserver-pro") - .consumeXml() - .build(); - - ServerInfo serverInfo = restApi.getServerInfo(); - serverInfo.setVersion(serverInfo.getVersion()); - - double version = serverInfo.getVersionCode(); - assertThat(version, is(not(0d))); - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/CheckReportStatusRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/CheckReportStatusRequestTest.java deleted file mode 100644 index 28c8a64c..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/CheckReportStatusRequestTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.CheckReportStatusRequest; -import com.jaspersoft.android.sdk.client.async.request.RunReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse; -import com.jaspersoft.android.sdk.client.oxm.report.ReportStatusResponse; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class CheckReportStatusRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(CheckReportStatusRequestTest.class); - } - - public CheckReportStatusRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void requestShouldReportStatus() throws Exception { - JsRestClient jsRestClient = getJsRestClient(); - ReportExecutionRequest reportExecutionRequest = getFactoryGirl().createExecutionData(jsRestClient); - RunReportExecutionRequest runReportExecutionRequest = new RunReportExecutionRequest(jsRestClient, reportExecutionRequest); - - ReportExecutionResponse runReportExecutionResponse = runReportExecutionRequest.loadDataFromNetwork(); - String requestId = runReportExecutionResponse.getRequestId(); - - CheckReportStatusRequest checkReportStatusRequest = new CheckReportStatusRequest(jsRestClient, requestId); - ReportStatusResponse response = checkReportStatusRequest.loadDataFromNetwork(); - assertThat(response.getStatus(), notNullValue()); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetReportResourceRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetReportResourceRequestTest.java deleted file mode 100644 index 1fbf3bff..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetReportResourceRequestTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.GetReportResourceRequest; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class GetReportResourceRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(GetReportResourceRequestTest.class); - } - - public GetReportResourceRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void requestShouldReportStatus() throws Exception { - JsRestClient jsRestClient = getJsRestClient(); - GetReportResourceRequest resourcesRequest = new GetReportResourceRequest(jsRestClient, - getFactoryGirl().getResourceUri(jsRestClient)); - ResourceLookup response = resourcesRequest.loadDataFromNetwork(); - assertThat(response.getResourceType(), is(ResourceLookup.ResourceType.reportUnit)); - assertThat(response.getLabel(), notNullValue()); - assertThat(response.getDescription(), notNullValue()); - assertThat(response.getUri(), notNullValue()); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetRootFolderDataRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetRootFolderDataRequestTest.java deleted file mode 100644 index 0fcaad57..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/GetRootFolderDataRequestTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. - * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. - * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. - * Vestibulum commodo. Ut rhoncus gravida arcu. - */ - -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.async.request.GetRootFolderDataRequest; -import com.jaspersoft.android.sdk.client.oxm.report.FolderDataResponse; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; -import com.jaspersoft.android.sdk.util.StaticCacheHelper; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.FakeHttp; - -import java.util.Collection; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class GetRootFolderDataRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(GetRootFolderDataRequestTest.class); - } - - public GetRootFolderDataRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void shouldGetRootFolderUriMethod() throws Exception { - StaticCacheHelper.clearCache(); - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - - GetRootFolderDataRequest request = new GetRootFolderDataRequest(getJsRestClient()); - FolderDataResponse response = request.loadDataFromNetwork(); - assertThat(response.getUri(), is("/")); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/JsRestClientTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/JsRestClientTest.java deleted file mode 100644 index 5e7c439e..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/JsRestClientTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.JsServerProfile; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.net.URI; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.mockito.Mockito.when; - -/** - * @author Tom Koptel - * @since 1.9 - */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) -public class JsRestClientTest { - private static final String SERVER_URL = "http://build-master.jaspersoft.com/jasperserver-pro"; - private static final String REQUEST_ID = "da977e74-561a-47ac-a92f-f3f3d98aac72"; - - private JsRestClient jsRestClient; - @Mock - private JsServerProfile jsServerProfile; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - jsRestClient = new JsRestClient(); - when(jsServerProfile.getServerUrl()).thenReturn(SERVER_URL); - when(jsServerProfile.getUsernameWithOrgId()).thenReturn(""); - when(jsServerProfile.getPassword()).thenReturn(""); - jsRestClient.setServerProfile(jsServerProfile); - } - - @Test - public void test_GetExportForReport_formsURI() { - URI uri = jsRestClient.getExportForReportURI(REQUEST_ID); - String expectedUri = "http://build-master.jaspersoft.com/jasperserver-pro/rest_v2/reportExecutions/da977e74-561a-47ac-a92f-f3f3d98aac72/exports"; - assertThat(uri.toString(), is(expectedUri)); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ParametrizedTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ParametrizedTest.java deleted file mode 100644 index 6310963e..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ParametrizedTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.util.FactoryGirl; -import com.jaspersoft.android.sdk.client.util.ServerCollection; -import com.jaspersoft.android.sdk.client.util.ServerUnderTest; - -import java.util.Collection; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public abstract class ParametrizedTest { - private final JsRestClient jsRestClient; - private final FactoryGirl factoryGirl; - private final ServerUnderTest mServer; - private final String mDatatype; - - public static Collection data(Class targetClass) { - return ServerCollection.newInstance(targetClass).load(); - } - - protected ParametrizedTest(String versionCode, String url, String dataType) { - mServer = ServerUnderTest.createBuilderWithDefaults() - .setVersionCode(versionCode) - .setServerUrl(url) - .build(); - mDatatype = dataType; - factoryGirl = FactoryGirl.newInstance(); - jsRestClient = factoryGirl.createJsRestClient(dataType, mServer); - } - - public JsRestClient getJsRestClient() { - return jsRestClient; - } - - public FactoryGirl getFactoryGirl() { - return factoryGirl; - } - - public String getDatatype() { - return mDatatype; - } - - public ServerUnderTest getServer() { - return mServer; - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ReportDetailsRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ReportDetailsRequestTest.java deleted file mode 100644 index 24da9afa..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ReportDetailsRequestTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.ReportDetailsRequest; -import com.jaspersoft.android.sdk.client.async.request.RunReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class ReportDetailsRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(ReportDetailsRequestTest.class); - } - - public ReportDetailsRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void shouldRequestReportDetails() throws Exception { - JsRestClient jsRestClient = getJsRestClient(); - ReportExecutionRequest reportExecutionRequest = getFactoryGirl().createExecutionData(jsRestClient); - - RunReportExecutionRequest runReportExecutionRequest = new RunReportExecutionRequest(jsRestClient, reportExecutionRequest); - ReportExecutionResponse runReportExecutionResponse = runReportExecutionRequest.loadDataFromNetwork(); - String requestId = runReportExecutionResponse.getRequestId(); - - ReportDetailsRequest reportDetailsRequest = new ReportDetailsRequest(jsRestClient, requestId); - ReportExecutionResponse response = reportDetailsRequest.loadDataFromNetwork(); - assertThat(response.getReportURI(), notNullValue()); - assertThat(response.getRequestId(), notNullValue()); - assertThat(response.getStatus(), notNullValue()); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ResourceLookupRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ResourceLookupRequestTest.java deleted file mode 100644 index a4ce4194..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ResourceLookupRequestTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.cacheable.GetResourceLookupsRequest; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupSearchCriteria; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupsList; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class ResourceLookupRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(ResourceLookupRequestTest.class); - } - - public ResourceLookupRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void shouldRequestForResourceLookup() throws Exception { - JsRestClient jsRestClient = getJsRestClient(); - ResourceLookupSearchCriteria searchCriteria = getFactoryGirl().createSearchCriteria(); - GetResourceLookupsRequest request = new GetResourceLookupsRequest(jsRestClient, searchCriteria); - ResourceLookupsList response = request.loadDataFromNetwork(); - assertThat(response.getResourceLookups(), is(not(empty()))); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/RootFolderLookupRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/RootFolderLookupRequestTest.java deleted file mode 100644 index ae2f5f53..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/RootFolderLookupRequestTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.GetRootFolderDataRequest; -import com.jaspersoft.android.sdk.client.oxm.report.FolderDataResponse; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class RootFolderLookupRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(RootFolderLookupRequestTest.class); - } - - public RootFolderLookupRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void shouldRequestForRootFolder() throws Exception { - JsRestClient jsRestClient = getJsRestClient(); - GetRootFolderDataRequest request = new GetRootFolderDataRequest(jsRestClient); - FolderDataResponse response = request.loadDataFromNetwork(); - assertThat(response.getUri(), is(notNullValue())); - assertThat(response.getDescription(), is(notNullValue())); - assertThat(response.getCreationDate(), is(notNullValue())); - assertThat(response.getResourceType(), is(notNullValue())); - assertThat(response.getUpdateDate(), is(notNullValue())); - assertThat(response.getVersion(), is(notNullValue())); - assertThat(response.getPermissionMask(), is(notNullValue())); - assertThat(response.getLabel(), is(notNullValue())); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/RunReportExportsRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/RunReportExportsRequestTest.java deleted file mode 100644 index ee32452d..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/RunReportExportsRequestTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.RunReportExecutionRequest; -import com.jaspersoft.android.sdk.client.async.request.RunReportExportOutputRequest; -import com.jaspersoft.android.sdk.client.async.request.RunReportExportsRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ExportExecution; -import com.jaspersoft.android.sdk.client.oxm.report.ExportsRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportDataResponse; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionResponse; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.IsNull.notNullValue; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class RunReportExportsRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(RunReportExportsRequestTest.class); - } - - public RunReportExportsRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void shouldRequestForExportsOnReport() throws Exception { - JsRestClient jsRestClient = getJsRestClient(); - ReportExecutionRequest reportExecutionRequest = getFactoryGirl().createExecutionData(jsRestClient); - RunReportExecutionRequest runReportExecutionRequest = new RunReportExecutionRequest(jsRestClient, reportExecutionRequest); - - ReportExecutionResponse runReportExecutionResponse = runReportExecutionRequest.loadDataFromNetwork(); - String requestId = runReportExecutionResponse.getRequestId(); - - ExportsRequest exr = new ExportsRequest(); - exr.setMarkupType(ReportExecutionRequest.MARKUP_TYPE_EMBEDDABLE); - exr.setAllowInlineScripts(false); - exr.setOutputFormat("html"); - exr.setPages("1"); - - RunReportExportsRequest runReportExportsRequest = new RunReportExportsRequest(jsRestClient, exr, requestId); - ExportExecution runReportExportsResponse = runReportExportsRequest.loadDataFromNetwork(); - assertThat(runReportExportsResponse.getStatus(), notNullValue()); - assertThat(runReportExportsResponse.getId(), notNullValue()); - - String executionId = runReportExportsResponse.getId(); - RunReportExportOutputRequest runReportExportOutputRequest - = new RunReportExportOutputRequest(jsRestClient, requestId, executionId); - ReportDataResponse response = runReportExportOutputRequest.loadDataFromNetwork(); - assertThat(response.getData(), notNullValue()); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ServerInfoRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ServerInfoRequestTest.java deleted file mode 100644 index c74ff97f..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ServerInfoRequestTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class ServerInfoRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(ServerInfoRequestTest.class); - } - - public ServerInfoRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void shouldRequestServerInfo() { - JsRestClient jsRestClient = getJsRestClient(); - ServerInfo serverInfo = jsRestClient.getServerInfo(); - assertThat(serverInfo.getVersion(), is(notNullValue())); - assertThat(serverInfo.getBuild(), is(notNullValue())); - assertThat(serverInfo.getEditionName(), is(notNullValue())); - assertThat(serverInfo.getEdition(), is(notNullValue())); - assertThat(serverInfo.getFeatures(), is(notNullValue())); - assertThat(serverInfo.getLicenseType(), is(notNullValue())); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ValidateInputControlsRequestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ValidateInputControlsRequestTest.java deleted file mode 100644 index ec58a27f..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/integration/ValidateInputControlsRequestTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.integration; - -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.async.request.cacheable.GetInputControlsRequest; -import com.jaspersoft.android.sdk.client.async.request.cacheable.GetInputControlsValuesRequest; -import com.jaspersoft.android.sdk.client.async.request.cacheable.ValidateInputControlsValuesRequest; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlStatesList; -import com.jaspersoft.android.sdk.client.oxm.control.InputControlsList; -import com.jaspersoft.android.sdk.client.util.RealHttpRule; -import com.jaspersoft.android.sdk.client.util.TargetDataType; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.ParameterizedRobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Collection; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@RunWith(ParameterizedRobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@TargetDataType(values = {"XML", "JSON"}) -public class ValidateInputControlsRequestTest extends ParametrizedTest { - @Rule - public RealHttpRule realHttpRule = new RealHttpRule(); - - @ParameterizedRobolectricTestRunner.Parameters(name = "Data type = {2} Server version = {0} url = {1}") - public static Collection data() { - return ParametrizedTest.data(ValidateInputControlsRequestTest.class); - } - - public ValidateInputControlsRequestTest(String versionCode, String url, String dataType) { - super(versionCode, url, dataType); - } - - @Test - public void shouldRequestInputControls() throws Exception { - JsRestClient jsRestClient = getJsRestClient(); - GetInputControlsRequest request = - new GetInputControlsRequest(jsRestClient, getFactoryGirl().getResourceUri(jsRestClient)); - InputControlsList inputControlsList = request.loadDataFromNetwork(); - assertThat(inputControlsList.getInputControls(), is(not(empty()))); - - String uri = getFactoryGirl().getResourceUri(jsRestClient); - ValidateInputControlsValuesRequest validateRequest = - new ValidateInputControlsValuesRequest(jsRestClient, uri, inputControlsList.getInputControls()); - InputControlStatesList statesList = validateRequest.loadDataFromNetwork(); - assertThat(statesList.getInputControlStates(), is(empty())); - - GetInputControlsValuesRequest valuesRequest = new GetInputControlsValuesRequest(jsRestClient, uri, inputControlsList.getInputControls()); - InputControlStatesList statesList2 = valuesRequest.loadDataFromNetwork(); - assertThat(statesList2.getInputControlStates(), is(not(empty()))); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/FactoryGirl.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/FactoryGirl.java deleted file mode 100644 index a4c53095..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/FactoryGirl.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.jaspersoft.android.sdk.client.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.jaspersoft.android.sdk.client.JsRestClient; -import com.jaspersoft.android.sdk.client.JsServerProfile; -import com.jaspersoft.android.sdk.client.oxm.report.ReportExecutionRequest; -import com.jaspersoft.android.sdk.client.oxm.report.ReportParametersList; -import com.jaspersoft.android.sdk.client.oxm.report.adapter.ReportParametersListDeserializer; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookupSearchCriteria; - -import java.util.ArrayList; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class FactoryGirl { - private static final String ATTACHMENT_PREFIX_5_6 = "/reportExecutions/{reportExecutionId}/exports/{exportExecutionId}/attachments/"; - private static final String ATTACHMENT_PREFIX_5_0 = "/reportExecutions/{reportExecutionId}/exports/{exportOptions}/attachments/"; - - public static FactoryGirl newInstance() { - return new FactoryGirl(); - } - - public JsRestClient createJsRestClient(String dataType) { - return createJsRestClient(dataType, createJsServerProfile()); - } - - public JsRestClient createJsRestClient(ServerUnderTest serverUnderTest) { - return createJsRestClient(JsRestClient.DataType.XML.toString(), JsServerProfileAdapter.newInstance().adapt(serverUnderTest)); - } - - public JsRestClient createJsRestClient(String dataType, ServerUnderTest serverUnderTest) { - return createJsRestClient(dataType, JsServerProfileAdapter.newInstance().adapt(serverUnderTest)); - } - - public JsRestClient createJsRestClient(JsServerProfile jsServerProfile) { - return createJsRestClient(JsRestClient.DataType.XML.toString(), jsServerProfile); - } - - public JsRestClient createJsRestClient(String dataType, JsServerProfile jsServerProfile) { - JsRestClient jsRestClient = JsRestClient - .builder() - .setDataType(JsRestClient.DataType.valueOf(dataType)) - .build(); - jsRestClient.setServerProfile(jsServerProfile); - return jsRestClient; - } - - public JsServerProfile createJsServerProfile() { - return JsServerProfileAdapter - .newInstance() - .adapt(ServerUnderTest.createDefault()); - } - - public ReportExecutionRequest createExecutionData(JsRestClient jsRestClient) { - return createExecutionData( - jsRestClient, - ResourceUnderTestFactory - .newInstance(jsRestClient.getServerProfile()) - .create() - ); - } - - public ReportExecutionRequest createExecutionData(JsRestClient jsRestClient, ResourceUnderTest resourceUnderTest) { - ReportExecutionRequest reportExecutionRequest = new ReportExecutionRequest(); - - JsServerProfile jsServerProfile = jsRestClient.getServerProfile(); - String serverUrl = jsServerProfile.getServerUrl(); - String attachmentsPrefix = (jsServerProfile.getServerUrl() + JsRestClient.REST_SERVICES_V2_URI + resourceUnderTest.getAttachmentPrefix()); - reportExecutionRequest.setAttachmentsPrefix(attachmentsPrefix); - reportExecutionRequest.setBaseUrl(serverUrl); - - reportExecutionRequest.setReportUnitUri(resourceUnderTest.getUri()); - reportExecutionRequest.setMarkupType(ReportExecutionRequest.MARKUP_TYPE_EMBEDDABLE); - reportExecutionRequest.setOutputFormat("HTML"); - reportExecutionRequest.setPages("1"); - reportExecutionRequest.setAsync(true); - reportExecutionRequest.setInteractive(true); - reportExecutionRequest.setFreshData(false); - reportExecutionRequest.setSaveDataSnapshot(false); - reportExecutionRequest.setAllowInlineScripts(false); - - String json = TestResource.getJson().rawData("report_parameters"); - - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(ReportParametersList.class, new ReportParametersListDeserializer()); - Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); - ReportParametersList reportParameter = gson.fromJson(json, ReportParametersList.class); - reportExecutionRequest.setParameters(reportParameter.getReportParameters()); - - return reportExecutionRequest; - } - - public String getResourceUri(JsRestClient jsRestClient) { - return ResourceUnderTestFactory - .newInstance(jsRestClient.getServerProfile()) - .create().getUri(); - } - - public ResourceLookupSearchCriteria createSearchCriteria() { - ResourceLookupSearchCriteria searchCriteria = new ResourceLookupSearchCriteria(); - searchCriteria.setForceFullPage(true); - searchCriteria.setLimit(10); - searchCriteria.setRecursive(true); - searchCriteria.setTypes(new ArrayList() { - { - add(ResourceLookup.ResourceType.dashboard.toString()); - add(ResourceLookup.ResourceType.legacyDashboard.toString()); - } - }); - searchCriteria.setFolderUri("/"); - searchCriteria.setSortBy("label"); - return searchCriteria; - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/JsServerProfileAdapter.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/JsServerProfileAdapter.java deleted file mode 100644 index 680f7aa3..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/JsServerProfileAdapter.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.jaspersoft.android.sdk.client.util; - -import com.jaspersoft.android.sdk.client.JsServerProfile; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class JsServerProfileAdapter { - public static JsServerProfileAdapter newInstance() { - return new JsServerProfileAdapter(); - } - - public JsServerProfile adapt(ServerUnderTest serverUnderTest) { - JsServerProfile adaptee = new JsServerProfile(); - adaptee.setAlias(serverUnderTest.getAlias()); - adaptee.setServerUrl(serverUnderTest.getServerUrl()); - adaptee.setOrganization(serverUnderTest.getOrganization()); - adaptee.setUsername(serverUnderTest.getUsername()); - adaptee.setPassword(serverUnderTest.getPassword()); - adaptee.setVersionCode(serverUnderTest.getVersionCode()); - adaptee.setServerEdition(serverUnderTest.getServerEdition()); - return adaptee; - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/RealHttpRule.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/RealHttpRule.java deleted file mode 100644 index bfc22e23..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/RealHttpRule.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.util; - -import com.jaspersoft.android.sdk.util.StaticCacheHelper; - -import org.junit.Before; -import org.junit.rules.ExternalResource; -import org.robolectric.shadows.FakeHttp; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class RealHttpRule extends ExternalResource { - @Before - public void before() throws Throwable { - super.before(); - StaticCacheHelper.clearCache(); - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - } - - @Override - protected void after() { - super.after(); - FakeHttp.getFakeHttpLayer().interceptHttpRequests(true); - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest.java deleted file mode 100644 index 4fda11e2..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.jaspersoft.android.sdk.client.util; - -/** - * @author Tom Koptel - * @since 1.10 - */ -interface ResourceUnderTest { - String getUri(); - String getAttachmentPrefix(); -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest5_5.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest5_5.java deleted file mode 100644 index ab50cf78..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTest5_5.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.util; - -/** - * @author Tom Koptel - * @since 1.10 - */ -class ResourceUnderTest5_5 implements ResourceUnderTest { - public static final String RESOURCE_URI = "/Reports/1._Geographic_Results_by_Segment_Report"; - private static final String ATTACHMENT_PREFIX = "/reportExecutions/{reportExecutionId}/exports/{exportOptions}/attachments/"; - - @Override - public String getUri() { - return RESOURCE_URI; - } - - @Override - public String getAttachmentPrefix() { - return ATTACHMENT_PREFIX; - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestFactory.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestFactory.java deleted file mode 100644 index dbd95311..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.util; - -import com.jaspersoft.android.sdk.client.JsServerProfile; - -/** - * @author Tom Koptel - * @since 1.10 - */ -class ResourceUnderTestFactory { - private final JsServerProfile jsServerProfile; - - private ResourceUnderTestFactory(JsServerProfile jsServerProfile) { - this.jsServerProfile = jsServerProfile; - } - - public static ResourceUnderTestFactory newInstance(JsServerProfile jsServerProfile) { - return new ResourceUnderTestFactory(jsServerProfile); - } - - public ResourceUnderTest create() { - if (jsServerProfile.getVersionCode().equals("5.5")) { - return new ResourceUnderTest5_5(); - } else { - return new ResourceUnderTestGreater5_5(); - } - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestGreater5_5.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestGreater5_5.java deleted file mode 100644 index 050801e1..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ResourceUnderTestGreater5_5.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.util; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class ResourceUnderTestGreater5_5 implements ResourceUnderTest { - public static final String RESOURCE_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; - private static final String ATTACHMENT_PREFIX= "/reportExecutions/{reportExecutionId}/exports/{exportExecutionId}/attachments/"; - - @Override - public String getUri() { - return RESOURCE_URI; - } - - @Override - public String getAttachmentPrefix() { - return ATTACHMENT_PREFIX; - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerCollection.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerCollection.java deleted file mode 100644 index 4b219289..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerCollection.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.util; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.math.BigDecimal; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ServerCollection { - private final List params = new ArrayList<>(); - private final Set servers; - private final String[] mDataTypes; - - private ServerCollection(String resourceName, String[] dataTypes) { - String data = TestResource.getJson().rawData(resourceName); - Type type = new TypeToken>() { - }.getType(); - servers = new Gson().fromJson(data, type); - mDataTypes = dataTypes; - } - - public static ServerCollection newInstance(Class targetClass) { - Annotation[] annotations = targetClass.getAnnotations(); - String[] dataTypes = {"XML"}; - for (Annotation annotation : annotations) { - if (annotation instanceof TargetDataType) { - TargetDataType dataType = (TargetDataType) annotation; - dataTypes = dataType.values(); - } - } - return new ServerCollection("servers_under_test", dataTypes); - } - - public Collection load() { - if (params.isEmpty()) { - for (String serveUrl : servers) { - createParams(readServerData(serveUrl)); - } - } - if (params.isEmpty()) { - throw new IllegalStateException("Oops! It looks like you forgot to setup 'servers_under_test.json' resource"); - } - return params; - } - - private void createParams(Map serverData) { - String version = serverData.get("version"); - String url = serverData.get("url"); - for (String dataType : mDataTypes) { - params.add(new Object[]{version, url, dataType}); - } - } - - private Map readServerData(String serveUrl) { - try { - URL url = new URL(serveUrl + "/rest_v2/serverInfo"); - - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("GET"); - connection.setRequestProperty("Accept", "application/json"); - connection.setRequestProperty("Content-Type", "application/json"); - - connection.setUseCaches(true); - connection.setDoOutput(true); - - InputStream is = connection.getInputStream(); - BufferedReader rd = new BufferedReader(new InputStreamReader(is)); - StringBuilder response = new StringBuilder(); // or StringBuffer if not Java 5+ - String line; - while ((line = rd.readLine()) != null) { - response.append(line); - response.append('\r'); - } - rd.close(); - - String json = response.toString(); - Type type = new TypeToken>() { - }.getType(); - - Map serverData = new Gson().fromJson(json, type); - serverData.put("url", serveUrl); - serverData.put("version", normalizeServerVersion(serverData.get("version"))); - return serverData; - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - - private static String normalizeServerVersion(String version) { - String[] subs = version.split("\\."); - - BigDecimal decimalSubVersion, decimalFactor, decimalResult; - BigDecimal decimalVersion = new BigDecimal("0"); - for (int i = 0; i < subs.length; i++) { - try { - decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); - } catch (NumberFormatException ex) { - decimalSubVersion = new BigDecimal("0"); - } - - decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); - decimalResult = decimalSubVersion.multiply(decimalFactor); - decimalVersion = decimalVersion.add(decimalResult); - } - return String.valueOf(decimalVersion.doubleValue()); - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerUnderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerUnderTest.java deleted file mode 100644 index 8095cf38..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerUnderTest.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.jaspersoft.android.sdk.client.util; - -import java.net.MalformedURLException; -import java.net.URL; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class ServerUnderTest { - private final String alias; - private final String organization; - private final String serverUrl; - private final String username; - private final String password; - private final String versionCode; - private final String serverEdition; - - private ServerUnderTest(Builder builder) { - this.alias = builder.alias; - this.organization = builder.organization; - this.serverUrl = builder.serverUrl; - this.username = builder.username; - this.password = builder.password; - this.versionCode = builder.versionCode; - this.serverEdition = builder.serverEdition; - } - - public static ServerUnderTest createDefault() { - return createBuilderWithDefaults().build(); - } - - public static Builder createBuilderWithDefaults() { - return builder() - .withDefaultAlias() - .withDefaultOrganization() - .withDefaultServerUrl() - .withDefaultUsername() - .withDefaultPassword() - .withDefaultServerEdition() - .withDefaultVersionCode(); - } - - public static Builder builder() { - return new Builder(); - } - - public String getAlias() { - return alias; - } - - public String getOrganization() { - return organization; - } - - public String getServerUrl() { - return serverUrl; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - public String getServerEdition() { - return serverEdition; - } - - public String getVersionCode() { - return versionCode; - } - - @Override - public String toString() { - return "ServerUnderTest{" + - "alias='" + alias + '\'' + - ", organization='" + organization + '\'' + - ", serverUrl='" + serverUrl + '\'' + - ", username='" + username + '\'' + - ", password='" + password + '\'' + - ", versionCode='" + versionCode + '\'' + - ", serverEdition='" + serverEdition + '\'' + - '}'; - } - - public static class Builder { - private String alias; - private String organization; - private String serverUrl; - private String username; - private String password; - private String versionCode; - private String serverEdition; - - public Builder setAlias(String alias) { - this.alias = alias; - return this; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setServerUrl(String serverUrl) { - this.serverUrl = serverUrl; - return this; - } - - public Builder setUsername(String username) { - this.username = username; - return this; - } - - public Builder setPassword(String pass) { - this.password = pass; - return this; - } - - public Builder setServerEdition(String serverEdition) { - this.serverEdition = serverEdition; - return this; - } - - public Builder setVersionCode(String versionCode) { - this.versionCode = versionCode; - return this; - } - - public Builder withDefaultAlias() { - this.alias = "Mobile Demo"; - return this; - } - - public Builder withDefaultOrganization() { - this.organization = "organization_1"; - return this; - } - - public Builder withDefaultServerUrl() { - this.serverUrl = "http://mobiledemo.jaspersoft.com/jasperserver-pro"; - return this; - } - - public Builder withDefaultUsername() { - this.username = "joeuser"; - return this; - } - - public Builder withDefaultPassword() { - this.password = "joeuser"; - return this; - } - - public Builder withDefaultVersionCode() { - this.versionCode = "5.5"; - return this; - } - - public Builder withDefaultServerEdition() { - this.serverEdition = "PRO"; - return this; - } - - public ServerUnderTest build() { - checkValues(); - return new ServerUnderTest(this); - } - - private void checkValues() { - assertPropertyNotEmpty(alias, "alias"); - assertPropertyNotNull(organization, "organization"); - assertPropertyNotEmpty(serverUrl, "serverUrl"); - assertPropertyNotEmpty(username, "username"); - assertPropertyNotEmpty(password, "password"); - assertPropertyNotEmpty(versionCode, "versionCode"); - assertPropertyNotEmpty(serverEdition, "serverEdition"); - serverUrl = trimUrl(serverUrl); - try { - new URL(serverUrl); - } catch (MalformedURLException e) { - throw new IllegalStateException(e); - } - } - - private void assertPropertyNotNull(String property, String propertyName) { - if (property == null) { - throw new IllegalStateException( - propertyName + " invalid should not be: " + String.valueOf(property)); - } - } - - private void assertPropertyNotEmpty(String property, String propertyName) { - if (isEmpty(property)) { - throw new IllegalStateException( - propertyName + " invalid should not be: " + String.valueOf(property)); - } - } - - private static String trimUrl(String url) { - if (!isEmpty(url) && url.endsWith("/")) { - url = url.substring(0, url.length() - 1); - } - return url; - } - - private static boolean isEmpty(String str) { - if (str == null || str.trim().length() == 0) - return true; - else - return false; - } - } -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerVersion.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerVersion.java deleted file mode 100644 index aed2ea55..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/ServerVersion.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.client.util; - -import com.jaspersoft.android.sdk.client.oxm.server.ServerInfo; - -/** - * Wrapper for version abstraction in order to provide much easier migration on new implementation in future. - * - * @author Tom Koptel - * @since 1.10 - */ -public enum ServerVersion { - V5_5 { - @Override - public String get() { - return String.valueOf(ServerInfo.VERSION_CODES.EMERALD_TWO); - } - }; - - public String get() { - throw new UnsupportedOperationException(); - } - -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/TargetDataType.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/TargetDataType.java deleted file mode 100644 index c8fefc3f..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/TargetDataType.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.jaspersoft.android.sdk.client.util; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author Tom Koptel - * @since 1.10 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface TargetDataType { - String[] values() default "XML"; -} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/client/util/TestResource.java b/client/src/test/java/com/jaspersoft/android/sdk/client/util/TestResource.java deleted file mode 100644 index c7ddf25d..00000000 --- a/client/src/test/java/com/jaspersoft/android/sdk/client/util/TestResource.java +++ /dev/null @@ -1,111 +0,0 @@ -/* -* Copyright � 2015 TIBCO Software, Inc. All rights reserved. -* http://community.jaspersoft.com/project/jaspermobile-android -* -* Unless you have purchased a commercial license agreement from Jaspersoft, -* the following license terms apply: -* -* This program is part of Jaspersoft Mobile for Android. -* -* Jaspersoft Mobile is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Jaspersoft Mobile is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Jaspersoft Mobile for Android. If not, see -* . -*/ - -package com.jaspersoft.android.sdk.client.util; - -import org.apache.commons.io.IOUtils; -import org.simpleframework.xml.Serializer; -import org.simpleframework.xml.core.Persister; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; - -/** - * @author Tom Koptel - * @since 1.10 - */ -public class TestResource { - public enum DataFormat { - JSON, XML - } - - private final DataFormat mFormat; - - public static TestResource get(DataFormat format) { - return new TestResource(format); - } - - public static TestResource getXml() { - return new TestResource(DataFormat.XML); - } - - public static TestResource getJson() { - return new TestResource(DataFormat.JSON); - } - - private TestResource(DataFormat format) { - mFormat = format; - } - - public T from(Class clazz, String fileName) { - if (mFormat == DataFormat.XML) { - return fromXML(clazz, fileName); - } - if (mFormat == DataFormat.JSON) { - return fromXML(clazz, fileName); - } - throw new UnsupportedOperationException(); - } - - public String rawData(String fileName) { - InputStream inputStream = getStream(fileName); - - StringWriter writer = new StringWriter(); - try { - IOUtils.copy(inputStream, writer, "UTF-8"); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - IOUtils.closeQuietly(inputStream); - } - return writer.toString(); - } - - public InputStream getStream(String fileName) { - return getClass().getClassLoader().getResourceAsStream(fileName + "." + mFormat.toString().toLowerCase()); - } - - public byte[] getBytes(String fileName) throws IOException { - InputStream stream = getStream(fileName); - try { - return IOUtils.toByteArray(stream); - } finally { - IOUtils.closeQuietly(stream); - } - } - - public T fromXML(Class clazz, String fileName) { - InputStream stream = getStream(fileName); - - Serializer serializer = new Persister(); - try { - return serializer.read(clazz, stream); - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - IOUtils.closeQuietly(stream); - } - } -} \ No newline at end of file diff --git a/client/src/test/resources/controls_01.json b/client/src/test/resources/controls_01.json deleted file mode 100644 index d30f1463..00000000 --- a/client/src/test/resources/controls_01.json +++ /dev/null @@ -1,7891 +0,0 @@ -{ - "inputControl": [ - { - "id": "sales_fact_ALL__store_sales_2013_1", - "type": "singleValueNumber", - "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", - "label": "Store Sales 2013 is greater than", - "mandatory": false, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "state": { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", - "id": "sales_fact_ALL__store_sales_2013_1", - "value": "19" - } - }, - { - "id": "sales__product__low_fat_1", - "type": "multiSelectCheckbox", - "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", - "label": "Low Fat", - "mandatory": false, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "state": { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", - "id": "sales__product__low_fat_1", - "options": [ - { - "selected": true, - "label": "true", - "value": "true" - }, - { - "selected": true, - "label": "false", - "value": "false" - } - ] - } - }, - { - "id": "sales__product__recyclable_package_1", - "type": "multiSelectCheckbox", - "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", - "label": "Recyclable Packaging", - "mandatory": false, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "state": { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", - "id": "sales__product__recyclable_package_1", - "options": [ - { - "selected": true, - "label": "true", - "value": "true" - }, - { - "selected": true, - "label": "false", - "value": "false" - } - ] - } - }, - { - "id": "sales__product__product_name_1", - "type": "multiSelect", - "uri": "repo:/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", - "label": "Product Name", - "mandatory": false, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "state": { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", - "id": "sales__product__product_name_1", - "options": [ - { - "selected": false, - "label": "ADJ Rosy Sunglasses", - "value": "ADJ Rosy Sunglasses" - }, - { - "selected": false, - "label": "Akron City Map", - "value": "Akron City Map" - }, - { - "selected": false, - "label": "Akron Eyeglass Screwdriver", - "value": "Akron Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "American Beef Bologna", - "value": "American Beef Bologna" - }, - { - "selected": false, - "label": "American Chicken Hot Dogs", - "value": "American Chicken Hot Dogs" - }, - { - "selected": false, - "label": "American Cole Slaw", - "value": "American Cole Slaw" - }, - { - "selected": false, - "label": "American Corned Beef", - "value": "American Corned Beef" - }, - { - "selected": false, - "label": "American Foot-Long Hot Dogs", - "value": "American Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "American Low Fat Bologna", - "value": "American Low Fat Bologna" - }, - { - "selected": false, - "label": "American Low Fat Cole Slaw", - "value": "American Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "American Pimento Loaf", - "value": "American Pimento Loaf" - }, - { - "selected": false, - "label": "American Potato Salad", - "value": "American Potato Salad" - }, - { - "selected": false, - "label": "American Roasted Chicken", - "value": "American Roasted Chicken" - }, - { - "selected": false, - "label": "American Sliced Chicken", - "value": "American Sliced Chicken" - }, - { - "selected": false, - "label": "American Sliced Ham", - "value": "American Sliced Ham" - }, - { - "selected": false, - "label": "American Sliced Turkey", - "value": "American Sliced Turkey" - }, - { - "selected": false, - "label": "American Turkey Hot Dogs", - "value": "American Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Amigo Lox", - "value": "Amigo Lox" - }, - { - "selected": false, - "label": "Amigo Scallops", - "value": "Amigo Scallops" - }, - { - "selected": false, - "label": "Applause Canned Mixed Fruit", - "value": "Applause Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Applause Canned Peaches", - "value": "Applause Canned Peaches" - }, - { - "selected": false, - "label": "Atomic Bubble Gum", - "value": "Atomic Bubble Gum" - }, - { - "selected": false, - "label": "Atomic Malted Milk Balls", - "value": "Atomic Malted Milk Balls" - }, - { - "selected": false, - "label": "Atomic Mint Chocolate Bar", - "value": "Atomic Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Atomic Mints", - "value": "Atomic Mints" - }, - { - "selected": false, - "label": "Atomic Semi-Sweet Chocolate Bar", - "value": "Atomic Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Atomic Spicy Mints", - "value": "Atomic Spicy Mints" - }, - { - "selected": false, - "label": "Atomic Tasty Candy Bar", - "value": "Atomic Tasty Candy Bar" - }, - { - "selected": false, - "label": "Atomic White Chocolate Bar", - "value": "Atomic White Chocolate Bar" - }, - { - "selected": false, - "label": "BBB Best Apple Butter", - "value": "BBB Best Apple Butter" - }, - { - "selected": false, - "label": "BBB Best Apple Jam", - "value": "BBB Best Apple Jam" - }, - { - "selected": false, - "label": "BBB Best Apple Jelly", - "value": "BBB Best Apple Jelly" - }, - { - "selected": false, - "label": "BBB Best Apple Preserves", - "value": "BBB Best Apple Preserves" - }, - { - "selected": false, - "label": "BBB Best Brown Sugar", - "value": "BBB Best Brown Sugar" - }, - { - "selected": false, - "label": "BBB Best Canola Oil", - "value": "BBB Best Canola Oil" - }, - { - "selected": false, - "label": "BBB Best Chunky Peanut Butter", - "value": "BBB Best Chunky Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best Columbian Coffee", - "value": "BBB Best Columbian Coffee" - }, - { - "selected": false, - "label": "BBB Best Corn Oil", - "value": "BBB Best Corn Oil" - }, - { - "selected": false, - "label": "BBB Best Creamy Peanut Butter", - "value": "BBB Best Creamy Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best Decaf Coffee", - "value": "BBB Best Decaf Coffee" - }, - { - "selected": false, - "label": "BBB Best Extra Chunky Peanut Butter", - "value": "BBB Best Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best French Roast Coffee", - "value": "BBB Best French Roast Coffee" - }, - { - "selected": false, - "label": "BBB Best Grape Jam", - "value": "BBB Best Grape Jam" - }, - { - "selected": false, - "label": "BBB Best Grape Jelly", - "value": "BBB Best Grape Jelly" - }, - { - "selected": false, - "label": "BBB Best Grape Preserves", - "value": "BBB Best Grape Preserves" - }, - { - "selected": false, - "label": "BBB Best Hot Chocolate", - "value": "BBB Best Hot Chocolate" - }, - { - "selected": false, - "label": "BBB Best Low Fat Apple Butter", - "value": "BBB Best Low Fat Apple Butter" - }, - { - "selected": false, - "label": "BBB Best Oregano", - "value": "BBB Best Oregano" - }, - { - "selected": false, - "label": "BBB Best Pepper", - "value": "BBB Best Pepper" - }, - { - "selected": false, - "label": "BBB Best Regular Coffee", - "value": "BBB Best Regular Coffee" - }, - { - "selected": false, - "label": "BBB Best Salt", - "value": "BBB Best Salt" - }, - { - "selected": false, - "label": "BBB Best Sesame Oil", - "value": "BBB Best Sesame Oil" - }, - { - "selected": false, - "label": "BBB Best Strawberry Jam", - "value": "BBB Best Strawberry Jam" - }, - { - "selected": false, - "label": "BBB Best Strawberry Jelly", - "value": "BBB Best Strawberry Jelly" - }, - { - "selected": false, - "label": "BBB Best Strawberry Preserves", - "value": "BBB Best Strawberry Preserves" - }, - { - "selected": false, - "label": "BBB Best Tomato Sauce", - "value": "BBB Best Tomato Sauce" - }, - { - "selected": false, - "label": "BBB Best Vegetable Oil", - "value": "BBB Best Vegetable Oil" - }, - { - "selected": false, - "label": "BBB Best White Sugar", - "value": "BBB Best White Sugar" - }, - { - "selected": false, - "label": "Best Choice Apple Fruit Roll", - "value": "Best Choice Apple Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Avocado Dip", - "value": "Best Choice Avocado Dip" - }, - { - "selected": false, - "label": "Best Choice BBQ Potato Chips", - "value": "Best Choice BBQ Potato Chips" - }, - { - "selected": false, - "label": "Best Choice Beef Jerky", - "value": "Best Choice Beef Jerky" - }, - { - "selected": false, - "label": "Best Choice Buttered Popcorn", - "value": "Best Choice Buttered Popcorn" - }, - { - "selected": false, - "label": "Best Choice Cheese Crackers", - "value": "Best Choice Cheese Crackers" - }, - { - "selected": false, - "label": "Best Choice Cheese Dip", - "value": "Best Choice Cheese Dip" - }, - { - "selected": false, - "label": "Best Choice Chocolate Chip Cookies", - "value": "Best Choice Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Best Choice Chocolate Donuts", - "value": "Best Choice Chocolate Donuts" - }, - { - "selected": false, - "label": "Best Choice Corn Chips", - "value": "Best Choice Corn Chips" - }, - { - "selected": false, - "label": "Best Choice Dried Apples", - "value": "Best Choice Dried Apples" - }, - { - "selected": false, - "label": "Best Choice Dried Apricots", - "value": "Best Choice Dried Apricots" - }, - { - "selected": false, - "label": "Best Choice Dried Dates", - "value": "Best Choice Dried Dates" - }, - { - "selected": false, - "label": "Best Choice Fondue Mix", - "value": "Best Choice Fondue Mix" - }, - { - "selected": false, - "label": "Best Choice Frosted Cookies", - "value": "Best Choice Frosted Cookies" - }, - { - "selected": false, - "label": "Best Choice Frosted Donuts", - "value": "Best Choice Frosted Donuts" - }, - { - "selected": false, - "label": "Best Choice Fudge Brownies", - "value": "Best Choice Fudge Brownies" - }, - { - "selected": false, - "label": "Best Choice Fudge Cookies", - "value": "Best Choice Fudge Cookies" - }, - { - "selected": false, - "label": "Best Choice Golden Raisins", - "value": "Best Choice Golden Raisins" - }, - { - "selected": false, - "label": "Best Choice Graham Crackers", - "value": "Best Choice Graham Crackers" - }, - { - "selected": false, - "label": "Best Choice Grape Fruit Roll", - "value": "Best Choice Grape Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Lemon Cookies", - "value": "Best Choice Lemon Cookies" - }, - { - "selected": false, - "label": "Best Choice Low Fat BBQ Chips", - "value": "Best Choice Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Best Choice Low Fat Chips", - "value": "Best Choice Low Fat Chips" - }, - { - "selected": false, - "label": "Best Choice Low Fat Cookies", - "value": "Best Choice Low Fat Cookies" - }, - { - "selected": false, - "label": "Best Choice Low Fat Popcorn", - "value": "Best Choice Low Fat Popcorn" - }, - { - "selected": false, - "label": "Best Choice Mini Donuts", - "value": "Best Choice Mini Donuts" - }, - { - "selected": false, - "label": "Best Choice No Salt Popcorn", - "value": "Best Choice No Salt Popcorn" - }, - { - "selected": false, - "label": "Best Choice Potato Chips", - "value": "Best Choice Potato Chips" - }, - { - "selected": false, - "label": "Best Choice Raisins", - "value": "Best Choice Raisins" - }, - { - "selected": false, - "label": "Best Choice Raspberry Fruit Roll", - "value": "Best Choice Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Salsa Dip", - "value": "Best Choice Salsa Dip" - }, - { - "selected": false, - "label": "Best Choice Salted Pretzels", - "value": "Best Choice Salted Pretzels" - }, - { - "selected": false, - "label": "Best Choice Sesame Crackers", - "value": "Best Choice Sesame Crackers" - }, - { - "selected": false, - "label": "Best Choice Strawberry Fruit Roll", - "value": "Best Choice Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Sugar Cookies", - "value": "Best Choice Sugar Cookies" - }, - { - "selected": false, - "label": "Best Corn Puffs", - "value": "Best Corn Puffs" - }, - { - "selected": false, - "label": "Best Grits", - "value": "Best Grits" - }, - { - "selected": false, - "label": "Best Oatmeal", - "value": "Best Oatmeal" - }, - { - "selected": false, - "label": "Best Wheat Puffs", - "value": "Best Wheat Puffs" - }, - { - "selected": false, - "label": "Better Beef Soup", - "value": "Better Beef Soup" - }, - { - "selected": false, - "label": "Better Canned Beets", - "value": "Better Canned Beets" - }, - { - "selected": false, - "label": "Better Canned Peas", - "value": "Better Canned Peas" - }, - { - "selected": false, - "label": "Better Canned String Beans", - "value": "Better Canned String Beans" - }, - { - "selected": false, - "label": "Better Canned Tomatos", - "value": "Better Canned Tomatos" - }, - { - "selected": false, - "label": "Better Canned Tuna in Oil", - "value": "Better Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Better Canned Tuna in Water", - "value": "Better Canned Tuna in Water" - }, - { - "selected": false, - "label": "Better Canned Yams", - "value": "Better Canned Yams" - }, - { - "selected": false, - "label": "Better Chicken Noodle Soup", - "value": "Better Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Better Chicken Ramen Soup", - "value": "Better Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Better Chicken Soup", - "value": "Better Chicken Soup" - }, - { - "selected": false, - "label": "Better Creamed Corn", - "value": "Better Creamed Corn" - }, - { - "selected": false, - "label": "Better Fancy Canned Anchovies", - "value": "Better Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Better Fancy Canned Clams", - "value": "Better Fancy Canned Clams" - }, - { - "selected": false, - "label": "Better Fancy Canned Oysters", - "value": "Better Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Better Fancy Canned Sardines", - "value": "Better Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Better Large Canned Shrimp", - "value": "Better Large Canned Shrimp" - }, - { - "selected": false, - "label": "Better Noodle Soup", - "value": "Better Noodle Soup" - }, - { - "selected": false, - "label": "Better Regular Ramen Soup", - "value": "Better Regular Ramen Soup" - }, - { - "selected": false, - "label": "Better Rice Soup", - "value": "Better Rice Soup" - }, - { - "selected": false, - "label": "Better Turkey Noodle Soup", - "value": "Better Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Better Vegetable Soup", - "value": "Better Vegetable Soup" - }, - { - "selected": false, - "label": "Big City Canned Mixed Fruit", - "value": "Big City Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Big City Canned Peaches", - "value": "Big City Canned Peaches" - }, - { - "selected": false, - "label": "Big Time Apple Cinnamon Waffles", - "value": "Big Time Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Big Time Beef TV Dinner", - "value": "Big Time Beef TV Dinner" - }, - { - "selected": false, - "label": "Big Time Blueberry Waffles", - "value": "Big Time Blueberry Waffles" - }, - { - "selected": false, - "label": "Big Time Chicken TV Dinner", - "value": "Big Time Chicken TV Dinner" - }, - { - "selected": false, - "label": "Big Time Fajita French Fries", - "value": "Big Time Fajita French Fries" - }, - { - "selected": false, - "label": "Big Time Frozen Broccoli", - "value": "Big Time Frozen Broccoli" - }, - { - "selected": false, - "label": "Big Time Frozen Carrots", - "value": "Big Time Frozen Carrots" - }, - { - "selected": false, - "label": "Big Time Frozen Cauliflower", - "value": "Big Time Frozen Cauliflower" - }, - { - "selected": false, - "label": "Big Time Frozen Cheese Pizza", - "value": "Big Time Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Breast", - "value": "Big Time Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Thighs", - "value": "Big Time Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Wings", - "value": "Big Time Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Big Time Frozen Corn", - "value": "Big Time Frozen Corn" - }, - { - "selected": false, - "label": "Big Time Frozen Mushroom Pizza", - "value": "Big Time Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Pancakes", - "value": "Big Time Frozen Pancakes" - }, - { - "selected": false, - "label": "Big Time Frozen Peas", - "value": "Big Time Frozen Peas" - }, - { - "selected": false, - "label": "Big Time Frozen Pepperoni Pizza", - "value": "Big Time Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Sausage Pizza", - "value": "Big Time Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Big Time Grape Popsicles", - "value": "Big Time Grape Popsicles" - }, - { - "selected": false, - "label": "Big Time Home Style French Fries", - "value": "Big Time Home Style French Fries" - }, - { - "selected": false, - "label": "Big Time Ice Cream", - "value": "Big Time Ice Cream" - }, - { - "selected": false, - "label": "Big Time Ice Cream Sandwich", - "value": "Big Time Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Big Time Lemon Popsicles", - "value": "Big Time Lemon Popsicles" - }, - { - "selected": false, - "label": "Big Time Lime Popsicles", - "value": "Big Time Lime Popsicles" - }, - { - "selected": false, - "label": "Big Time Low Fat French Fries", - "value": "Big Time Low Fat French Fries" - }, - { - "selected": false, - "label": "Big Time Low Fat Waffles", - "value": "Big Time Low Fat Waffles" - }, - { - "selected": false, - "label": "Big Time Orange Popsicles", - "value": "Big Time Orange Popsicles" - }, - { - "selected": false, - "label": "Big Time Pancake Mix", - "value": "Big Time Pancake Mix" - }, - { - "selected": false, - "label": "Big Time Popsicles", - "value": "Big Time Popsicles" - }, - { - "selected": false, - "label": "Big Time Turkey TV Dinner", - "value": "Big Time Turkey TV Dinner" - }, - { - "selected": false, - "label": "Big Time Waffles", - "value": "Big Time Waffles" - }, - { - "selected": false, - "label": "Bird Call 200 MG Acetominifen", - "value": "Bird Call 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Bird Call 200 MG Ibuprofen", - "value": "Bird Call 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Bird Call Angled Toothbrush", - "value": "Bird Call Angled Toothbrush" - }, - { - "selected": false, - "label": "Bird Call Apricot Shampoo", - "value": "Bird Call Apricot Shampoo" - }, - { - "selected": false, - "label": "Bird Call Buffered Aspirin", - "value": "Bird Call Buffered Aspirin" - }, - { - "selected": false, - "label": "Bird Call Childrens Aspirin", - "value": "Bird Call Childrens Aspirin" - }, - { - "selected": false, - "label": "Bird Call Childrens Cold Remedy", - "value": "Bird Call Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Bird Call Conditioning Shampoo", - "value": "Bird Call Conditioning Shampoo" - }, - { - "selected": false, - "label": "Bird Call Deodorant", - "value": "Bird Call Deodorant" - }, - { - "selected": false, - "label": "Bird Call Dishwasher Detergent", - "value": "Bird Call Dishwasher Detergent" - }, - { - "selected": false, - "label": "Bird Call Extra Moisture Shampoo", - "value": "Bird Call Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Bird Call HCL Nasal Spray", - "value": "Bird Call HCL Nasal Spray" - }, - { - "selected": false, - "label": "Bird Call Laundry Detergent", - "value": "Bird Call Laundry Detergent" - }, - { - "selected": false, - "label": "Bird Call Mint Mouthwash", - "value": "Bird Call Mint Mouthwash" - }, - { - "selected": false, - "label": "Bird Call Multi-Symptom Cold Remedy", - "value": "Bird Call Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Bird Call Silky Smooth Hair Conditioner", - "value": "Bird Call Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Bird Call Tartar Control Toothpaste", - "value": "Bird Call Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Bird Call Toothpaste", - "value": "Bird Call Toothpaste" - }, - { - "selected": false, - "label": "Bird Call Whitening Toothpast", - "value": "Bird Call Whitening Toothpast" - }, - { - "selected": false, - "label": "Black Tie City Map", - "value": "Black Tie City Map" - }, - { - "selected": false, - "label": "Black Tie Eyeglass Screwdriver", - "value": "Black Tie Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Blue Label Beef Soup", - "value": "Blue Label Beef Soup" - }, - { - "selected": false, - "label": "Blue Label Canned Beets", - "value": "Blue Label Canned Beets" - }, - { - "selected": false, - "label": "Blue Label Canned Peas", - "value": "Blue Label Canned Peas" - }, - { - "selected": false, - "label": "Blue Label Canned String Beans", - "value": "Blue Label Canned String Beans" - }, - { - "selected": false, - "label": "Blue Label Canned Tomatos", - "value": "Blue Label Canned Tomatos" - }, - { - "selected": false, - "label": "Blue Label Canned Tuna in Oil", - "value": "Blue Label Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Blue Label Canned Tuna in Water", - "value": "Blue Label Canned Tuna in Water" - }, - { - "selected": false, - "label": "Blue Label Canned Yams", - "value": "Blue Label Canned Yams" - }, - { - "selected": false, - "label": "Blue Label Chicken Noodle Soup", - "value": "Blue Label Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Chicken Ramen Soup", - "value": "Blue Label Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Blue Label Chicken Soup", - "value": "Blue Label Chicken Soup" - }, - { - "selected": false, - "label": "Blue Label Creamed Corn", - "value": "Blue Label Creamed Corn" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Anchovies", - "value": "Blue Label Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Clams", - "value": "Blue Label Fancy Canned Clams" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Oysters", - "value": "Blue Label Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Sardines", - "value": "Blue Label Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Blue Label Large Canned Shrimp", - "value": "Blue Label Large Canned Shrimp" - }, - { - "selected": false, - "label": "Blue Label Noodle Soup", - "value": "Blue Label Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Regular Ramen Soup", - "value": "Blue Label Regular Ramen Soup" - }, - { - "selected": false, - "label": "Blue Label Rice Soup", - "value": "Blue Label Rice Soup" - }, - { - "selected": false, - "label": "Blue Label Turkey Noodle Soup", - "value": "Blue Label Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Vegetable Soup", - "value": "Blue Label Vegetable Soup" - }, - { - "selected": false, - "label": "Blue Medal Egg Substitute", - "value": "Blue Medal Egg Substitute" - }, - { - "selected": false, - "label": "Blue Medal Large Brown Eggs", - "value": "Blue Medal Large Brown Eggs" - }, - { - "selected": false, - "label": "Blue Medal Large Eggs", - "value": "Blue Medal Large Eggs" - }, - { - "selected": false, - "label": "Blue Medal Small Brown Eggs", - "value": "Blue Medal Small Brown Eggs" - }, - { - "selected": false, - "label": "Blue Medal Small Eggs", - "value": "Blue Medal Small Eggs" - }, - { - "selected": false, - "label": "Booker 1% Milk", - "value": "Booker 1% Milk" - }, - { - "selected": false, - "label": "Booker 2% Milk", - "value": "Booker 2% Milk" - }, - { - "selected": false, - "label": "Booker Blueberry Yogurt", - "value": "Booker Blueberry Yogurt" - }, - { - "selected": false, - "label": "Booker Buttermilk", - "value": "Booker Buttermilk" - }, - { - "selected": false, - "label": "Booker Cheese Spread", - "value": "Booker Cheese Spread" - }, - { - "selected": false, - "label": "Booker Chocolate Milk", - "value": "Booker Chocolate Milk" - }, - { - "selected": false, - "label": "Booker Havarti Cheese", - "value": "Booker Havarti Cheese" - }, - { - "selected": false, - "label": "Booker Head Cheese", - "value": "Booker Head Cheese" - }, - { - "selected": false, - "label": "Booker Jack Cheese", - "value": "Booker Jack Cheese" - }, - { - "selected": false, - "label": "Booker Large Curd Cottage Cheese", - "value": "Booker Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Booker Low Fat Cottage Cheese", - "value": "Booker Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Booker Low Fat Sour Cream", - "value": "Booker Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Booker Low Fat String Cheese", - "value": "Booker Low Fat String Cheese" - }, - { - "selected": false, - "label": "Booker Mild Cheddar Cheese", - "value": "Booker Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Booker Muenster Cheese", - "value": "Booker Muenster Cheese" - }, - { - "selected": false, - "label": "Booker Sharp Cheddar Cheese", - "value": "Booker Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Booker Sour Cream", - "value": "Booker Sour Cream" - }, - { - "selected": false, - "label": "Booker Strawberry Yogurt", - "value": "Booker Strawberry Yogurt" - }, - { - "selected": false, - "label": "Booker String Cheese", - "value": "Booker String Cheese" - }, - { - "selected": false, - "label": "Booker Whole Milk", - "value": "Booker Whole Milk" - }, - { - "selected": false, - "label": "Bravo Beef Soup", - "value": "Bravo Beef Soup" - }, - { - "selected": false, - "label": "Bravo Canned Beets", - "value": "Bravo Canned Beets" - }, - { - "selected": false, - "label": "Bravo Canned Peas", - "value": "Bravo Canned Peas" - }, - { - "selected": false, - "label": "Bravo Canned String Beans", - "value": "Bravo Canned String Beans" - }, - { - "selected": false, - "label": "Bravo Canned Tomatos", - "value": "Bravo Canned Tomatos" - }, - { - "selected": false, - "label": "Bravo Canned Tuna in Oil", - "value": "Bravo Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Bravo Canned Tuna in Water", - "value": "Bravo Canned Tuna in Water" - }, - { - "selected": false, - "label": "Bravo Canned Yams", - "value": "Bravo Canned Yams" - }, - { - "selected": false, - "label": "Bravo Chicken Noodle Soup", - "value": "Bravo Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Chicken Ramen Soup", - "value": "Bravo Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Bravo Chicken Soup", - "value": "Bravo Chicken Soup" - }, - { - "selected": false, - "label": "Bravo Creamed Corn", - "value": "Bravo Creamed Corn" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Anchovies", - "value": "Bravo Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Clams", - "value": "Bravo Fancy Canned Clams" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Oysters", - "value": "Bravo Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Sardines", - "value": "Bravo Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Bravo Large Canned Shrimp", - "value": "Bravo Large Canned Shrimp" - }, - { - "selected": false, - "label": "Bravo Noodle Soup", - "value": "Bravo Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Regular Ramen Soup", - "value": "Bravo Regular Ramen Soup" - }, - { - "selected": false, - "label": "Bravo Rice Soup", - "value": "Bravo Rice Soup" - }, - { - "selected": false, - "label": "Bravo Turkey Noodle Soup", - "value": "Bravo Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Vegetable Soup", - "value": "Bravo Vegetable Soup" - }, - { - "selected": false, - "label": "Carlson 1% Milk", - "value": "Carlson 1% Milk" - }, - { - "selected": false, - "label": "Carlson 2% Milk", - "value": "Carlson 2% Milk" - }, - { - "selected": false, - "label": "Carlson Blueberry Yogurt", - "value": "Carlson Blueberry Yogurt" - }, - { - "selected": false, - "label": "Carlson Buttermilk", - "value": "Carlson Buttermilk" - }, - { - "selected": false, - "label": "Carlson Cheese Spread", - "value": "Carlson Cheese Spread" - }, - { - "selected": false, - "label": "Carlson Chocolate Milk", - "value": "Carlson Chocolate Milk" - }, - { - "selected": false, - "label": "Carlson Havarti Cheese", - "value": "Carlson Havarti Cheese" - }, - { - "selected": false, - "label": "Carlson Head Cheese", - "value": "Carlson Head Cheese" - }, - { - "selected": false, - "label": "Carlson Jack Cheese", - "value": "Carlson Jack Cheese" - }, - { - "selected": false, - "label": "Carlson Large Curd Cottage Cheese", - "value": "Carlson Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Carlson Low Fat Cottage Cheese", - "value": "Carlson Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Carlson Low Fat Sour Cream", - "value": "Carlson Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Carlson Low Fat String Cheese", - "value": "Carlson Low Fat String Cheese" - }, - { - "selected": false, - "label": "Carlson Mild Cheddar Cheese", - "value": "Carlson Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Carlson Muenster Cheese", - "value": "Carlson Muenster Cheese" - }, - { - "selected": false, - "label": "Carlson Sharp Cheddar Cheese", - "value": "Carlson Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Carlson Sour Cream", - "value": "Carlson Sour Cream" - }, - { - "selected": false, - "label": "Carlson Strawberry Yogurt", - "value": "Carlson Strawberry Yogurt" - }, - { - "selected": false, - "label": "Carlson String Cheese", - "value": "Carlson String Cheese" - }, - { - "selected": false, - "label": "Carlson Whole Milk", - "value": "Carlson Whole Milk" - }, - { - "selected": false, - "label": "Carrington Apple Cinnamon Waffles", - "value": "Carrington Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Carrington Beef TV Dinner", - "value": "Carrington Beef TV Dinner" - }, - { - "selected": false, - "label": "Carrington Blueberry Waffles", - "value": "Carrington Blueberry Waffles" - }, - { - "selected": false, - "label": "Carrington Chicken TV Dinner", - "value": "Carrington Chicken TV Dinner" - }, - { - "selected": false, - "label": "Carrington Fajita French Fries", - "value": "Carrington Fajita French Fries" - }, - { - "selected": false, - "label": "Carrington Frozen Broccoli", - "value": "Carrington Frozen Broccoli" - }, - { - "selected": false, - "label": "Carrington Frozen Carrots", - "value": "Carrington Frozen Carrots" - }, - { - "selected": false, - "label": "Carrington Frozen Cauliflower", - "value": "Carrington Frozen Cauliflower" - }, - { - "selected": false, - "label": "Carrington Frozen Cheese Pizza", - "value": "Carrington Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Breast", - "value": "Carrington Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Thighs", - "value": "Carrington Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Wings", - "value": "Carrington Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Carrington Frozen Corn", - "value": "Carrington Frozen Corn" - }, - { - "selected": false, - "label": "Carrington Frozen Mushroom Pizza", - "value": "Carrington Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Pancakes", - "value": "Carrington Frozen Pancakes" - }, - { - "selected": false, - "label": "Carrington Frozen Peas", - "value": "Carrington Frozen Peas" - }, - { - "selected": false, - "label": "Carrington Frozen Pepperoni Pizza", - "value": "Carrington Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Sausage Pizza", - "value": "Carrington Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Carrington Grape Popsicles", - "value": "Carrington Grape Popsicles" - }, - { - "selected": false, - "label": "Carrington Home Style French Fries", - "value": "Carrington Home Style French Fries" - }, - { - "selected": false, - "label": "Carrington Ice Cream", - "value": "Carrington Ice Cream" - }, - { - "selected": false, - "label": "Carrington Ice Cream Sandwich", - "value": "Carrington Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Carrington Lemon Popsicles", - "value": "Carrington Lemon Popsicles" - }, - { - "selected": false, - "label": "Carrington Lime Popsicles", - "value": "Carrington Lime Popsicles" - }, - { - "selected": false, - "label": "Carrington Low Fat French Fries", - "value": "Carrington Low Fat French Fries" - }, - { - "selected": false, - "label": "Carrington Low Fat Waffles", - "value": "Carrington Low Fat Waffles" - }, - { - "selected": false, - "label": "Carrington Orange Popsicles", - "value": "Carrington Orange Popsicles" - }, - { - "selected": false, - "label": "Carrington Pancake Mix", - "value": "Carrington Pancake Mix" - }, - { - "selected": false, - "label": "Carrington Popsicles", - "value": "Carrington Popsicles" - }, - { - "selected": false, - "label": "Carrington Turkey TV Dinner", - "value": "Carrington Turkey TV Dinner" - }, - { - "selected": false, - "label": "Carrington Waffles", - "value": "Carrington Waffles" - }, - { - "selected": false, - "label": "CDR Apple Butter", - "value": "CDR Apple Butter" - }, - { - "selected": false, - "label": "CDR Apple Jam", - "value": "CDR Apple Jam" - }, - { - "selected": false, - "label": "CDR Apple Jelly", - "value": "CDR Apple Jelly" - }, - { - "selected": false, - "label": "CDR Apple Preserves", - "value": "CDR Apple Preserves" - }, - { - "selected": false, - "label": "CDR Brown Sugar", - "value": "CDR Brown Sugar" - }, - { - "selected": false, - "label": "CDR Canola Oil", - "value": "CDR Canola Oil" - }, - { - "selected": false, - "label": "CDR Chunky Peanut Butter", - "value": "CDR Chunky Peanut Butter" - }, - { - "selected": false, - "label": "CDR Columbian Coffee", - "value": "CDR Columbian Coffee" - }, - { - "selected": false, - "label": "CDR Corn Oil", - "value": "CDR Corn Oil" - }, - { - "selected": false, - "label": "CDR Creamy Peanut Butter", - "value": "CDR Creamy Peanut Butter" - }, - { - "selected": false, - "label": "CDR Decaf Coffee", - "value": "CDR Decaf Coffee" - }, - { - "selected": false, - "label": "CDR Extra Chunky Peanut Butter", - "value": "CDR Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "CDR French Roast Coffee", - "value": "CDR French Roast Coffee" - }, - { - "selected": false, - "label": "CDR Grape Jam", - "value": "CDR Grape Jam" - }, - { - "selected": false, - "label": "CDR Grape Jelly", - "value": "CDR Grape Jelly" - }, - { - "selected": false, - "label": "CDR Grape Preserves", - "value": "CDR Grape Preserves" - }, - { - "selected": false, - "label": "CDR Hot Chocolate", - "value": "CDR Hot Chocolate" - }, - { - "selected": false, - "label": "CDR Low Fat Apple Butter", - "value": "CDR Low Fat Apple Butter" - }, - { - "selected": false, - "label": "CDR Oregano", - "value": "CDR Oregano" - }, - { - "selected": false, - "label": "CDR Pepper", - "value": "CDR Pepper" - }, - { - "selected": false, - "label": "CDR Regular Coffee", - "value": "CDR Regular Coffee" - }, - { - "selected": false, - "label": "CDR Salt", - "value": "CDR Salt" - }, - { - "selected": false, - "label": "CDR Sesame Oil", - "value": "CDR Sesame Oil" - }, - { - "selected": false, - "label": "CDR Strawberry Jam", - "value": "CDR Strawberry Jam" - }, - { - "selected": false, - "label": "CDR Strawberry Jelly", - "value": "CDR Strawberry Jelly" - }, - { - "selected": false, - "label": "CDR Strawberry Preserves", - "value": "CDR Strawberry Preserves" - }, - { - "selected": false, - "label": "CDR Tomato Sauce", - "value": "CDR Tomato Sauce" - }, - { - "selected": false, - "label": "CDR Vegetable Oil", - "value": "CDR Vegetable Oil" - }, - { - "selected": false, - "label": "CDR White Sugar", - "value": "CDR White Sugar" - }, - { - "selected": false, - "label": "Choice Bubble Gum", - "value": "Choice Bubble Gum" - }, - { - "selected": false, - "label": "Choice Malted Milk Balls", - "value": "Choice Malted Milk Balls" - }, - { - "selected": false, - "label": "Choice Mint Chocolate Bar", - "value": "Choice Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Choice Mints", - "value": "Choice Mints" - }, - { - "selected": false, - "label": "Choice Semi-Sweet Chocolate Bar", - "value": "Choice Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Choice Spicy Mints", - "value": "Choice Spicy Mints" - }, - { - "selected": false, - "label": "Choice Tasty Candy Bar", - "value": "Choice Tasty Candy Bar" - }, - { - "selected": false, - "label": "Choice White Chocolate Bar", - "value": "Choice White Chocolate Bar" - }, - { - "selected": false, - "label": "Club 1% Milk", - "value": "Club 1% Milk" - }, - { - "selected": false, - "label": "Club 2% Milk", - "value": "Club 2% Milk" - }, - { - "selected": false, - "label": "Club Blueberry Yogurt", - "value": "Club Blueberry Yogurt" - }, - { - "selected": false, - "label": "Club Buttermilk", - "value": "Club Buttermilk" - }, - { - "selected": false, - "label": "Club Cheese Spread", - "value": "Club Cheese Spread" - }, - { - "selected": false, - "label": "Club Chocolate Milk", - "value": "Club Chocolate Milk" - }, - { - "selected": false, - "label": "Club Havarti Cheese", - "value": "Club Havarti Cheese" - }, - { - "selected": false, - "label": "Club Head Cheese", - "value": "Club Head Cheese" - }, - { - "selected": false, - "label": "Club Jack Cheese", - "value": "Club Jack Cheese" - }, - { - "selected": false, - "label": "Club Large Curd Cottage Cheese", - "value": "Club Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Club Low Fat Cottage Cheese", - "value": "Club Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Club Low Fat Sour Cream", - "value": "Club Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Club Low Fat String Cheese", - "value": "Club Low Fat String Cheese" - }, - { - "selected": false, - "label": "Club Mild Cheddar Cheese", - "value": "Club Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Club Muenster Cheese", - "value": "Club Muenster Cheese" - }, - { - "selected": false, - "label": "Club Sharp Cheddar Cheese", - "value": "Club Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Club Sour Cream", - "value": "Club Sour Cream" - }, - { - "selected": false, - "label": "Club Strawberry Yogurt", - "value": "Club Strawberry Yogurt" - }, - { - "selected": false, - "label": "Club String Cheese", - "value": "Club String Cheese" - }, - { - "selected": false, - "label": "Club Whole Milk", - "value": "Club Whole Milk" - }, - { - "selected": false, - "label": "Colony Bagels", - "value": "Colony Bagels" - }, - { - "selected": false, - "label": "Colony Blueberry Muffins", - "value": "Colony Blueberry Muffins" - }, - { - "selected": false, - "label": "Colony Cranberry Muffins", - "value": "Colony Cranberry Muffins" - }, - { - "selected": false, - "label": "Colony English Muffins", - "value": "Colony English Muffins" - }, - { - "selected": false, - "label": "Colony Muffins", - "value": "Colony Muffins" - }, - { - "selected": false, - "label": "Colony Pumpernickel Bread", - "value": "Colony Pumpernickel Bread" - }, - { - "selected": false, - "label": "Colony Rye Bread", - "value": "Colony Rye Bread" - }, - { - "selected": false, - "label": "Colony Wheat Bread", - "value": "Colony Wheat Bread" - }, - { - "selected": false, - "label": "Colony White Bread", - "value": "Colony White Bread" - }, - { - "selected": false, - "label": "Colossal Manicotti", - "value": "Colossal Manicotti" - }, - { - "selected": false, - "label": "Colossal Ravioli", - "value": "Colossal Ravioli" - }, - { - "selected": false, - "label": "Colossal Rice Medly", - "value": "Colossal Rice Medly" - }, - { - "selected": false, - "label": "Colossal Spaghetti", - "value": "Colossal Spaghetti" - }, - { - "selected": false, - "label": "Colossal Thai Rice", - "value": "Colossal Thai Rice" - }, - { - "selected": false, - "label": "Consolidated 200 MG Acetominifen", - "value": "Consolidated 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Consolidated 200 MG Ibuprofen", - "value": "Consolidated 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Consolidated Angled Toothbrush", - "value": "Consolidated Angled Toothbrush" - }, - { - "selected": false, - "label": "Consolidated Apricot Shampoo", - "value": "Consolidated Apricot Shampoo" - }, - { - "selected": false, - "label": "Consolidated Buffered Aspirin", - "value": "Consolidated Buffered Aspirin" - }, - { - "selected": false, - "label": "Consolidated Childrens Aspirin", - "value": "Consolidated Childrens Aspirin" - }, - { - "selected": false, - "label": "Consolidated Childrens Cold Remedy", - "value": "Consolidated Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Consolidated Conditioning Shampoo", - "value": "Consolidated Conditioning Shampoo" - }, - { - "selected": false, - "label": "Consolidated Deodorant", - "value": "Consolidated Deodorant" - }, - { - "selected": false, - "label": "Consolidated Dishwasher Detergent", - "value": "Consolidated Dishwasher Detergent" - }, - { - "selected": false, - "label": "Consolidated Extra Moisture Shampoo", - "value": "Consolidated Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Consolidated HCL Nasal Spray", - "value": "Consolidated HCL Nasal Spray" - }, - { - "selected": false, - "label": "Consolidated Laundry Detergent", - "value": "Consolidated Laundry Detergent" - }, - { - "selected": false, - "label": "Consolidated Mint Mouthwash", - "value": "Consolidated Mint Mouthwash" - }, - { - "selected": false, - "label": "Consolidated Multi-Symptom Cold Remedy", - "value": "Consolidated Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Consolidated Silky Smooth Hair Conditioner", - "value": "Consolidated Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Consolidated Tartar Control Toothpaste", - "value": "Consolidated Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Consolidated Toothpaste", - "value": "Consolidated Toothpaste" - }, - { - "selected": false, - "label": "Consolidated Whitening Toothpast", - "value": "Consolidated Whitening Toothpast" - }, - { - "selected": false, - "label": "Cormorant 100 Watt Lightbulb", - "value": "Cormorant 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 25 Watt Lightbulb", - "value": "Cormorant 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 60 Watt Lightbulb", - "value": "Cormorant 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 75 Watt Lightbulb", - "value": "Cormorant 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant AAA-Size Batteries", - "value": "Cormorant AAA-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant AA-Size Batteries", - "value": "Cormorant AA-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant Bees Wax Candles", - "value": "Cormorant Bees Wax Candles" - }, - { - "selected": false, - "label": "Cormorant Copper Cleaner", - "value": "Cormorant Copper Cleaner" - }, - { - "selected": false, - "label": "Cormorant Copper Pot Scrubber", - "value": "Cormorant Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Cormorant Counter Cleaner", - "value": "Cormorant Counter Cleaner" - }, - { - "selected": false, - "label": "Cormorant C-Size Batteries", - "value": "Cormorant C-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant D-Size Batteries", - "value": "Cormorant D-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant Economy Toilet Brush", - "value": "Cormorant Economy Toilet Brush" - }, - { - "selected": false, - "label": "Cormorant Frying Pan", - "value": "Cormorant Frying Pan" - }, - { - "selected": false, - "label": "Cormorant Glass Cleaner", - "value": "Cormorant Glass Cleaner" - }, - { - "selected": false, - "label": "Cormorant Large Sponge", - "value": "Cormorant Large Sponge" - }, - { - "selected": false, - "label": "Cormorant Paper Cups", - "value": "Cormorant Paper Cups" - }, - { - "selected": false, - "label": "Cormorant Paper Plates", - "value": "Cormorant Paper Plates" - }, - { - "selected": false, - "label": "Cormorant Paper Towels", - "value": "Cormorant Paper Towels" - }, - { - "selected": false, - "label": "Cormorant Plastic Forks", - "value": "Cormorant Plastic Forks" - }, - { - "selected": false, - "label": "Cormorant Plastic Knives", - "value": "Cormorant Plastic Knives" - }, - { - "selected": false, - "label": "Cormorant Plastic Spoons", - "value": "Cormorant Plastic Spoons" - }, - { - "selected": false, - "label": "Cormorant Room Freshener", - "value": "Cormorant Room Freshener" - }, - { - "selected": false, - "label": "Cormorant Scented Tissue", - "value": "Cormorant Scented Tissue" - }, - { - "selected": false, - "label": "Cormorant Scented Toilet Tissue", - "value": "Cormorant Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Cormorant Scissors", - "value": "Cormorant Scissors" - }, - { - "selected": false, - "label": "Cormorant Screw Driver", - "value": "Cormorant Screw Driver" - }, - { - "selected": false, - "label": "Cormorant Silver Cleaner", - "value": "Cormorant Silver Cleaner" - }, - { - "selected": false, - "label": "Cormorant Soft Napkins", - "value": "Cormorant Soft Napkins" - }, - { - "selected": false, - "label": "Cormorant Tissues", - "value": "Cormorant Tissues" - }, - { - "selected": false, - "label": "Cormorant Toilet Bowl Cleaner", - "value": "Cormorant Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Cormorant Toilet Paper", - "value": "Cormorant Toilet Paper" - }, - { - "selected": false, - "label": "Curlew Lox", - "value": "Curlew Lox" - }, - { - "selected": false, - "label": "Curlew Scallops", - "value": "Curlew Scallops" - }, - { - "selected": false, - "label": "Cutting Edge Beef Bologna", - "value": "Cutting Edge Beef Bologna" - }, - { - "selected": false, - "label": "Cutting Edge Chicken Hot Dogs", - "value": "Cutting Edge Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Cutting Edge Cole Slaw", - "value": "Cutting Edge Cole Slaw" - }, - { - "selected": false, - "label": "Cutting Edge Corned Beef", - "value": "Cutting Edge Corned Beef" - }, - { - "selected": false, - "label": "Cutting Edge Foot-Long Hot Dogs", - "value": "Cutting Edge Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Cutting Edge Low Fat Bologna", - "value": "Cutting Edge Low Fat Bologna" - }, - { - "selected": false, - "label": "Cutting Edge Low Fat Cole Slaw", - "value": "Cutting Edge Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Cutting Edge Pimento Loaf", - "value": "Cutting Edge Pimento Loaf" - }, - { - "selected": false, - "label": "Cutting Edge Potato Salad", - "value": "Cutting Edge Potato Salad" - }, - { - "selected": false, - "label": "Cutting Edge Roasted Chicken", - "value": "Cutting Edge Roasted Chicken" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Chicken", - "value": "Cutting Edge Sliced Chicken" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Ham", - "value": "Cutting Edge Sliced Ham" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Turkey", - "value": "Cutting Edge Sliced Turkey" - }, - { - "selected": false, - "label": "Cutting Edge Turkey Hot Dogs", - "value": "Cutting Edge Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Denny 100 Watt Lightbulb", - "value": "Denny 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 25 Watt Lightbulb", - "value": "Denny 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 60 Watt Lightbulb", - "value": "Denny 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 75 Watt Lightbulb", - "value": "Denny 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny AAA-Size Batteries", - "value": "Denny AAA-Size Batteries" - }, - { - "selected": false, - "label": "Denny AA-Size Batteries", - "value": "Denny AA-Size Batteries" - }, - { - "selected": false, - "label": "Denny Bees Wax Candles", - "value": "Denny Bees Wax Candles" - }, - { - "selected": false, - "label": "Denny Copper Cleaner", - "value": "Denny Copper Cleaner" - }, - { - "selected": false, - "label": "Denny Copper Pot Scrubber", - "value": "Denny Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Denny Counter Cleaner", - "value": "Denny Counter Cleaner" - }, - { - "selected": false, - "label": "Denny C-Size Batteries", - "value": "Denny C-Size Batteries" - }, - { - "selected": false, - "label": "Denny D-Size Batteries", - "value": "Denny D-Size Batteries" - }, - { - "selected": false, - "label": "Denny Economy Toilet Brush", - "value": "Denny Economy Toilet Brush" - }, - { - "selected": false, - "label": "Denny Frying Pan", - "value": "Denny Frying Pan" - }, - { - "selected": false, - "label": "Denny Glass Cleaner", - "value": "Denny Glass Cleaner" - }, - { - "selected": false, - "label": "Denny Large Sponge", - "value": "Denny Large Sponge" - }, - { - "selected": false, - "label": "Denny Paper Cups", - "value": "Denny Paper Cups" - }, - { - "selected": false, - "label": "Denny Paper Plates", - "value": "Denny Paper Plates" - }, - { - "selected": false, - "label": "Denny Paper Towels", - "value": "Denny Paper Towels" - }, - { - "selected": false, - "label": "Denny Plastic Forks", - "value": "Denny Plastic Forks" - }, - { - "selected": false, - "label": "Denny Plastic Knives", - "value": "Denny Plastic Knives" - }, - { - "selected": false, - "label": "Denny Plastic Spoons", - "value": "Denny Plastic Spoons" - }, - { - "selected": false, - "label": "Denny Room Freshener", - "value": "Denny Room Freshener" - }, - { - "selected": false, - "label": "Denny Scented Tissue", - "value": "Denny Scented Tissue" - }, - { - "selected": false, - "label": "Denny Scented Toilet Tissue", - "value": "Denny Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Denny Scissors", - "value": "Denny Scissors" - }, - { - "selected": false, - "label": "Denny Screw Driver", - "value": "Denny Screw Driver" - }, - { - "selected": false, - "label": "Denny Silver Cleaner", - "value": "Denny Silver Cleaner" - }, - { - "selected": false, - "label": "Denny Soft Napkins", - "value": "Denny Soft Napkins" - }, - { - "selected": false, - "label": "Denny Tissues", - "value": "Denny Tissues" - }, - { - "selected": false, - "label": "Denny Toilet Bowl Cleaner", - "value": "Denny Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Denny Toilet Paper", - "value": "Denny Toilet Paper" - }, - { - "selected": false, - "label": "Discover Manicotti", - "value": "Discover Manicotti" - }, - { - "selected": false, - "label": "Discover Ravioli", - "value": "Discover Ravioli" - }, - { - "selected": false, - "label": "Discover Rice Medly", - "value": "Discover Rice Medly" - }, - { - "selected": false, - "label": "Discover Spaghetti", - "value": "Discover Spaghetti" - }, - { - "selected": false, - "label": "Discover Thai Rice", - "value": "Discover Thai Rice" - }, - { - "selected": false, - "label": "Dollar Monthly Auto Magazine", - "value": "Dollar Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Computer Magazine", - "value": "Dollar Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Fashion Magazine", - "value": "Dollar Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Home Magazine", - "value": "Dollar Monthly Home Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Sports Magazine", - "value": "Dollar Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Dual City Lox", - "value": "Dual City Lox" - }, - { - "selected": false, - "label": "Dual City Scallops", - "value": "Dual City Scallops" - }, - { - "selected": false, - "label": "Ebony Almonds", - "value": "Ebony Almonds" - }, - { - "selected": false, - "label": "Ebony Asparagus", - "value": "Ebony Asparagus" - }, - { - "selected": false, - "label": "Ebony Baby Onion", - "value": "Ebony Baby Onion" - }, - { - "selected": false, - "label": "Ebony Beets", - "value": "Ebony Beets" - }, - { - "selected": false, - "label": "Ebony Broccoli", - "value": "Ebony Broccoli" - }, - { - "selected": false, - "label": "Ebony Canned Peanuts", - "value": "Ebony Canned Peanuts" - }, - { - "selected": false, - "label": "Ebony Cantelope", - "value": "Ebony Cantelope" - }, - { - "selected": false, - "label": "Ebony Cauliflower", - "value": "Ebony Cauliflower" - }, - { - "selected": false, - "label": "Ebony Corn on the Cob", - "value": "Ebony Corn on the Cob" - }, - { - "selected": false, - "label": "Ebony Dried Mushrooms", - "value": "Ebony Dried Mushrooms" - }, - { - "selected": false, - "label": "Ebony Elephant Garlic", - "value": "Ebony Elephant Garlic" - }, - { - "selected": false, - "label": "Ebony Fancy Plums", - "value": "Ebony Fancy Plums" - }, - { - "selected": false, - "label": "Ebony Firm Tofu", - "value": "Ebony Firm Tofu" - }, - { - "selected": false, - "label": "Ebony Fresh Lima Beans", - "value": "Ebony Fresh Lima Beans" - }, - { - "selected": false, - "label": "Ebony Fuji Apples", - "value": "Ebony Fuji Apples" - }, - { - "selected": false, - "label": "Ebony Garlic", - "value": "Ebony Garlic" - }, - { - "selected": false, - "label": "Ebony Golden Delcious Apples", - "value": "Ebony Golden Delcious Apples" - }, - { - "selected": false, - "label": "Ebony Green Pepper", - "value": "Ebony Green Pepper" - }, - { - "selected": false, - "label": "Ebony Honey Dew", - "value": "Ebony Honey Dew" - }, - { - "selected": false, - "label": "Ebony Lemons", - "value": "Ebony Lemons" - }, - { - "selected": false, - "label": "Ebony Lettuce", - "value": "Ebony Lettuce" - }, - { - "selected": false, - "label": "Ebony Limes", - "value": "Ebony Limes" - }, - { - "selected": false, - "label": "Ebony Macintosh Apples", - "value": "Ebony Macintosh Apples" - }, - { - "selected": false, - "label": "Ebony Mandarin Oranges", - "value": "Ebony Mandarin Oranges" - }, - { - "selected": false, - "label": "Ebony Mixed Nuts", - "value": "Ebony Mixed Nuts" - }, - { - "selected": false, - "label": "Ebony Mushrooms", - "value": "Ebony Mushrooms" - }, - { - "selected": false, - "label": "Ebony New Potatos", - "value": "Ebony New Potatos" - }, - { - "selected": false, - "label": "Ebony Onions", - "value": "Ebony Onions" - }, - { - "selected": false, - "label": "Ebony Oranges", - "value": "Ebony Oranges" - }, - { - "selected": false, - "label": "Ebony Party Nuts", - "value": "Ebony Party Nuts" - }, - { - "selected": false, - "label": "Ebony Peaches", - "value": "Ebony Peaches" - }, - { - "selected": false, - "label": "Ebony Plums", - "value": "Ebony Plums" - }, - { - "selected": false, - "label": "Ebony Potatos", - "value": "Ebony Potatos" - }, - { - "selected": false, - "label": "Ebony Prepared Salad", - "value": "Ebony Prepared Salad" - }, - { - "selected": false, - "label": "Ebony Red Delcious Apples", - "value": "Ebony Red Delcious Apples" - }, - { - "selected": false, - "label": "Ebony Red Pepper", - "value": "Ebony Red Pepper" - }, - { - "selected": false, - "label": "Ebony Shitake Mushrooms", - "value": "Ebony Shitake Mushrooms" - }, - { - "selected": false, - "label": "Ebony Squash", - "value": "Ebony Squash" - }, - { - "selected": false, - "label": "Ebony Summer Squash", - "value": "Ebony Summer Squash" - }, - { - "selected": false, - "label": "Ebony Sweet Onion", - "value": "Ebony Sweet Onion" - }, - { - "selected": false, - "label": "Ebony Sweet Peas", - "value": "Ebony Sweet Peas" - }, - { - "selected": false, - "label": "Ebony Tangerines", - "value": "Ebony Tangerines" - }, - { - "selected": false, - "label": "Ebony Tomatos", - "value": "Ebony Tomatos" - }, - { - "selected": false, - "label": "Ebony Walnuts", - "value": "Ebony Walnuts" - }, - { - "selected": false, - "label": "Even Better 1% Milk", - "value": "Even Better 1% Milk" - }, - { - "selected": false, - "label": "Even Better 2% Milk", - "value": "Even Better 2% Milk" - }, - { - "selected": false, - "label": "Even Better Blueberry Yogurt", - "value": "Even Better Blueberry Yogurt" - }, - { - "selected": false, - "label": "Even Better Buttermilk", - "value": "Even Better Buttermilk" - }, - { - "selected": false, - "label": "Even Better Cheese Spread", - "value": "Even Better Cheese Spread" - }, - { - "selected": false, - "label": "Even Better Chocolate Milk", - "value": "Even Better Chocolate Milk" - }, - { - "selected": false, - "label": "Even Better Havarti Cheese", - "value": "Even Better Havarti Cheese" - }, - { - "selected": false, - "label": "Even Better Head Cheese", - "value": "Even Better Head Cheese" - }, - { - "selected": false, - "label": "Even Better Jack Cheese", - "value": "Even Better Jack Cheese" - }, - { - "selected": false, - "label": "Even Better Large Curd Cottage Cheese", - "value": "Even Better Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Even Better Low Fat Cottage Cheese", - "value": "Even Better Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Even Better Low Fat Sour Cream", - "value": "Even Better Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Even Better Low Fat String Cheese", - "value": "Even Better Low Fat String Cheese" - }, - { - "selected": false, - "label": "Even Better Mild Cheddar Cheese", - "value": "Even Better Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Even Better Muenster Cheese", - "value": "Even Better Muenster Cheese" - }, - { - "selected": false, - "label": "Even Better Sharp Cheddar Cheese", - "value": "Even Better Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Even Better Sour Cream", - "value": "Even Better Sour Cream" - }, - { - "selected": false, - "label": "Even Better Strawberry Yogurt", - "value": "Even Better Strawberry Yogurt" - }, - { - "selected": false, - "label": "Even Better String Cheese", - "value": "Even Better String Cheese" - }, - { - "selected": false, - "label": "Even Better Whole Milk", - "value": "Even Better Whole Milk" - }, - { - "selected": false, - "label": "Excellent Apple Drink", - "value": "Excellent Apple Drink" - }, - { - "selected": false, - "label": "Excellent Apple Juice", - "value": "Excellent Apple Juice" - }, - { - "selected": false, - "label": "Excellent Berry Juice", - "value": "Excellent Berry Juice" - }, - { - "selected": false, - "label": "Excellent Cola", - "value": "Excellent Cola" - }, - { - "selected": false, - "label": "Excellent Cranberry Juice", - "value": "Excellent Cranberry Juice" - }, - { - "selected": false, - "label": "Excellent Cream Soda", - "value": "Excellent Cream Soda" - }, - { - "selected": false, - "label": "Excellent Diet Cola", - "value": "Excellent Diet Cola" - }, - { - "selected": false, - "label": "Excellent Diet Soda", - "value": "Excellent Diet Soda" - }, - { - "selected": false, - "label": "Excellent Mango Drink", - "value": "Excellent Mango Drink" - }, - { - "selected": false, - "label": "Excellent Orange Juice", - "value": "Excellent Orange Juice" - }, - { - "selected": false, - "label": "Excellent Strawberry Drink", - "value": "Excellent Strawberry Drink" - }, - { - "selected": false, - "label": "Excel Monthly Auto Magazine", - "value": "Excel Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Computer Magazine", - "value": "Excel Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Fashion Magazine", - "value": "Excel Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Home Magazine", - "value": "Excel Monthly Home Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Sports Magazine", - "value": "Excel Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Fabulous Apple Drink", - "value": "Fabulous Apple Drink" - }, - { - "selected": false, - "label": "Fabulous Apple Juice", - "value": "Fabulous Apple Juice" - }, - { - "selected": false, - "label": "Fabulous Berry Juice", - "value": "Fabulous Berry Juice" - }, - { - "selected": false, - "label": "Fabulous Cola", - "value": "Fabulous Cola" - }, - { - "selected": false, - "label": "Fabulous Cranberry Juice", - "value": "Fabulous Cranberry Juice" - }, - { - "selected": false, - "label": "Fabulous Cream Soda", - "value": "Fabulous Cream Soda" - }, - { - "selected": false, - "label": "Fabulous Diet Cola", - "value": "Fabulous Diet Cola" - }, - { - "selected": false, - "label": "Fabulous Diet Soda", - "value": "Fabulous Diet Soda" - }, - { - "selected": false, - "label": "Fabulous Mango Drink", - "value": "Fabulous Mango Drink" - }, - { - "selected": false, - "label": "Fabulous Orange Juice", - "value": "Fabulous Orange Juice" - }, - { - "selected": false, - "label": "Fabulous Strawberry Drink", - "value": "Fabulous Strawberry Drink" - }, - { - "selected": false, - "label": "Fantastic Bagels", - "value": "Fantastic Bagels" - }, - { - "selected": false, - "label": "Fantastic Blueberry Muffins", - "value": "Fantastic Blueberry Muffins" - }, - { - "selected": false, - "label": "Fantastic Cranberry Muffins", - "value": "Fantastic Cranberry Muffins" - }, - { - "selected": false, - "label": "Fantastic English Muffins", - "value": "Fantastic English Muffins" - }, - { - "selected": false, - "label": "Fantastic Muffins", - "value": "Fantastic Muffins" - }, - { - "selected": false, - "label": "Fantastic Pumpernickel Bread", - "value": "Fantastic Pumpernickel Bread" - }, - { - "selected": false, - "label": "Fantastic Rye Bread", - "value": "Fantastic Rye Bread" - }, - { - "selected": false, - "label": "Fantastic Wheat Bread", - "value": "Fantastic Wheat Bread" - }, - { - "selected": false, - "label": "Fantastic White Bread", - "value": "Fantastic White Bread" - }, - { - "selected": false, - "label": "Fast Apple Fruit Roll", - "value": "Fast Apple Fruit Roll" - }, - { - "selected": false, - "label": "Fast Avocado Dip", - "value": "Fast Avocado Dip" - }, - { - "selected": false, - "label": "Fast BBQ Potato Chips", - "value": "Fast BBQ Potato Chips" - }, - { - "selected": false, - "label": "Fast Beef Jerky", - "value": "Fast Beef Jerky" - }, - { - "selected": false, - "label": "Fast Buttered Popcorn", - "value": "Fast Buttered Popcorn" - }, - { - "selected": false, - "label": "Fast Cheese Crackers", - "value": "Fast Cheese Crackers" - }, - { - "selected": false, - "label": "Fast Cheese Dip", - "value": "Fast Cheese Dip" - }, - { - "selected": false, - "label": "Fast Chocolate Chip Cookies", - "value": "Fast Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Fast Chocolate Donuts", - "value": "Fast Chocolate Donuts" - }, - { - "selected": false, - "label": "Fast Corn Chips", - "value": "Fast Corn Chips" - }, - { - "selected": false, - "label": "Fast Dried Apples", - "value": "Fast Dried Apples" - }, - { - "selected": false, - "label": "Fast Dried Apricots", - "value": "Fast Dried Apricots" - }, - { - "selected": false, - "label": "Fast Dried Dates", - "value": "Fast Dried Dates" - }, - { - "selected": false, - "label": "Fast Fondue Mix", - "value": "Fast Fondue Mix" - }, - { - "selected": false, - "label": "Fast Frosted Cookies", - "value": "Fast Frosted Cookies" - }, - { - "selected": false, - "label": "Fast Frosted Donuts", - "value": "Fast Frosted Donuts" - }, - { - "selected": false, - "label": "Fast Fudge Brownies", - "value": "Fast Fudge Brownies" - }, - { - "selected": false, - "label": "Fast Fudge Cookies", - "value": "Fast Fudge Cookies" - }, - { - "selected": false, - "label": "Fast Golden Raisins", - "value": "Fast Golden Raisins" - }, - { - "selected": false, - "label": "Fast Graham Crackers", - "value": "Fast Graham Crackers" - }, - { - "selected": false, - "label": "Fast Grape Fruit Roll", - "value": "Fast Grape Fruit Roll" - }, - { - "selected": false, - "label": "Fast Lemon Cookies", - "value": "Fast Lemon Cookies" - }, - { - "selected": false, - "label": "Fast Low Fat BBQ Chips", - "value": "Fast Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Fast Low Fat Chips", - "value": "Fast Low Fat Chips" - }, - { - "selected": false, - "label": "Fast Low Fat Cookies", - "value": "Fast Low Fat Cookies" - }, - { - "selected": false, - "label": "Fast Low Fat Popcorn", - "value": "Fast Low Fat Popcorn" - }, - { - "selected": false, - "label": "Fast Mini Donuts", - "value": "Fast Mini Donuts" - }, - { - "selected": false, - "label": "Fast No Salt Popcorn", - "value": "Fast No Salt Popcorn" - }, - { - "selected": false, - "label": "Fast Potato Chips", - "value": "Fast Potato Chips" - }, - { - "selected": false, - "label": "Fast Raisins", - "value": "Fast Raisins" - }, - { - "selected": false, - "label": "Fast Raspberry Fruit Roll", - "value": "Fast Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Fast Salsa Dip", - "value": "Fast Salsa Dip" - }, - { - "selected": false, - "label": "Fast Salted Pretzels", - "value": "Fast Salted Pretzels" - }, - { - "selected": false, - "label": "Fast Sesame Crackers", - "value": "Fast Sesame Crackers" - }, - { - "selected": false, - "label": "Fast Strawberry Fruit Roll", - "value": "Fast Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Fast Sugar Cookies", - "value": "Fast Sugar Cookies" - }, - { - "selected": false, - "label": "Faux Products 200 MG Acetominifen", - "value": "Faux Products 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Faux Products 200 MG Ibuprofen", - "value": "Faux Products 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Faux Products Angled Toothbrush", - "value": "Faux Products Angled Toothbrush" - }, - { - "selected": false, - "label": "Faux Products Apricot Shampoo", - "value": "Faux Products Apricot Shampoo" - }, - { - "selected": false, - "label": "Faux Products Buffered Aspirin", - "value": "Faux Products Buffered Aspirin" - }, - { - "selected": false, - "label": "Faux Products Childrens Aspirin", - "value": "Faux Products Childrens Aspirin" - }, - { - "selected": false, - "label": "Faux Products Childrens Cold Remedy", - "value": "Faux Products Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Faux Products Conditioning Shampoo", - "value": "Faux Products Conditioning Shampoo" - }, - { - "selected": false, - "label": "Faux Products Deodorant", - "value": "Faux Products Deodorant" - }, - { - "selected": false, - "label": "Faux Products Dishwasher Detergent", - "value": "Faux Products Dishwasher Detergent" - }, - { - "selected": false, - "label": "Faux Products Extra Moisture Shampoo", - "value": "Faux Products Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Faux Products HCL Nasal Spray", - "value": "Faux Products HCL Nasal Spray" - }, - { - "selected": false, - "label": "Faux Products Laundry Detergent", - "value": "Faux Products Laundry Detergent" - }, - { - "selected": false, - "label": "Faux Products Mint Mouthwash", - "value": "Faux Products Mint Mouthwash" - }, - { - "selected": false, - "label": "Faux Products Multi-Symptom Cold Remedy", - "value": "Faux Products Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Faux Products Silky Smooth Hair Conditioner", - "value": "Faux Products Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Faux Products Tartar Control Toothpaste", - "value": "Faux Products Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Faux Products Toothpaste", - "value": "Faux Products Toothpaste" - }, - { - "selected": false, - "label": "Faux Products Whitening Toothpast", - "value": "Faux Products Whitening Toothpast" - }, - { - "selected": false, - "label": "Footnote Extra Lean Hamburger", - "value": "Footnote Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Footnote Seasoned Hamburger", - "value": "Footnote Seasoned Hamburger" - }, - { - "selected": false, - "label": "Fort West Apple Fruit Roll", - "value": "Fort West Apple Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Avocado Dip", - "value": "Fort West Avocado Dip" - }, - { - "selected": false, - "label": "Fort West BBQ Potato Chips", - "value": "Fort West BBQ Potato Chips" - }, - { - "selected": false, - "label": "Fort West Beef Jerky", - "value": "Fort West Beef Jerky" - }, - { - "selected": false, - "label": "Fort West Buttered Popcorn", - "value": "Fort West Buttered Popcorn" - }, - { - "selected": false, - "label": "Fort West Cheese Crackers", - "value": "Fort West Cheese Crackers" - }, - { - "selected": false, - "label": "Fort West Cheese Dip", - "value": "Fort West Cheese Dip" - }, - { - "selected": false, - "label": "Fort West Chocolate Chip Cookies", - "value": "Fort West Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Fort West Chocolate Donuts", - "value": "Fort West Chocolate Donuts" - }, - { - "selected": false, - "label": "Fort West Corn Chips", - "value": "Fort West Corn Chips" - }, - { - "selected": false, - "label": "Fort West Dried Apples", - "value": "Fort West Dried Apples" - }, - { - "selected": false, - "label": "Fort West Dried Apricots", - "value": "Fort West Dried Apricots" - }, - { - "selected": false, - "label": "Fort West Dried Dates", - "value": "Fort West Dried Dates" - }, - { - "selected": false, - "label": "Fort West Fondue Mix", - "value": "Fort West Fondue Mix" - }, - { - "selected": false, - "label": "Fort West Frosted Cookies", - "value": "Fort West Frosted Cookies" - }, - { - "selected": false, - "label": "Fort West Frosted Donuts", - "value": "Fort West Frosted Donuts" - }, - { - "selected": false, - "label": "Fort West Fudge Brownies", - "value": "Fort West Fudge Brownies" - }, - { - "selected": false, - "label": "Fort West Fudge Cookies", - "value": "Fort West Fudge Cookies" - }, - { - "selected": false, - "label": "Fort West Golden Raisins", - "value": "Fort West Golden Raisins" - }, - { - "selected": false, - "label": "Fort West Graham Crackers", - "value": "Fort West Graham Crackers" - }, - { - "selected": false, - "label": "Fort West Grape Fruit Roll", - "value": "Fort West Grape Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Lemon Cookies", - "value": "Fort West Lemon Cookies" - }, - { - "selected": false, - "label": "Fort West Low Fat BBQ Chips", - "value": "Fort West Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Fort West Low Fat Chips", - "value": "Fort West Low Fat Chips" - }, - { - "selected": false, - "label": "Fort West Low Fat Cookies", - "value": "Fort West Low Fat Cookies" - }, - { - "selected": false, - "label": "Fort West Low Fat Popcorn", - "value": "Fort West Low Fat Popcorn" - }, - { - "selected": false, - "label": "Fort West Mini Donuts", - "value": "Fort West Mini Donuts" - }, - { - "selected": false, - "label": "Fort West No Salt Popcorn", - "value": "Fort West No Salt Popcorn" - }, - { - "selected": false, - "label": "Fort West Potato Chips", - "value": "Fort West Potato Chips" - }, - { - "selected": false, - "label": "Fort West Raisins", - "value": "Fort West Raisins" - }, - { - "selected": false, - "label": "Fort West Raspberry Fruit Roll", - "value": "Fort West Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Salsa Dip", - "value": "Fort West Salsa Dip" - }, - { - "selected": false, - "label": "Fort West Salted Pretzels", - "value": "Fort West Salted Pretzels" - }, - { - "selected": false, - "label": "Fort West Sesame Crackers", - "value": "Fort West Sesame Crackers" - }, - { - "selected": false, - "label": "Fort West Strawberry Fruit Roll", - "value": "Fort West Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Sugar Cookies", - "value": "Fort West Sugar Cookies" - }, - { - "selected": false, - "label": "Framton City Map", - "value": "Framton City Map" - }, - { - "selected": false, - "label": "Framton Eyeglass Screwdriver", - "value": "Framton Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Gauss Monthly Auto Magazine", - "value": "Gauss Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Computer Magazine", - "value": "Gauss Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Fashion Magazine", - "value": "Gauss Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Home Magazine", - "value": "Gauss Monthly Home Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Sports Magazine", - "value": "Gauss Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Genteel Extra Lean Hamburger", - "value": "Genteel Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Genteel Seasoned Hamburger", - "value": "Genteel Seasoned Hamburger" - }, - { - "selected": false, - "label": "Gerolli Extra Lean Hamburger", - "value": "Gerolli Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Gerolli Seasoned Hamburger", - "value": "Gerolli Seasoned Hamburger" - }, - { - "selected": false, - "label": "Giant Egg Substitute", - "value": "Giant Egg Substitute" - }, - { - "selected": false, - "label": "Giant Large Brown Eggs", - "value": "Giant Large Brown Eggs" - }, - { - "selected": false, - "label": "Giant Large Eggs", - "value": "Giant Large Eggs" - }, - { - "selected": false, - "label": "Giant Small Brown Eggs", - "value": "Giant Small Brown Eggs" - }, - { - "selected": false, - "label": "Giant Small Eggs", - "value": "Giant Small Eggs" - }, - { - "selected": false, - "label": "Golden Apple Cinnamon Waffles", - "value": "Golden Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Golden Beef TV Dinner", - "value": "Golden Beef TV Dinner" - }, - { - "selected": false, - "label": "Golden Blueberry Waffles", - "value": "Golden Blueberry Waffles" - }, - { - "selected": false, - "label": "Golden Chicken TV Dinner", - "value": "Golden Chicken TV Dinner" - }, - { - "selected": false, - "label": "Golden Fajita French Fries", - "value": "Golden Fajita French Fries" - }, - { - "selected": false, - "label": "Golden Frozen Broccoli", - "value": "Golden Frozen Broccoli" - }, - { - "selected": false, - "label": "Golden Frozen Carrots", - "value": "Golden Frozen Carrots" - }, - { - "selected": false, - "label": "Golden Frozen Cauliflower", - "value": "Golden Frozen Cauliflower" - }, - { - "selected": false, - "label": "Golden Frozen Cheese Pizza", - "value": "Golden Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Breast", - "value": "Golden Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Thighs", - "value": "Golden Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Wings", - "value": "Golden Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Golden Frozen Corn", - "value": "Golden Frozen Corn" - }, - { - "selected": false, - "label": "Golden Frozen Mushroom Pizza", - "value": "Golden Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Pancakes", - "value": "Golden Frozen Pancakes" - }, - { - "selected": false, - "label": "Golden Frozen Peas", - "value": "Golden Frozen Peas" - }, - { - "selected": false, - "label": "Golden Frozen Pepperoni Pizza", - "value": "Golden Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Sausage Pizza", - "value": "Golden Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Golden Grape Popsicles", - "value": "Golden Grape Popsicles" - }, - { - "selected": false, - "label": "Golden Home Style French Fries", - "value": "Golden Home Style French Fries" - }, - { - "selected": false, - "label": "Golden Ice Cream", - "value": "Golden Ice Cream" - }, - { - "selected": false, - "label": "Golden Ice Cream Sandwich", - "value": "Golden Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Golden Lemon Popsicles", - "value": "Golden Lemon Popsicles" - }, - { - "selected": false, - "label": "Golden Lime Popsicles", - "value": "Golden Lime Popsicles" - }, - { - "selected": false, - "label": "Golden Low Fat French Fries", - "value": "Golden Low Fat French Fries" - }, - { - "selected": false, - "label": "Golden Low Fat Waffles", - "value": "Golden Low Fat Waffles" - }, - { - "selected": false, - "label": "Golden Orange Popsicles", - "value": "Golden Orange Popsicles" - }, - { - "selected": false, - "label": "Golden Pancake Mix", - "value": "Golden Pancake Mix" - }, - { - "selected": false, - "label": "Golden Popsicles", - "value": "Golden Popsicles" - }, - { - "selected": false, - "label": "Golden Turkey TV Dinner", - "value": "Golden Turkey TV Dinner" - }, - { - "selected": false, - "label": "Golden Waffles", - "value": "Golden Waffles" - }, - { - "selected": false, - "label": "Good Chablis Wine", - "value": "Good Chablis Wine" - }, - { - "selected": false, - "label": "Good Chardonnay", - "value": "Good Chardonnay" - }, - { - "selected": false, - "label": "Good Chardonnay Wine", - "value": "Good Chardonnay Wine" - }, - { - "selected": false, - "label": "Good Imported Beer", - "value": "Good Imported Beer" - }, - { - "selected": false, - "label": "Good Light Beer", - "value": "Good Light Beer" - }, - { - "selected": false, - "label": "Good Light Wine", - "value": "Good Light Wine" - }, - { - "selected": false, - "label": "Good Merlot Wine", - "value": "Good Merlot Wine" - }, - { - "selected": false, - "label": "Good White Zinfandel Wine", - "value": "Good White Zinfandel Wine" - }, - { - "selected": false, - "label": "Gorilla 1% Milk", - "value": "Gorilla 1% Milk" - }, - { - "selected": false, - "label": "Gorilla 2% Milk", - "value": "Gorilla 2% Milk" - }, - { - "selected": false, - "label": "Gorilla Blueberry Yogurt", - "value": "Gorilla Blueberry Yogurt" - }, - { - "selected": false, - "label": "Gorilla Buttermilk", - "value": "Gorilla Buttermilk" - }, - { - "selected": false, - "label": "Gorilla Cheese Spread", - "value": "Gorilla Cheese Spread" - }, - { - "selected": false, - "label": "Gorilla Chocolate Milk", - "value": "Gorilla Chocolate Milk" - }, - { - "selected": false, - "label": "Gorilla Havarti Cheese", - "value": "Gorilla Havarti Cheese" - }, - { - "selected": false, - "label": "Gorilla Head Cheese", - "value": "Gorilla Head Cheese" - }, - { - "selected": false, - "label": "Gorilla Jack Cheese", - "value": "Gorilla Jack Cheese" - }, - { - "selected": false, - "label": "Gorilla Large Curd Cottage Cheese", - "value": "Gorilla Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Gorilla Low Fat Cottage Cheese", - "value": "Gorilla Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Gorilla Low Fat Sour Cream", - "value": "Gorilla Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Gorilla Low Fat String Cheese", - "value": "Gorilla Low Fat String Cheese" - }, - { - "selected": false, - "label": "Gorilla Mild Cheddar Cheese", - "value": "Gorilla Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Gorilla Muenster Cheese", - "value": "Gorilla Muenster Cheese" - }, - { - "selected": false, - "label": "Gorilla Sharp Cheddar Cheese", - "value": "Gorilla Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Gorilla Sour Cream", - "value": "Gorilla Sour Cream" - }, - { - "selected": false, - "label": "Gorilla Strawberry Yogurt", - "value": "Gorilla Strawberry Yogurt" - }, - { - "selected": false, - "label": "Gorilla String Cheese", - "value": "Gorilla String Cheese" - }, - { - "selected": false, - "label": "Gorilla Whole Milk", - "value": "Gorilla Whole Milk" - }, - { - "selected": false, - "label": "Great Bagels", - "value": "Great Bagels" - }, - { - "selected": false, - "label": "Great Blueberry Muffins", - "value": "Great Blueberry Muffins" - }, - { - "selected": false, - "label": "Great Cranberry Muffins", - "value": "Great Cranberry Muffins" - }, - { - "selected": false, - "label": "Great English Muffins", - "value": "Great English Muffins" - }, - { - "selected": false, - "label": "Great Muffins", - "value": "Great Muffins" - }, - { - "selected": false, - "label": "Great Pumpernickel Bread", - "value": "Great Pumpernickel Bread" - }, - { - "selected": false, - "label": "Great Rye Bread", - "value": "Great Rye Bread" - }, - { - "selected": false, - "label": "Great Wheat Bread", - "value": "Great Wheat Bread" - }, - { - "selected": false, - "label": "Great White Bread", - "value": "Great White Bread" - }, - { - "selected": false, - "label": "Green Ribbon Canned Mixed Fruit", - "value": "Green Ribbon Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Green Ribbon Canned Peaches", - "value": "Green Ribbon Canned Peaches" - }, - { - "selected": false, - "label": "Gulf Coast Bubble Gum", - "value": "Gulf Coast Bubble Gum" - }, - { - "selected": false, - "label": "Gulf Coast Malted Milk Balls", - "value": "Gulf Coast Malted Milk Balls" - }, - { - "selected": false, - "label": "Gulf Coast Mint Chocolate Bar", - "value": "Gulf Coast Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Gulf Coast Mints", - "value": "Gulf Coast Mints" - }, - { - "selected": false, - "label": "Gulf Coast Semi-Sweet Chocolate Bar", - "value": "Gulf Coast Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Gulf Coast Spicy Mints", - "value": "Gulf Coast Spicy Mints" - }, - { - "selected": false, - "label": "Gulf Coast Tasty Candy Bar", - "value": "Gulf Coast Tasty Candy Bar" - }, - { - "selected": false, - "label": "Gulf Coast White Chocolate Bar", - "value": "Gulf Coast White Chocolate Bar" - }, - { - "selected": false, - "label": "Hermanos Almonds", - "value": "Hermanos Almonds" - }, - { - "selected": false, - "label": "Hermanos Asparagus", - "value": "Hermanos Asparagus" - }, - { - "selected": false, - "label": "Hermanos Baby Onion", - "value": "Hermanos Baby Onion" - }, - { - "selected": false, - "label": "Hermanos Beets", - "value": "Hermanos Beets" - }, - { - "selected": false, - "label": "Hermanos Broccoli", - "value": "Hermanos Broccoli" - }, - { - "selected": false, - "label": "Hermanos Canned Peanuts", - "value": "Hermanos Canned Peanuts" - }, - { - "selected": false, - "label": "Hermanos Cantelope", - "value": "Hermanos Cantelope" - }, - { - "selected": false, - "label": "Hermanos Cauliflower", - "value": "Hermanos Cauliflower" - }, - { - "selected": false, - "label": "Hermanos Corn on the Cob", - "value": "Hermanos Corn on the Cob" - }, - { - "selected": false, - "label": "Hermanos Dried Mushrooms", - "value": "Hermanos Dried Mushrooms" - }, - { - "selected": false, - "label": "Hermanos Elephant Garlic", - "value": "Hermanos Elephant Garlic" - }, - { - "selected": false, - "label": "Hermanos Fancy Plums", - "value": "Hermanos Fancy Plums" - }, - { - "selected": false, - "label": "Hermanos Firm Tofu", - "value": "Hermanos Firm Tofu" - }, - { - "selected": false, - "label": "Hermanos Fresh Lima Beans", - "value": "Hermanos Fresh Lima Beans" - }, - { - "selected": false, - "label": "Hermanos Fuji Apples", - "value": "Hermanos Fuji Apples" - }, - { - "selected": false, - "label": "Hermanos Garlic", - "value": "Hermanos Garlic" - }, - { - "selected": false, - "label": "Hermanos Golden Delcious Apples", - "value": "Hermanos Golden Delcious Apples" - }, - { - "selected": false, - "label": "Hermanos Green Pepper", - "value": "Hermanos Green Pepper" - }, - { - "selected": false, - "label": "Hermanos Honey Dew", - "value": "Hermanos Honey Dew" - }, - { - "selected": false, - "label": "Hermanos Lemons", - "value": "Hermanos Lemons" - }, - { - "selected": false, - "label": "Hermanos Lettuce", - "value": "Hermanos Lettuce" - }, - { - "selected": false, - "label": "Hermanos Limes", - "value": "Hermanos Limes" - }, - { - "selected": false, - "label": "Hermanos Macintosh Apples", - "value": "Hermanos Macintosh Apples" - }, - { - "selected": false, - "label": "Hermanos Mandarin Oranges", - "value": "Hermanos Mandarin Oranges" - }, - { - "selected": false, - "label": "Hermanos Mixed Nuts", - "value": "Hermanos Mixed Nuts" - }, - { - "selected": false, - "label": "Hermanos Mushrooms", - "value": "Hermanos Mushrooms" - }, - { - "selected": false, - "label": "Hermanos New Potatos", - "value": "Hermanos New Potatos" - }, - { - "selected": false, - "label": "Hermanos Onions", - "value": "Hermanos Onions" - }, - { - "selected": false, - "label": "Hermanos Oranges", - "value": "Hermanos Oranges" - }, - { - "selected": false, - "label": "Hermanos Party Nuts", - "value": "Hermanos Party Nuts" - }, - { - "selected": false, - "label": "Hermanos Peaches", - "value": "Hermanos Peaches" - }, - { - "selected": false, - "label": "Hermanos Plums", - "value": "Hermanos Plums" - }, - { - "selected": false, - "label": "Hermanos Potatos", - "value": "Hermanos Potatos" - }, - { - "selected": false, - "label": "Hermanos Prepared Salad", - "value": "Hermanos Prepared Salad" - }, - { - "selected": false, - "label": "Hermanos Red Delcious Apples", - "value": "Hermanos Red Delcious Apples" - }, - { - "selected": false, - "label": "Hermanos Red Pepper", - "value": "Hermanos Red Pepper" - }, - { - "selected": false, - "label": "Hermanos Shitake Mushrooms", - "value": "Hermanos Shitake Mushrooms" - }, - { - "selected": false, - "label": "Hermanos Squash", - "value": "Hermanos Squash" - }, - { - "selected": false, - "label": "Hermanos Summer Squash", - "value": "Hermanos Summer Squash" - }, - { - "selected": false, - "label": "Hermanos Sweet Onion", - "value": "Hermanos Sweet Onion" - }, - { - "selected": false, - "label": "Hermanos Sweet Peas", - "value": "Hermanos Sweet Peas" - }, - { - "selected": false, - "label": "Hermanos Tangerines", - "value": "Hermanos Tangerines" - }, - { - "selected": false, - "label": "Hermanos Tomatos", - "value": "Hermanos Tomatos" - }, - { - "selected": false, - "label": "Hermanos Walnuts", - "value": "Hermanos Walnuts" - }, - { - "selected": false, - "label": "High Quality 100 Watt Lightbulb", - "value": "High Quality 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 25 Watt Lightbulb", - "value": "High Quality 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 60 Watt Lightbulb", - "value": "High Quality 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 75 Watt Lightbulb", - "value": "High Quality 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality AAA-Size Batteries", - "value": "High Quality AAA-Size Batteries" - }, - { - "selected": false, - "label": "High Quality AA-Size Batteries", - "value": "High Quality AA-Size Batteries" - }, - { - "selected": false, - "label": "High Quality Bees Wax Candles", - "value": "High Quality Bees Wax Candles" - }, - { - "selected": false, - "label": "High Quality Copper Cleaner", - "value": "High Quality Copper Cleaner" - }, - { - "selected": false, - "label": "High Quality Copper Pot Scrubber", - "value": "High Quality Copper Pot Scrubber" - }, - { - "selected": false, - "label": "High Quality Counter Cleaner", - "value": "High Quality Counter Cleaner" - }, - { - "selected": false, - "label": "High Quality C-Size Batteries", - "value": "High Quality C-Size Batteries" - }, - { - "selected": false, - "label": "High Quality D-Size Batteries", - "value": "High Quality D-Size Batteries" - }, - { - "selected": false, - "label": "High Quality Economy Toilet Brush", - "value": "High Quality Economy Toilet Brush" - }, - { - "selected": false, - "label": "High Quality Frying Pan", - "value": "High Quality Frying Pan" - }, - { - "selected": false, - "label": "High Quality Glass Cleaner", - "value": "High Quality Glass Cleaner" - }, - { - "selected": false, - "label": "High Quality Large Sponge", - "value": "High Quality Large Sponge" - }, - { - "selected": false, - "label": "High Quality Paper Cups", - "value": "High Quality Paper Cups" - }, - { - "selected": false, - "label": "High Quality Paper Plates", - "value": "High Quality Paper Plates" - }, - { - "selected": false, - "label": "High Quality Paper Towels", - "value": "High Quality Paper Towels" - }, - { - "selected": false, - "label": "High Quality Plastic Forks", - "value": "High Quality Plastic Forks" - }, - { - "selected": false, - "label": "High Quality Plastic Knives", - "value": "High Quality Plastic Knives" - }, - { - "selected": false, - "label": "High Quality Plastic Spoons", - "value": "High Quality Plastic Spoons" - }, - { - "selected": false, - "label": "High Quality Room Freshener", - "value": "High Quality Room Freshener" - }, - { - "selected": false, - "label": "High Quality Scented Tissue", - "value": "High Quality Scented Tissue" - }, - { - "selected": false, - "label": "High Quality Scented Toilet Tissue", - "value": "High Quality Scented Toilet Tissue" - }, - { - "selected": false, - "label": "High Quality Scissors", - "value": "High Quality Scissors" - }, - { - "selected": false, - "label": "High Quality Screw Driver", - "value": "High Quality Screw Driver" - }, - { - "selected": false, - "label": "High Quality Silver Cleaner", - "value": "High Quality Silver Cleaner" - }, - { - "selected": false, - "label": "High Quality Soft Napkins", - "value": "High Quality Soft Napkins" - }, - { - "selected": false, - "label": "High Quality Tissues", - "value": "High Quality Tissues" - }, - { - "selected": false, - "label": "High Quality Toilet Bowl Cleaner", - "value": "High Quality Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "High Quality Toilet Paper", - "value": "High Quality Toilet Paper" - }, - { - "selected": false, - "label": "High Top Almonds", - "value": "High Top Almonds" - }, - { - "selected": false, - "label": "High Top Asparagus", - "value": "High Top Asparagus" - }, - { - "selected": false, - "label": "High Top Baby Onion", - "value": "High Top Baby Onion" - }, - { - "selected": false, - "label": "High Top Beets", - "value": "High Top Beets" - }, - { - "selected": false, - "label": "High Top Broccoli", - "value": "High Top Broccoli" - }, - { - "selected": false, - "label": "High Top Canned Peanuts", - "value": "High Top Canned Peanuts" - }, - { - "selected": false, - "label": "High Top Cantelope", - "value": "High Top Cantelope" - }, - { - "selected": false, - "label": "High Top Cauliflower", - "value": "High Top Cauliflower" - }, - { - "selected": false, - "label": "High Top Corn on the Cob", - "value": "High Top Corn on the Cob" - }, - { - "selected": false, - "label": "High Top Dried Mushrooms", - "value": "High Top Dried Mushrooms" - }, - { - "selected": false, - "label": "High Top Elephant Garlic", - "value": "High Top Elephant Garlic" - }, - { - "selected": false, - "label": "High Top Fancy Plums", - "value": "High Top Fancy Plums" - }, - { - "selected": false, - "label": "High Top Firm Tofu", - "value": "High Top Firm Tofu" - }, - { - "selected": false, - "label": "High Top Fresh Lima Beans", - "value": "High Top Fresh Lima Beans" - }, - { - "selected": false, - "label": "High Top Fuji Apples", - "value": "High Top Fuji Apples" - }, - { - "selected": false, - "label": "High Top Garlic", - "value": "High Top Garlic" - }, - { - "selected": false, - "label": "High Top Golden Delcious Apples", - "value": "High Top Golden Delcious Apples" - }, - { - "selected": false, - "label": "High Top Green Pepper", - "value": "High Top Green Pepper" - }, - { - "selected": false, - "label": "High Top Honey Dew", - "value": "High Top Honey Dew" - }, - { - "selected": false, - "label": "High Top Lemons", - "value": "High Top Lemons" - }, - { - "selected": false, - "label": "High Top Lettuce", - "value": "High Top Lettuce" - }, - { - "selected": false, - "label": "High Top Limes", - "value": "High Top Limes" - }, - { - "selected": false, - "label": "High Top Macintosh Apples", - "value": "High Top Macintosh Apples" - }, - { - "selected": false, - "label": "High Top Mandarin Oranges", - "value": "High Top Mandarin Oranges" - }, - { - "selected": false, - "label": "High Top Mixed Nuts", - "value": "High Top Mixed Nuts" - }, - { - "selected": false, - "label": "High Top Mushrooms", - "value": "High Top Mushrooms" - }, - { - "selected": false, - "label": "High Top New Potatos", - "value": "High Top New Potatos" - }, - { - "selected": false, - "label": "High Top Onions", - "value": "High Top Onions" - }, - { - "selected": false, - "label": "High Top Oranges", - "value": "High Top Oranges" - }, - { - "selected": false, - "label": "High Top Party Nuts", - "value": "High Top Party Nuts" - }, - { - "selected": false, - "label": "High Top Peaches", - "value": "High Top Peaches" - }, - { - "selected": false, - "label": "High Top Plums", - "value": "High Top Plums" - }, - { - "selected": false, - "label": "High Top Potatos", - "value": "High Top Potatos" - }, - { - "selected": false, - "label": "High Top Prepared Salad", - "value": "High Top Prepared Salad" - }, - { - "selected": false, - "label": "High Top Red Delcious Apples", - "value": "High Top Red Delcious Apples" - }, - { - "selected": false, - "label": "High Top Red Pepper", - "value": "High Top Red Pepper" - }, - { - "selected": false, - "label": "High Top Shitake Mushrooms", - "value": "High Top Shitake Mushrooms" - }, - { - "selected": false, - "label": "High Top Squash", - "value": "High Top Squash" - }, - { - "selected": false, - "label": "High Top Summer Squash", - "value": "High Top Summer Squash" - }, - { - "selected": false, - "label": "High Top Sweet Onion", - "value": "High Top Sweet Onion" - }, - { - "selected": false, - "label": "High Top Sweet Peas", - "value": "High Top Sweet Peas" - }, - { - "selected": false, - "label": "High Top Tangerines", - "value": "High Top Tangerines" - }, - { - "selected": false, - "label": "High Top Tomatos", - "value": "High Top Tomatos" - }, - { - "selected": false, - "label": "High Top Walnuts", - "value": "High Top Walnuts" - }, - { - "selected": false, - "label": "Hilltop 200 MG Acetominifen", - "value": "Hilltop 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Hilltop 200 MG Ibuprofen", - "value": "Hilltop 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Hilltop Angled Toothbrush", - "value": "Hilltop Angled Toothbrush" - }, - { - "selected": false, - "label": "Hilltop Apricot Shampoo", - "value": "Hilltop Apricot Shampoo" - }, - { - "selected": false, - "label": "Hilltop Buffered Aspirin", - "value": "Hilltop Buffered Aspirin" - }, - { - "selected": false, - "label": "Hilltop Childrens Aspirin", - "value": "Hilltop Childrens Aspirin" - }, - { - "selected": false, - "label": "Hilltop Childrens Cold Remedy", - "value": "Hilltop Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Hilltop Conditioning Shampoo", - "value": "Hilltop Conditioning Shampoo" - }, - { - "selected": false, - "label": "Hilltop Deodorant", - "value": "Hilltop Deodorant" - }, - { - "selected": false, - "label": "Hilltop Dishwasher Detergent", - "value": "Hilltop Dishwasher Detergent" - }, - { - "selected": false, - "label": "Hilltop Extra Moisture Shampoo", - "value": "Hilltop Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Hilltop HCL Nasal Spray", - "value": "Hilltop HCL Nasal Spray" - }, - { - "selected": false, - "label": "Hilltop Laundry Detergent", - "value": "Hilltop Laundry Detergent" - }, - { - "selected": false, - "label": "Hilltop Mint Mouthwash", - "value": "Hilltop Mint Mouthwash" - }, - { - "selected": false, - "label": "Hilltop Multi-Symptom Cold Remedy", - "value": "Hilltop Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Hilltop Silky Smooth Hair Conditioner", - "value": "Hilltop Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Hilltop Tartar Control Toothpaste", - "value": "Hilltop Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Hilltop Toothpaste", - "value": "Hilltop Toothpaste" - }, - { - "selected": false, - "label": "Hilltop Whitening Toothpast", - "value": "Hilltop Whitening Toothpast" - }, - { - "selected": false, - "label": "Horatio Apple Fruit Roll", - "value": "Horatio Apple Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Avocado Dip", - "value": "Horatio Avocado Dip" - }, - { - "selected": false, - "label": "Horatio BBQ Potato Chips", - "value": "Horatio BBQ Potato Chips" - }, - { - "selected": false, - "label": "Horatio Beef Jerky", - "value": "Horatio Beef Jerky" - }, - { - "selected": false, - "label": "Horatio Buttered Popcorn", - "value": "Horatio Buttered Popcorn" - }, - { - "selected": false, - "label": "Horatio Cheese Crackers", - "value": "Horatio Cheese Crackers" - }, - { - "selected": false, - "label": "Horatio Cheese Dip", - "value": "Horatio Cheese Dip" - }, - { - "selected": false, - "label": "Horatio Chocolate Chip Cookies", - "value": "Horatio Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Horatio Chocolate Donuts", - "value": "Horatio Chocolate Donuts" - }, - { - "selected": false, - "label": "Horatio Corn Chips", - "value": "Horatio Corn Chips" - }, - { - "selected": false, - "label": "Horatio Dried Apples", - "value": "Horatio Dried Apples" - }, - { - "selected": false, - "label": "Horatio Dried Apricots", - "value": "Horatio Dried Apricots" - }, - { - "selected": false, - "label": "Horatio Dried Dates", - "value": "Horatio Dried Dates" - }, - { - "selected": false, - "label": "Horatio Fondue Mix", - "value": "Horatio Fondue Mix" - }, - { - "selected": false, - "label": "Horatio Frosted Cookies", - "value": "Horatio Frosted Cookies" - }, - { - "selected": false, - "label": "Horatio Frosted Donuts", - "value": "Horatio Frosted Donuts" - }, - { - "selected": false, - "label": "Horatio Fudge Brownies", - "value": "Horatio Fudge Brownies" - }, - { - "selected": false, - "label": "Horatio Fudge Cookies", - "value": "Horatio Fudge Cookies" - }, - { - "selected": false, - "label": "Horatio Golden Raisins", - "value": "Horatio Golden Raisins" - }, - { - "selected": false, - "label": "Horatio Graham Crackers", - "value": "Horatio Graham Crackers" - }, - { - "selected": false, - "label": "Horatio Grape Fruit Roll", - "value": "Horatio Grape Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Lemon Cookies", - "value": "Horatio Lemon Cookies" - }, - { - "selected": false, - "label": "Horatio Low Fat BBQ Chips", - "value": "Horatio Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Horatio Low Fat Chips", - "value": "Horatio Low Fat Chips" - }, - { - "selected": false, - "label": "Horatio Low Fat Cookies", - "value": "Horatio Low Fat Cookies" - }, - { - "selected": false, - "label": "Horatio Low Fat Popcorn", - "value": "Horatio Low Fat Popcorn" - }, - { - "selected": false, - "label": "Horatio Mini Donuts", - "value": "Horatio Mini Donuts" - }, - { - "selected": false, - "label": "Horatio No Salt Popcorn", - "value": "Horatio No Salt Popcorn" - }, - { - "selected": false, - "label": "Horatio Potato Chips", - "value": "Horatio Potato Chips" - }, - { - "selected": false, - "label": "Horatio Raisins", - "value": "Horatio Raisins" - }, - { - "selected": false, - "label": "Horatio Raspberry Fruit Roll", - "value": "Horatio Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Salsa Dip", - "value": "Horatio Salsa Dip" - }, - { - "selected": false, - "label": "Horatio Salted Pretzels", - "value": "Horatio Salted Pretzels" - }, - { - "selected": false, - "label": "Horatio Sesame Crackers", - "value": "Horatio Sesame Crackers" - }, - { - "selected": false, - "label": "Horatio Strawberry Fruit Roll", - "value": "Horatio Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Sugar Cookies", - "value": "Horatio Sugar Cookies" - }, - { - "selected": false, - "label": "Imagine Apple Cinnamon Waffles", - "value": "Imagine Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Imagine Beef TV Dinner", - "value": "Imagine Beef TV Dinner" - }, - { - "selected": false, - "label": "Imagine Blueberry Waffles", - "value": "Imagine Blueberry Waffles" - }, - { - "selected": false, - "label": "Imagine Chicken TV Dinner", - "value": "Imagine Chicken TV Dinner" - }, - { - "selected": false, - "label": "Imagine Fajita French Fries", - "value": "Imagine Fajita French Fries" - }, - { - "selected": false, - "label": "Imagine Frozen Broccoli", - "value": "Imagine Frozen Broccoli" - }, - { - "selected": false, - "label": "Imagine Frozen Carrots", - "value": "Imagine Frozen Carrots" - }, - { - "selected": false, - "label": "Imagine Frozen Cauliflower", - "value": "Imagine Frozen Cauliflower" - }, - { - "selected": false, - "label": "Imagine Frozen Cheese Pizza", - "value": "Imagine Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Breast", - "value": "Imagine Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Thighs", - "value": "Imagine Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Wings", - "value": "Imagine Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Imagine Frozen Corn", - "value": "Imagine Frozen Corn" - }, - { - "selected": false, - "label": "Imagine Frozen Mushroom Pizza", - "value": "Imagine Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Pancakes", - "value": "Imagine Frozen Pancakes" - }, - { - "selected": false, - "label": "Imagine Frozen Peas", - "value": "Imagine Frozen Peas" - }, - { - "selected": false, - "label": "Imagine Frozen Pepperoni Pizza", - "value": "Imagine Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Sausage Pizza", - "value": "Imagine Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Imagine Grape Popsicles", - "value": "Imagine Grape Popsicles" - }, - { - "selected": false, - "label": "Imagine Home Style French Fries", - "value": "Imagine Home Style French Fries" - }, - { - "selected": false, - "label": "Imagine Ice Cream", - "value": "Imagine Ice Cream" - }, - { - "selected": false, - "label": "Imagine Ice Cream Sandwich", - "value": "Imagine Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Imagine Lemon Popsicles", - "value": "Imagine Lemon Popsicles" - }, - { - "selected": false, - "label": "Imagine Lime Popsicles", - "value": "Imagine Lime Popsicles" - }, - { - "selected": false, - "label": "Imagine Low Fat French Fries", - "value": "Imagine Low Fat French Fries" - }, - { - "selected": false, - "label": "Imagine Low Fat Waffles", - "value": "Imagine Low Fat Waffles" - }, - { - "selected": false, - "label": "Imagine Orange Popsicles", - "value": "Imagine Orange Popsicles" - }, - { - "selected": false, - "label": "Imagine Pancake Mix", - "value": "Imagine Pancake Mix" - }, - { - "selected": false, - "label": "Imagine Popsicles", - "value": "Imagine Popsicles" - }, - { - "selected": false, - "label": "Imagine Turkey TV Dinner", - "value": "Imagine Turkey TV Dinner" - }, - { - "selected": false, - "label": "Imagine Waffles", - "value": "Imagine Waffles" - }, - { - "selected": false, - "label": "James Bay City Map", - "value": "James Bay City Map" - }, - { - "selected": false, - "label": "James Bay Eyeglass Screwdriver", - "value": "James Bay Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Jardon Manicotti", - "value": "Jardon Manicotti" - }, - { - "selected": false, - "label": "Jardon Ravioli", - "value": "Jardon Ravioli" - }, - { - "selected": false, - "label": "Jardon Rice Medly", - "value": "Jardon Rice Medly" - }, - { - "selected": false, - "label": "Jardon Spaghetti", - "value": "Jardon Spaghetti" - }, - { - "selected": false, - "label": "Jardon Thai Rice", - "value": "Jardon Thai Rice" - }, - { - "selected": false, - "label": "Jeffers Corn Puffs", - "value": "Jeffers Corn Puffs" - }, - { - "selected": false, - "label": "Jeffers Grits", - "value": "Jeffers Grits" - }, - { - "selected": false, - "label": "Jeffers Oatmeal", - "value": "Jeffers Oatmeal" - }, - { - "selected": false, - "label": "Jeffers Wheat Puffs", - "value": "Jeffers Wheat Puffs" - }, - { - "selected": false, - "label": "Johnson Corn Puffs", - "value": "Johnson Corn Puffs" - }, - { - "selected": false, - "label": "Johnson Grits", - "value": "Johnson Grits" - }, - { - "selected": false, - "label": "Johnson Oatmeal", - "value": "Johnson Oatmeal" - }, - { - "selected": false, - "label": "Johnson Wheat Puffs", - "value": "Johnson Wheat Puffs" - }, - { - "selected": false, - "label": "Jumbo Egg Substitute", - "value": "Jumbo Egg Substitute" - }, - { - "selected": false, - "label": "Jumbo Large Brown Eggs", - "value": "Jumbo Large Brown Eggs" - }, - { - "selected": false, - "label": "Jumbo Large Eggs", - "value": "Jumbo Large Eggs" - }, - { - "selected": false, - "label": "Jumbo Small Brown Eggs", - "value": "Jumbo Small Brown Eggs" - }, - { - "selected": false, - "label": "Jumbo Small Eggs", - "value": "Jumbo Small Eggs" - }, - { - "selected": false, - "label": "Just Right Beef Soup", - "value": "Just Right Beef Soup" - }, - { - "selected": false, - "label": "Just Right Canned Beets", - "value": "Just Right Canned Beets" - }, - { - "selected": false, - "label": "Just Right Canned Peas", - "value": "Just Right Canned Peas" - }, - { - "selected": false, - "label": "Just Right Canned String Beans", - "value": "Just Right Canned String Beans" - }, - { - "selected": false, - "label": "Just Right Canned Tomatos", - "value": "Just Right Canned Tomatos" - }, - { - "selected": false, - "label": "Just Right Canned Tuna in Oil", - "value": "Just Right Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Just Right Canned Tuna in Water", - "value": "Just Right Canned Tuna in Water" - }, - { - "selected": false, - "label": "Just Right Canned Yams", - "value": "Just Right Canned Yams" - }, - { - "selected": false, - "label": "Just Right Chicken Noodle Soup", - "value": "Just Right Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Chicken Ramen Soup", - "value": "Just Right Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Just Right Chicken Soup", - "value": "Just Right Chicken Soup" - }, - { - "selected": false, - "label": "Just Right Creamed Corn", - "value": "Just Right Creamed Corn" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Anchovies", - "value": "Just Right Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Clams", - "value": "Just Right Fancy Canned Clams" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Oysters", - "value": "Just Right Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Sardines", - "value": "Just Right Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Just Right Large Canned Shrimp", - "value": "Just Right Large Canned Shrimp" - }, - { - "selected": false, - "label": "Just Right Noodle Soup", - "value": "Just Right Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Regular Ramen Soup", - "value": "Just Right Regular Ramen Soup" - }, - { - "selected": false, - "label": "Just Right Rice Soup", - "value": "Just Right Rice Soup" - }, - { - "selected": false, - "label": "Just Right Turkey Noodle Soup", - "value": "Just Right Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Vegetable Soup", - "value": "Just Right Vegetable Soup" - }, - { - "selected": false, - "label": "King Rosy Sunglasses", - "value": "King Rosy Sunglasses" - }, - { - "selected": false, - "label": "Kiwi Lox", - "value": "Kiwi Lox" - }, - { - "selected": false, - "label": "Kiwi Scallops", - "value": "Kiwi Scallops" - }, - { - "selected": false, - "label": "Lake Beef Bologna", - "value": "Lake Beef Bologna" - }, - { - "selected": false, - "label": "Lake Chicken Hot Dogs", - "value": "Lake Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Lake Cole Slaw", - "value": "Lake Cole Slaw" - }, - { - "selected": false, - "label": "Lake Corned Beef", - "value": "Lake Corned Beef" - }, - { - "selected": false, - "label": "Lake Foot-Long Hot Dogs", - "value": "Lake Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Lake Low Fat Bologna", - "value": "Lake Low Fat Bologna" - }, - { - "selected": false, - "label": "Lake Low Fat Cole Slaw", - "value": "Lake Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Lake Pimento Loaf", - "value": "Lake Pimento Loaf" - }, - { - "selected": false, - "label": "Lake Potato Salad", - "value": "Lake Potato Salad" - }, - { - "selected": false, - "label": "Lake Roasted Chicken", - "value": "Lake Roasted Chicken" - }, - { - "selected": false, - "label": "Lake Sliced Chicken", - "value": "Lake Sliced Chicken" - }, - { - "selected": false, - "label": "Lake Sliced Ham", - "value": "Lake Sliced Ham" - }, - { - "selected": false, - "label": "Lake Sliced Turkey", - "value": "Lake Sliced Turkey" - }, - { - "selected": false, - "label": "Lake Turkey Hot Dogs", - "value": "Lake Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Landslide Apple Butter", - "value": "Landslide Apple Butter" - }, - { - "selected": false, - "label": "Landslide Apple Jam", - "value": "Landslide Apple Jam" - }, - { - "selected": false, - "label": "Landslide Apple Jelly", - "value": "Landslide Apple Jelly" - }, - { - "selected": false, - "label": "Landslide Apple Preserves", - "value": "Landslide Apple Preserves" - }, - { - "selected": false, - "label": "Landslide Brown Sugar", - "value": "Landslide Brown Sugar" - }, - { - "selected": false, - "label": "Landslide Canola Oil", - "value": "Landslide Canola Oil" - }, - { - "selected": false, - "label": "Landslide Chunky Peanut Butter", - "value": "Landslide Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Landslide Columbian Coffee", - "value": "Landslide Columbian Coffee" - }, - { - "selected": false, - "label": "Landslide Corn Oil", - "value": "Landslide Corn Oil" - }, - { - "selected": false, - "label": "Landslide Creamy Peanut Butter", - "value": "Landslide Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Landslide Decaf Coffee", - "value": "Landslide Decaf Coffee" - }, - { - "selected": false, - "label": "Landslide Extra Chunky Peanut Butter", - "value": "Landslide Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Landslide French Roast Coffee", - "value": "Landslide French Roast Coffee" - }, - { - "selected": false, - "label": "Landslide Grape Jam", - "value": "Landslide Grape Jam" - }, - { - "selected": false, - "label": "Landslide Grape Jelly", - "value": "Landslide Grape Jelly" - }, - { - "selected": false, - "label": "Landslide Grape Preserves", - "value": "Landslide Grape Preserves" - }, - { - "selected": false, - "label": "Landslide Hot Chocolate", - "value": "Landslide Hot Chocolate" - }, - { - "selected": false, - "label": "Landslide Low Fat Apple Butter", - "value": "Landslide Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Landslide Oregano", - "value": "Landslide Oregano" - }, - { - "selected": false, - "label": "Landslide Pepper", - "value": "Landslide Pepper" - }, - { - "selected": false, - "label": "Landslide Regular Coffee", - "value": "Landslide Regular Coffee" - }, - { - "selected": false, - "label": "Landslide Salt", - "value": "Landslide Salt" - }, - { - "selected": false, - "label": "Landslide Sesame Oil", - "value": "Landslide Sesame Oil" - }, - { - "selected": false, - "label": "Landslide Strawberry Jam", - "value": "Landslide Strawberry Jam" - }, - { - "selected": false, - "label": "Landslide Strawberry Jelly", - "value": "Landslide Strawberry Jelly" - }, - { - "selected": false, - "label": "Landslide Strawberry Preserves", - "value": "Landslide Strawberry Preserves" - }, - { - "selected": false, - "label": "Landslide Tomato Sauce", - "value": "Landslide Tomato Sauce" - }, - { - "selected": false, - "label": "Landslide Vegetable Oil", - "value": "Landslide Vegetable Oil" - }, - { - "selected": false, - "label": "Landslide White Sugar", - "value": "Landslide White Sugar" - }, - { - "selected": false, - "label": "Medalist Manicotti", - "value": "Medalist Manicotti" - }, - { - "selected": false, - "label": "Medalist Ravioli", - "value": "Medalist Ravioli" - }, - { - "selected": false, - "label": "Medalist Rice Medly", - "value": "Medalist Rice Medly" - }, - { - "selected": false, - "label": "Medalist Spaghetti", - "value": "Medalist Spaghetti" - }, - { - "selected": false, - "label": "Medalist Thai Rice", - "value": "Medalist Thai Rice" - }, - { - "selected": false, - "label": "Mighty Good Monthly Auto Magazine", - "value": "Mighty Good Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Computer Magazine", - "value": "Mighty Good Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Fashion Magazine", - "value": "Mighty Good Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Home Magazine", - "value": "Mighty Good Monthly Home Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Sports Magazine", - "value": "Mighty Good Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Modell Bagels", - "value": "Modell Bagels" - }, - { - "selected": false, - "label": "Modell Blueberry Muffins", - "value": "Modell Blueberry Muffins" - }, - { - "selected": false, - "label": "Modell Cranberry Muffins", - "value": "Modell Cranberry Muffins" - }, - { - "selected": false, - "label": "Modell English Muffins", - "value": "Modell English Muffins" - }, - { - "selected": false, - "label": "Modell Muffins", - "value": "Modell Muffins" - }, - { - "selected": false, - "label": "Modell Pumpernickel Bread", - "value": "Modell Pumpernickel Bread" - }, - { - "selected": false, - "label": "Modell Rye Bread", - "value": "Modell Rye Bread" - }, - { - "selected": false, - "label": "Modell Wheat Bread", - "value": "Modell Wheat Bread" - }, - { - "selected": false, - "label": "Modell White Bread", - "value": "Modell White Bread" - }, - { - "selected": false, - "label": "Moms Beef Bologna", - "value": "Moms Beef Bologna" - }, - { - "selected": false, - "label": "Moms Chicken Hot Dogs", - "value": "Moms Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Moms Cole Slaw", - "value": "Moms Cole Slaw" - }, - { - "selected": false, - "label": "Moms Corned Beef", - "value": "Moms Corned Beef" - }, - { - "selected": false, - "label": "Moms Foot-Long Hot Dogs", - "value": "Moms Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Moms Low Fat Bologna", - "value": "Moms Low Fat Bologna" - }, - { - "selected": false, - "label": "Moms Low Fat Cole Slaw", - "value": "Moms Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Moms Pimento Loaf", - "value": "Moms Pimento Loaf" - }, - { - "selected": false, - "label": "Moms Potato Salad", - "value": "Moms Potato Salad" - }, - { - "selected": false, - "label": "Moms Roasted Chicken", - "value": "Moms Roasted Chicken" - }, - { - "selected": false, - "label": "Moms Sliced Chicken", - "value": "Moms Sliced Chicken" - }, - { - "selected": false, - "label": "Moms Sliced Ham", - "value": "Moms Sliced Ham" - }, - { - "selected": false, - "label": "Moms Sliced Turkey", - "value": "Moms Sliced Turkey" - }, - { - "selected": false, - "label": "Moms Turkey Hot Dogs", - "value": "Moms Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Monarch Manicotti", - "value": "Monarch Manicotti" - }, - { - "selected": false, - "label": "Monarch Ravioli", - "value": "Monarch Ravioli" - }, - { - "selected": false, - "label": "Monarch Rice Medly", - "value": "Monarch Rice Medly" - }, - { - "selected": false, - "label": "Monarch Spaghetti", - "value": "Monarch Spaghetti" - }, - { - "selected": false, - "label": "Monarch Thai Rice", - "value": "Monarch Thai Rice" - }, - { - "selected": false, - "label": "Musial Bubble Gum", - "value": "Musial Bubble Gum" - }, - { - "selected": false, - "label": "Musial Malted Milk Balls", - "value": "Musial Malted Milk Balls" - }, - { - "selected": false, - "label": "Musial Mint Chocolate Bar", - "value": "Musial Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Musial Mints", - "value": "Musial Mints" - }, - { - "selected": false, - "label": "Musial Semi-Sweet Chocolate Bar", - "value": "Musial Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Musial Spicy Mints", - "value": "Musial Spicy Mints" - }, - { - "selected": false, - "label": "Musial Tasty Candy Bar", - "value": "Musial Tasty Candy Bar" - }, - { - "selected": false, - "label": "Musial White Chocolate Bar", - "value": "Musial White Chocolate Bar" - }, - { - "selected": false, - "label": "National Egg Substitute", - "value": "National Egg Substitute" - }, - { - "selected": false, - "label": "National Large Brown Eggs", - "value": "National Large Brown Eggs" - }, - { - "selected": false, - "label": "National Large Eggs", - "value": "National Large Eggs" - }, - { - "selected": false, - "label": "National Small Brown Eggs", - "value": "National Small Brown Eggs" - }, - { - "selected": false, - "label": "National Small Eggs", - "value": "National Small Eggs" - }, - { - "selected": false, - "label": "Nationeel Apple Fruit Roll", - "value": "Nationeel Apple Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Avocado Dip", - "value": "Nationeel Avocado Dip" - }, - { - "selected": false, - "label": "Nationeel BBQ Potato Chips", - "value": "Nationeel BBQ Potato Chips" - }, - { - "selected": false, - "label": "Nationeel Beef Jerky", - "value": "Nationeel Beef Jerky" - }, - { - "selected": false, - "label": "Nationeel Buttered Popcorn", - "value": "Nationeel Buttered Popcorn" - }, - { - "selected": false, - "label": "Nationeel Cheese Crackers", - "value": "Nationeel Cheese Crackers" - }, - { - "selected": false, - "label": "Nationeel Cheese Dip", - "value": "Nationeel Cheese Dip" - }, - { - "selected": false, - "label": "Nationeel Chocolate Chip Cookies", - "value": "Nationeel Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Nationeel Chocolate Donuts", - "value": "Nationeel Chocolate Donuts" - }, - { - "selected": false, - "label": "Nationeel Corn Chips", - "value": "Nationeel Corn Chips" - }, - { - "selected": false, - "label": "Nationeel Dried Apples", - "value": "Nationeel Dried Apples" - }, - { - "selected": false, - "label": "Nationeel Dried Apricots", - "value": "Nationeel Dried Apricots" - }, - { - "selected": false, - "label": "Nationeel Dried Dates", - "value": "Nationeel Dried Dates" - }, - { - "selected": false, - "label": "Nationeel Fondue Mix", - "value": "Nationeel Fondue Mix" - }, - { - "selected": false, - "label": "Nationeel Frosted Cookies", - "value": "Nationeel Frosted Cookies" - }, - { - "selected": false, - "label": "Nationeel Frosted Donuts", - "value": "Nationeel Frosted Donuts" - }, - { - "selected": false, - "label": "Nationeel Fudge Brownies", - "value": "Nationeel Fudge Brownies" - }, - { - "selected": false, - "label": "Nationeel Fudge Cookies", - "value": "Nationeel Fudge Cookies" - }, - { - "selected": false, - "label": "Nationeel Golden Raisins", - "value": "Nationeel Golden Raisins" - }, - { - "selected": false, - "label": "Nationeel Graham Crackers", - "value": "Nationeel Graham Crackers" - }, - { - "selected": false, - "label": "Nationeel Grape Fruit Roll", - "value": "Nationeel Grape Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Lemon Cookies", - "value": "Nationeel Lemon Cookies" - }, - { - "selected": false, - "label": "Nationeel Low Fat BBQ Chips", - "value": "Nationeel Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Nationeel Low Fat Chips", - "value": "Nationeel Low Fat Chips" - }, - { - "selected": false, - "label": "Nationeel Low Fat Cookies", - "value": "Nationeel Low Fat Cookies" - }, - { - "selected": false, - "label": "Nationeel Low Fat Popcorn", - "value": "Nationeel Low Fat Popcorn" - }, - { - "selected": false, - "label": "Nationeel Mini Donuts", - "value": "Nationeel Mini Donuts" - }, - { - "selected": false, - "label": "Nationeel No Salt Popcorn", - "value": "Nationeel No Salt Popcorn" - }, - { - "selected": false, - "label": "Nationeel Potato Chips", - "value": "Nationeel Potato Chips" - }, - { - "selected": false, - "label": "Nationeel Raisins", - "value": "Nationeel Raisins" - }, - { - "selected": false, - "label": "Nationeel Raspberry Fruit Roll", - "value": "Nationeel Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Salsa Dip", - "value": "Nationeel Salsa Dip" - }, - { - "selected": false, - "label": "Nationeel Salted Pretzels", - "value": "Nationeel Salted Pretzels" - }, - { - "selected": false, - "label": "Nationeel Sesame Crackers", - "value": "Nationeel Sesame Crackers" - }, - { - "selected": false, - "label": "Nationeel Strawberry Fruit Roll", - "value": "Nationeel Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Sugar Cookies", - "value": "Nationeel Sugar Cookies" - }, - { - "selected": false, - "label": "Pearl Chablis Wine", - "value": "Pearl Chablis Wine" - }, - { - "selected": false, - "label": "Pearl Chardonnay", - "value": "Pearl Chardonnay" - }, - { - "selected": false, - "label": "Pearl Chardonnay Wine", - "value": "Pearl Chardonnay Wine" - }, - { - "selected": false, - "label": "Pearl Imported Beer", - "value": "Pearl Imported Beer" - }, - { - "selected": false, - "label": "Pearl Light Beer", - "value": "Pearl Light Beer" - }, - { - "selected": false, - "label": "Pearl Light Wine", - "value": "Pearl Light Wine" - }, - { - "selected": false, - "label": "Pearl Merlot Wine", - "value": "Pearl Merlot Wine" - }, - { - "selected": false, - "label": "Pearl White Zinfandel Wine", - "value": "Pearl White Zinfandel Wine" - }, - { - "selected": false, - "label": "PigTail Apple Cinnamon Waffles", - "value": "PigTail Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "PigTail Beef TV Dinner", - "value": "PigTail Beef TV Dinner" - }, - { - "selected": false, - "label": "PigTail Blueberry Waffles", - "value": "PigTail Blueberry Waffles" - }, - { - "selected": false, - "label": "PigTail Chicken TV Dinner", - "value": "PigTail Chicken TV Dinner" - }, - { - "selected": false, - "label": "PigTail Fajita French Fries", - "value": "PigTail Fajita French Fries" - }, - { - "selected": false, - "label": "PigTail Frozen Broccoli", - "value": "PigTail Frozen Broccoli" - }, - { - "selected": false, - "label": "PigTail Frozen Carrots", - "value": "PigTail Frozen Carrots" - }, - { - "selected": false, - "label": "PigTail Frozen Cauliflower", - "value": "PigTail Frozen Cauliflower" - }, - { - "selected": false, - "label": "PigTail Frozen Cheese Pizza", - "value": "PigTail Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Breast", - "value": "PigTail Frozen Chicken Breast" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Thighs", - "value": "PigTail Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Wings", - "value": "PigTail Frozen Chicken Wings" - }, - { - "selected": false, - "label": "PigTail Frozen Corn", - "value": "PigTail Frozen Corn" - }, - { - "selected": false, - "label": "PigTail Frozen Mushroom Pizza", - "value": "PigTail Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Pancakes", - "value": "PigTail Frozen Pancakes" - }, - { - "selected": false, - "label": "PigTail Frozen Peas", - "value": "PigTail Frozen Peas" - }, - { - "selected": false, - "label": "PigTail Frozen Pepperoni Pizza", - "value": "PigTail Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Sausage Pizza", - "value": "PigTail Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "PigTail Grape Popsicles", - "value": "PigTail Grape Popsicles" - }, - { - "selected": false, - "label": "PigTail Home Style French Fries", - "value": "PigTail Home Style French Fries" - }, - { - "selected": false, - "label": "PigTail Ice Cream", - "value": "PigTail Ice Cream" - }, - { - "selected": false, - "label": "PigTail Ice Cream Sandwich", - "value": "PigTail Ice Cream Sandwich" - }, - { - "selected": false, - "label": "PigTail Lemon Popsicles", - "value": "PigTail Lemon Popsicles" - }, - { - "selected": false, - "label": "PigTail Lime Popsicles", - "value": "PigTail Lime Popsicles" - }, - { - "selected": false, - "label": "PigTail Low Fat French Fries", - "value": "PigTail Low Fat French Fries" - }, - { - "selected": false, - "label": "PigTail Low Fat Waffles", - "value": "PigTail Low Fat Waffles" - }, - { - "selected": false, - "label": "PigTail Orange Popsicles", - "value": "PigTail Orange Popsicles" - }, - { - "selected": false, - "label": "PigTail Pancake Mix", - "value": "PigTail Pancake Mix" - }, - { - "selected": false, - "label": "PigTail Popsicles", - "value": "PigTail Popsicles" - }, - { - "selected": false, - "label": "PigTail Turkey TV Dinner", - "value": "PigTail Turkey TV Dinner" - }, - { - "selected": false, - "label": "PigTail Waffles", - "value": "PigTail Waffles" - }, - { - "selected": false, - "label": "Plato Apple Butter", - "value": "Plato Apple Butter" - }, - { - "selected": false, - "label": "Plato Apple Jam", - "value": "Plato Apple Jam" - }, - { - "selected": false, - "label": "Plato Apple Jelly", - "value": "Plato Apple Jelly" - }, - { - "selected": false, - "label": "Plato Apple Preserves", - "value": "Plato Apple Preserves" - }, - { - "selected": false, - "label": "Plato Brown Sugar", - "value": "Plato Brown Sugar" - }, - { - "selected": false, - "label": "Plato Canola Oil", - "value": "Plato Canola Oil" - }, - { - "selected": false, - "label": "Plato Chunky Peanut Butter", - "value": "Plato Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Plato Columbian Coffee", - "value": "Plato Columbian Coffee" - }, - { - "selected": false, - "label": "Plato Corn Oil", - "value": "Plato Corn Oil" - }, - { - "selected": false, - "label": "Plato Creamy Peanut Butter", - "value": "Plato Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Plato Decaf Coffee", - "value": "Plato Decaf Coffee" - }, - { - "selected": false, - "label": "Plato Extra Chunky Peanut Butter", - "value": "Plato Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Plato French Roast Coffee", - "value": "Plato French Roast Coffee" - }, - { - "selected": false, - "label": "Plato Grape Jam", - "value": "Plato Grape Jam" - }, - { - "selected": false, - "label": "Plato Grape Jelly", - "value": "Plato Grape Jelly" - }, - { - "selected": false, - "label": "Plato Grape Preserves", - "value": "Plato Grape Preserves" - }, - { - "selected": false, - "label": "Plato Hot Chocolate", - "value": "Plato Hot Chocolate" - }, - { - "selected": false, - "label": "Plato Low Fat Apple Butter", - "value": "Plato Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Plato Oregano", - "value": "Plato Oregano" - }, - { - "selected": false, - "label": "Plato Pepper", - "value": "Plato Pepper" - }, - { - "selected": false, - "label": "Plato Regular Coffee", - "value": "Plato Regular Coffee" - }, - { - "selected": false, - "label": "Plato Salt", - "value": "Plato Salt" - }, - { - "selected": false, - "label": "Plato Sesame Oil", - "value": "Plato Sesame Oil" - }, - { - "selected": false, - "label": "Plato Strawberry Jam", - "value": "Plato Strawberry Jam" - }, - { - "selected": false, - "label": "Plato Strawberry Jelly", - "value": "Plato Strawberry Jelly" - }, - { - "selected": false, - "label": "Plato Strawberry Preserves", - "value": "Plato Strawberry Preserves" - }, - { - "selected": false, - "label": "Plato Tomato Sauce", - "value": "Plato Tomato Sauce" - }, - { - "selected": false, - "label": "Plato Vegetable Oil", - "value": "Plato Vegetable Oil" - }, - { - "selected": false, - "label": "Plato White Sugar", - "value": "Plato White Sugar" - }, - { - "selected": false, - "label": "Pleasant Beef Soup", - "value": "Pleasant Beef Soup" - }, - { - "selected": false, - "label": "Pleasant Canned Beets", - "value": "Pleasant Canned Beets" - }, - { - "selected": false, - "label": "Pleasant Canned Peas", - "value": "Pleasant Canned Peas" - }, - { - "selected": false, - "label": "Pleasant Canned String Beans", - "value": "Pleasant Canned String Beans" - }, - { - "selected": false, - "label": "Pleasant Canned Tomatos", - "value": "Pleasant Canned Tomatos" - }, - { - "selected": false, - "label": "Pleasant Canned Tuna in Oil", - "value": "Pleasant Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Pleasant Canned Tuna in Water", - "value": "Pleasant Canned Tuna in Water" - }, - { - "selected": false, - "label": "Pleasant Canned Yams", - "value": "Pleasant Canned Yams" - }, - { - "selected": false, - "label": "Pleasant Chicken Noodle Soup", - "value": "Pleasant Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Chicken Ramen Soup", - "value": "Pleasant Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Pleasant Chicken Soup", - "value": "Pleasant Chicken Soup" - }, - { - "selected": false, - "label": "Pleasant Creamed Corn", - "value": "Pleasant Creamed Corn" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Anchovies", - "value": "Pleasant Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Clams", - "value": "Pleasant Fancy Canned Clams" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Oysters", - "value": "Pleasant Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Sardines", - "value": "Pleasant Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Pleasant Large Canned Shrimp", - "value": "Pleasant Large Canned Shrimp" - }, - { - "selected": false, - "label": "Pleasant Noodle Soup", - "value": "Pleasant Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Regular Ramen Soup", - "value": "Pleasant Regular Ramen Soup" - }, - { - "selected": false, - "label": "Pleasant Rice Soup", - "value": "Pleasant Rice Soup" - }, - { - "selected": false, - "label": "Pleasant Turkey Noodle Soup", - "value": "Pleasant Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Vegetable Soup", - "value": "Pleasant Vegetable Soup" - }, - { - "selected": false, - "label": "Portsmouth Chablis Wine", - "value": "Portsmouth Chablis Wine" - }, - { - "selected": false, - "label": "Portsmouth Chardonnay", - "value": "Portsmouth Chardonnay" - }, - { - "selected": false, - "label": "Portsmouth Chardonnay Wine", - "value": "Portsmouth Chardonnay Wine" - }, - { - "selected": false, - "label": "Portsmouth Imported Beer", - "value": "Portsmouth Imported Beer" - }, - { - "selected": false, - "label": "Portsmouth Light Beer", - "value": "Portsmouth Light Beer" - }, - { - "selected": false, - "label": "Portsmouth Light Wine", - "value": "Portsmouth Light Wine" - }, - { - "selected": false, - "label": "Portsmouth Merlot Wine", - "value": "Portsmouth Merlot Wine" - }, - { - "selected": false, - "label": "Portsmouth White Zinfandel Wine", - "value": "Portsmouth White Zinfandel Wine" - }, - { - "selected": false, - "label": "Prelude Rosy Sunglasses", - "value": "Prelude Rosy Sunglasses" - }, - { - "selected": false, - "label": "Queen City Map", - "value": "Queen City Map" - }, - { - "selected": false, - "label": "Queen Eyeglass Screwdriver", - "value": "Queen Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Quick Extra Lean Hamburger", - "value": "Quick Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Quick Seasoned Hamburger", - "value": "Quick Seasoned Hamburger" - }, - { - "selected": false, - "label": "Radius Corn Puffs", - "value": "Radius Corn Puffs" - }, - { - "selected": false, - "label": "Radius Grits", - "value": "Radius Grits" - }, - { - "selected": false, - "label": "Radius Oatmeal", - "value": "Radius Oatmeal" - }, - { - "selected": false, - "label": "Radius Wheat Puffs", - "value": "Radius Wheat Puffs" - }, - { - "selected": false, - "label": "Red Spade Beef Bologna", - "value": "Red Spade Beef Bologna" - }, - { - "selected": false, - "label": "Red Spade Chicken Hot Dogs", - "value": "Red Spade Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Red Spade Cole Slaw", - "value": "Red Spade Cole Slaw" - }, - { - "selected": false, - "label": "Red Spade Corned Beef", - "value": "Red Spade Corned Beef" - }, - { - "selected": false, - "label": "Red Spade Foot-Long Hot Dogs", - "value": "Red Spade Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Red Spade Low Fat Bologna", - "value": "Red Spade Low Fat Bologna" - }, - { - "selected": false, - "label": "Red Spade Low Fat Cole Slaw", - "value": "Red Spade Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Red Spade Pimento Loaf", - "value": "Red Spade Pimento Loaf" - }, - { - "selected": false, - "label": "Red Spade Potato Salad", - "value": "Red Spade Potato Salad" - }, - { - "selected": false, - "label": "Red Spade Roasted Chicken", - "value": "Red Spade Roasted Chicken" - }, - { - "selected": false, - "label": "Red Spade Sliced Chicken", - "value": "Red Spade Sliced Chicken" - }, - { - "selected": false, - "label": "Red Spade Sliced Ham", - "value": "Red Spade Sliced Ham" - }, - { - "selected": false, - "label": "Red Spade Sliced Turkey", - "value": "Red Spade Sliced Turkey" - }, - { - "selected": false, - "label": "Red Spade Turkey Hot Dogs", - "value": "Red Spade Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Red Wing 100 Watt Lightbulb", - "value": "Red Wing 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 25 Watt Lightbulb", - "value": "Red Wing 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 60 Watt Lightbulb", - "value": "Red Wing 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 75 Watt Lightbulb", - "value": "Red Wing 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing AAA-Size Batteries", - "value": "Red Wing AAA-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing AA-Size Batteries", - "value": "Red Wing AA-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing Bees Wax Candles", - "value": "Red Wing Bees Wax Candles" - }, - { - "selected": false, - "label": "Red Wing Copper Cleaner", - "value": "Red Wing Copper Cleaner" - }, - { - "selected": false, - "label": "Red Wing Copper Pot Scrubber", - "value": "Red Wing Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Red Wing Counter Cleaner", - "value": "Red Wing Counter Cleaner" - }, - { - "selected": false, - "label": "Red Wing C-Size Batteries", - "value": "Red Wing C-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing D-Size Batteries", - "value": "Red Wing D-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing Economy Toilet Brush", - "value": "Red Wing Economy Toilet Brush" - }, - { - "selected": false, - "label": "Red Wing Frying Pan", - "value": "Red Wing Frying Pan" - }, - { - "selected": false, - "label": "Red Wing Glass Cleaner", - "value": "Red Wing Glass Cleaner" - }, - { - "selected": false, - "label": "Red Wing Large Sponge", - "value": "Red Wing Large Sponge" - }, - { - "selected": false, - "label": "Red Wing Paper Cups", - "value": "Red Wing Paper Cups" - }, - { - "selected": false, - "label": "Red Wing Paper Plates", - "value": "Red Wing Paper Plates" - }, - { - "selected": false, - "label": "Red Wing Paper Towels", - "value": "Red Wing Paper Towels" - }, - { - "selected": false, - "label": "Red Wing Plastic Forks", - "value": "Red Wing Plastic Forks" - }, - { - "selected": false, - "label": "Red Wing Plastic Knives", - "value": "Red Wing Plastic Knives" - }, - { - "selected": false, - "label": "Red Wing Plastic Spoons", - "value": "Red Wing Plastic Spoons" - }, - { - "selected": false, - "label": "Red Wing Room Freshener", - "value": "Red Wing Room Freshener" - }, - { - "selected": false, - "label": "Red Wing Scented Tissue", - "value": "Red Wing Scented Tissue" - }, - { - "selected": false, - "label": "Red Wing Scented Toilet Tissue", - "value": "Red Wing Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Red Wing Scissors", - "value": "Red Wing Scissors" - }, - { - "selected": false, - "label": "Red Wing Screw Driver", - "value": "Red Wing Screw Driver" - }, - { - "selected": false, - "label": "Red Wing Silver Cleaner", - "value": "Red Wing Silver Cleaner" - }, - { - "selected": false, - "label": "Red Wing Soft Napkins", - "value": "Red Wing Soft Napkins" - }, - { - "selected": false, - "label": "Red Wing Tissues", - "value": "Red Wing Tissues" - }, - { - "selected": false, - "label": "Red Wing Toilet Bowl Cleaner", - "value": "Red Wing Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Red Wing Toilet Paper", - "value": "Red Wing Toilet Paper" - }, - { - "selected": false, - "label": "Robust Monthly Auto Magazine", - "value": "Robust Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Computer Magazine", - "value": "Robust Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Fashion Magazine", - "value": "Robust Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Home Magazine", - "value": "Robust Monthly Home Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Sports Magazine", - "value": "Robust Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Shady Lake Manicotti", - "value": "Shady Lake Manicotti" - }, - { - "selected": false, - "label": "Shady Lake Ravioli", - "value": "Shady Lake Ravioli" - }, - { - "selected": false, - "label": "Shady Lake Rice Medly", - "value": "Shady Lake Rice Medly" - }, - { - "selected": false, - "label": "Shady Lake Spaghetti", - "value": "Shady Lake Spaghetti" - }, - { - "selected": false, - "label": "Shady Lake Thai Rice", - "value": "Shady Lake Thai Rice" - }, - { - "selected": false, - "label": "Ship Shape Extra Lean Hamburger", - "value": "Ship Shape Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Ship Shape Seasoned Hamburger", - "value": "Ship Shape Seasoned Hamburger" - }, - { - "selected": false, - "label": "Skinner Apple Drink", - "value": "Skinner Apple Drink" - }, - { - "selected": false, - "label": "Skinner Apple Juice", - "value": "Skinner Apple Juice" - }, - { - "selected": false, - "label": "Skinner Berry Juice", - "value": "Skinner Berry Juice" - }, - { - "selected": false, - "label": "Skinner Cola", - "value": "Skinner Cola" - }, - { - "selected": false, - "label": "Skinner Cranberry Juice", - "value": "Skinner Cranberry Juice" - }, - { - "selected": false, - "label": "Skinner Cream Soda", - "value": "Skinner Cream Soda" - }, - { - "selected": false, - "label": "Skinner Diet Cola", - "value": "Skinner Diet Cola" - }, - { - "selected": false, - "label": "Skinner Diet Soda", - "value": "Skinner Diet Soda" - }, - { - "selected": false, - "label": "Skinner Mango Drink", - "value": "Skinner Mango Drink" - }, - { - "selected": false, - "label": "Skinner Orange Juice", - "value": "Skinner Orange Juice" - }, - { - "selected": false, - "label": "Skinner Strawberry Drink", - "value": "Skinner Strawberry Drink" - }, - { - "selected": false, - "label": "Special Corn Puffs", - "value": "Special Corn Puffs" - }, - { - "selected": false, - "label": "Special Grits", - "value": "Special Grits" - }, - { - "selected": false, - "label": "Special Oatmeal", - "value": "Special Oatmeal" - }, - { - "selected": false, - "label": "Special Wheat Puffs", - "value": "Special Wheat Puffs" - }, - { - "selected": false, - "label": "Sphinx Bagels", - "value": "Sphinx Bagels" - }, - { - "selected": false, - "label": "Sphinx Blueberry Muffins", - "value": "Sphinx Blueberry Muffins" - }, - { - "selected": false, - "label": "Sphinx Cranberry Muffins", - "value": "Sphinx Cranberry Muffins" - }, - { - "selected": false, - "label": "Sphinx English Muffins", - "value": "Sphinx English Muffins" - }, - { - "selected": false, - "label": "Sphinx Muffins", - "value": "Sphinx Muffins" - }, - { - "selected": false, - "label": "Sphinx Pumpernickel Bread", - "value": "Sphinx Pumpernickel Bread" - }, - { - "selected": false, - "label": "Sphinx Rye Bread", - "value": "Sphinx Rye Bread" - }, - { - "selected": false, - "label": "Sphinx Wheat Bread", - "value": "Sphinx Wheat Bread" - }, - { - "selected": false, - "label": "Sphinx White Bread", - "value": "Sphinx White Bread" - }, - { - "selected": false, - "label": "Steady 200 MG Acetominifen", - "value": "Steady 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Steady 200 MG Ibuprofen", - "value": "Steady 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Steady Angled Toothbrush", - "value": "Steady Angled Toothbrush" - }, - { - "selected": false, - "label": "Steady Apricot Shampoo", - "value": "Steady Apricot Shampoo" - }, - { - "selected": false, - "label": "Steady Buffered Aspirin", - "value": "Steady Buffered Aspirin" - }, - { - "selected": false, - "label": "Steady Childrens Aspirin", - "value": "Steady Childrens Aspirin" - }, - { - "selected": false, - "label": "Steady Childrens Cold Remedy", - "value": "Steady Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Steady Conditioning Shampoo", - "value": "Steady Conditioning Shampoo" - }, - { - "selected": false, - "label": "Steady Deodorant", - "value": "Steady Deodorant" - }, - { - "selected": false, - "label": "Steady Dishwasher Detergent", - "value": "Steady Dishwasher Detergent" - }, - { - "selected": false, - "label": "Steady Extra Moisture Shampoo", - "value": "Steady Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Steady HCL Nasal Spray", - "value": "Steady HCL Nasal Spray" - }, - { - "selected": false, - "label": "Steady Laundry Detergent", - "value": "Steady Laundry Detergent" - }, - { - "selected": false, - "label": "Steady Mint Mouthwash", - "value": "Steady Mint Mouthwash" - }, - { - "selected": false, - "label": "Steady Multi-Symptom Cold Remedy", - "value": "Steady Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Steady Silky Smooth Hair Conditioner", - "value": "Steady Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Steady Tartar Control Toothpaste", - "value": "Steady Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Steady Toothpaste", - "value": "Steady Toothpaste" - }, - { - "selected": false, - "label": "Steady Whitening Toothpast", - "value": "Steady Whitening Toothpast" - }, - { - "selected": false, - "label": "Sunset 100 Watt Lightbulb", - "value": "Sunset 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 25 Watt Lightbulb", - "value": "Sunset 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 60 Watt Lightbulb", - "value": "Sunset 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 75 Watt Lightbulb", - "value": "Sunset 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset AAA-Size Batteries", - "value": "Sunset AAA-Size Batteries" - }, - { - "selected": false, - "label": "Sunset AA-Size Batteries", - "value": "Sunset AA-Size Batteries" - }, - { - "selected": false, - "label": "Sunset Bees Wax Candles", - "value": "Sunset Bees Wax Candles" - }, - { - "selected": false, - "label": "Sunset Copper Cleaner", - "value": "Sunset Copper Cleaner" - }, - { - "selected": false, - "label": "Sunset Copper Pot Scrubber", - "value": "Sunset Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Sunset Counter Cleaner", - "value": "Sunset Counter Cleaner" - }, - { - "selected": false, - "label": "Sunset C-Size Batteries", - "value": "Sunset C-Size Batteries" - }, - { - "selected": false, - "label": "Sunset D-Size Batteries", - "value": "Sunset D-Size Batteries" - }, - { - "selected": false, - "label": "Sunset Economy Toilet Brush", - "value": "Sunset Economy Toilet Brush" - }, - { - "selected": false, - "label": "Sunset Frying Pan", - "value": "Sunset Frying Pan" - }, - { - "selected": false, - "label": "Sunset Glass Cleaner", - "value": "Sunset Glass Cleaner" - }, - { - "selected": false, - "label": "Sunset Large Sponge", - "value": "Sunset Large Sponge" - }, - { - "selected": false, - "label": "Sunset Paper Cups", - "value": "Sunset Paper Cups" - }, - { - "selected": false, - "label": "Sunset Paper Plates", - "value": "Sunset Paper Plates" - }, - { - "selected": false, - "label": "Sunset Paper Towels", - "value": "Sunset Paper Towels" - }, - { - "selected": false, - "label": "Sunset Plastic Forks", - "value": "Sunset Plastic Forks" - }, - { - "selected": false, - "label": "Sunset Plastic Knives", - "value": "Sunset Plastic Knives" - }, - { - "selected": false, - "label": "Sunset Plastic Spoons", - "value": "Sunset Plastic Spoons" - }, - { - "selected": false, - "label": "Sunset Room Freshener", - "value": "Sunset Room Freshener" - }, - { - "selected": false, - "label": "Sunset Scented Tissue", - "value": "Sunset Scented Tissue" - }, - { - "selected": false, - "label": "Sunset Scented Toilet Tissue", - "value": "Sunset Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Sunset Scissors", - "value": "Sunset Scissors" - }, - { - "selected": false, - "label": "Sunset Screw Driver", - "value": "Sunset Screw Driver" - }, - { - "selected": false, - "label": "Sunset Silver Cleaner", - "value": "Sunset Silver Cleaner" - }, - { - "selected": false, - "label": "Sunset Soft Napkins", - "value": "Sunset Soft Napkins" - }, - { - "selected": false, - "label": "Sunset Tissues", - "value": "Sunset Tissues" - }, - { - "selected": false, - "label": "Sunset Toilet Bowl Cleaner", - "value": "Sunset Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Sunset Toilet Paper", - "value": "Sunset Toilet Paper" - }, - { - "selected": false, - "label": "Super Apple Butter", - "value": "Super Apple Butter" - }, - { - "selected": false, - "label": "Super Apple Jam", - "value": "Super Apple Jam" - }, - { - "selected": false, - "label": "Super Apple Jelly", - "value": "Super Apple Jelly" - }, - { - "selected": false, - "label": "Super Apple Preserves", - "value": "Super Apple Preserves" - }, - { - "selected": false, - "label": "Super Brown Sugar", - "value": "Super Brown Sugar" - }, - { - "selected": false, - "label": "Super Canola Oil", - "value": "Super Canola Oil" - }, - { - "selected": false, - "label": "Super Chunky Peanut Butter", - "value": "Super Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Super Columbian Coffee", - "value": "Super Columbian Coffee" - }, - { - "selected": false, - "label": "Super Corn Oil", - "value": "Super Corn Oil" - }, - { - "selected": false, - "label": "Super Creamy Peanut Butter", - "value": "Super Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Super Decaf Coffee", - "value": "Super Decaf Coffee" - }, - { - "selected": false, - "label": "Super Extra Chunky Peanut Butter", - "value": "Super Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Super French Roast Coffee", - "value": "Super French Roast Coffee" - }, - { - "selected": false, - "label": "Super Grape Jam", - "value": "Super Grape Jam" - }, - { - "selected": false, - "label": "Super Grape Jelly", - "value": "Super Grape Jelly" - }, - { - "selected": false, - "label": "Super Grape Preserves", - "value": "Super Grape Preserves" - }, - { - "selected": false, - "label": "Super Hot Chocolate", - "value": "Super Hot Chocolate" - }, - { - "selected": false, - "label": "Super Low Fat Apple Butter", - "value": "Super Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Super Oregano", - "value": "Super Oregano" - }, - { - "selected": false, - "label": "Super Pepper", - "value": "Super Pepper" - }, - { - "selected": false, - "label": "Super Regular Coffee", - "value": "Super Regular Coffee" - }, - { - "selected": false, - "label": "Super Salt", - "value": "Super Salt" - }, - { - "selected": false, - "label": "Super Sesame Oil", - "value": "Super Sesame Oil" - }, - { - "selected": false, - "label": "Super Strawberry Jam", - "value": "Super Strawberry Jam" - }, - { - "selected": false, - "label": "Super Strawberry Jelly", - "value": "Super Strawberry Jelly" - }, - { - "selected": false, - "label": "Super Strawberry Preserves", - "value": "Super Strawberry Preserves" - }, - { - "selected": false, - "label": "Super Tomato Sauce", - "value": "Super Tomato Sauce" - }, - { - "selected": false, - "label": "Super Vegetable Oil", - "value": "Super Vegetable Oil" - }, - { - "selected": false, - "label": "Super White Sugar", - "value": "Super White Sugar" - }, - { - "selected": false, - "label": "Swell Canned Mixed Fruit", - "value": "Swell Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Swell Canned Peaches", - "value": "Swell Canned Peaches" - }, - { - "selected": false, - "label": "Symphony Rosy Sunglasses", - "value": "Symphony Rosy Sunglasses" - }, - { - "selected": false, - "label": "Tell Tale Almonds", - "value": "Tell Tale Almonds" - }, - { - "selected": false, - "label": "Tell Tale Asparagus", - "value": "Tell Tale Asparagus" - }, - { - "selected": false, - "label": "Tell Tale Baby Onion", - "value": "Tell Tale Baby Onion" - }, - { - "selected": false, - "label": "Tell Tale Beets", - "value": "Tell Tale Beets" - }, - { - "selected": false, - "label": "Tell Tale Broccoli", - "value": "Tell Tale Broccoli" - }, - { - "selected": false, - "label": "Tell Tale Canned Peanuts", - "value": "Tell Tale Canned Peanuts" - }, - { - "selected": false, - "label": "Tell Tale Cantelope", - "value": "Tell Tale Cantelope" - }, - { - "selected": false, - "label": "Tell Tale Cauliflower", - "value": "Tell Tale Cauliflower" - }, - { - "selected": false, - "label": "Tell Tale Corn on the Cob", - "value": "Tell Tale Corn on the Cob" - }, - { - "selected": false, - "label": "Tell Tale Dried Mushrooms", - "value": "Tell Tale Dried Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale Elephant Garlic", - "value": "Tell Tale Elephant Garlic" - }, - { - "selected": false, - "label": "Tell Tale Fancy Plums", - "value": "Tell Tale Fancy Plums" - }, - { - "selected": false, - "label": "Tell Tale Firm Tofu", - "value": "Tell Tale Firm Tofu" - }, - { - "selected": false, - "label": "Tell Tale Fresh Lima Beans", - "value": "Tell Tale Fresh Lima Beans" - }, - { - "selected": false, - "label": "Tell Tale Fuji Apples", - "value": "Tell Tale Fuji Apples" - }, - { - "selected": false, - "label": "Tell Tale Garlic", - "value": "Tell Tale Garlic" - }, - { - "selected": false, - "label": "Tell Tale Golden Delcious Apples", - "value": "Tell Tale Golden Delcious Apples" - }, - { - "selected": false, - "label": "Tell Tale Green Pepper", - "value": "Tell Tale Green Pepper" - }, - { - "selected": false, - "label": "Tell Tale Honey Dew", - "value": "Tell Tale Honey Dew" - }, - { - "selected": false, - "label": "Tell Tale Lemons", - "value": "Tell Tale Lemons" - }, - { - "selected": false, - "label": "Tell Tale Lettuce", - "value": "Tell Tale Lettuce" - }, - { - "selected": false, - "label": "Tell Tale Limes", - "value": "Tell Tale Limes" - }, - { - "selected": false, - "label": "Tell Tale Macintosh Apples", - "value": "Tell Tale Macintosh Apples" - }, - { - "selected": false, - "label": "Tell Tale Mandarin Oranges", - "value": "Tell Tale Mandarin Oranges" - }, - { - "selected": false, - "label": "Tell Tale Mixed Nuts", - "value": "Tell Tale Mixed Nuts" - }, - { - "selected": false, - "label": "Tell Tale Mushrooms", - "value": "Tell Tale Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale New Potatos", - "value": "Tell Tale New Potatos" - }, - { - "selected": false, - "label": "Tell Tale Onions", - "value": "Tell Tale Onions" - }, - { - "selected": false, - "label": "Tell Tale Oranges", - "value": "Tell Tale Oranges" - }, - { - "selected": false, - "label": "Tell Tale Party Nuts", - "value": "Tell Tale Party Nuts" - }, - { - "selected": false, - "label": "Tell Tale Peaches", - "value": "Tell Tale Peaches" - }, - { - "selected": false, - "label": "Tell Tale Plums", - "value": "Tell Tale Plums" - }, - { - "selected": false, - "label": "Tell Tale Potatos", - "value": "Tell Tale Potatos" - }, - { - "selected": false, - "label": "Tell Tale Prepared Salad", - "value": "Tell Tale Prepared Salad" - }, - { - "selected": false, - "label": "Tell Tale Red Delcious Apples", - "value": "Tell Tale Red Delcious Apples" - }, - { - "selected": false, - "label": "Tell Tale Red Pepper", - "value": "Tell Tale Red Pepper" - }, - { - "selected": false, - "label": "Tell Tale Shitake Mushrooms", - "value": "Tell Tale Shitake Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale Squash", - "value": "Tell Tale Squash" - }, - { - "selected": false, - "label": "Tell Tale Summer Squash", - "value": "Tell Tale Summer Squash" - }, - { - "selected": false, - "label": "Tell Tale Sweet Onion", - "value": "Tell Tale Sweet Onion" - }, - { - "selected": false, - "label": "Tell Tale Sweet Peas", - "value": "Tell Tale Sweet Peas" - }, - { - "selected": false, - "label": "Tell Tale Tangerines", - "value": "Tell Tale Tangerines" - }, - { - "selected": false, - "label": "Tell Tale Tomatos", - "value": "Tell Tale Tomatos" - }, - { - "selected": false, - "label": "Tell Tale Walnuts", - "value": "Tell Tale Walnuts" - }, - { - "selected": false, - "label": "Thresher Bubble Gum", - "value": "Thresher Bubble Gum" - }, - { - "selected": false, - "label": "Thresher Malted Milk Balls", - "value": "Thresher Malted Milk Balls" - }, - { - "selected": false, - "label": "Thresher Mint Chocolate Bar", - "value": "Thresher Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Thresher Mints", - "value": "Thresher Mints" - }, - { - "selected": false, - "label": "Thresher Semi-Sweet Chocolate Bar", - "value": "Thresher Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Thresher Spicy Mints", - "value": "Thresher Spicy Mints" - }, - { - "selected": false, - "label": "Thresher Tasty Candy Bar", - "value": "Thresher Tasty Candy Bar" - }, - { - "selected": false, - "label": "Thresher White Chocolate Bar", - "value": "Thresher White Chocolate Bar" - }, - { - "selected": false, - "label": "Tip Top Lox", - "value": "Tip Top Lox" - }, - { - "selected": false, - "label": "Tip Top Scallops", - "value": "Tip Top Scallops" - }, - { - "selected": false, - "label": "Token Apple Drink", - "value": "Token Apple Drink" - }, - { - "selected": false, - "label": "Token Apple Juice", - "value": "Token Apple Juice" - }, - { - "selected": false, - "label": "Token Berry Juice", - "value": "Token Berry Juice" - }, - { - "selected": false, - "label": "Token Cola", - "value": "Token Cola" - }, - { - "selected": false, - "label": "Token Cranberry Juice", - "value": "Token Cranberry Juice" - }, - { - "selected": false, - "label": "Token Cream Soda", - "value": "Token Cream Soda" - }, - { - "selected": false, - "label": "Token Diet Cola", - "value": "Token Diet Cola" - }, - { - "selected": false, - "label": "Token Diet Soda", - "value": "Token Diet Soda" - }, - { - "selected": false, - "label": "Token Mango Drink", - "value": "Token Mango Drink" - }, - { - "selected": false, - "label": "Token Orange Juice", - "value": "Token Orange Juice" - }, - { - "selected": false, - "label": "Token Strawberry Drink", - "value": "Token Strawberry Drink" - }, - { - "selected": false, - "label": "Top Measure Chablis Wine", - "value": "Top Measure Chablis Wine" - }, - { - "selected": false, - "label": "Top Measure Chardonnay", - "value": "Top Measure Chardonnay" - }, - { - "selected": false, - "label": "Top Measure Chardonnay Wine", - "value": "Top Measure Chardonnay Wine" - }, - { - "selected": false, - "label": "Top Measure Imported Beer", - "value": "Top Measure Imported Beer" - }, - { - "selected": false, - "label": "Top Measure Light Beer", - "value": "Top Measure Light Beer" - }, - { - "selected": false, - "label": "Top Measure Light Wine", - "value": "Top Measure Light Wine" - }, - { - "selected": false, - "label": "Top Measure Merlot Wine", - "value": "Top Measure Merlot Wine" - }, - { - "selected": false, - "label": "Top Measure White Zinfandel Wine", - "value": "Top Measure White Zinfandel Wine" - }, - { - "selected": false, - "label": "Toretti Rosy Sunglasses", - "value": "Toretti Rosy Sunglasses" - }, - { - "selected": false, - "label": "Toucan Canned Mixed Fruit", - "value": "Toucan Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Toucan Canned Peaches", - "value": "Toucan Canned Peaches" - }, - { - "selected": false, - "label": "Tri-State Almonds", - "value": "Tri-State Almonds" - }, - { - "selected": false, - "label": "Tri-State Asparagus", - "value": "Tri-State Asparagus" - }, - { - "selected": false, - "label": "Tri-State Baby Onion", - "value": "Tri-State Baby Onion" - }, - { - "selected": false, - "label": "Tri-State Beets", - "value": "Tri-State Beets" - }, - { - "selected": false, - "label": "Tri-State Broccoli", - "value": "Tri-State Broccoli" - }, - { - "selected": false, - "label": "Tri-State Canned Peanuts", - "value": "Tri-State Canned Peanuts" - }, - { - "selected": false, - "label": "Tri-State Cantelope", - "value": "Tri-State Cantelope" - }, - { - "selected": false, - "label": "Tri-State Cauliflower", - "value": "Tri-State Cauliflower" - }, - { - "selected": false, - "label": "Tri-State Corn on the Cob", - "value": "Tri-State Corn on the Cob" - }, - { - "selected": false, - "label": "Tri-State Dried Mushrooms", - "value": "Tri-State Dried Mushrooms" - }, - { - "selected": false, - "label": "Tri-State Elephant Garlic", - "value": "Tri-State Elephant Garlic" - }, - { - "selected": false, - "label": "Tri-State Fancy Plums", - "value": "Tri-State Fancy Plums" - }, - { - "selected": false, - "label": "Tri-State Firm Tofu", - "value": "Tri-State Firm Tofu" - }, - { - "selected": false, - "label": "Tri-State Fresh Lima Beans", - "value": "Tri-State Fresh Lima Beans" - }, - { - "selected": false, - "label": "Tri-State Fuji Apples", - "value": "Tri-State Fuji Apples" - }, - { - "selected": false, - "label": "Tri-State Garlic", - "value": "Tri-State Garlic" - }, - { - "selected": false, - "label": "Tri-State Golden Delcious Apples", - "value": "Tri-State Golden Delcious Apples" - }, - { - "selected": false, - "label": "Tri-State Green Pepper", - "value": "Tri-State Green Pepper" - }, - { - "selected": false, - "label": "Tri-State Honey Dew", - "value": "Tri-State Honey Dew" - }, - { - "selected": false, - "label": "Tri-State Lemons", - "value": "Tri-State Lemons" - }, - { - "selected": false, - "label": "Tri-State Lettuce", - "value": "Tri-State Lettuce" - }, - { - "selected": false, - "label": "Tri-State Limes", - "value": "Tri-State Limes" - }, - { - "selected": false, - "label": "Tri-State Macintosh Apples", - "value": "Tri-State Macintosh Apples" - }, - { - "selected": false, - "label": "Tri-State Mandarin Oranges", - "value": "Tri-State Mandarin Oranges" - }, - { - "selected": false, - "label": "Tri-State Mixed Nuts", - "value": "Tri-State Mixed Nuts" - }, - { - "selected": false, - "label": "Tri-State Mushrooms", - "value": "Tri-State Mushrooms" - }, - { - "selected": false, - "label": "Tri-State New Potatos", - "value": "Tri-State New Potatos" - }, - { - "selected": false, - "label": "Tri-State Onions", - "value": "Tri-State Onions" - }, - { - "selected": false, - "label": "Tri-State Oranges", - "value": "Tri-State Oranges" - }, - { - "selected": false, - "label": "Tri-State Party Nuts", - "value": "Tri-State Party Nuts" - }, - { - "selected": false, - "label": "Tri-State Peaches", - "value": "Tri-State Peaches" - }, - { - "selected": false, - "label": "Tri-State Plums", - "value": "Tri-State Plums" - }, - { - "selected": false, - "label": "Tri-State Potatos", - "value": "Tri-State Potatos" - }, - { - "selected": false, - "label": "Tri-State Prepared Salad", - "value": "Tri-State Prepared Salad" - }, - { - "selected": false, - "label": "Tri-State Red Delcious Apples", - "value": "Tri-State Red Delcious Apples" - }, - { - "selected": false, - "label": "Tri-State Red Pepper", - "value": "Tri-State Red Pepper" - }, - { - "selected": false, - "label": "Tri-State Shitake Mushrooms", - "value": "Tri-State Shitake Mushrooms" - }, - { - "selected": false, - "label": "Tri-State Squash", - "value": "Tri-State Squash" - }, - { - "selected": false, - "label": "Tri-State Summer Squash", - "value": "Tri-State Summer Squash" - }, - { - "selected": false, - "label": "Tri-State Sweet Onion", - "value": "Tri-State Sweet Onion" - }, - { - "selected": false, - "label": "Tri-State Sweet Peas", - "value": "Tri-State Sweet Peas" - }, - { - "selected": false, - "label": "Tri-State Tangerines", - "value": "Tri-State Tangerines" - }, - { - "selected": false, - "label": "Tri-State Tomatos", - "value": "Tri-State Tomatos" - }, - { - "selected": false, - "label": "Tri-State Walnuts", - "value": "Tri-State Walnuts" - }, - { - "selected": false, - "label": "Urban Egg Substitute", - "value": "Urban Egg Substitute" - }, - { - "selected": false, - "label": "Urban Large Brown Eggs", - "value": "Urban Large Brown Eggs" - }, - { - "selected": false, - "label": "Urban Large Eggs", - "value": "Urban Large Eggs" - }, - { - "selected": false, - "label": "Urban Small Brown Eggs", - "value": "Urban Small Brown Eggs" - }, - { - "selected": false, - "label": "Urban Small Eggs", - "value": "Urban Small Eggs" - }, - { - "selected": false, - "label": "Walrus Chablis Wine", - "value": "Walrus Chablis Wine" - }, - { - "selected": false, - "label": "Walrus Chardonnay", - "value": "Walrus Chardonnay" - }, - { - "selected": false, - "label": "Walrus Chardonnay Wine", - "value": "Walrus Chardonnay Wine" - }, - { - "selected": false, - "label": "Walrus Imported Beer", - "value": "Walrus Imported Beer" - }, - { - "selected": false, - "label": "Walrus Light Beer", - "value": "Walrus Light Beer" - }, - { - "selected": false, - "label": "Walrus Light Wine", - "value": "Walrus Light Wine" - }, - { - "selected": false, - "label": "Walrus Merlot Wine", - "value": "Walrus Merlot Wine" - }, - { - "selected": false, - "label": "Walrus White Zinfandel Wine", - "value": "Walrus White Zinfandel Wine" - }, - { - "selected": false, - "label": "Washington Apple Drink", - "value": "Washington Apple Drink" - }, - { - "selected": false, - "label": "Washington Apple Juice", - "value": "Washington Apple Juice" - }, - { - "selected": false, - "label": "Washington Berry Juice", - "value": "Washington Berry Juice" - }, - { - "selected": false, - "label": "Washington Cola", - "value": "Washington Cola" - }, - { - "selected": false, - "label": "Washington Cranberry Juice", - "value": "Washington Cranberry Juice" - }, - { - "selected": false, - "label": "Washington Cream Soda", - "value": "Washington Cream Soda" - }, - { - "selected": false, - "label": "Washington Diet Cola", - "value": "Washington Diet Cola" - }, - { - "selected": false, - "label": "Washington Diet Soda", - "value": "Washington Diet Soda" - }, - { - "selected": false, - "label": "Washington Mango Drink", - "value": "Washington Mango Drink" - }, - { - "selected": false, - "label": "Washington Orange Juice", - "value": "Washington Orange Juice" - }, - { - "selected": false, - "label": "Washington Strawberry Drink", - "value": "Washington Strawberry Drink" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/client/src/test/resources/controls_04.json b/client/src/test/resources/controls_04.json deleted file mode 100644 index 6843aba1..00000000 --- a/client/src/test/resources/controls_04.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "inputControl": [ - { - "id": "sales__store__store_contact__store_country_1", - "type": "singleSelect", - "uri": "repo:/public/Samples/Ad_Hoc_Views/04__Product_Results_by_Store_Type_files/sales__store__store_contact__store_country_1", - "label": "Country", - "mandatory": false, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "state": { - "uri": "/public/Samples/Ad_Hoc_Views/04__Product_Results_by_Store_Type_files/sales__store__store_contact__store_country_1", - "id": "sales__store__store_contact__store_country_1", - "options": [ - { - "selected": false, - "label": "---", - "value": "~NOTHING~" - }, - { - "selected": true, - "label": "Canada", - "value": "Canada" - }, - { - "selected": false, - "label": "Mexico", - "value": "Mexico" - }, - { - "selected": false, - "label": "USA", - "value": "USA" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/client/src/test/resources/controls_06.json b/client/src/test/resources/controls_06.json deleted file mode 100644 index 98164829..00000000 --- a/client/src/test/resources/controls_06.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "inputControl": [ - { - "id": "ProductFamily", - "description": "Product Family Multi-Select", - "type": "multiSelect", - "uri": "repo:/public/Samples/Resources/Input_Controls/ProductFamily", - "label": "ProductFamily", - "mandatory": true, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "validationRules": [ - { - "mandatoryValidationRule": { - "errorMessage": "This field is mandatory so you must enter data." - } - } - ], - "state": { - "uri": "/public/Samples/Resources/Input_Controls/ProductFamily", - "id": "ProductFamily", - "options": [ - { - "selected": true, - "label": "Drink", - "value": "Drink" - }, - { - "selected": true, - "label": "Food", - "value": "Food" - }, - { - "selected": true, - "label": "Non-Consumable", - "value": "Non-Consumable" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/client/src/test/resources/controls_07.json b/client/src/test/resources/controls_07.json deleted file mode 100644 index 98164829..00000000 --- a/client/src/test/resources/controls_07.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "inputControl": [ - { - "id": "ProductFamily", - "description": "Product Family Multi-Select", - "type": "multiSelect", - "uri": "repo:/public/Samples/Resources/Input_Controls/ProductFamily", - "label": "ProductFamily", - "mandatory": true, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "validationRules": [ - { - "mandatoryValidationRule": { - "errorMessage": "This field is mandatory so you must enter data." - } - } - ], - "state": { - "uri": "/public/Samples/Resources/Input_Controls/ProductFamily", - "id": "ProductFamily", - "options": [ - { - "selected": true, - "label": "Drink", - "value": "Drink" - }, - { - "selected": true, - "label": "Food", - "value": "Food" - }, - { - "selected": true, - "label": "Non-Consumable", - "value": "Non-Consumable" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/client/src/test/resources/input_control_states_list.json b/client/src/test/resources/input_control_states_list.json deleted file mode 100644 index abb1b76a..00000000 --- a/client/src/test/resources/input_control_states_list.json +++ /dev/null @@ -1,7847 +0,0 @@ -{ - "inputControlState": [ - { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__product_name_1", - "id": "sales__product__product_name_1", - "options": [ - { - "selected": false, - "label": "ADJ Rosy Sunglasses", - "value": "ADJ Rosy Sunglasses" - }, - { - "selected": false, - "label": "Akron City Map", - "value": "Akron City Map" - }, - { - "selected": false, - "label": "Akron Eyeglass Screwdriver", - "value": "Akron Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "American Beef Bologna", - "value": "American Beef Bologna" - }, - { - "selected": false, - "label": "American Chicken Hot Dogs", - "value": "American Chicken Hot Dogs" - }, - { - "selected": false, - "label": "American Cole Slaw", - "value": "American Cole Slaw" - }, - { - "selected": false, - "label": "American Corned Beef", - "value": "American Corned Beef" - }, - { - "selected": false, - "label": "American Foot-Long Hot Dogs", - "value": "American Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "American Low Fat Bologna", - "value": "American Low Fat Bologna" - }, - { - "selected": false, - "label": "American Low Fat Cole Slaw", - "value": "American Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "American Pimento Loaf", - "value": "American Pimento Loaf" - }, - { - "selected": false, - "label": "American Potato Salad", - "value": "American Potato Salad" - }, - { - "selected": false, - "label": "American Roasted Chicken", - "value": "American Roasted Chicken" - }, - { - "selected": false, - "label": "American Sliced Chicken", - "value": "American Sliced Chicken" - }, - { - "selected": false, - "label": "American Sliced Ham", - "value": "American Sliced Ham" - }, - { - "selected": false, - "label": "American Sliced Turkey", - "value": "American Sliced Turkey" - }, - { - "selected": false, - "label": "American Turkey Hot Dogs", - "value": "American Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Amigo Lox", - "value": "Amigo Lox" - }, - { - "selected": false, - "label": "Amigo Scallops", - "value": "Amigo Scallops" - }, - { - "selected": false, - "label": "Applause Canned Mixed Fruit", - "value": "Applause Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Applause Canned Peaches", - "value": "Applause Canned Peaches" - }, - { - "selected": false, - "label": "Atomic Bubble Gum", - "value": "Atomic Bubble Gum" - }, - { - "selected": false, - "label": "Atomic Malted Milk Balls", - "value": "Atomic Malted Milk Balls" - }, - { - "selected": false, - "label": "Atomic Mint Chocolate Bar", - "value": "Atomic Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Atomic Mints", - "value": "Atomic Mints" - }, - { - "selected": false, - "label": "Atomic Semi-Sweet Chocolate Bar", - "value": "Atomic Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Atomic Spicy Mints", - "value": "Atomic Spicy Mints" - }, - { - "selected": false, - "label": "Atomic Tasty Candy Bar", - "value": "Atomic Tasty Candy Bar" - }, - { - "selected": false, - "label": "Atomic White Chocolate Bar", - "value": "Atomic White Chocolate Bar" - }, - { - "selected": false, - "label": "BBB Best Apple Butter", - "value": "BBB Best Apple Butter" - }, - { - "selected": false, - "label": "BBB Best Apple Jam", - "value": "BBB Best Apple Jam" - }, - { - "selected": false, - "label": "BBB Best Apple Jelly", - "value": "BBB Best Apple Jelly" - }, - { - "selected": false, - "label": "BBB Best Apple Preserves", - "value": "BBB Best Apple Preserves" - }, - { - "selected": false, - "label": "BBB Best Brown Sugar", - "value": "BBB Best Brown Sugar" - }, - { - "selected": false, - "label": "BBB Best Canola Oil", - "value": "BBB Best Canola Oil" - }, - { - "selected": false, - "label": "BBB Best Chunky Peanut Butter", - "value": "BBB Best Chunky Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best Columbian Coffee", - "value": "BBB Best Columbian Coffee" - }, - { - "selected": false, - "label": "BBB Best Corn Oil", - "value": "BBB Best Corn Oil" - }, - { - "selected": false, - "label": "BBB Best Creamy Peanut Butter", - "value": "BBB Best Creamy Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best Decaf Coffee", - "value": "BBB Best Decaf Coffee" - }, - { - "selected": false, - "label": "BBB Best Extra Chunky Peanut Butter", - "value": "BBB Best Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "BBB Best French Roast Coffee", - "value": "BBB Best French Roast Coffee" - }, - { - "selected": false, - "label": "BBB Best Grape Jam", - "value": "BBB Best Grape Jam" - }, - { - "selected": false, - "label": "BBB Best Grape Jelly", - "value": "BBB Best Grape Jelly" - }, - { - "selected": false, - "label": "BBB Best Grape Preserves", - "value": "BBB Best Grape Preserves" - }, - { - "selected": false, - "label": "BBB Best Hot Chocolate", - "value": "BBB Best Hot Chocolate" - }, - { - "selected": false, - "label": "BBB Best Low Fat Apple Butter", - "value": "BBB Best Low Fat Apple Butter" - }, - { - "selected": false, - "label": "BBB Best Oregano", - "value": "BBB Best Oregano" - }, - { - "selected": false, - "label": "BBB Best Pepper", - "value": "BBB Best Pepper" - }, - { - "selected": false, - "label": "BBB Best Regular Coffee", - "value": "BBB Best Regular Coffee" - }, - { - "selected": false, - "label": "BBB Best Salt", - "value": "BBB Best Salt" - }, - { - "selected": false, - "label": "BBB Best Sesame Oil", - "value": "BBB Best Sesame Oil" - }, - { - "selected": false, - "label": "BBB Best Strawberry Jam", - "value": "BBB Best Strawberry Jam" - }, - { - "selected": false, - "label": "BBB Best Strawberry Jelly", - "value": "BBB Best Strawberry Jelly" - }, - { - "selected": false, - "label": "BBB Best Strawberry Preserves", - "value": "BBB Best Strawberry Preserves" - }, - { - "selected": false, - "label": "BBB Best Tomato Sauce", - "value": "BBB Best Tomato Sauce" - }, - { - "selected": false, - "label": "BBB Best Vegetable Oil", - "value": "BBB Best Vegetable Oil" - }, - { - "selected": false, - "label": "BBB Best White Sugar", - "value": "BBB Best White Sugar" - }, - { - "selected": false, - "label": "Best Choice Apple Fruit Roll", - "value": "Best Choice Apple Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Avocado Dip", - "value": "Best Choice Avocado Dip" - }, - { - "selected": false, - "label": "Best Choice BBQ Potato Chips", - "value": "Best Choice BBQ Potato Chips" - }, - { - "selected": false, - "label": "Best Choice Beef Jerky", - "value": "Best Choice Beef Jerky" - }, - { - "selected": false, - "label": "Best Choice Buttered Popcorn", - "value": "Best Choice Buttered Popcorn" - }, - { - "selected": false, - "label": "Best Choice Cheese Crackers", - "value": "Best Choice Cheese Crackers" - }, - { - "selected": false, - "label": "Best Choice Cheese Dip", - "value": "Best Choice Cheese Dip" - }, - { - "selected": false, - "label": "Best Choice Chocolate Chip Cookies", - "value": "Best Choice Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Best Choice Chocolate Donuts", - "value": "Best Choice Chocolate Donuts" - }, - { - "selected": false, - "label": "Best Choice Corn Chips", - "value": "Best Choice Corn Chips" - }, - { - "selected": false, - "label": "Best Choice Dried Apples", - "value": "Best Choice Dried Apples" - }, - { - "selected": false, - "label": "Best Choice Dried Apricots", - "value": "Best Choice Dried Apricots" - }, - { - "selected": false, - "label": "Best Choice Dried Dates", - "value": "Best Choice Dried Dates" - }, - { - "selected": false, - "label": "Best Choice Fondue Mix", - "value": "Best Choice Fondue Mix" - }, - { - "selected": false, - "label": "Best Choice Frosted Cookies", - "value": "Best Choice Frosted Cookies" - }, - { - "selected": false, - "label": "Best Choice Frosted Donuts", - "value": "Best Choice Frosted Donuts" - }, - { - "selected": false, - "label": "Best Choice Fudge Brownies", - "value": "Best Choice Fudge Brownies" - }, - { - "selected": false, - "label": "Best Choice Fudge Cookies", - "value": "Best Choice Fudge Cookies" - }, - { - "selected": false, - "label": "Best Choice Golden Raisins", - "value": "Best Choice Golden Raisins" - }, - { - "selected": false, - "label": "Best Choice Graham Crackers", - "value": "Best Choice Graham Crackers" - }, - { - "selected": false, - "label": "Best Choice Grape Fruit Roll", - "value": "Best Choice Grape Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Lemon Cookies", - "value": "Best Choice Lemon Cookies" - }, - { - "selected": false, - "label": "Best Choice Low Fat BBQ Chips", - "value": "Best Choice Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Best Choice Low Fat Chips", - "value": "Best Choice Low Fat Chips" - }, - { - "selected": false, - "label": "Best Choice Low Fat Cookies", - "value": "Best Choice Low Fat Cookies" - }, - { - "selected": false, - "label": "Best Choice Low Fat Popcorn", - "value": "Best Choice Low Fat Popcorn" - }, - { - "selected": false, - "label": "Best Choice Mini Donuts", - "value": "Best Choice Mini Donuts" - }, - { - "selected": false, - "label": "Best Choice No Salt Popcorn", - "value": "Best Choice No Salt Popcorn" - }, - { - "selected": false, - "label": "Best Choice Potato Chips", - "value": "Best Choice Potato Chips" - }, - { - "selected": false, - "label": "Best Choice Raisins", - "value": "Best Choice Raisins" - }, - { - "selected": false, - "label": "Best Choice Raspberry Fruit Roll", - "value": "Best Choice Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Salsa Dip", - "value": "Best Choice Salsa Dip" - }, - { - "selected": false, - "label": "Best Choice Salted Pretzels", - "value": "Best Choice Salted Pretzels" - }, - { - "selected": false, - "label": "Best Choice Sesame Crackers", - "value": "Best Choice Sesame Crackers" - }, - { - "selected": false, - "label": "Best Choice Strawberry Fruit Roll", - "value": "Best Choice Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Best Choice Sugar Cookies", - "value": "Best Choice Sugar Cookies" - }, - { - "selected": false, - "label": "Best Corn Puffs", - "value": "Best Corn Puffs" - }, - { - "selected": false, - "label": "Best Grits", - "value": "Best Grits" - }, - { - "selected": false, - "label": "Best Oatmeal", - "value": "Best Oatmeal" - }, - { - "selected": false, - "label": "Best Wheat Puffs", - "value": "Best Wheat Puffs" - }, - { - "selected": false, - "label": "Better Beef Soup", - "value": "Better Beef Soup" - }, - { - "selected": false, - "label": "Better Canned Beets", - "value": "Better Canned Beets" - }, - { - "selected": false, - "label": "Better Canned Peas", - "value": "Better Canned Peas" - }, - { - "selected": false, - "label": "Better Canned String Beans", - "value": "Better Canned String Beans" - }, - { - "selected": false, - "label": "Better Canned Tomatos", - "value": "Better Canned Tomatos" - }, - { - "selected": false, - "label": "Better Canned Tuna in Oil", - "value": "Better Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Better Canned Tuna in Water", - "value": "Better Canned Tuna in Water" - }, - { - "selected": false, - "label": "Better Canned Yams", - "value": "Better Canned Yams" - }, - { - "selected": false, - "label": "Better Chicken Noodle Soup", - "value": "Better Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Better Chicken Ramen Soup", - "value": "Better Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Better Chicken Soup", - "value": "Better Chicken Soup" - }, - { - "selected": false, - "label": "Better Creamed Corn", - "value": "Better Creamed Corn" - }, - { - "selected": false, - "label": "Better Fancy Canned Anchovies", - "value": "Better Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Better Fancy Canned Clams", - "value": "Better Fancy Canned Clams" - }, - { - "selected": false, - "label": "Better Fancy Canned Oysters", - "value": "Better Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Better Fancy Canned Sardines", - "value": "Better Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Better Large Canned Shrimp", - "value": "Better Large Canned Shrimp" - }, - { - "selected": false, - "label": "Better Noodle Soup", - "value": "Better Noodle Soup" - }, - { - "selected": false, - "label": "Better Regular Ramen Soup", - "value": "Better Regular Ramen Soup" - }, - { - "selected": false, - "label": "Better Rice Soup", - "value": "Better Rice Soup" - }, - { - "selected": false, - "label": "Better Turkey Noodle Soup", - "value": "Better Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Better Vegetable Soup", - "value": "Better Vegetable Soup" - }, - { - "selected": false, - "label": "Big City Canned Mixed Fruit", - "value": "Big City Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Big City Canned Peaches", - "value": "Big City Canned Peaches" - }, - { - "selected": false, - "label": "Big Time Apple Cinnamon Waffles", - "value": "Big Time Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Big Time Beef TV Dinner", - "value": "Big Time Beef TV Dinner" - }, - { - "selected": false, - "label": "Big Time Blueberry Waffles", - "value": "Big Time Blueberry Waffles" - }, - { - "selected": false, - "label": "Big Time Chicken TV Dinner", - "value": "Big Time Chicken TV Dinner" - }, - { - "selected": false, - "label": "Big Time Fajita French Fries", - "value": "Big Time Fajita French Fries" - }, - { - "selected": false, - "label": "Big Time Frozen Broccoli", - "value": "Big Time Frozen Broccoli" - }, - { - "selected": false, - "label": "Big Time Frozen Carrots", - "value": "Big Time Frozen Carrots" - }, - { - "selected": false, - "label": "Big Time Frozen Cauliflower", - "value": "Big Time Frozen Cauliflower" - }, - { - "selected": false, - "label": "Big Time Frozen Cheese Pizza", - "value": "Big Time Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Breast", - "value": "Big Time Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Thighs", - "value": "Big Time Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Big Time Frozen Chicken Wings", - "value": "Big Time Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Big Time Frozen Corn", - "value": "Big Time Frozen Corn" - }, - { - "selected": false, - "label": "Big Time Frozen Mushroom Pizza", - "value": "Big Time Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Pancakes", - "value": "Big Time Frozen Pancakes" - }, - { - "selected": false, - "label": "Big Time Frozen Peas", - "value": "Big Time Frozen Peas" - }, - { - "selected": false, - "label": "Big Time Frozen Pepperoni Pizza", - "value": "Big Time Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Big Time Frozen Sausage Pizza", - "value": "Big Time Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Big Time Grape Popsicles", - "value": "Big Time Grape Popsicles" - }, - { - "selected": false, - "label": "Big Time Home Style French Fries", - "value": "Big Time Home Style French Fries" - }, - { - "selected": false, - "label": "Big Time Ice Cream", - "value": "Big Time Ice Cream" - }, - { - "selected": false, - "label": "Big Time Ice Cream Sandwich", - "value": "Big Time Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Big Time Lemon Popsicles", - "value": "Big Time Lemon Popsicles" - }, - { - "selected": false, - "label": "Big Time Lime Popsicles", - "value": "Big Time Lime Popsicles" - }, - { - "selected": false, - "label": "Big Time Low Fat French Fries", - "value": "Big Time Low Fat French Fries" - }, - { - "selected": false, - "label": "Big Time Low Fat Waffles", - "value": "Big Time Low Fat Waffles" - }, - { - "selected": false, - "label": "Big Time Orange Popsicles", - "value": "Big Time Orange Popsicles" - }, - { - "selected": false, - "label": "Big Time Pancake Mix", - "value": "Big Time Pancake Mix" - }, - { - "selected": false, - "label": "Big Time Popsicles", - "value": "Big Time Popsicles" - }, - { - "selected": false, - "label": "Big Time Turkey TV Dinner", - "value": "Big Time Turkey TV Dinner" - }, - { - "selected": false, - "label": "Big Time Waffles", - "value": "Big Time Waffles" - }, - { - "selected": false, - "label": "Bird Call 200 MG Acetominifen", - "value": "Bird Call 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Bird Call 200 MG Ibuprofen", - "value": "Bird Call 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Bird Call Angled Toothbrush", - "value": "Bird Call Angled Toothbrush" - }, - { - "selected": false, - "label": "Bird Call Apricot Shampoo", - "value": "Bird Call Apricot Shampoo" - }, - { - "selected": false, - "label": "Bird Call Buffered Aspirin", - "value": "Bird Call Buffered Aspirin" - }, - { - "selected": false, - "label": "Bird Call Childrens Aspirin", - "value": "Bird Call Childrens Aspirin" - }, - { - "selected": false, - "label": "Bird Call Childrens Cold Remedy", - "value": "Bird Call Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Bird Call Conditioning Shampoo", - "value": "Bird Call Conditioning Shampoo" - }, - { - "selected": false, - "label": "Bird Call Deodorant", - "value": "Bird Call Deodorant" - }, - { - "selected": false, - "label": "Bird Call Dishwasher Detergent", - "value": "Bird Call Dishwasher Detergent" - }, - { - "selected": false, - "label": "Bird Call Extra Moisture Shampoo", - "value": "Bird Call Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Bird Call HCL Nasal Spray", - "value": "Bird Call HCL Nasal Spray" - }, - { - "selected": false, - "label": "Bird Call Laundry Detergent", - "value": "Bird Call Laundry Detergent" - }, - { - "selected": false, - "label": "Bird Call Mint Mouthwash", - "value": "Bird Call Mint Mouthwash" - }, - { - "selected": false, - "label": "Bird Call Multi-Symptom Cold Remedy", - "value": "Bird Call Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Bird Call Silky Smooth Hair Conditioner", - "value": "Bird Call Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Bird Call Tartar Control Toothpaste", - "value": "Bird Call Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Bird Call Toothpaste", - "value": "Bird Call Toothpaste" - }, - { - "selected": false, - "label": "Bird Call Whitening Toothpast", - "value": "Bird Call Whitening Toothpast" - }, - { - "selected": false, - "label": "Black Tie City Map", - "value": "Black Tie City Map" - }, - { - "selected": false, - "label": "Black Tie Eyeglass Screwdriver", - "value": "Black Tie Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Blue Label Beef Soup", - "value": "Blue Label Beef Soup" - }, - { - "selected": false, - "label": "Blue Label Canned Beets", - "value": "Blue Label Canned Beets" - }, - { - "selected": false, - "label": "Blue Label Canned Peas", - "value": "Blue Label Canned Peas" - }, - { - "selected": false, - "label": "Blue Label Canned String Beans", - "value": "Blue Label Canned String Beans" - }, - { - "selected": false, - "label": "Blue Label Canned Tomatos", - "value": "Blue Label Canned Tomatos" - }, - { - "selected": false, - "label": "Blue Label Canned Tuna in Oil", - "value": "Blue Label Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Blue Label Canned Tuna in Water", - "value": "Blue Label Canned Tuna in Water" - }, - { - "selected": false, - "label": "Blue Label Canned Yams", - "value": "Blue Label Canned Yams" - }, - { - "selected": false, - "label": "Blue Label Chicken Noodle Soup", - "value": "Blue Label Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Chicken Ramen Soup", - "value": "Blue Label Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Blue Label Chicken Soup", - "value": "Blue Label Chicken Soup" - }, - { - "selected": false, - "label": "Blue Label Creamed Corn", - "value": "Blue Label Creamed Corn" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Anchovies", - "value": "Blue Label Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Clams", - "value": "Blue Label Fancy Canned Clams" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Oysters", - "value": "Blue Label Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Blue Label Fancy Canned Sardines", - "value": "Blue Label Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Blue Label Large Canned Shrimp", - "value": "Blue Label Large Canned Shrimp" - }, - { - "selected": false, - "label": "Blue Label Noodle Soup", - "value": "Blue Label Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Regular Ramen Soup", - "value": "Blue Label Regular Ramen Soup" - }, - { - "selected": false, - "label": "Blue Label Rice Soup", - "value": "Blue Label Rice Soup" - }, - { - "selected": false, - "label": "Blue Label Turkey Noodle Soup", - "value": "Blue Label Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Blue Label Vegetable Soup", - "value": "Blue Label Vegetable Soup" - }, - { - "selected": false, - "label": "Blue Medal Egg Substitute", - "value": "Blue Medal Egg Substitute" - }, - { - "selected": false, - "label": "Blue Medal Large Brown Eggs", - "value": "Blue Medal Large Brown Eggs" - }, - { - "selected": false, - "label": "Blue Medal Large Eggs", - "value": "Blue Medal Large Eggs" - }, - { - "selected": false, - "label": "Blue Medal Small Brown Eggs", - "value": "Blue Medal Small Brown Eggs" - }, - { - "selected": false, - "label": "Blue Medal Small Eggs", - "value": "Blue Medal Small Eggs" - }, - { - "selected": false, - "label": "Booker 1% Milk", - "value": "Booker 1% Milk" - }, - { - "selected": false, - "label": "Booker 2% Milk", - "value": "Booker 2% Milk" - }, - { - "selected": false, - "label": "Booker Blueberry Yogurt", - "value": "Booker Blueberry Yogurt" - }, - { - "selected": false, - "label": "Booker Buttermilk", - "value": "Booker Buttermilk" - }, - { - "selected": false, - "label": "Booker Cheese Spread", - "value": "Booker Cheese Spread" - }, - { - "selected": false, - "label": "Booker Chocolate Milk", - "value": "Booker Chocolate Milk" - }, - { - "selected": false, - "label": "Booker Havarti Cheese", - "value": "Booker Havarti Cheese" - }, - { - "selected": false, - "label": "Booker Head Cheese", - "value": "Booker Head Cheese" - }, - { - "selected": false, - "label": "Booker Jack Cheese", - "value": "Booker Jack Cheese" - }, - { - "selected": false, - "label": "Booker Large Curd Cottage Cheese", - "value": "Booker Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Booker Low Fat Cottage Cheese", - "value": "Booker Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Booker Low Fat Sour Cream", - "value": "Booker Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Booker Low Fat String Cheese", - "value": "Booker Low Fat String Cheese" - }, - { - "selected": false, - "label": "Booker Mild Cheddar Cheese", - "value": "Booker Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Booker Muenster Cheese", - "value": "Booker Muenster Cheese" - }, - { - "selected": false, - "label": "Booker Sharp Cheddar Cheese", - "value": "Booker Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Booker Sour Cream", - "value": "Booker Sour Cream" - }, - { - "selected": false, - "label": "Booker Strawberry Yogurt", - "value": "Booker Strawberry Yogurt" - }, - { - "selected": false, - "label": "Booker String Cheese", - "value": "Booker String Cheese" - }, - { - "selected": false, - "label": "Booker Whole Milk", - "value": "Booker Whole Milk" - }, - { - "selected": false, - "label": "Bravo Beef Soup", - "value": "Bravo Beef Soup" - }, - { - "selected": false, - "label": "Bravo Canned Beets", - "value": "Bravo Canned Beets" - }, - { - "selected": false, - "label": "Bravo Canned Peas", - "value": "Bravo Canned Peas" - }, - { - "selected": false, - "label": "Bravo Canned String Beans", - "value": "Bravo Canned String Beans" - }, - { - "selected": false, - "label": "Bravo Canned Tomatos", - "value": "Bravo Canned Tomatos" - }, - { - "selected": false, - "label": "Bravo Canned Tuna in Oil", - "value": "Bravo Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Bravo Canned Tuna in Water", - "value": "Bravo Canned Tuna in Water" - }, - { - "selected": false, - "label": "Bravo Canned Yams", - "value": "Bravo Canned Yams" - }, - { - "selected": false, - "label": "Bravo Chicken Noodle Soup", - "value": "Bravo Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Chicken Ramen Soup", - "value": "Bravo Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Bravo Chicken Soup", - "value": "Bravo Chicken Soup" - }, - { - "selected": false, - "label": "Bravo Creamed Corn", - "value": "Bravo Creamed Corn" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Anchovies", - "value": "Bravo Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Clams", - "value": "Bravo Fancy Canned Clams" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Oysters", - "value": "Bravo Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Bravo Fancy Canned Sardines", - "value": "Bravo Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Bravo Large Canned Shrimp", - "value": "Bravo Large Canned Shrimp" - }, - { - "selected": false, - "label": "Bravo Noodle Soup", - "value": "Bravo Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Regular Ramen Soup", - "value": "Bravo Regular Ramen Soup" - }, - { - "selected": false, - "label": "Bravo Rice Soup", - "value": "Bravo Rice Soup" - }, - { - "selected": false, - "label": "Bravo Turkey Noodle Soup", - "value": "Bravo Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Bravo Vegetable Soup", - "value": "Bravo Vegetable Soup" - }, - { - "selected": false, - "label": "Carlson 1% Milk", - "value": "Carlson 1% Milk" - }, - { - "selected": false, - "label": "Carlson 2% Milk", - "value": "Carlson 2% Milk" - }, - { - "selected": false, - "label": "Carlson Blueberry Yogurt", - "value": "Carlson Blueberry Yogurt" - }, - { - "selected": false, - "label": "Carlson Buttermilk", - "value": "Carlson Buttermilk" - }, - { - "selected": false, - "label": "Carlson Cheese Spread", - "value": "Carlson Cheese Spread" - }, - { - "selected": false, - "label": "Carlson Chocolate Milk", - "value": "Carlson Chocolate Milk" - }, - { - "selected": false, - "label": "Carlson Havarti Cheese", - "value": "Carlson Havarti Cheese" - }, - { - "selected": false, - "label": "Carlson Head Cheese", - "value": "Carlson Head Cheese" - }, - { - "selected": false, - "label": "Carlson Jack Cheese", - "value": "Carlson Jack Cheese" - }, - { - "selected": false, - "label": "Carlson Large Curd Cottage Cheese", - "value": "Carlson Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Carlson Low Fat Cottage Cheese", - "value": "Carlson Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Carlson Low Fat Sour Cream", - "value": "Carlson Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Carlson Low Fat String Cheese", - "value": "Carlson Low Fat String Cheese" - }, - { - "selected": false, - "label": "Carlson Mild Cheddar Cheese", - "value": "Carlson Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Carlson Muenster Cheese", - "value": "Carlson Muenster Cheese" - }, - { - "selected": false, - "label": "Carlson Sharp Cheddar Cheese", - "value": "Carlson Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Carlson Sour Cream", - "value": "Carlson Sour Cream" - }, - { - "selected": false, - "label": "Carlson Strawberry Yogurt", - "value": "Carlson Strawberry Yogurt" - }, - { - "selected": false, - "label": "Carlson String Cheese", - "value": "Carlson String Cheese" - }, - { - "selected": false, - "label": "Carlson Whole Milk", - "value": "Carlson Whole Milk" - }, - { - "selected": false, - "label": "Carrington Apple Cinnamon Waffles", - "value": "Carrington Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Carrington Beef TV Dinner", - "value": "Carrington Beef TV Dinner" - }, - { - "selected": false, - "label": "Carrington Blueberry Waffles", - "value": "Carrington Blueberry Waffles" - }, - { - "selected": false, - "label": "Carrington Chicken TV Dinner", - "value": "Carrington Chicken TV Dinner" - }, - { - "selected": false, - "label": "Carrington Fajita French Fries", - "value": "Carrington Fajita French Fries" - }, - { - "selected": false, - "label": "Carrington Frozen Broccoli", - "value": "Carrington Frozen Broccoli" - }, - { - "selected": false, - "label": "Carrington Frozen Carrots", - "value": "Carrington Frozen Carrots" - }, - { - "selected": false, - "label": "Carrington Frozen Cauliflower", - "value": "Carrington Frozen Cauliflower" - }, - { - "selected": false, - "label": "Carrington Frozen Cheese Pizza", - "value": "Carrington Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Breast", - "value": "Carrington Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Thighs", - "value": "Carrington Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Carrington Frozen Chicken Wings", - "value": "Carrington Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Carrington Frozen Corn", - "value": "Carrington Frozen Corn" - }, - { - "selected": false, - "label": "Carrington Frozen Mushroom Pizza", - "value": "Carrington Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Pancakes", - "value": "Carrington Frozen Pancakes" - }, - { - "selected": false, - "label": "Carrington Frozen Peas", - "value": "Carrington Frozen Peas" - }, - { - "selected": false, - "label": "Carrington Frozen Pepperoni Pizza", - "value": "Carrington Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Carrington Frozen Sausage Pizza", - "value": "Carrington Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Carrington Grape Popsicles", - "value": "Carrington Grape Popsicles" - }, - { - "selected": false, - "label": "Carrington Home Style French Fries", - "value": "Carrington Home Style French Fries" - }, - { - "selected": false, - "label": "Carrington Ice Cream", - "value": "Carrington Ice Cream" - }, - { - "selected": false, - "label": "Carrington Ice Cream Sandwich", - "value": "Carrington Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Carrington Lemon Popsicles", - "value": "Carrington Lemon Popsicles" - }, - { - "selected": false, - "label": "Carrington Lime Popsicles", - "value": "Carrington Lime Popsicles" - }, - { - "selected": false, - "label": "Carrington Low Fat French Fries", - "value": "Carrington Low Fat French Fries" - }, - { - "selected": false, - "label": "Carrington Low Fat Waffles", - "value": "Carrington Low Fat Waffles" - }, - { - "selected": false, - "label": "Carrington Orange Popsicles", - "value": "Carrington Orange Popsicles" - }, - { - "selected": false, - "label": "Carrington Pancake Mix", - "value": "Carrington Pancake Mix" - }, - { - "selected": false, - "label": "Carrington Popsicles", - "value": "Carrington Popsicles" - }, - { - "selected": false, - "label": "Carrington Turkey TV Dinner", - "value": "Carrington Turkey TV Dinner" - }, - { - "selected": false, - "label": "Carrington Waffles", - "value": "Carrington Waffles" - }, - { - "selected": false, - "label": "CDR Apple Butter", - "value": "CDR Apple Butter" - }, - { - "selected": false, - "label": "CDR Apple Jam", - "value": "CDR Apple Jam" - }, - { - "selected": false, - "label": "CDR Apple Jelly", - "value": "CDR Apple Jelly" - }, - { - "selected": false, - "label": "CDR Apple Preserves", - "value": "CDR Apple Preserves" - }, - { - "selected": false, - "label": "CDR Brown Sugar", - "value": "CDR Brown Sugar" - }, - { - "selected": false, - "label": "CDR Canola Oil", - "value": "CDR Canola Oil" - }, - { - "selected": false, - "label": "CDR Chunky Peanut Butter", - "value": "CDR Chunky Peanut Butter" - }, - { - "selected": false, - "label": "CDR Columbian Coffee", - "value": "CDR Columbian Coffee" - }, - { - "selected": false, - "label": "CDR Corn Oil", - "value": "CDR Corn Oil" - }, - { - "selected": false, - "label": "CDR Creamy Peanut Butter", - "value": "CDR Creamy Peanut Butter" - }, - { - "selected": false, - "label": "CDR Decaf Coffee", - "value": "CDR Decaf Coffee" - }, - { - "selected": false, - "label": "CDR Extra Chunky Peanut Butter", - "value": "CDR Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "CDR French Roast Coffee", - "value": "CDR French Roast Coffee" - }, - { - "selected": false, - "label": "CDR Grape Jam", - "value": "CDR Grape Jam" - }, - { - "selected": false, - "label": "CDR Grape Jelly", - "value": "CDR Grape Jelly" - }, - { - "selected": false, - "label": "CDR Grape Preserves", - "value": "CDR Grape Preserves" - }, - { - "selected": false, - "label": "CDR Hot Chocolate", - "value": "CDR Hot Chocolate" - }, - { - "selected": false, - "label": "CDR Low Fat Apple Butter", - "value": "CDR Low Fat Apple Butter" - }, - { - "selected": false, - "label": "CDR Oregano", - "value": "CDR Oregano" - }, - { - "selected": false, - "label": "CDR Pepper", - "value": "CDR Pepper" - }, - { - "selected": false, - "label": "CDR Regular Coffee", - "value": "CDR Regular Coffee" - }, - { - "selected": false, - "label": "CDR Salt", - "value": "CDR Salt" - }, - { - "selected": false, - "label": "CDR Sesame Oil", - "value": "CDR Sesame Oil" - }, - { - "selected": false, - "label": "CDR Strawberry Jam", - "value": "CDR Strawberry Jam" - }, - { - "selected": false, - "label": "CDR Strawberry Jelly", - "value": "CDR Strawberry Jelly" - }, - { - "selected": false, - "label": "CDR Strawberry Preserves", - "value": "CDR Strawberry Preserves" - }, - { - "selected": false, - "label": "CDR Tomato Sauce", - "value": "CDR Tomato Sauce" - }, - { - "selected": false, - "label": "CDR Vegetable Oil", - "value": "CDR Vegetable Oil" - }, - { - "selected": false, - "label": "CDR White Sugar", - "value": "CDR White Sugar" - }, - { - "selected": false, - "label": "Choice Bubble Gum", - "value": "Choice Bubble Gum" - }, - { - "selected": false, - "label": "Choice Malted Milk Balls", - "value": "Choice Malted Milk Balls" - }, - { - "selected": false, - "label": "Choice Mint Chocolate Bar", - "value": "Choice Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Choice Mints", - "value": "Choice Mints" - }, - { - "selected": false, - "label": "Choice Semi-Sweet Chocolate Bar", - "value": "Choice Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Choice Spicy Mints", - "value": "Choice Spicy Mints" - }, - { - "selected": false, - "label": "Choice Tasty Candy Bar", - "value": "Choice Tasty Candy Bar" - }, - { - "selected": false, - "label": "Choice White Chocolate Bar", - "value": "Choice White Chocolate Bar" - }, - { - "selected": false, - "label": "Club 1% Milk", - "value": "Club 1% Milk" - }, - { - "selected": false, - "label": "Club 2% Milk", - "value": "Club 2% Milk" - }, - { - "selected": false, - "label": "Club Blueberry Yogurt", - "value": "Club Blueberry Yogurt" - }, - { - "selected": false, - "label": "Club Buttermilk", - "value": "Club Buttermilk" - }, - { - "selected": false, - "label": "Club Cheese Spread", - "value": "Club Cheese Spread" - }, - { - "selected": false, - "label": "Club Chocolate Milk", - "value": "Club Chocolate Milk" - }, - { - "selected": false, - "label": "Club Havarti Cheese", - "value": "Club Havarti Cheese" - }, - { - "selected": false, - "label": "Club Head Cheese", - "value": "Club Head Cheese" - }, - { - "selected": false, - "label": "Club Jack Cheese", - "value": "Club Jack Cheese" - }, - { - "selected": false, - "label": "Club Large Curd Cottage Cheese", - "value": "Club Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Club Low Fat Cottage Cheese", - "value": "Club Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Club Low Fat Sour Cream", - "value": "Club Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Club Low Fat String Cheese", - "value": "Club Low Fat String Cheese" - }, - { - "selected": false, - "label": "Club Mild Cheddar Cheese", - "value": "Club Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Club Muenster Cheese", - "value": "Club Muenster Cheese" - }, - { - "selected": false, - "label": "Club Sharp Cheddar Cheese", - "value": "Club Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Club Sour Cream", - "value": "Club Sour Cream" - }, - { - "selected": false, - "label": "Club Strawberry Yogurt", - "value": "Club Strawberry Yogurt" - }, - { - "selected": false, - "label": "Club String Cheese", - "value": "Club String Cheese" - }, - { - "selected": false, - "label": "Club Whole Milk", - "value": "Club Whole Milk" - }, - { - "selected": false, - "label": "Colony Bagels", - "value": "Colony Bagels" - }, - { - "selected": false, - "label": "Colony Blueberry Muffins", - "value": "Colony Blueberry Muffins" - }, - { - "selected": false, - "label": "Colony Cranberry Muffins", - "value": "Colony Cranberry Muffins" - }, - { - "selected": false, - "label": "Colony English Muffins", - "value": "Colony English Muffins" - }, - { - "selected": false, - "label": "Colony Muffins", - "value": "Colony Muffins" - }, - { - "selected": false, - "label": "Colony Pumpernickel Bread", - "value": "Colony Pumpernickel Bread" - }, - { - "selected": false, - "label": "Colony Rye Bread", - "value": "Colony Rye Bread" - }, - { - "selected": false, - "label": "Colony Wheat Bread", - "value": "Colony Wheat Bread" - }, - { - "selected": false, - "label": "Colony White Bread", - "value": "Colony White Bread" - }, - { - "selected": false, - "label": "Colossal Manicotti", - "value": "Colossal Manicotti" - }, - { - "selected": false, - "label": "Colossal Ravioli", - "value": "Colossal Ravioli" - }, - { - "selected": false, - "label": "Colossal Rice Medly", - "value": "Colossal Rice Medly" - }, - { - "selected": false, - "label": "Colossal Spaghetti", - "value": "Colossal Spaghetti" - }, - { - "selected": false, - "label": "Colossal Thai Rice", - "value": "Colossal Thai Rice" - }, - { - "selected": false, - "label": "Consolidated 200 MG Acetominifen", - "value": "Consolidated 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Consolidated 200 MG Ibuprofen", - "value": "Consolidated 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Consolidated Angled Toothbrush", - "value": "Consolidated Angled Toothbrush" - }, - { - "selected": false, - "label": "Consolidated Apricot Shampoo", - "value": "Consolidated Apricot Shampoo" - }, - { - "selected": false, - "label": "Consolidated Buffered Aspirin", - "value": "Consolidated Buffered Aspirin" - }, - { - "selected": false, - "label": "Consolidated Childrens Aspirin", - "value": "Consolidated Childrens Aspirin" - }, - { - "selected": false, - "label": "Consolidated Childrens Cold Remedy", - "value": "Consolidated Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Consolidated Conditioning Shampoo", - "value": "Consolidated Conditioning Shampoo" - }, - { - "selected": false, - "label": "Consolidated Deodorant", - "value": "Consolidated Deodorant" - }, - { - "selected": false, - "label": "Consolidated Dishwasher Detergent", - "value": "Consolidated Dishwasher Detergent" - }, - { - "selected": false, - "label": "Consolidated Extra Moisture Shampoo", - "value": "Consolidated Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Consolidated HCL Nasal Spray", - "value": "Consolidated HCL Nasal Spray" - }, - { - "selected": false, - "label": "Consolidated Laundry Detergent", - "value": "Consolidated Laundry Detergent" - }, - { - "selected": false, - "label": "Consolidated Mint Mouthwash", - "value": "Consolidated Mint Mouthwash" - }, - { - "selected": false, - "label": "Consolidated Multi-Symptom Cold Remedy", - "value": "Consolidated Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Consolidated Silky Smooth Hair Conditioner", - "value": "Consolidated Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Consolidated Tartar Control Toothpaste", - "value": "Consolidated Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Consolidated Toothpaste", - "value": "Consolidated Toothpaste" - }, - { - "selected": false, - "label": "Consolidated Whitening Toothpast", - "value": "Consolidated Whitening Toothpast" - }, - { - "selected": false, - "label": "Cormorant 100 Watt Lightbulb", - "value": "Cormorant 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 25 Watt Lightbulb", - "value": "Cormorant 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 60 Watt Lightbulb", - "value": "Cormorant 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant 75 Watt Lightbulb", - "value": "Cormorant 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Cormorant AAA-Size Batteries", - "value": "Cormorant AAA-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant AA-Size Batteries", - "value": "Cormorant AA-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant Bees Wax Candles", - "value": "Cormorant Bees Wax Candles" - }, - { - "selected": false, - "label": "Cormorant Copper Cleaner", - "value": "Cormorant Copper Cleaner" - }, - { - "selected": false, - "label": "Cormorant Copper Pot Scrubber", - "value": "Cormorant Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Cormorant Counter Cleaner", - "value": "Cormorant Counter Cleaner" - }, - { - "selected": false, - "label": "Cormorant C-Size Batteries", - "value": "Cormorant C-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant D-Size Batteries", - "value": "Cormorant D-Size Batteries" - }, - { - "selected": false, - "label": "Cormorant Economy Toilet Brush", - "value": "Cormorant Economy Toilet Brush" - }, - { - "selected": false, - "label": "Cormorant Frying Pan", - "value": "Cormorant Frying Pan" - }, - { - "selected": false, - "label": "Cormorant Glass Cleaner", - "value": "Cormorant Glass Cleaner" - }, - { - "selected": false, - "label": "Cormorant Large Sponge", - "value": "Cormorant Large Sponge" - }, - { - "selected": false, - "label": "Cormorant Paper Cups", - "value": "Cormorant Paper Cups" - }, - { - "selected": false, - "label": "Cormorant Paper Plates", - "value": "Cormorant Paper Plates" - }, - { - "selected": false, - "label": "Cormorant Paper Towels", - "value": "Cormorant Paper Towels" - }, - { - "selected": false, - "label": "Cormorant Plastic Forks", - "value": "Cormorant Plastic Forks" - }, - { - "selected": false, - "label": "Cormorant Plastic Knives", - "value": "Cormorant Plastic Knives" - }, - { - "selected": false, - "label": "Cormorant Plastic Spoons", - "value": "Cormorant Plastic Spoons" - }, - { - "selected": false, - "label": "Cormorant Room Freshener", - "value": "Cormorant Room Freshener" - }, - { - "selected": false, - "label": "Cormorant Scented Tissue", - "value": "Cormorant Scented Tissue" - }, - { - "selected": false, - "label": "Cormorant Scented Toilet Tissue", - "value": "Cormorant Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Cormorant Scissors", - "value": "Cormorant Scissors" - }, - { - "selected": false, - "label": "Cormorant Screw Driver", - "value": "Cormorant Screw Driver" - }, - { - "selected": false, - "label": "Cormorant Silver Cleaner", - "value": "Cormorant Silver Cleaner" - }, - { - "selected": false, - "label": "Cormorant Soft Napkins", - "value": "Cormorant Soft Napkins" - }, - { - "selected": false, - "label": "Cormorant Tissues", - "value": "Cormorant Tissues" - }, - { - "selected": false, - "label": "Cormorant Toilet Bowl Cleaner", - "value": "Cormorant Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Cormorant Toilet Paper", - "value": "Cormorant Toilet Paper" - }, - { - "selected": false, - "label": "Curlew Lox", - "value": "Curlew Lox" - }, - { - "selected": false, - "label": "Curlew Scallops", - "value": "Curlew Scallops" - }, - { - "selected": false, - "label": "Cutting Edge Beef Bologna", - "value": "Cutting Edge Beef Bologna" - }, - { - "selected": false, - "label": "Cutting Edge Chicken Hot Dogs", - "value": "Cutting Edge Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Cutting Edge Cole Slaw", - "value": "Cutting Edge Cole Slaw" - }, - { - "selected": false, - "label": "Cutting Edge Corned Beef", - "value": "Cutting Edge Corned Beef" - }, - { - "selected": false, - "label": "Cutting Edge Foot-Long Hot Dogs", - "value": "Cutting Edge Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Cutting Edge Low Fat Bologna", - "value": "Cutting Edge Low Fat Bologna" - }, - { - "selected": false, - "label": "Cutting Edge Low Fat Cole Slaw", - "value": "Cutting Edge Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Cutting Edge Pimento Loaf", - "value": "Cutting Edge Pimento Loaf" - }, - { - "selected": false, - "label": "Cutting Edge Potato Salad", - "value": "Cutting Edge Potato Salad" - }, - { - "selected": false, - "label": "Cutting Edge Roasted Chicken", - "value": "Cutting Edge Roasted Chicken" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Chicken", - "value": "Cutting Edge Sliced Chicken" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Ham", - "value": "Cutting Edge Sliced Ham" - }, - { - "selected": false, - "label": "Cutting Edge Sliced Turkey", - "value": "Cutting Edge Sliced Turkey" - }, - { - "selected": false, - "label": "Cutting Edge Turkey Hot Dogs", - "value": "Cutting Edge Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Denny 100 Watt Lightbulb", - "value": "Denny 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 25 Watt Lightbulb", - "value": "Denny 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 60 Watt Lightbulb", - "value": "Denny 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny 75 Watt Lightbulb", - "value": "Denny 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Denny AAA-Size Batteries", - "value": "Denny AAA-Size Batteries" - }, - { - "selected": false, - "label": "Denny AA-Size Batteries", - "value": "Denny AA-Size Batteries" - }, - { - "selected": false, - "label": "Denny Bees Wax Candles", - "value": "Denny Bees Wax Candles" - }, - { - "selected": false, - "label": "Denny Copper Cleaner", - "value": "Denny Copper Cleaner" - }, - { - "selected": false, - "label": "Denny Copper Pot Scrubber", - "value": "Denny Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Denny Counter Cleaner", - "value": "Denny Counter Cleaner" - }, - { - "selected": false, - "label": "Denny C-Size Batteries", - "value": "Denny C-Size Batteries" - }, - { - "selected": false, - "label": "Denny D-Size Batteries", - "value": "Denny D-Size Batteries" - }, - { - "selected": false, - "label": "Denny Economy Toilet Brush", - "value": "Denny Economy Toilet Brush" - }, - { - "selected": false, - "label": "Denny Frying Pan", - "value": "Denny Frying Pan" - }, - { - "selected": false, - "label": "Denny Glass Cleaner", - "value": "Denny Glass Cleaner" - }, - { - "selected": false, - "label": "Denny Large Sponge", - "value": "Denny Large Sponge" - }, - { - "selected": false, - "label": "Denny Paper Cups", - "value": "Denny Paper Cups" - }, - { - "selected": false, - "label": "Denny Paper Plates", - "value": "Denny Paper Plates" - }, - { - "selected": false, - "label": "Denny Paper Towels", - "value": "Denny Paper Towels" - }, - { - "selected": false, - "label": "Denny Plastic Forks", - "value": "Denny Plastic Forks" - }, - { - "selected": false, - "label": "Denny Plastic Knives", - "value": "Denny Plastic Knives" - }, - { - "selected": false, - "label": "Denny Plastic Spoons", - "value": "Denny Plastic Spoons" - }, - { - "selected": false, - "label": "Denny Room Freshener", - "value": "Denny Room Freshener" - }, - { - "selected": false, - "label": "Denny Scented Tissue", - "value": "Denny Scented Tissue" - }, - { - "selected": false, - "label": "Denny Scented Toilet Tissue", - "value": "Denny Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Denny Scissors", - "value": "Denny Scissors" - }, - { - "selected": false, - "label": "Denny Screw Driver", - "value": "Denny Screw Driver" - }, - { - "selected": false, - "label": "Denny Silver Cleaner", - "value": "Denny Silver Cleaner" - }, - { - "selected": false, - "label": "Denny Soft Napkins", - "value": "Denny Soft Napkins" - }, - { - "selected": false, - "label": "Denny Tissues", - "value": "Denny Tissues" - }, - { - "selected": false, - "label": "Denny Toilet Bowl Cleaner", - "value": "Denny Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Denny Toilet Paper", - "value": "Denny Toilet Paper" - }, - { - "selected": false, - "label": "Discover Manicotti", - "value": "Discover Manicotti" - }, - { - "selected": false, - "label": "Discover Ravioli", - "value": "Discover Ravioli" - }, - { - "selected": false, - "label": "Discover Rice Medly", - "value": "Discover Rice Medly" - }, - { - "selected": false, - "label": "Discover Spaghetti", - "value": "Discover Spaghetti" - }, - { - "selected": false, - "label": "Discover Thai Rice", - "value": "Discover Thai Rice" - }, - { - "selected": false, - "label": "Dollar Monthly Auto Magazine", - "value": "Dollar Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Computer Magazine", - "value": "Dollar Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Fashion Magazine", - "value": "Dollar Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Home Magazine", - "value": "Dollar Monthly Home Magazine" - }, - { - "selected": false, - "label": "Dollar Monthly Sports Magazine", - "value": "Dollar Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Dual City Lox", - "value": "Dual City Lox" - }, - { - "selected": false, - "label": "Dual City Scallops", - "value": "Dual City Scallops" - }, - { - "selected": false, - "label": "Ebony Almonds", - "value": "Ebony Almonds" - }, - { - "selected": false, - "label": "Ebony Asparagus", - "value": "Ebony Asparagus" - }, - { - "selected": false, - "label": "Ebony Baby Onion", - "value": "Ebony Baby Onion" - }, - { - "selected": false, - "label": "Ebony Beets", - "value": "Ebony Beets" - }, - { - "selected": false, - "label": "Ebony Broccoli", - "value": "Ebony Broccoli" - }, - { - "selected": false, - "label": "Ebony Canned Peanuts", - "value": "Ebony Canned Peanuts" - }, - { - "selected": false, - "label": "Ebony Cantelope", - "value": "Ebony Cantelope" - }, - { - "selected": false, - "label": "Ebony Cauliflower", - "value": "Ebony Cauliflower" - }, - { - "selected": false, - "label": "Ebony Corn on the Cob", - "value": "Ebony Corn on the Cob" - }, - { - "selected": false, - "label": "Ebony Dried Mushrooms", - "value": "Ebony Dried Mushrooms" - }, - { - "selected": false, - "label": "Ebony Elephant Garlic", - "value": "Ebony Elephant Garlic" - }, - { - "selected": false, - "label": "Ebony Fancy Plums", - "value": "Ebony Fancy Plums" - }, - { - "selected": false, - "label": "Ebony Firm Tofu", - "value": "Ebony Firm Tofu" - }, - { - "selected": false, - "label": "Ebony Fresh Lima Beans", - "value": "Ebony Fresh Lima Beans" - }, - { - "selected": false, - "label": "Ebony Fuji Apples", - "value": "Ebony Fuji Apples" - }, - { - "selected": false, - "label": "Ebony Garlic", - "value": "Ebony Garlic" - }, - { - "selected": false, - "label": "Ebony Golden Delcious Apples", - "value": "Ebony Golden Delcious Apples" - }, - { - "selected": false, - "label": "Ebony Green Pepper", - "value": "Ebony Green Pepper" - }, - { - "selected": false, - "label": "Ebony Honey Dew", - "value": "Ebony Honey Dew" - }, - { - "selected": false, - "label": "Ebony Lemons", - "value": "Ebony Lemons" - }, - { - "selected": false, - "label": "Ebony Lettuce", - "value": "Ebony Lettuce" - }, - { - "selected": false, - "label": "Ebony Limes", - "value": "Ebony Limes" - }, - { - "selected": false, - "label": "Ebony Macintosh Apples", - "value": "Ebony Macintosh Apples" - }, - { - "selected": false, - "label": "Ebony Mandarin Oranges", - "value": "Ebony Mandarin Oranges" - }, - { - "selected": false, - "label": "Ebony Mixed Nuts", - "value": "Ebony Mixed Nuts" - }, - { - "selected": false, - "label": "Ebony Mushrooms", - "value": "Ebony Mushrooms" - }, - { - "selected": false, - "label": "Ebony New Potatos", - "value": "Ebony New Potatos" - }, - { - "selected": false, - "label": "Ebony Onions", - "value": "Ebony Onions" - }, - { - "selected": false, - "label": "Ebony Oranges", - "value": "Ebony Oranges" - }, - { - "selected": false, - "label": "Ebony Party Nuts", - "value": "Ebony Party Nuts" - }, - { - "selected": false, - "label": "Ebony Peaches", - "value": "Ebony Peaches" - }, - { - "selected": false, - "label": "Ebony Plums", - "value": "Ebony Plums" - }, - { - "selected": false, - "label": "Ebony Potatos", - "value": "Ebony Potatos" - }, - { - "selected": false, - "label": "Ebony Prepared Salad", - "value": "Ebony Prepared Salad" - }, - { - "selected": false, - "label": "Ebony Red Delcious Apples", - "value": "Ebony Red Delcious Apples" - }, - { - "selected": false, - "label": "Ebony Red Pepper", - "value": "Ebony Red Pepper" - }, - { - "selected": false, - "label": "Ebony Shitake Mushrooms", - "value": "Ebony Shitake Mushrooms" - }, - { - "selected": false, - "label": "Ebony Squash", - "value": "Ebony Squash" - }, - { - "selected": false, - "label": "Ebony Summer Squash", - "value": "Ebony Summer Squash" - }, - { - "selected": false, - "label": "Ebony Sweet Onion", - "value": "Ebony Sweet Onion" - }, - { - "selected": false, - "label": "Ebony Sweet Peas", - "value": "Ebony Sweet Peas" - }, - { - "selected": false, - "label": "Ebony Tangerines", - "value": "Ebony Tangerines" - }, - { - "selected": false, - "label": "Ebony Tomatos", - "value": "Ebony Tomatos" - }, - { - "selected": false, - "label": "Ebony Walnuts", - "value": "Ebony Walnuts" - }, - { - "selected": false, - "label": "Even Better 1% Milk", - "value": "Even Better 1% Milk" - }, - { - "selected": false, - "label": "Even Better 2% Milk", - "value": "Even Better 2% Milk" - }, - { - "selected": false, - "label": "Even Better Blueberry Yogurt", - "value": "Even Better Blueberry Yogurt" - }, - { - "selected": false, - "label": "Even Better Buttermilk", - "value": "Even Better Buttermilk" - }, - { - "selected": false, - "label": "Even Better Cheese Spread", - "value": "Even Better Cheese Spread" - }, - { - "selected": false, - "label": "Even Better Chocolate Milk", - "value": "Even Better Chocolate Milk" - }, - { - "selected": false, - "label": "Even Better Havarti Cheese", - "value": "Even Better Havarti Cheese" - }, - { - "selected": false, - "label": "Even Better Head Cheese", - "value": "Even Better Head Cheese" - }, - { - "selected": false, - "label": "Even Better Jack Cheese", - "value": "Even Better Jack Cheese" - }, - { - "selected": false, - "label": "Even Better Large Curd Cottage Cheese", - "value": "Even Better Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Even Better Low Fat Cottage Cheese", - "value": "Even Better Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Even Better Low Fat Sour Cream", - "value": "Even Better Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Even Better Low Fat String Cheese", - "value": "Even Better Low Fat String Cheese" - }, - { - "selected": false, - "label": "Even Better Mild Cheddar Cheese", - "value": "Even Better Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Even Better Muenster Cheese", - "value": "Even Better Muenster Cheese" - }, - { - "selected": false, - "label": "Even Better Sharp Cheddar Cheese", - "value": "Even Better Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Even Better Sour Cream", - "value": "Even Better Sour Cream" - }, - { - "selected": false, - "label": "Even Better Strawberry Yogurt", - "value": "Even Better Strawberry Yogurt" - }, - { - "selected": false, - "label": "Even Better String Cheese", - "value": "Even Better String Cheese" - }, - { - "selected": false, - "label": "Even Better Whole Milk", - "value": "Even Better Whole Milk" - }, - { - "selected": false, - "label": "Excellent Apple Drink", - "value": "Excellent Apple Drink" - }, - { - "selected": false, - "label": "Excellent Apple Juice", - "value": "Excellent Apple Juice" - }, - { - "selected": false, - "label": "Excellent Berry Juice", - "value": "Excellent Berry Juice" - }, - { - "selected": false, - "label": "Excellent Cola", - "value": "Excellent Cola" - }, - { - "selected": false, - "label": "Excellent Cranberry Juice", - "value": "Excellent Cranberry Juice" - }, - { - "selected": false, - "label": "Excellent Cream Soda", - "value": "Excellent Cream Soda" - }, - { - "selected": false, - "label": "Excellent Diet Cola", - "value": "Excellent Diet Cola" - }, - { - "selected": false, - "label": "Excellent Diet Soda", - "value": "Excellent Diet Soda" - }, - { - "selected": false, - "label": "Excellent Mango Drink", - "value": "Excellent Mango Drink" - }, - { - "selected": false, - "label": "Excellent Orange Juice", - "value": "Excellent Orange Juice" - }, - { - "selected": false, - "label": "Excellent Strawberry Drink", - "value": "Excellent Strawberry Drink" - }, - { - "selected": false, - "label": "Excel Monthly Auto Magazine", - "value": "Excel Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Computer Magazine", - "value": "Excel Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Fashion Magazine", - "value": "Excel Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Home Magazine", - "value": "Excel Monthly Home Magazine" - }, - { - "selected": false, - "label": "Excel Monthly Sports Magazine", - "value": "Excel Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Fabulous Apple Drink", - "value": "Fabulous Apple Drink" - }, - { - "selected": false, - "label": "Fabulous Apple Juice", - "value": "Fabulous Apple Juice" - }, - { - "selected": false, - "label": "Fabulous Berry Juice", - "value": "Fabulous Berry Juice" - }, - { - "selected": false, - "label": "Fabulous Cola", - "value": "Fabulous Cola" - }, - { - "selected": false, - "label": "Fabulous Cranberry Juice", - "value": "Fabulous Cranberry Juice" - }, - { - "selected": false, - "label": "Fabulous Cream Soda", - "value": "Fabulous Cream Soda" - }, - { - "selected": false, - "label": "Fabulous Diet Cola", - "value": "Fabulous Diet Cola" - }, - { - "selected": false, - "label": "Fabulous Diet Soda", - "value": "Fabulous Diet Soda" - }, - { - "selected": false, - "label": "Fabulous Mango Drink", - "value": "Fabulous Mango Drink" - }, - { - "selected": false, - "label": "Fabulous Orange Juice", - "value": "Fabulous Orange Juice" - }, - { - "selected": false, - "label": "Fabulous Strawberry Drink", - "value": "Fabulous Strawberry Drink" - }, - { - "selected": false, - "label": "Fantastic Bagels", - "value": "Fantastic Bagels" - }, - { - "selected": false, - "label": "Fantastic Blueberry Muffins", - "value": "Fantastic Blueberry Muffins" - }, - { - "selected": false, - "label": "Fantastic Cranberry Muffins", - "value": "Fantastic Cranberry Muffins" - }, - { - "selected": false, - "label": "Fantastic English Muffins", - "value": "Fantastic English Muffins" - }, - { - "selected": false, - "label": "Fantastic Muffins", - "value": "Fantastic Muffins" - }, - { - "selected": false, - "label": "Fantastic Pumpernickel Bread", - "value": "Fantastic Pumpernickel Bread" - }, - { - "selected": false, - "label": "Fantastic Rye Bread", - "value": "Fantastic Rye Bread" - }, - { - "selected": false, - "label": "Fantastic Wheat Bread", - "value": "Fantastic Wheat Bread" - }, - { - "selected": false, - "label": "Fantastic White Bread", - "value": "Fantastic White Bread" - }, - { - "selected": false, - "label": "Fast Apple Fruit Roll", - "value": "Fast Apple Fruit Roll" - }, - { - "selected": false, - "label": "Fast Avocado Dip", - "value": "Fast Avocado Dip" - }, - { - "selected": false, - "label": "Fast BBQ Potato Chips", - "value": "Fast BBQ Potato Chips" - }, - { - "selected": false, - "label": "Fast Beef Jerky", - "value": "Fast Beef Jerky" - }, - { - "selected": false, - "label": "Fast Buttered Popcorn", - "value": "Fast Buttered Popcorn" - }, - { - "selected": false, - "label": "Fast Cheese Crackers", - "value": "Fast Cheese Crackers" - }, - { - "selected": false, - "label": "Fast Cheese Dip", - "value": "Fast Cheese Dip" - }, - { - "selected": false, - "label": "Fast Chocolate Chip Cookies", - "value": "Fast Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Fast Chocolate Donuts", - "value": "Fast Chocolate Donuts" - }, - { - "selected": false, - "label": "Fast Corn Chips", - "value": "Fast Corn Chips" - }, - { - "selected": false, - "label": "Fast Dried Apples", - "value": "Fast Dried Apples" - }, - { - "selected": false, - "label": "Fast Dried Apricots", - "value": "Fast Dried Apricots" - }, - { - "selected": false, - "label": "Fast Dried Dates", - "value": "Fast Dried Dates" - }, - { - "selected": false, - "label": "Fast Fondue Mix", - "value": "Fast Fondue Mix" - }, - { - "selected": false, - "label": "Fast Frosted Cookies", - "value": "Fast Frosted Cookies" - }, - { - "selected": false, - "label": "Fast Frosted Donuts", - "value": "Fast Frosted Donuts" - }, - { - "selected": false, - "label": "Fast Fudge Brownies", - "value": "Fast Fudge Brownies" - }, - { - "selected": false, - "label": "Fast Fudge Cookies", - "value": "Fast Fudge Cookies" - }, - { - "selected": false, - "label": "Fast Golden Raisins", - "value": "Fast Golden Raisins" - }, - { - "selected": false, - "label": "Fast Graham Crackers", - "value": "Fast Graham Crackers" - }, - { - "selected": false, - "label": "Fast Grape Fruit Roll", - "value": "Fast Grape Fruit Roll" - }, - { - "selected": false, - "label": "Fast Lemon Cookies", - "value": "Fast Lemon Cookies" - }, - { - "selected": false, - "label": "Fast Low Fat BBQ Chips", - "value": "Fast Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Fast Low Fat Chips", - "value": "Fast Low Fat Chips" - }, - { - "selected": false, - "label": "Fast Low Fat Cookies", - "value": "Fast Low Fat Cookies" - }, - { - "selected": false, - "label": "Fast Low Fat Popcorn", - "value": "Fast Low Fat Popcorn" - }, - { - "selected": false, - "label": "Fast Mini Donuts", - "value": "Fast Mini Donuts" - }, - { - "selected": false, - "label": "Fast No Salt Popcorn", - "value": "Fast No Salt Popcorn" - }, - { - "selected": false, - "label": "Fast Potato Chips", - "value": "Fast Potato Chips" - }, - { - "selected": false, - "label": "Fast Raisins", - "value": "Fast Raisins" - }, - { - "selected": false, - "label": "Fast Raspberry Fruit Roll", - "value": "Fast Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Fast Salsa Dip", - "value": "Fast Salsa Dip" - }, - { - "selected": false, - "label": "Fast Salted Pretzels", - "value": "Fast Salted Pretzels" - }, - { - "selected": false, - "label": "Fast Sesame Crackers", - "value": "Fast Sesame Crackers" - }, - { - "selected": false, - "label": "Fast Strawberry Fruit Roll", - "value": "Fast Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Fast Sugar Cookies", - "value": "Fast Sugar Cookies" - }, - { - "selected": false, - "label": "Faux Products 200 MG Acetominifen", - "value": "Faux Products 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Faux Products 200 MG Ibuprofen", - "value": "Faux Products 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Faux Products Angled Toothbrush", - "value": "Faux Products Angled Toothbrush" - }, - { - "selected": false, - "label": "Faux Products Apricot Shampoo", - "value": "Faux Products Apricot Shampoo" - }, - { - "selected": false, - "label": "Faux Products Buffered Aspirin", - "value": "Faux Products Buffered Aspirin" - }, - { - "selected": false, - "label": "Faux Products Childrens Aspirin", - "value": "Faux Products Childrens Aspirin" - }, - { - "selected": false, - "label": "Faux Products Childrens Cold Remedy", - "value": "Faux Products Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Faux Products Conditioning Shampoo", - "value": "Faux Products Conditioning Shampoo" - }, - { - "selected": false, - "label": "Faux Products Deodorant", - "value": "Faux Products Deodorant" - }, - { - "selected": false, - "label": "Faux Products Dishwasher Detergent", - "value": "Faux Products Dishwasher Detergent" - }, - { - "selected": false, - "label": "Faux Products Extra Moisture Shampoo", - "value": "Faux Products Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Faux Products HCL Nasal Spray", - "value": "Faux Products HCL Nasal Spray" - }, - { - "selected": false, - "label": "Faux Products Laundry Detergent", - "value": "Faux Products Laundry Detergent" - }, - { - "selected": false, - "label": "Faux Products Mint Mouthwash", - "value": "Faux Products Mint Mouthwash" - }, - { - "selected": false, - "label": "Faux Products Multi-Symptom Cold Remedy", - "value": "Faux Products Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Faux Products Silky Smooth Hair Conditioner", - "value": "Faux Products Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Faux Products Tartar Control Toothpaste", - "value": "Faux Products Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Faux Products Toothpaste", - "value": "Faux Products Toothpaste" - }, - { - "selected": false, - "label": "Faux Products Whitening Toothpast", - "value": "Faux Products Whitening Toothpast" - }, - { - "selected": false, - "label": "Footnote Extra Lean Hamburger", - "value": "Footnote Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Footnote Seasoned Hamburger", - "value": "Footnote Seasoned Hamburger" - }, - { - "selected": false, - "label": "Fort West Apple Fruit Roll", - "value": "Fort West Apple Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Avocado Dip", - "value": "Fort West Avocado Dip" - }, - { - "selected": false, - "label": "Fort West BBQ Potato Chips", - "value": "Fort West BBQ Potato Chips" - }, - { - "selected": false, - "label": "Fort West Beef Jerky", - "value": "Fort West Beef Jerky" - }, - { - "selected": false, - "label": "Fort West Buttered Popcorn", - "value": "Fort West Buttered Popcorn" - }, - { - "selected": false, - "label": "Fort West Cheese Crackers", - "value": "Fort West Cheese Crackers" - }, - { - "selected": false, - "label": "Fort West Cheese Dip", - "value": "Fort West Cheese Dip" - }, - { - "selected": false, - "label": "Fort West Chocolate Chip Cookies", - "value": "Fort West Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Fort West Chocolate Donuts", - "value": "Fort West Chocolate Donuts" - }, - { - "selected": false, - "label": "Fort West Corn Chips", - "value": "Fort West Corn Chips" - }, - { - "selected": false, - "label": "Fort West Dried Apples", - "value": "Fort West Dried Apples" - }, - { - "selected": false, - "label": "Fort West Dried Apricots", - "value": "Fort West Dried Apricots" - }, - { - "selected": false, - "label": "Fort West Dried Dates", - "value": "Fort West Dried Dates" - }, - { - "selected": false, - "label": "Fort West Fondue Mix", - "value": "Fort West Fondue Mix" - }, - { - "selected": false, - "label": "Fort West Frosted Cookies", - "value": "Fort West Frosted Cookies" - }, - { - "selected": false, - "label": "Fort West Frosted Donuts", - "value": "Fort West Frosted Donuts" - }, - { - "selected": false, - "label": "Fort West Fudge Brownies", - "value": "Fort West Fudge Brownies" - }, - { - "selected": false, - "label": "Fort West Fudge Cookies", - "value": "Fort West Fudge Cookies" - }, - { - "selected": false, - "label": "Fort West Golden Raisins", - "value": "Fort West Golden Raisins" - }, - { - "selected": false, - "label": "Fort West Graham Crackers", - "value": "Fort West Graham Crackers" - }, - { - "selected": false, - "label": "Fort West Grape Fruit Roll", - "value": "Fort West Grape Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Lemon Cookies", - "value": "Fort West Lemon Cookies" - }, - { - "selected": false, - "label": "Fort West Low Fat BBQ Chips", - "value": "Fort West Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Fort West Low Fat Chips", - "value": "Fort West Low Fat Chips" - }, - { - "selected": false, - "label": "Fort West Low Fat Cookies", - "value": "Fort West Low Fat Cookies" - }, - { - "selected": false, - "label": "Fort West Low Fat Popcorn", - "value": "Fort West Low Fat Popcorn" - }, - { - "selected": false, - "label": "Fort West Mini Donuts", - "value": "Fort West Mini Donuts" - }, - { - "selected": false, - "label": "Fort West No Salt Popcorn", - "value": "Fort West No Salt Popcorn" - }, - { - "selected": false, - "label": "Fort West Potato Chips", - "value": "Fort West Potato Chips" - }, - { - "selected": false, - "label": "Fort West Raisins", - "value": "Fort West Raisins" - }, - { - "selected": false, - "label": "Fort West Raspberry Fruit Roll", - "value": "Fort West Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Salsa Dip", - "value": "Fort West Salsa Dip" - }, - { - "selected": false, - "label": "Fort West Salted Pretzels", - "value": "Fort West Salted Pretzels" - }, - { - "selected": false, - "label": "Fort West Sesame Crackers", - "value": "Fort West Sesame Crackers" - }, - { - "selected": false, - "label": "Fort West Strawberry Fruit Roll", - "value": "Fort West Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Fort West Sugar Cookies", - "value": "Fort West Sugar Cookies" - }, - { - "selected": false, - "label": "Framton City Map", - "value": "Framton City Map" - }, - { - "selected": false, - "label": "Framton Eyeglass Screwdriver", - "value": "Framton Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Gauss Monthly Auto Magazine", - "value": "Gauss Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Computer Magazine", - "value": "Gauss Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Fashion Magazine", - "value": "Gauss Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Home Magazine", - "value": "Gauss Monthly Home Magazine" - }, - { - "selected": false, - "label": "Gauss Monthly Sports Magazine", - "value": "Gauss Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Genteel Extra Lean Hamburger", - "value": "Genteel Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Genteel Seasoned Hamburger", - "value": "Genteel Seasoned Hamburger" - }, - { - "selected": false, - "label": "Gerolli Extra Lean Hamburger", - "value": "Gerolli Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Gerolli Seasoned Hamburger", - "value": "Gerolli Seasoned Hamburger" - }, - { - "selected": false, - "label": "Giant Egg Substitute", - "value": "Giant Egg Substitute" - }, - { - "selected": false, - "label": "Giant Large Brown Eggs", - "value": "Giant Large Brown Eggs" - }, - { - "selected": false, - "label": "Giant Large Eggs", - "value": "Giant Large Eggs" - }, - { - "selected": false, - "label": "Giant Small Brown Eggs", - "value": "Giant Small Brown Eggs" - }, - { - "selected": false, - "label": "Giant Small Eggs", - "value": "Giant Small Eggs" - }, - { - "selected": false, - "label": "Golden Apple Cinnamon Waffles", - "value": "Golden Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Golden Beef TV Dinner", - "value": "Golden Beef TV Dinner" - }, - { - "selected": false, - "label": "Golden Blueberry Waffles", - "value": "Golden Blueberry Waffles" - }, - { - "selected": false, - "label": "Golden Chicken TV Dinner", - "value": "Golden Chicken TV Dinner" - }, - { - "selected": false, - "label": "Golden Fajita French Fries", - "value": "Golden Fajita French Fries" - }, - { - "selected": false, - "label": "Golden Frozen Broccoli", - "value": "Golden Frozen Broccoli" - }, - { - "selected": false, - "label": "Golden Frozen Carrots", - "value": "Golden Frozen Carrots" - }, - { - "selected": false, - "label": "Golden Frozen Cauliflower", - "value": "Golden Frozen Cauliflower" - }, - { - "selected": false, - "label": "Golden Frozen Cheese Pizza", - "value": "Golden Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Breast", - "value": "Golden Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Thighs", - "value": "Golden Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Golden Frozen Chicken Wings", - "value": "Golden Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Golden Frozen Corn", - "value": "Golden Frozen Corn" - }, - { - "selected": false, - "label": "Golden Frozen Mushroom Pizza", - "value": "Golden Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Pancakes", - "value": "Golden Frozen Pancakes" - }, - { - "selected": false, - "label": "Golden Frozen Peas", - "value": "Golden Frozen Peas" - }, - { - "selected": false, - "label": "Golden Frozen Pepperoni Pizza", - "value": "Golden Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Golden Frozen Sausage Pizza", - "value": "Golden Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Golden Grape Popsicles", - "value": "Golden Grape Popsicles" - }, - { - "selected": false, - "label": "Golden Home Style French Fries", - "value": "Golden Home Style French Fries" - }, - { - "selected": false, - "label": "Golden Ice Cream", - "value": "Golden Ice Cream" - }, - { - "selected": false, - "label": "Golden Ice Cream Sandwich", - "value": "Golden Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Golden Lemon Popsicles", - "value": "Golden Lemon Popsicles" - }, - { - "selected": false, - "label": "Golden Lime Popsicles", - "value": "Golden Lime Popsicles" - }, - { - "selected": false, - "label": "Golden Low Fat French Fries", - "value": "Golden Low Fat French Fries" - }, - { - "selected": false, - "label": "Golden Low Fat Waffles", - "value": "Golden Low Fat Waffles" - }, - { - "selected": false, - "label": "Golden Orange Popsicles", - "value": "Golden Orange Popsicles" - }, - { - "selected": false, - "label": "Golden Pancake Mix", - "value": "Golden Pancake Mix" - }, - { - "selected": false, - "label": "Golden Popsicles", - "value": "Golden Popsicles" - }, - { - "selected": false, - "label": "Golden Turkey TV Dinner", - "value": "Golden Turkey TV Dinner" - }, - { - "selected": false, - "label": "Golden Waffles", - "value": "Golden Waffles" - }, - { - "selected": false, - "label": "Good Chablis Wine", - "value": "Good Chablis Wine" - }, - { - "selected": false, - "label": "Good Chardonnay", - "value": "Good Chardonnay" - }, - { - "selected": false, - "label": "Good Chardonnay Wine", - "value": "Good Chardonnay Wine" - }, - { - "selected": false, - "label": "Good Imported Beer", - "value": "Good Imported Beer" - }, - { - "selected": false, - "label": "Good Light Beer", - "value": "Good Light Beer" - }, - { - "selected": false, - "label": "Good Light Wine", - "value": "Good Light Wine" - }, - { - "selected": false, - "label": "Good Merlot Wine", - "value": "Good Merlot Wine" - }, - { - "selected": false, - "label": "Good White Zinfandel Wine", - "value": "Good White Zinfandel Wine" - }, - { - "selected": false, - "label": "Gorilla 1% Milk", - "value": "Gorilla 1% Milk" - }, - { - "selected": false, - "label": "Gorilla 2% Milk", - "value": "Gorilla 2% Milk" - }, - { - "selected": false, - "label": "Gorilla Blueberry Yogurt", - "value": "Gorilla Blueberry Yogurt" - }, - { - "selected": false, - "label": "Gorilla Buttermilk", - "value": "Gorilla Buttermilk" - }, - { - "selected": false, - "label": "Gorilla Cheese Spread", - "value": "Gorilla Cheese Spread" - }, - { - "selected": false, - "label": "Gorilla Chocolate Milk", - "value": "Gorilla Chocolate Milk" - }, - { - "selected": false, - "label": "Gorilla Havarti Cheese", - "value": "Gorilla Havarti Cheese" - }, - { - "selected": false, - "label": "Gorilla Head Cheese", - "value": "Gorilla Head Cheese" - }, - { - "selected": false, - "label": "Gorilla Jack Cheese", - "value": "Gorilla Jack Cheese" - }, - { - "selected": false, - "label": "Gorilla Large Curd Cottage Cheese", - "value": "Gorilla Large Curd Cottage Cheese" - }, - { - "selected": false, - "label": "Gorilla Low Fat Cottage Cheese", - "value": "Gorilla Low Fat Cottage Cheese" - }, - { - "selected": false, - "label": "Gorilla Low Fat Sour Cream", - "value": "Gorilla Low Fat Sour Cream" - }, - { - "selected": false, - "label": "Gorilla Low Fat String Cheese", - "value": "Gorilla Low Fat String Cheese" - }, - { - "selected": false, - "label": "Gorilla Mild Cheddar Cheese", - "value": "Gorilla Mild Cheddar Cheese" - }, - { - "selected": false, - "label": "Gorilla Muenster Cheese", - "value": "Gorilla Muenster Cheese" - }, - { - "selected": false, - "label": "Gorilla Sharp Cheddar Cheese", - "value": "Gorilla Sharp Cheddar Cheese" - }, - { - "selected": false, - "label": "Gorilla Sour Cream", - "value": "Gorilla Sour Cream" - }, - { - "selected": false, - "label": "Gorilla Strawberry Yogurt", - "value": "Gorilla Strawberry Yogurt" - }, - { - "selected": false, - "label": "Gorilla String Cheese", - "value": "Gorilla String Cheese" - }, - { - "selected": false, - "label": "Gorilla Whole Milk", - "value": "Gorilla Whole Milk" - }, - { - "selected": false, - "label": "Great Bagels", - "value": "Great Bagels" - }, - { - "selected": false, - "label": "Great Blueberry Muffins", - "value": "Great Blueberry Muffins" - }, - { - "selected": false, - "label": "Great Cranberry Muffins", - "value": "Great Cranberry Muffins" - }, - { - "selected": false, - "label": "Great English Muffins", - "value": "Great English Muffins" - }, - { - "selected": false, - "label": "Great Muffins", - "value": "Great Muffins" - }, - { - "selected": false, - "label": "Great Pumpernickel Bread", - "value": "Great Pumpernickel Bread" - }, - { - "selected": false, - "label": "Great Rye Bread", - "value": "Great Rye Bread" - }, - { - "selected": false, - "label": "Great Wheat Bread", - "value": "Great Wheat Bread" - }, - { - "selected": false, - "label": "Great White Bread", - "value": "Great White Bread" - }, - { - "selected": false, - "label": "Green Ribbon Canned Mixed Fruit", - "value": "Green Ribbon Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Green Ribbon Canned Peaches", - "value": "Green Ribbon Canned Peaches" - }, - { - "selected": false, - "label": "Gulf Coast Bubble Gum", - "value": "Gulf Coast Bubble Gum" - }, - { - "selected": false, - "label": "Gulf Coast Malted Milk Balls", - "value": "Gulf Coast Malted Milk Balls" - }, - { - "selected": false, - "label": "Gulf Coast Mint Chocolate Bar", - "value": "Gulf Coast Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Gulf Coast Mints", - "value": "Gulf Coast Mints" - }, - { - "selected": false, - "label": "Gulf Coast Semi-Sweet Chocolate Bar", - "value": "Gulf Coast Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Gulf Coast Spicy Mints", - "value": "Gulf Coast Spicy Mints" - }, - { - "selected": false, - "label": "Gulf Coast Tasty Candy Bar", - "value": "Gulf Coast Tasty Candy Bar" - }, - { - "selected": false, - "label": "Gulf Coast White Chocolate Bar", - "value": "Gulf Coast White Chocolate Bar" - }, - { - "selected": false, - "label": "Hermanos Almonds", - "value": "Hermanos Almonds" - }, - { - "selected": false, - "label": "Hermanos Asparagus", - "value": "Hermanos Asparagus" - }, - { - "selected": false, - "label": "Hermanos Baby Onion", - "value": "Hermanos Baby Onion" - }, - { - "selected": false, - "label": "Hermanos Beets", - "value": "Hermanos Beets" - }, - { - "selected": false, - "label": "Hermanos Broccoli", - "value": "Hermanos Broccoli" - }, - { - "selected": false, - "label": "Hermanos Canned Peanuts", - "value": "Hermanos Canned Peanuts" - }, - { - "selected": false, - "label": "Hermanos Cantelope", - "value": "Hermanos Cantelope" - }, - { - "selected": false, - "label": "Hermanos Cauliflower", - "value": "Hermanos Cauliflower" - }, - { - "selected": false, - "label": "Hermanos Corn on the Cob", - "value": "Hermanos Corn on the Cob" - }, - { - "selected": false, - "label": "Hermanos Dried Mushrooms", - "value": "Hermanos Dried Mushrooms" - }, - { - "selected": false, - "label": "Hermanos Elephant Garlic", - "value": "Hermanos Elephant Garlic" - }, - { - "selected": false, - "label": "Hermanos Fancy Plums", - "value": "Hermanos Fancy Plums" - }, - { - "selected": false, - "label": "Hermanos Firm Tofu", - "value": "Hermanos Firm Tofu" - }, - { - "selected": false, - "label": "Hermanos Fresh Lima Beans", - "value": "Hermanos Fresh Lima Beans" - }, - { - "selected": false, - "label": "Hermanos Fuji Apples", - "value": "Hermanos Fuji Apples" - }, - { - "selected": false, - "label": "Hermanos Garlic", - "value": "Hermanos Garlic" - }, - { - "selected": false, - "label": "Hermanos Golden Delcious Apples", - "value": "Hermanos Golden Delcious Apples" - }, - { - "selected": false, - "label": "Hermanos Green Pepper", - "value": "Hermanos Green Pepper" - }, - { - "selected": false, - "label": "Hermanos Honey Dew", - "value": "Hermanos Honey Dew" - }, - { - "selected": false, - "label": "Hermanos Lemons", - "value": "Hermanos Lemons" - }, - { - "selected": false, - "label": "Hermanos Lettuce", - "value": "Hermanos Lettuce" - }, - { - "selected": false, - "label": "Hermanos Limes", - "value": "Hermanos Limes" - }, - { - "selected": false, - "label": "Hermanos Macintosh Apples", - "value": "Hermanos Macintosh Apples" - }, - { - "selected": false, - "label": "Hermanos Mandarin Oranges", - "value": "Hermanos Mandarin Oranges" - }, - { - "selected": false, - "label": "Hermanos Mixed Nuts", - "value": "Hermanos Mixed Nuts" - }, - { - "selected": false, - "label": "Hermanos Mushrooms", - "value": "Hermanos Mushrooms" - }, - { - "selected": false, - "label": "Hermanos New Potatos", - "value": "Hermanos New Potatos" - }, - { - "selected": false, - "label": "Hermanos Onions", - "value": "Hermanos Onions" - }, - { - "selected": false, - "label": "Hermanos Oranges", - "value": "Hermanos Oranges" - }, - { - "selected": false, - "label": "Hermanos Party Nuts", - "value": "Hermanos Party Nuts" - }, - { - "selected": false, - "label": "Hermanos Peaches", - "value": "Hermanos Peaches" - }, - { - "selected": false, - "label": "Hermanos Plums", - "value": "Hermanos Plums" - }, - { - "selected": false, - "label": "Hermanos Potatos", - "value": "Hermanos Potatos" - }, - { - "selected": false, - "label": "Hermanos Prepared Salad", - "value": "Hermanos Prepared Salad" - }, - { - "selected": false, - "label": "Hermanos Red Delcious Apples", - "value": "Hermanos Red Delcious Apples" - }, - { - "selected": false, - "label": "Hermanos Red Pepper", - "value": "Hermanos Red Pepper" - }, - { - "selected": false, - "label": "Hermanos Shitake Mushrooms", - "value": "Hermanos Shitake Mushrooms" - }, - { - "selected": false, - "label": "Hermanos Squash", - "value": "Hermanos Squash" - }, - { - "selected": false, - "label": "Hermanos Summer Squash", - "value": "Hermanos Summer Squash" - }, - { - "selected": false, - "label": "Hermanos Sweet Onion", - "value": "Hermanos Sweet Onion" - }, - { - "selected": false, - "label": "Hermanos Sweet Peas", - "value": "Hermanos Sweet Peas" - }, - { - "selected": false, - "label": "Hermanos Tangerines", - "value": "Hermanos Tangerines" - }, - { - "selected": false, - "label": "Hermanos Tomatos", - "value": "Hermanos Tomatos" - }, - { - "selected": false, - "label": "Hermanos Walnuts", - "value": "Hermanos Walnuts" - }, - { - "selected": false, - "label": "High Quality 100 Watt Lightbulb", - "value": "High Quality 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 25 Watt Lightbulb", - "value": "High Quality 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 60 Watt Lightbulb", - "value": "High Quality 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality 75 Watt Lightbulb", - "value": "High Quality 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "High Quality AAA-Size Batteries", - "value": "High Quality AAA-Size Batteries" - }, - { - "selected": false, - "label": "High Quality AA-Size Batteries", - "value": "High Quality AA-Size Batteries" - }, - { - "selected": false, - "label": "High Quality Bees Wax Candles", - "value": "High Quality Bees Wax Candles" - }, - { - "selected": false, - "label": "High Quality Copper Cleaner", - "value": "High Quality Copper Cleaner" - }, - { - "selected": false, - "label": "High Quality Copper Pot Scrubber", - "value": "High Quality Copper Pot Scrubber" - }, - { - "selected": false, - "label": "High Quality Counter Cleaner", - "value": "High Quality Counter Cleaner" - }, - { - "selected": false, - "label": "High Quality C-Size Batteries", - "value": "High Quality C-Size Batteries" - }, - { - "selected": false, - "label": "High Quality D-Size Batteries", - "value": "High Quality D-Size Batteries" - }, - { - "selected": false, - "label": "High Quality Economy Toilet Brush", - "value": "High Quality Economy Toilet Brush" - }, - { - "selected": false, - "label": "High Quality Frying Pan", - "value": "High Quality Frying Pan" - }, - { - "selected": false, - "label": "High Quality Glass Cleaner", - "value": "High Quality Glass Cleaner" - }, - { - "selected": false, - "label": "High Quality Large Sponge", - "value": "High Quality Large Sponge" - }, - { - "selected": false, - "label": "High Quality Paper Cups", - "value": "High Quality Paper Cups" - }, - { - "selected": false, - "label": "High Quality Paper Plates", - "value": "High Quality Paper Plates" - }, - { - "selected": false, - "label": "High Quality Paper Towels", - "value": "High Quality Paper Towels" - }, - { - "selected": false, - "label": "High Quality Plastic Forks", - "value": "High Quality Plastic Forks" - }, - { - "selected": false, - "label": "High Quality Plastic Knives", - "value": "High Quality Plastic Knives" - }, - { - "selected": false, - "label": "High Quality Plastic Spoons", - "value": "High Quality Plastic Spoons" - }, - { - "selected": false, - "label": "High Quality Room Freshener", - "value": "High Quality Room Freshener" - }, - { - "selected": false, - "label": "High Quality Scented Tissue", - "value": "High Quality Scented Tissue" - }, - { - "selected": false, - "label": "High Quality Scented Toilet Tissue", - "value": "High Quality Scented Toilet Tissue" - }, - { - "selected": false, - "label": "High Quality Scissors", - "value": "High Quality Scissors" - }, - { - "selected": false, - "label": "High Quality Screw Driver", - "value": "High Quality Screw Driver" - }, - { - "selected": false, - "label": "High Quality Silver Cleaner", - "value": "High Quality Silver Cleaner" - }, - { - "selected": false, - "label": "High Quality Soft Napkins", - "value": "High Quality Soft Napkins" - }, - { - "selected": false, - "label": "High Quality Tissues", - "value": "High Quality Tissues" - }, - { - "selected": false, - "label": "High Quality Toilet Bowl Cleaner", - "value": "High Quality Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "High Quality Toilet Paper", - "value": "High Quality Toilet Paper" - }, - { - "selected": false, - "label": "High Top Almonds", - "value": "High Top Almonds" - }, - { - "selected": false, - "label": "High Top Asparagus", - "value": "High Top Asparagus" - }, - { - "selected": false, - "label": "High Top Baby Onion", - "value": "High Top Baby Onion" - }, - { - "selected": false, - "label": "High Top Beets", - "value": "High Top Beets" - }, - { - "selected": false, - "label": "High Top Broccoli", - "value": "High Top Broccoli" - }, - { - "selected": false, - "label": "High Top Canned Peanuts", - "value": "High Top Canned Peanuts" - }, - { - "selected": false, - "label": "High Top Cantelope", - "value": "High Top Cantelope" - }, - { - "selected": false, - "label": "High Top Cauliflower", - "value": "High Top Cauliflower" - }, - { - "selected": false, - "label": "High Top Corn on the Cob", - "value": "High Top Corn on the Cob" - }, - { - "selected": false, - "label": "High Top Dried Mushrooms", - "value": "High Top Dried Mushrooms" - }, - { - "selected": false, - "label": "High Top Elephant Garlic", - "value": "High Top Elephant Garlic" - }, - { - "selected": false, - "label": "High Top Fancy Plums", - "value": "High Top Fancy Plums" - }, - { - "selected": false, - "label": "High Top Firm Tofu", - "value": "High Top Firm Tofu" - }, - { - "selected": false, - "label": "High Top Fresh Lima Beans", - "value": "High Top Fresh Lima Beans" - }, - { - "selected": false, - "label": "High Top Fuji Apples", - "value": "High Top Fuji Apples" - }, - { - "selected": false, - "label": "High Top Garlic", - "value": "High Top Garlic" - }, - { - "selected": false, - "label": "High Top Golden Delcious Apples", - "value": "High Top Golden Delcious Apples" - }, - { - "selected": false, - "label": "High Top Green Pepper", - "value": "High Top Green Pepper" - }, - { - "selected": false, - "label": "High Top Honey Dew", - "value": "High Top Honey Dew" - }, - { - "selected": false, - "label": "High Top Lemons", - "value": "High Top Lemons" - }, - { - "selected": false, - "label": "High Top Lettuce", - "value": "High Top Lettuce" - }, - { - "selected": false, - "label": "High Top Limes", - "value": "High Top Limes" - }, - { - "selected": false, - "label": "High Top Macintosh Apples", - "value": "High Top Macintosh Apples" - }, - { - "selected": false, - "label": "High Top Mandarin Oranges", - "value": "High Top Mandarin Oranges" - }, - { - "selected": false, - "label": "High Top Mixed Nuts", - "value": "High Top Mixed Nuts" - }, - { - "selected": false, - "label": "High Top Mushrooms", - "value": "High Top Mushrooms" - }, - { - "selected": false, - "label": "High Top New Potatos", - "value": "High Top New Potatos" - }, - { - "selected": false, - "label": "High Top Onions", - "value": "High Top Onions" - }, - { - "selected": false, - "label": "High Top Oranges", - "value": "High Top Oranges" - }, - { - "selected": false, - "label": "High Top Party Nuts", - "value": "High Top Party Nuts" - }, - { - "selected": false, - "label": "High Top Peaches", - "value": "High Top Peaches" - }, - { - "selected": false, - "label": "High Top Plums", - "value": "High Top Plums" - }, - { - "selected": false, - "label": "High Top Potatos", - "value": "High Top Potatos" - }, - { - "selected": false, - "label": "High Top Prepared Salad", - "value": "High Top Prepared Salad" - }, - { - "selected": false, - "label": "High Top Red Delcious Apples", - "value": "High Top Red Delcious Apples" - }, - { - "selected": false, - "label": "High Top Red Pepper", - "value": "High Top Red Pepper" - }, - { - "selected": false, - "label": "High Top Shitake Mushrooms", - "value": "High Top Shitake Mushrooms" - }, - { - "selected": false, - "label": "High Top Squash", - "value": "High Top Squash" - }, - { - "selected": false, - "label": "High Top Summer Squash", - "value": "High Top Summer Squash" - }, - { - "selected": false, - "label": "High Top Sweet Onion", - "value": "High Top Sweet Onion" - }, - { - "selected": false, - "label": "High Top Sweet Peas", - "value": "High Top Sweet Peas" - }, - { - "selected": false, - "label": "High Top Tangerines", - "value": "High Top Tangerines" - }, - { - "selected": false, - "label": "High Top Tomatos", - "value": "High Top Tomatos" - }, - { - "selected": false, - "label": "High Top Walnuts", - "value": "High Top Walnuts" - }, - { - "selected": false, - "label": "Hilltop 200 MG Acetominifen", - "value": "Hilltop 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Hilltop 200 MG Ibuprofen", - "value": "Hilltop 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Hilltop Angled Toothbrush", - "value": "Hilltop Angled Toothbrush" - }, - { - "selected": false, - "label": "Hilltop Apricot Shampoo", - "value": "Hilltop Apricot Shampoo" - }, - { - "selected": false, - "label": "Hilltop Buffered Aspirin", - "value": "Hilltop Buffered Aspirin" - }, - { - "selected": false, - "label": "Hilltop Childrens Aspirin", - "value": "Hilltop Childrens Aspirin" - }, - { - "selected": false, - "label": "Hilltop Childrens Cold Remedy", - "value": "Hilltop Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Hilltop Conditioning Shampoo", - "value": "Hilltop Conditioning Shampoo" - }, - { - "selected": false, - "label": "Hilltop Deodorant", - "value": "Hilltop Deodorant" - }, - { - "selected": false, - "label": "Hilltop Dishwasher Detergent", - "value": "Hilltop Dishwasher Detergent" - }, - { - "selected": false, - "label": "Hilltop Extra Moisture Shampoo", - "value": "Hilltop Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Hilltop HCL Nasal Spray", - "value": "Hilltop HCL Nasal Spray" - }, - { - "selected": false, - "label": "Hilltop Laundry Detergent", - "value": "Hilltop Laundry Detergent" - }, - { - "selected": false, - "label": "Hilltop Mint Mouthwash", - "value": "Hilltop Mint Mouthwash" - }, - { - "selected": false, - "label": "Hilltop Multi-Symptom Cold Remedy", - "value": "Hilltop Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Hilltop Silky Smooth Hair Conditioner", - "value": "Hilltop Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Hilltop Tartar Control Toothpaste", - "value": "Hilltop Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Hilltop Toothpaste", - "value": "Hilltop Toothpaste" - }, - { - "selected": false, - "label": "Hilltop Whitening Toothpast", - "value": "Hilltop Whitening Toothpast" - }, - { - "selected": false, - "label": "Horatio Apple Fruit Roll", - "value": "Horatio Apple Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Avocado Dip", - "value": "Horatio Avocado Dip" - }, - { - "selected": false, - "label": "Horatio BBQ Potato Chips", - "value": "Horatio BBQ Potato Chips" - }, - { - "selected": false, - "label": "Horatio Beef Jerky", - "value": "Horatio Beef Jerky" - }, - { - "selected": false, - "label": "Horatio Buttered Popcorn", - "value": "Horatio Buttered Popcorn" - }, - { - "selected": false, - "label": "Horatio Cheese Crackers", - "value": "Horatio Cheese Crackers" - }, - { - "selected": false, - "label": "Horatio Cheese Dip", - "value": "Horatio Cheese Dip" - }, - { - "selected": false, - "label": "Horatio Chocolate Chip Cookies", - "value": "Horatio Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Horatio Chocolate Donuts", - "value": "Horatio Chocolate Donuts" - }, - { - "selected": false, - "label": "Horatio Corn Chips", - "value": "Horatio Corn Chips" - }, - { - "selected": false, - "label": "Horatio Dried Apples", - "value": "Horatio Dried Apples" - }, - { - "selected": false, - "label": "Horatio Dried Apricots", - "value": "Horatio Dried Apricots" - }, - { - "selected": false, - "label": "Horatio Dried Dates", - "value": "Horatio Dried Dates" - }, - { - "selected": false, - "label": "Horatio Fondue Mix", - "value": "Horatio Fondue Mix" - }, - { - "selected": false, - "label": "Horatio Frosted Cookies", - "value": "Horatio Frosted Cookies" - }, - { - "selected": false, - "label": "Horatio Frosted Donuts", - "value": "Horatio Frosted Donuts" - }, - { - "selected": false, - "label": "Horatio Fudge Brownies", - "value": "Horatio Fudge Brownies" - }, - { - "selected": false, - "label": "Horatio Fudge Cookies", - "value": "Horatio Fudge Cookies" - }, - { - "selected": false, - "label": "Horatio Golden Raisins", - "value": "Horatio Golden Raisins" - }, - { - "selected": false, - "label": "Horatio Graham Crackers", - "value": "Horatio Graham Crackers" - }, - { - "selected": false, - "label": "Horatio Grape Fruit Roll", - "value": "Horatio Grape Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Lemon Cookies", - "value": "Horatio Lemon Cookies" - }, - { - "selected": false, - "label": "Horatio Low Fat BBQ Chips", - "value": "Horatio Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Horatio Low Fat Chips", - "value": "Horatio Low Fat Chips" - }, - { - "selected": false, - "label": "Horatio Low Fat Cookies", - "value": "Horatio Low Fat Cookies" - }, - { - "selected": false, - "label": "Horatio Low Fat Popcorn", - "value": "Horatio Low Fat Popcorn" - }, - { - "selected": false, - "label": "Horatio Mini Donuts", - "value": "Horatio Mini Donuts" - }, - { - "selected": false, - "label": "Horatio No Salt Popcorn", - "value": "Horatio No Salt Popcorn" - }, - { - "selected": false, - "label": "Horatio Potato Chips", - "value": "Horatio Potato Chips" - }, - { - "selected": false, - "label": "Horatio Raisins", - "value": "Horatio Raisins" - }, - { - "selected": false, - "label": "Horatio Raspberry Fruit Roll", - "value": "Horatio Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Salsa Dip", - "value": "Horatio Salsa Dip" - }, - { - "selected": false, - "label": "Horatio Salted Pretzels", - "value": "Horatio Salted Pretzels" - }, - { - "selected": false, - "label": "Horatio Sesame Crackers", - "value": "Horatio Sesame Crackers" - }, - { - "selected": false, - "label": "Horatio Strawberry Fruit Roll", - "value": "Horatio Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Horatio Sugar Cookies", - "value": "Horatio Sugar Cookies" - }, - { - "selected": false, - "label": "Imagine Apple Cinnamon Waffles", - "value": "Imagine Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "Imagine Beef TV Dinner", - "value": "Imagine Beef TV Dinner" - }, - { - "selected": false, - "label": "Imagine Blueberry Waffles", - "value": "Imagine Blueberry Waffles" - }, - { - "selected": false, - "label": "Imagine Chicken TV Dinner", - "value": "Imagine Chicken TV Dinner" - }, - { - "selected": false, - "label": "Imagine Fajita French Fries", - "value": "Imagine Fajita French Fries" - }, - { - "selected": false, - "label": "Imagine Frozen Broccoli", - "value": "Imagine Frozen Broccoli" - }, - { - "selected": false, - "label": "Imagine Frozen Carrots", - "value": "Imagine Frozen Carrots" - }, - { - "selected": false, - "label": "Imagine Frozen Cauliflower", - "value": "Imagine Frozen Cauliflower" - }, - { - "selected": false, - "label": "Imagine Frozen Cheese Pizza", - "value": "Imagine Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Breast", - "value": "Imagine Frozen Chicken Breast" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Thighs", - "value": "Imagine Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "Imagine Frozen Chicken Wings", - "value": "Imagine Frozen Chicken Wings" - }, - { - "selected": false, - "label": "Imagine Frozen Corn", - "value": "Imagine Frozen Corn" - }, - { - "selected": false, - "label": "Imagine Frozen Mushroom Pizza", - "value": "Imagine Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Pancakes", - "value": "Imagine Frozen Pancakes" - }, - { - "selected": false, - "label": "Imagine Frozen Peas", - "value": "Imagine Frozen Peas" - }, - { - "selected": false, - "label": "Imagine Frozen Pepperoni Pizza", - "value": "Imagine Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "Imagine Frozen Sausage Pizza", - "value": "Imagine Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "Imagine Grape Popsicles", - "value": "Imagine Grape Popsicles" - }, - { - "selected": false, - "label": "Imagine Home Style French Fries", - "value": "Imagine Home Style French Fries" - }, - { - "selected": false, - "label": "Imagine Ice Cream", - "value": "Imagine Ice Cream" - }, - { - "selected": false, - "label": "Imagine Ice Cream Sandwich", - "value": "Imagine Ice Cream Sandwich" - }, - { - "selected": false, - "label": "Imagine Lemon Popsicles", - "value": "Imagine Lemon Popsicles" - }, - { - "selected": false, - "label": "Imagine Lime Popsicles", - "value": "Imagine Lime Popsicles" - }, - { - "selected": false, - "label": "Imagine Low Fat French Fries", - "value": "Imagine Low Fat French Fries" - }, - { - "selected": false, - "label": "Imagine Low Fat Waffles", - "value": "Imagine Low Fat Waffles" - }, - { - "selected": false, - "label": "Imagine Orange Popsicles", - "value": "Imagine Orange Popsicles" - }, - { - "selected": false, - "label": "Imagine Pancake Mix", - "value": "Imagine Pancake Mix" - }, - { - "selected": false, - "label": "Imagine Popsicles", - "value": "Imagine Popsicles" - }, - { - "selected": false, - "label": "Imagine Turkey TV Dinner", - "value": "Imagine Turkey TV Dinner" - }, - { - "selected": false, - "label": "Imagine Waffles", - "value": "Imagine Waffles" - }, - { - "selected": false, - "label": "James Bay City Map", - "value": "James Bay City Map" - }, - { - "selected": false, - "label": "James Bay Eyeglass Screwdriver", - "value": "James Bay Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Jardon Manicotti", - "value": "Jardon Manicotti" - }, - { - "selected": false, - "label": "Jardon Ravioli", - "value": "Jardon Ravioli" - }, - { - "selected": false, - "label": "Jardon Rice Medly", - "value": "Jardon Rice Medly" - }, - { - "selected": false, - "label": "Jardon Spaghetti", - "value": "Jardon Spaghetti" - }, - { - "selected": false, - "label": "Jardon Thai Rice", - "value": "Jardon Thai Rice" - }, - { - "selected": false, - "label": "Jeffers Corn Puffs", - "value": "Jeffers Corn Puffs" - }, - { - "selected": false, - "label": "Jeffers Grits", - "value": "Jeffers Grits" - }, - { - "selected": false, - "label": "Jeffers Oatmeal", - "value": "Jeffers Oatmeal" - }, - { - "selected": false, - "label": "Jeffers Wheat Puffs", - "value": "Jeffers Wheat Puffs" - }, - { - "selected": false, - "label": "Johnson Corn Puffs", - "value": "Johnson Corn Puffs" - }, - { - "selected": false, - "label": "Johnson Grits", - "value": "Johnson Grits" - }, - { - "selected": false, - "label": "Johnson Oatmeal", - "value": "Johnson Oatmeal" - }, - { - "selected": false, - "label": "Johnson Wheat Puffs", - "value": "Johnson Wheat Puffs" - }, - { - "selected": false, - "label": "Jumbo Egg Substitute", - "value": "Jumbo Egg Substitute" - }, - { - "selected": false, - "label": "Jumbo Large Brown Eggs", - "value": "Jumbo Large Brown Eggs" - }, - { - "selected": false, - "label": "Jumbo Large Eggs", - "value": "Jumbo Large Eggs" - }, - { - "selected": false, - "label": "Jumbo Small Brown Eggs", - "value": "Jumbo Small Brown Eggs" - }, - { - "selected": false, - "label": "Jumbo Small Eggs", - "value": "Jumbo Small Eggs" - }, - { - "selected": false, - "label": "Just Right Beef Soup", - "value": "Just Right Beef Soup" - }, - { - "selected": false, - "label": "Just Right Canned Beets", - "value": "Just Right Canned Beets" - }, - { - "selected": false, - "label": "Just Right Canned Peas", - "value": "Just Right Canned Peas" - }, - { - "selected": false, - "label": "Just Right Canned String Beans", - "value": "Just Right Canned String Beans" - }, - { - "selected": false, - "label": "Just Right Canned Tomatos", - "value": "Just Right Canned Tomatos" - }, - { - "selected": false, - "label": "Just Right Canned Tuna in Oil", - "value": "Just Right Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Just Right Canned Tuna in Water", - "value": "Just Right Canned Tuna in Water" - }, - { - "selected": false, - "label": "Just Right Canned Yams", - "value": "Just Right Canned Yams" - }, - { - "selected": false, - "label": "Just Right Chicken Noodle Soup", - "value": "Just Right Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Chicken Ramen Soup", - "value": "Just Right Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Just Right Chicken Soup", - "value": "Just Right Chicken Soup" - }, - { - "selected": false, - "label": "Just Right Creamed Corn", - "value": "Just Right Creamed Corn" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Anchovies", - "value": "Just Right Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Clams", - "value": "Just Right Fancy Canned Clams" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Oysters", - "value": "Just Right Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Just Right Fancy Canned Sardines", - "value": "Just Right Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Just Right Large Canned Shrimp", - "value": "Just Right Large Canned Shrimp" - }, - { - "selected": false, - "label": "Just Right Noodle Soup", - "value": "Just Right Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Regular Ramen Soup", - "value": "Just Right Regular Ramen Soup" - }, - { - "selected": false, - "label": "Just Right Rice Soup", - "value": "Just Right Rice Soup" - }, - { - "selected": false, - "label": "Just Right Turkey Noodle Soup", - "value": "Just Right Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Just Right Vegetable Soup", - "value": "Just Right Vegetable Soup" - }, - { - "selected": false, - "label": "King Rosy Sunglasses", - "value": "King Rosy Sunglasses" - }, - { - "selected": false, - "label": "Kiwi Lox", - "value": "Kiwi Lox" - }, - { - "selected": false, - "label": "Kiwi Scallops", - "value": "Kiwi Scallops" - }, - { - "selected": false, - "label": "Lake Beef Bologna", - "value": "Lake Beef Bologna" - }, - { - "selected": false, - "label": "Lake Chicken Hot Dogs", - "value": "Lake Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Lake Cole Slaw", - "value": "Lake Cole Slaw" - }, - { - "selected": false, - "label": "Lake Corned Beef", - "value": "Lake Corned Beef" - }, - { - "selected": false, - "label": "Lake Foot-Long Hot Dogs", - "value": "Lake Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Lake Low Fat Bologna", - "value": "Lake Low Fat Bologna" - }, - { - "selected": false, - "label": "Lake Low Fat Cole Slaw", - "value": "Lake Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Lake Pimento Loaf", - "value": "Lake Pimento Loaf" - }, - { - "selected": false, - "label": "Lake Potato Salad", - "value": "Lake Potato Salad" - }, - { - "selected": false, - "label": "Lake Roasted Chicken", - "value": "Lake Roasted Chicken" - }, - { - "selected": false, - "label": "Lake Sliced Chicken", - "value": "Lake Sliced Chicken" - }, - { - "selected": false, - "label": "Lake Sliced Ham", - "value": "Lake Sliced Ham" - }, - { - "selected": false, - "label": "Lake Sliced Turkey", - "value": "Lake Sliced Turkey" - }, - { - "selected": false, - "label": "Lake Turkey Hot Dogs", - "value": "Lake Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Landslide Apple Butter", - "value": "Landslide Apple Butter" - }, - { - "selected": false, - "label": "Landslide Apple Jam", - "value": "Landslide Apple Jam" - }, - { - "selected": false, - "label": "Landslide Apple Jelly", - "value": "Landslide Apple Jelly" - }, - { - "selected": false, - "label": "Landslide Apple Preserves", - "value": "Landslide Apple Preserves" - }, - { - "selected": false, - "label": "Landslide Brown Sugar", - "value": "Landslide Brown Sugar" - }, - { - "selected": false, - "label": "Landslide Canola Oil", - "value": "Landslide Canola Oil" - }, - { - "selected": false, - "label": "Landslide Chunky Peanut Butter", - "value": "Landslide Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Landslide Columbian Coffee", - "value": "Landslide Columbian Coffee" - }, - { - "selected": false, - "label": "Landslide Corn Oil", - "value": "Landslide Corn Oil" - }, - { - "selected": false, - "label": "Landslide Creamy Peanut Butter", - "value": "Landslide Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Landslide Decaf Coffee", - "value": "Landslide Decaf Coffee" - }, - { - "selected": false, - "label": "Landslide Extra Chunky Peanut Butter", - "value": "Landslide Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Landslide French Roast Coffee", - "value": "Landslide French Roast Coffee" - }, - { - "selected": false, - "label": "Landslide Grape Jam", - "value": "Landslide Grape Jam" - }, - { - "selected": false, - "label": "Landslide Grape Jelly", - "value": "Landslide Grape Jelly" - }, - { - "selected": false, - "label": "Landslide Grape Preserves", - "value": "Landslide Grape Preserves" - }, - { - "selected": false, - "label": "Landslide Hot Chocolate", - "value": "Landslide Hot Chocolate" - }, - { - "selected": false, - "label": "Landslide Low Fat Apple Butter", - "value": "Landslide Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Landslide Oregano", - "value": "Landslide Oregano" - }, - { - "selected": false, - "label": "Landslide Pepper", - "value": "Landslide Pepper" - }, - { - "selected": false, - "label": "Landslide Regular Coffee", - "value": "Landslide Regular Coffee" - }, - { - "selected": false, - "label": "Landslide Salt", - "value": "Landslide Salt" - }, - { - "selected": false, - "label": "Landslide Sesame Oil", - "value": "Landslide Sesame Oil" - }, - { - "selected": false, - "label": "Landslide Strawberry Jam", - "value": "Landslide Strawberry Jam" - }, - { - "selected": false, - "label": "Landslide Strawberry Jelly", - "value": "Landslide Strawberry Jelly" - }, - { - "selected": false, - "label": "Landslide Strawberry Preserves", - "value": "Landslide Strawberry Preserves" - }, - { - "selected": false, - "label": "Landslide Tomato Sauce", - "value": "Landslide Tomato Sauce" - }, - { - "selected": false, - "label": "Landslide Vegetable Oil", - "value": "Landslide Vegetable Oil" - }, - { - "selected": false, - "label": "Landslide White Sugar", - "value": "Landslide White Sugar" - }, - { - "selected": false, - "label": "Medalist Manicotti", - "value": "Medalist Manicotti" - }, - { - "selected": false, - "label": "Medalist Ravioli", - "value": "Medalist Ravioli" - }, - { - "selected": false, - "label": "Medalist Rice Medly", - "value": "Medalist Rice Medly" - }, - { - "selected": false, - "label": "Medalist Spaghetti", - "value": "Medalist Spaghetti" - }, - { - "selected": false, - "label": "Medalist Thai Rice", - "value": "Medalist Thai Rice" - }, - { - "selected": false, - "label": "Mighty Good Monthly Auto Magazine", - "value": "Mighty Good Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Computer Magazine", - "value": "Mighty Good Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Fashion Magazine", - "value": "Mighty Good Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Home Magazine", - "value": "Mighty Good Monthly Home Magazine" - }, - { - "selected": false, - "label": "Mighty Good Monthly Sports Magazine", - "value": "Mighty Good Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Modell Bagels", - "value": "Modell Bagels" - }, - { - "selected": false, - "label": "Modell Blueberry Muffins", - "value": "Modell Blueberry Muffins" - }, - { - "selected": false, - "label": "Modell Cranberry Muffins", - "value": "Modell Cranberry Muffins" - }, - { - "selected": false, - "label": "Modell English Muffins", - "value": "Modell English Muffins" - }, - { - "selected": false, - "label": "Modell Muffins", - "value": "Modell Muffins" - }, - { - "selected": false, - "label": "Modell Pumpernickel Bread", - "value": "Modell Pumpernickel Bread" - }, - { - "selected": false, - "label": "Modell Rye Bread", - "value": "Modell Rye Bread" - }, - { - "selected": false, - "label": "Modell Wheat Bread", - "value": "Modell Wheat Bread" - }, - { - "selected": false, - "label": "Modell White Bread", - "value": "Modell White Bread" - }, - { - "selected": false, - "label": "Moms Beef Bologna", - "value": "Moms Beef Bologna" - }, - { - "selected": false, - "label": "Moms Chicken Hot Dogs", - "value": "Moms Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Moms Cole Slaw", - "value": "Moms Cole Slaw" - }, - { - "selected": false, - "label": "Moms Corned Beef", - "value": "Moms Corned Beef" - }, - { - "selected": false, - "label": "Moms Foot-Long Hot Dogs", - "value": "Moms Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Moms Low Fat Bologna", - "value": "Moms Low Fat Bologna" - }, - { - "selected": false, - "label": "Moms Low Fat Cole Slaw", - "value": "Moms Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Moms Pimento Loaf", - "value": "Moms Pimento Loaf" - }, - { - "selected": false, - "label": "Moms Potato Salad", - "value": "Moms Potato Salad" - }, - { - "selected": false, - "label": "Moms Roasted Chicken", - "value": "Moms Roasted Chicken" - }, - { - "selected": false, - "label": "Moms Sliced Chicken", - "value": "Moms Sliced Chicken" - }, - { - "selected": false, - "label": "Moms Sliced Ham", - "value": "Moms Sliced Ham" - }, - { - "selected": false, - "label": "Moms Sliced Turkey", - "value": "Moms Sliced Turkey" - }, - { - "selected": false, - "label": "Moms Turkey Hot Dogs", - "value": "Moms Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Monarch Manicotti", - "value": "Monarch Manicotti" - }, - { - "selected": false, - "label": "Monarch Ravioli", - "value": "Monarch Ravioli" - }, - { - "selected": false, - "label": "Monarch Rice Medly", - "value": "Monarch Rice Medly" - }, - { - "selected": false, - "label": "Monarch Spaghetti", - "value": "Monarch Spaghetti" - }, - { - "selected": false, - "label": "Monarch Thai Rice", - "value": "Monarch Thai Rice" - }, - { - "selected": false, - "label": "Musial Bubble Gum", - "value": "Musial Bubble Gum" - }, - { - "selected": false, - "label": "Musial Malted Milk Balls", - "value": "Musial Malted Milk Balls" - }, - { - "selected": false, - "label": "Musial Mint Chocolate Bar", - "value": "Musial Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Musial Mints", - "value": "Musial Mints" - }, - { - "selected": false, - "label": "Musial Semi-Sweet Chocolate Bar", - "value": "Musial Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Musial Spicy Mints", - "value": "Musial Spicy Mints" - }, - { - "selected": false, - "label": "Musial Tasty Candy Bar", - "value": "Musial Tasty Candy Bar" - }, - { - "selected": false, - "label": "Musial White Chocolate Bar", - "value": "Musial White Chocolate Bar" - }, - { - "selected": false, - "label": "National Egg Substitute", - "value": "National Egg Substitute" - }, - { - "selected": false, - "label": "National Large Brown Eggs", - "value": "National Large Brown Eggs" - }, - { - "selected": false, - "label": "National Large Eggs", - "value": "National Large Eggs" - }, - { - "selected": false, - "label": "National Small Brown Eggs", - "value": "National Small Brown Eggs" - }, - { - "selected": false, - "label": "National Small Eggs", - "value": "National Small Eggs" - }, - { - "selected": false, - "label": "Nationeel Apple Fruit Roll", - "value": "Nationeel Apple Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Avocado Dip", - "value": "Nationeel Avocado Dip" - }, - { - "selected": false, - "label": "Nationeel BBQ Potato Chips", - "value": "Nationeel BBQ Potato Chips" - }, - { - "selected": false, - "label": "Nationeel Beef Jerky", - "value": "Nationeel Beef Jerky" - }, - { - "selected": false, - "label": "Nationeel Buttered Popcorn", - "value": "Nationeel Buttered Popcorn" - }, - { - "selected": false, - "label": "Nationeel Cheese Crackers", - "value": "Nationeel Cheese Crackers" - }, - { - "selected": false, - "label": "Nationeel Cheese Dip", - "value": "Nationeel Cheese Dip" - }, - { - "selected": false, - "label": "Nationeel Chocolate Chip Cookies", - "value": "Nationeel Chocolate Chip Cookies" - }, - { - "selected": false, - "label": "Nationeel Chocolate Donuts", - "value": "Nationeel Chocolate Donuts" - }, - { - "selected": false, - "label": "Nationeel Corn Chips", - "value": "Nationeel Corn Chips" - }, - { - "selected": false, - "label": "Nationeel Dried Apples", - "value": "Nationeel Dried Apples" - }, - { - "selected": false, - "label": "Nationeel Dried Apricots", - "value": "Nationeel Dried Apricots" - }, - { - "selected": false, - "label": "Nationeel Dried Dates", - "value": "Nationeel Dried Dates" - }, - { - "selected": false, - "label": "Nationeel Fondue Mix", - "value": "Nationeel Fondue Mix" - }, - { - "selected": false, - "label": "Nationeel Frosted Cookies", - "value": "Nationeel Frosted Cookies" - }, - { - "selected": false, - "label": "Nationeel Frosted Donuts", - "value": "Nationeel Frosted Donuts" - }, - { - "selected": false, - "label": "Nationeel Fudge Brownies", - "value": "Nationeel Fudge Brownies" - }, - { - "selected": false, - "label": "Nationeel Fudge Cookies", - "value": "Nationeel Fudge Cookies" - }, - { - "selected": false, - "label": "Nationeel Golden Raisins", - "value": "Nationeel Golden Raisins" - }, - { - "selected": false, - "label": "Nationeel Graham Crackers", - "value": "Nationeel Graham Crackers" - }, - { - "selected": false, - "label": "Nationeel Grape Fruit Roll", - "value": "Nationeel Grape Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Lemon Cookies", - "value": "Nationeel Lemon Cookies" - }, - { - "selected": false, - "label": "Nationeel Low Fat BBQ Chips", - "value": "Nationeel Low Fat BBQ Chips" - }, - { - "selected": false, - "label": "Nationeel Low Fat Chips", - "value": "Nationeel Low Fat Chips" - }, - { - "selected": false, - "label": "Nationeel Low Fat Cookies", - "value": "Nationeel Low Fat Cookies" - }, - { - "selected": false, - "label": "Nationeel Low Fat Popcorn", - "value": "Nationeel Low Fat Popcorn" - }, - { - "selected": false, - "label": "Nationeel Mini Donuts", - "value": "Nationeel Mini Donuts" - }, - { - "selected": false, - "label": "Nationeel No Salt Popcorn", - "value": "Nationeel No Salt Popcorn" - }, - { - "selected": false, - "label": "Nationeel Potato Chips", - "value": "Nationeel Potato Chips" - }, - { - "selected": false, - "label": "Nationeel Raisins", - "value": "Nationeel Raisins" - }, - { - "selected": false, - "label": "Nationeel Raspberry Fruit Roll", - "value": "Nationeel Raspberry Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Salsa Dip", - "value": "Nationeel Salsa Dip" - }, - { - "selected": false, - "label": "Nationeel Salted Pretzels", - "value": "Nationeel Salted Pretzels" - }, - { - "selected": false, - "label": "Nationeel Sesame Crackers", - "value": "Nationeel Sesame Crackers" - }, - { - "selected": false, - "label": "Nationeel Strawberry Fruit Roll", - "value": "Nationeel Strawberry Fruit Roll" - }, - { - "selected": false, - "label": "Nationeel Sugar Cookies", - "value": "Nationeel Sugar Cookies" - }, - { - "selected": false, - "label": "Pearl Chablis Wine", - "value": "Pearl Chablis Wine" - }, - { - "selected": false, - "label": "Pearl Chardonnay", - "value": "Pearl Chardonnay" - }, - { - "selected": false, - "label": "Pearl Chardonnay Wine", - "value": "Pearl Chardonnay Wine" - }, - { - "selected": false, - "label": "Pearl Imported Beer", - "value": "Pearl Imported Beer" - }, - { - "selected": false, - "label": "Pearl Light Beer", - "value": "Pearl Light Beer" - }, - { - "selected": false, - "label": "Pearl Light Wine", - "value": "Pearl Light Wine" - }, - { - "selected": false, - "label": "Pearl Merlot Wine", - "value": "Pearl Merlot Wine" - }, - { - "selected": false, - "label": "Pearl White Zinfandel Wine", - "value": "Pearl White Zinfandel Wine" - }, - { - "selected": false, - "label": "PigTail Apple Cinnamon Waffles", - "value": "PigTail Apple Cinnamon Waffles" - }, - { - "selected": false, - "label": "PigTail Beef TV Dinner", - "value": "PigTail Beef TV Dinner" - }, - { - "selected": false, - "label": "PigTail Blueberry Waffles", - "value": "PigTail Blueberry Waffles" - }, - { - "selected": false, - "label": "PigTail Chicken TV Dinner", - "value": "PigTail Chicken TV Dinner" - }, - { - "selected": false, - "label": "PigTail Fajita French Fries", - "value": "PigTail Fajita French Fries" - }, - { - "selected": false, - "label": "PigTail Frozen Broccoli", - "value": "PigTail Frozen Broccoli" - }, - { - "selected": false, - "label": "PigTail Frozen Carrots", - "value": "PigTail Frozen Carrots" - }, - { - "selected": false, - "label": "PigTail Frozen Cauliflower", - "value": "PigTail Frozen Cauliflower" - }, - { - "selected": false, - "label": "PigTail Frozen Cheese Pizza", - "value": "PigTail Frozen Cheese Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Breast", - "value": "PigTail Frozen Chicken Breast" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Thighs", - "value": "PigTail Frozen Chicken Thighs" - }, - { - "selected": false, - "label": "PigTail Frozen Chicken Wings", - "value": "PigTail Frozen Chicken Wings" - }, - { - "selected": false, - "label": "PigTail Frozen Corn", - "value": "PigTail Frozen Corn" - }, - { - "selected": false, - "label": "PigTail Frozen Mushroom Pizza", - "value": "PigTail Frozen Mushroom Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Pancakes", - "value": "PigTail Frozen Pancakes" - }, - { - "selected": false, - "label": "PigTail Frozen Peas", - "value": "PigTail Frozen Peas" - }, - { - "selected": false, - "label": "PigTail Frozen Pepperoni Pizza", - "value": "PigTail Frozen Pepperoni Pizza" - }, - { - "selected": false, - "label": "PigTail Frozen Sausage Pizza", - "value": "PigTail Frozen Sausage Pizza" - }, - { - "selected": false, - "label": "PigTail Grape Popsicles", - "value": "PigTail Grape Popsicles" - }, - { - "selected": false, - "label": "PigTail Home Style French Fries", - "value": "PigTail Home Style French Fries" - }, - { - "selected": false, - "label": "PigTail Ice Cream", - "value": "PigTail Ice Cream" - }, - { - "selected": false, - "label": "PigTail Ice Cream Sandwich", - "value": "PigTail Ice Cream Sandwich" - }, - { - "selected": false, - "label": "PigTail Lemon Popsicles", - "value": "PigTail Lemon Popsicles" - }, - { - "selected": false, - "label": "PigTail Lime Popsicles", - "value": "PigTail Lime Popsicles" - }, - { - "selected": false, - "label": "PigTail Low Fat French Fries", - "value": "PigTail Low Fat French Fries" - }, - { - "selected": false, - "label": "PigTail Low Fat Waffles", - "value": "PigTail Low Fat Waffles" - }, - { - "selected": false, - "label": "PigTail Orange Popsicles", - "value": "PigTail Orange Popsicles" - }, - { - "selected": false, - "label": "PigTail Pancake Mix", - "value": "PigTail Pancake Mix" - }, - { - "selected": false, - "label": "PigTail Popsicles", - "value": "PigTail Popsicles" - }, - { - "selected": false, - "label": "PigTail Turkey TV Dinner", - "value": "PigTail Turkey TV Dinner" - }, - { - "selected": false, - "label": "PigTail Waffles", - "value": "PigTail Waffles" - }, - { - "selected": false, - "label": "Plato Apple Butter", - "value": "Plato Apple Butter" - }, - { - "selected": false, - "label": "Plato Apple Jam", - "value": "Plato Apple Jam" - }, - { - "selected": false, - "label": "Plato Apple Jelly", - "value": "Plato Apple Jelly" - }, - { - "selected": false, - "label": "Plato Apple Preserves", - "value": "Plato Apple Preserves" - }, - { - "selected": false, - "label": "Plato Brown Sugar", - "value": "Plato Brown Sugar" - }, - { - "selected": false, - "label": "Plato Canola Oil", - "value": "Plato Canola Oil" - }, - { - "selected": false, - "label": "Plato Chunky Peanut Butter", - "value": "Plato Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Plato Columbian Coffee", - "value": "Plato Columbian Coffee" - }, - { - "selected": false, - "label": "Plato Corn Oil", - "value": "Plato Corn Oil" - }, - { - "selected": false, - "label": "Plato Creamy Peanut Butter", - "value": "Plato Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Plato Decaf Coffee", - "value": "Plato Decaf Coffee" - }, - { - "selected": false, - "label": "Plato Extra Chunky Peanut Butter", - "value": "Plato Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Plato French Roast Coffee", - "value": "Plato French Roast Coffee" - }, - { - "selected": false, - "label": "Plato Grape Jam", - "value": "Plato Grape Jam" - }, - { - "selected": false, - "label": "Plato Grape Jelly", - "value": "Plato Grape Jelly" - }, - { - "selected": false, - "label": "Plato Grape Preserves", - "value": "Plato Grape Preserves" - }, - { - "selected": false, - "label": "Plato Hot Chocolate", - "value": "Plato Hot Chocolate" - }, - { - "selected": false, - "label": "Plato Low Fat Apple Butter", - "value": "Plato Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Plato Oregano", - "value": "Plato Oregano" - }, - { - "selected": false, - "label": "Plato Pepper", - "value": "Plato Pepper" - }, - { - "selected": false, - "label": "Plato Regular Coffee", - "value": "Plato Regular Coffee" - }, - { - "selected": false, - "label": "Plato Salt", - "value": "Plato Salt" - }, - { - "selected": false, - "label": "Plato Sesame Oil", - "value": "Plato Sesame Oil" - }, - { - "selected": false, - "label": "Plato Strawberry Jam", - "value": "Plato Strawberry Jam" - }, - { - "selected": false, - "label": "Plato Strawberry Jelly", - "value": "Plato Strawberry Jelly" - }, - { - "selected": false, - "label": "Plato Strawberry Preserves", - "value": "Plato Strawberry Preserves" - }, - { - "selected": false, - "label": "Plato Tomato Sauce", - "value": "Plato Tomato Sauce" - }, - { - "selected": false, - "label": "Plato Vegetable Oil", - "value": "Plato Vegetable Oil" - }, - { - "selected": false, - "label": "Plato White Sugar", - "value": "Plato White Sugar" - }, - { - "selected": false, - "label": "Pleasant Beef Soup", - "value": "Pleasant Beef Soup" - }, - { - "selected": false, - "label": "Pleasant Canned Beets", - "value": "Pleasant Canned Beets" - }, - { - "selected": false, - "label": "Pleasant Canned Peas", - "value": "Pleasant Canned Peas" - }, - { - "selected": false, - "label": "Pleasant Canned String Beans", - "value": "Pleasant Canned String Beans" - }, - { - "selected": false, - "label": "Pleasant Canned Tomatos", - "value": "Pleasant Canned Tomatos" - }, - { - "selected": false, - "label": "Pleasant Canned Tuna in Oil", - "value": "Pleasant Canned Tuna in Oil" - }, - { - "selected": false, - "label": "Pleasant Canned Tuna in Water", - "value": "Pleasant Canned Tuna in Water" - }, - { - "selected": false, - "label": "Pleasant Canned Yams", - "value": "Pleasant Canned Yams" - }, - { - "selected": false, - "label": "Pleasant Chicken Noodle Soup", - "value": "Pleasant Chicken Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Chicken Ramen Soup", - "value": "Pleasant Chicken Ramen Soup" - }, - { - "selected": false, - "label": "Pleasant Chicken Soup", - "value": "Pleasant Chicken Soup" - }, - { - "selected": false, - "label": "Pleasant Creamed Corn", - "value": "Pleasant Creamed Corn" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Anchovies", - "value": "Pleasant Fancy Canned Anchovies" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Clams", - "value": "Pleasant Fancy Canned Clams" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Oysters", - "value": "Pleasant Fancy Canned Oysters" - }, - { - "selected": false, - "label": "Pleasant Fancy Canned Sardines", - "value": "Pleasant Fancy Canned Sardines" - }, - { - "selected": false, - "label": "Pleasant Large Canned Shrimp", - "value": "Pleasant Large Canned Shrimp" - }, - { - "selected": false, - "label": "Pleasant Noodle Soup", - "value": "Pleasant Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Regular Ramen Soup", - "value": "Pleasant Regular Ramen Soup" - }, - { - "selected": false, - "label": "Pleasant Rice Soup", - "value": "Pleasant Rice Soup" - }, - { - "selected": false, - "label": "Pleasant Turkey Noodle Soup", - "value": "Pleasant Turkey Noodle Soup" - }, - { - "selected": false, - "label": "Pleasant Vegetable Soup", - "value": "Pleasant Vegetable Soup" - }, - { - "selected": false, - "label": "Portsmouth Chablis Wine", - "value": "Portsmouth Chablis Wine" - }, - { - "selected": false, - "label": "Portsmouth Chardonnay", - "value": "Portsmouth Chardonnay" - }, - { - "selected": false, - "label": "Portsmouth Chardonnay Wine", - "value": "Portsmouth Chardonnay Wine" - }, - { - "selected": false, - "label": "Portsmouth Imported Beer", - "value": "Portsmouth Imported Beer" - }, - { - "selected": false, - "label": "Portsmouth Light Beer", - "value": "Portsmouth Light Beer" - }, - { - "selected": false, - "label": "Portsmouth Light Wine", - "value": "Portsmouth Light Wine" - }, - { - "selected": false, - "label": "Portsmouth Merlot Wine", - "value": "Portsmouth Merlot Wine" - }, - { - "selected": false, - "label": "Portsmouth White Zinfandel Wine", - "value": "Portsmouth White Zinfandel Wine" - }, - { - "selected": false, - "label": "Prelude Rosy Sunglasses", - "value": "Prelude Rosy Sunglasses" - }, - { - "selected": false, - "label": "Queen City Map", - "value": "Queen City Map" - }, - { - "selected": false, - "label": "Queen Eyeglass Screwdriver", - "value": "Queen Eyeglass Screwdriver" - }, - { - "selected": false, - "label": "Quick Extra Lean Hamburger", - "value": "Quick Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Quick Seasoned Hamburger", - "value": "Quick Seasoned Hamburger" - }, - { - "selected": false, - "label": "Radius Corn Puffs", - "value": "Radius Corn Puffs" - }, - { - "selected": false, - "label": "Radius Grits", - "value": "Radius Grits" - }, - { - "selected": false, - "label": "Radius Oatmeal", - "value": "Radius Oatmeal" - }, - { - "selected": false, - "label": "Radius Wheat Puffs", - "value": "Radius Wheat Puffs" - }, - { - "selected": false, - "label": "Red Spade Beef Bologna", - "value": "Red Spade Beef Bologna" - }, - { - "selected": false, - "label": "Red Spade Chicken Hot Dogs", - "value": "Red Spade Chicken Hot Dogs" - }, - { - "selected": false, - "label": "Red Spade Cole Slaw", - "value": "Red Spade Cole Slaw" - }, - { - "selected": false, - "label": "Red Spade Corned Beef", - "value": "Red Spade Corned Beef" - }, - { - "selected": false, - "label": "Red Spade Foot-Long Hot Dogs", - "value": "Red Spade Foot-Long Hot Dogs" - }, - { - "selected": false, - "label": "Red Spade Low Fat Bologna", - "value": "Red Spade Low Fat Bologna" - }, - { - "selected": false, - "label": "Red Spade Low Fat Cole Slaw", - "value": "Red Spade Low Fat Cole Slaw" - }, - { - "selected": false, - "label": "Red Spade Pimento Loaf", - "value": "Red Spade Pimento Loaf" - }, - { - "selected": false, - "label": "Red Spade Potato Salad", - "value": "Red Spade Potato Salad" - }, - { - "selected": false, - "label": "Red Spade Roasted Chicken", - "value": "Red Spade Roasted Chicken" - }, - { - "selected": false, - "label": "Red Spade Sliced Chicken", - "value": "Red Spade Sliced Chicken" - }, - { - "selected": false, - "label": "Red Spade Sliced Ham", - "value": "Red Spade Sliced Ham" - }, - { - "selected": false, - "label": "Red Spade Sliced Turkey", - "value": "Red Spade Sliced Turkey" - }, - { - "selected": false, - "label": "Red Spade Turkey Hot Dogs", - "value": "Red Spade Turkey Hot Dogs" - }, - { - "selected": false, - "label": "Red Wing 100 Watt Lightbulb", - "value": "Red Wing 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 25 Watt Lightbulb", - "value": "Red Wing 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 60 Watt Lightbulb", - "value": "Red Wing 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing 75 Watt Lightbulb", - "value": "Red Wing 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Red Wing AAA-Size Batteries", - "value": "Red Wing AAA-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing AA-Size Batteries", - "value": "Red Wing AA-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing Bees Wax Candles", - "value": "Red Wing Bees Wax Candles" - }, - { - "selected": false, - "label": "Red Wing Copper Cleaner", - "value": "Red Wing Copper Cleaner" - }, - { - "selected": false, - "label": "Red Wing Copper Pot Scrubber", - "value": "Red Wing Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Red Wing Counter Cleaner", - "value": "Red Wing Counter Cleaner" - }, - { - "selected": false, - "label": "Red Wing C-Size Batteries", - "value": "Red Wing C-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing D-Size Batteries", - "value": "Red Wing D-Size Batteries" - }, - { - "selected": false, - "label": "Red Wing Economy Toilet Brush", - "value": "Red Wing Economy Toilet Brush" - }, - { - "selected": false, - "label": "Red Wing Frying Pan", - "value": "Red Wing Frying Pan" - }, - { - "selected": false, - "label": "Red Wing Glass Cleaner", - "value": "Red Wing Glass Cleaner" - }, - { - "selected": false, - "label": "Red Wing Large Sponge", - "value": "Red Wing Large Sponge" - }, - { - "selected": false, - "label": "Red Wing Paper Cups", - "value": "Red Wing Paper Cups" - }, - { - "selected": false, - "label": "Red Wing Paper Plates", - "value": "Red Wing Paper Plates" - }, - { - "selected": false, - "label": "Red Wing Paper Towels", - "value": "Red Wing Paper Towels" - }, - { - "selected": false, - "label": "Red Wing Plastic Forks", - "value": "Red Wing Plastic Forks" - }, - { - "selected": false, - "label": "Red Wing Plastic Knives", - "value": "Red Wing Plastic Knives" - }, - { - "selected": false, - "label": "Red Wing Plastic Spoons", - "value": "Red Wing Plastic Spoons" - }, - { - "selected": false, - "label": "Red Wing Room Freshener", - "value": "Red Wing Room Freshener" - }, - { - "selected": false, - "label": "Red Wing Scented Tissue", - "value": "Red Wing Scented Tissue" - }, - { - "selected": false, - "label": "Red Wing Scented Toilet Tissue", - "value": "Red Wing Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Red Wing Scissors", - "value": "Red Wing Scissors" - }, - { - "selected": false, - "label": "Red Wing Screw Driver", - "value": "Red Wing Screw Driver" - }, - { - "selected": false, - "label": "Red Wing Silver Cleaner", - "value": "Red Wing Silver Cleaner" - }, - { - "selected": false, - "label": "Red Wing Soft Napkins", - "value": "Red Wing Soft Napkins" - }, - { - "selected": false, - "label": "Red Wing Tissues", - "value": "Red Wing Tissues" - }, - { - "selected": false, - "label": "Red Wing Toilet Bowl Cleaner", - "value": "Red Wing Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Red Wing Toilet Paper", - "value": "Red Wing Toilet Paper" - }, - { - "selected": false, - "label": "Robust Monthly Auto Magazine", - "value": "Robust Monthly Auto Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Computer Magazine", - "value": "Robust Monthly Computer Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Fashion Magazine", - "value": "Robust Monthly Fashion Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Home Magazine", - "value": "Robust Monthly Home Magazine" - }, - { - "selected": false, - "label": "Robust Monthly Sports Magazine", - "value": "Robust Monthly Sports Magazine" - }, - { - "selected": false, - "label": "Shady Lake Manicotti", - "value": "Shady Lake Manicotti" - }, - { - "selected": false, - "label": "Shady Lake Ravioli", - "value": "Shady Lake Ravioli" - }, - { - "selected": false, - "label": "Shady Lake Rice Medly", - "value": "Shady Lake Rice Medly" - }, - { - "selected": false, - "label": "Shady Lake Spaghetti", - "value": "Shady Lake Spaghetti" - }, - { - "selected": false, - "label": "Shady Lake Thai Rice", - "value": "Shady Lake Thai Rice" - }, - { - "selected": false, - "label": "Ship Shape Extra Lean Hamburger", - "value": "Ship Shape Extra Lean Hamburger" - }, - { - "selected": false, - "label": "Ship Shape Seasoned Hamburger", - "value": "Ship Shape Seasoned Hamburger" - }, - { - "selected": false, - "label": "Skinner Apple Drink", - "value": "Skinner Apple Drink" - }, - { - "selected": false, - "label": "Skinner Apple Juice", - "value": "Skinner Apple Juice" - }, - { - "selected": false, - "label": "Skinner Berry Juice", - "value": "Skinner Berry Juice" - }, - { - "selected": false, - "label": "Skinner Cola", - "value": "Skinner Cola" - }, - { - "selected": false, - "label": "Skinner Cranberry Juice", - "value": "Skinner Cranberry Juice" - }, - { - "selected": false, - "label": "Skinner Cream Soda", - "value": "Skinner Cream Soda" - }, - { - "selected": false, - "label": "Skinner Diet Cola", - "value": "Skinner Diet Cola" - }, - { - "selected": false, - "label": "Skinner Diet Soda", - "value": "Skinner Diet Soda" - }, - { - "selected": false, - "label": "Skinner Mango Drink", - "value": "Skinner Mango Drink" - }, - { - "selected": false, - "label": "Skinner Orange Juice", - "value": "Skinner Orange Juice" - }, - { - "selected": false, - "label": "Skinner Strawberry Drink", - "value": "Skinner Strawberry Drink" - }, - { - "selected": false, - "label": "Special Corn Puffs", - "value": "Special Corn Puffs" - }, - { - "selected": false, - "label": "Special Grits", - "value": "Special Grits" - }, - { - "selected": false, - "label": "Special Oatmeal", - "value": "Special Oatmeal" - }, - { - "selected": false, - "label": "Special Wheat Puffs", - "value": "Special Wheat Puffs" - }, - { - "selected": false, - "label": "Sphinx Bagels", - "value": "Sphinx Bagels" - }, - { - "selected": false, - "label": "Sphinx Blueberry Muffins", - "value": "Sphinx Blueberry Muffins" - }, - { - "selected": false, - "label": "Sphinx Cranberry Muffins", - "value": "Sphinx Cranberry Muffins" - }, - { - "selected": false, - "label": "Sphinx English Muffins", - "value": "Sphinx English Muffins" - }, - { - "selected": false, - "label": "Sphinx Muffins", - "value": "Sphinx Muffins" - }, - { - "selected": false, - "label": "Sphinx Pumpernickel Bread", - "value": "Sphinx Pumpernickel Bread" - }, - { - "selected": false, - "label": "Sphinx Rye Bread", - "value": "Sphinx Rye Bread" - }, - { - "selected": false, - "label": "Sphinx Wheat Bread", - "value": "Sphinx Wheat Bread" - }, - { - "selected": false, - "label": "Sphinx White Bread", - "value": "Sphinx White Bread" - }, - { - "selected": false, - "label": "Steady 200 MG Acetominifen", - "value": "Steady 200 MG Acetominifen" - }, - { - "selected": false, - "label": "Steady 200 MG Ibuprofen", - "value": "Steady 200 MG Ibuprofen" - }, - { - "selected": false, - "label": "Steady Angled Toothbrush", - "value": "Steady Angled Toothbrush" - }, - { - "selected": false, - "label": "Steady Apricot Shampoo", - "value": "Steady Apricot Shampoo" - }, - { - "selected": false, - "label": "Steady Buffered Aspirin", - "value": "Steady Buffered Aspirin" - }, - { - "selected": false, - "label": "Steady Childrens Aspirin", - "value": "Steady Childrens Aspirin" - }, - { - "selected": false, - "label": "Steady Childrens Cold Remedy", - "value": "Steady Childrens Cold Remedy" - }, - { - "selected": false, - "label": "Steady Conditioning Shampoo", - "value": "Steady Conditioning Shampoo" - }, - { - "selected": false, - "label": "Steady Deodorant", - "value": "Steady Deodorant" - }, - { - "selected": false, - "label": "Steady Dishwasher Detergent", - "value": "Steady Dishwasher Detergent" - }, - { - "selected": false, - "label": "Steady Extra Moisture Shampoo", - "value": "Steady Extra Moisture Shampoo" - }, - { - "selected": false, - "label": "Steady HCL Nasal Spray", - "value": "Steady HCL Nasal Spray" - }, - { - "selected": false, - "label": "Steady Laundry Detergent", - "value": "Steady Laundry Detergent" - }, - { - "selected": false, - "label": "Steady Mint Mouthwash", - "value": "Steady Mint Mouthwash" - }, - { - "selected": false, - "label": "Steady Multi-Symptom Cold Remedy", - "value": "Steady Multi-Symptom Cold Remedy" - }, - { - "selected": false, - "label": "Steady Silky Smooth Hair Conditioner", - "value": "Steady Silky Smooth Hair Conditioner" - }, - { - "selected": false, - "label": "Steady Tartar Control Toothpaste", - "value": "Steady Tartar Control Toothpaste" - }, - { - "selected": false, - "label": "Steady Toothpaste", - "value": "Steady Toothpaste" - }, - { - "selected": false, - "label": "Steady Whitening Toothpast", - "value": "Steady Whitening Toothpast" - }, - { - "selected": false, - "label": "Sunset 100 Watt Lightbulb", - "value": "Sunset 100 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 25 Watt Lightbulb", - "value": "Sunset 25 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 60 Watt Lightbulb", - "value": "Sunset 60 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset 75 Watt Lightbulb", - "value": "Sunset 75 Watt Lightbulb" - }, - { - "selected": false, - "label": "Sunset AAA-Size Batteries", - "value": "Sunset AAA-Size Batteries" - }, - { - "selected": false, - "label": "Sunset AA-Size Batteries", - "value": "Sunset AA-Size Batteries" - }, - { - "selected": false, - "label": "Sunset Bees Wax Candles", - "value": "Sunset Bees Wax Candles" - }, - { - "selected": false, - "label": "Sunset Copper Cleaner", - "value": "Sunset Copper Cleaner" - }, - { - "selected": false, - "label": "Sunset Copper Pot Scrubber", - "value": "Sunset Copper Pot Scrubber" - }, - { - "selected": false, - "label": "Sunset Counter Cleaner", - "value": "Sunset Counter Cleaner" - }, - { - "selected": false, - "label": "Sunset C-Size Batteries", - "value": "Sunset C-Size Batteries" - }, - { - "selected": false, - "label": "Sunset D-Size Batteries", - "value": "Sunset D-Size Batteries" - }, - { - "selected": false, - "label": "Sunset Economy Toilet Brush", - "value": "Sunset Economy Toilet Brush" - }, - { - "selected": false, - "label": "Sunset Frying Pan", - "value": "Sunset Frying Pan" - }, - { - "selected": false, - "label": "Sunset Glass Cleaner", - "value": "Sunset Glass Cleaner" - }, - { - "selected": false, - "label": "Sunset Large Sponge", - "value": "Sunset Large Sponge" - }, - { - "selected": false, - "label": "Sunset Paper Cups", - "value": "Sunset Paper Cups" - }, - { - "selected": false, - "label": "Sunset Paper Plates", - "value": "Sunset Paper Plates" - }, - { - "selected": false, - "label": "Sunset Paper Towels", - "value": "Sunset Paper Towels" - }, - { - "selected": false, - "label": "Sunset Plastic Forks", - "value": "Sunset Plastic Forks" - }, - { - "selected": false, - "label": "Sunset Plastic Knives", - "value": "Sunset Plastic Knives" - }, - { - "selected": false, - "label": "Sunset Plastic Spoons", - "value": "Sunset Plastic Spoons" - }, - { - "selected": false, - "label": "Sunset Room Freshener", - "value": "Sunset Room Freshener" - }, - { - "selected": false, - "label": "Sunset Scented Tissue", - "value": "Sunset Scented Tissue" - }, - { - "selected": false, - "label": "Sunset Scented Toilet Tissue", - "value": "Sunset Scented Toilet Tissue" - }, - { - "selected": false, - "label": "Sunset Scissors", - "value": "Sunset Scissors" - }, - { - "selected": false, - "label": "Sunset Screw Driver", - "value": "Sunset Screw Driver" - }, - { - "selected": false, - "label": "Sunset Silver Cleaner", - "value": "Sunset Silver Cleaner" - }, - { - "selected": false, - "label": "Sunset Soft Napkins", - "value": "Sunset Soft Napkins" - }, - { - "selected": false, - "label": "Sunset Tissues", - "value": "Sunset Tissues" - }, - { - "selected": false, - "label": "Sunset Toilet Bowl Cleaner", - "value": "Sunset Toilet Bowl Cleaner" - }, - { - "selected": false, - "label": "Sunset Toilet Paper", - "value": "Sunset Toilet Paper" - }, - { - "selected": false, - "label": "Super Apple Butter", - "value": "Super Apple Butter" - }, - { - "selected": false, - "label": "Super Apple Jam", - "value": "Super Apple Jam" - }, - { - "selected": false, - "label": "Super Apple Jelly", - "value": "Super Apple Jelly" - }, - { - "selected": false, - "label": "Super Apple Preserves", - "value": "Super Apple Preserves" - }, - { - "selected": false, - "label": "Super Brown Sugar", - "value": "Super Brown Sugar" - }, - { - "selected": false, - "label": "Super Canola Oil", - "value": "Super Canola Oil" - }, - { - "selected": false, - "label": "Super Chunky Peanut Butter", - "value": "Super Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Super Columbian Coffee", - "value": "Super Columbian Coffee" - }, - { - "selected": false, - "label": "Super Corn Oil", - "value": "Super Corn Oil" - }, - { - "selected": false, - "label": "Super Creamy Peanut Butter", - "value": "Super Creamy Peanut Butter" - }, - { - "selected": false, - "label": "Super Decaf Coffee", - "value": "Super Decaf Coffee" - }, - { - "selected": false, - "label": "Super Extra Chunky Peanut Butter", - "value": "Super Extra Chunky Peanut Butter" - }, - { - "selected": false, - "label": "Super French Roast Coffee", - "value": "Super French Roast Coffee" - }, - { - "selected": false, - "label": "Super Grape Jam", - "value": "Super Grape Jam" - }, - { - "selected": false, - "label": "Super Grape Jelly", - "value": "Super Grape Jelly" - }, - { - "selected": false, - "label": "Super Grape Preserves", - "value": "Super Grape Preserves" - }, - { - "selected": false, - "label": "Super Hot Chocolate", - "value": "Super Hot Chocolate" - }, - { - "selected": false, - "label": "Super Low Fat Apple Butter", - "value": "Super Low Fat Apple Butter" - }, - { - "selected": false, - "label": "Super Oregano", - "value": "Super Oregano" - }, - { - "selected": false, - "label": "Super Pepper", - "value": "Super Pepper" - }, - { - "selected": false, - "label": "Super Regular Coffee", - "value": "Super Regular Coffee" - }, - { - "selected": false, - "label": "Super Salt", - "value": "Super Salt" - }, - { - "selected": false, - "label": "Super Sesame Oil", - "value": "Super Sesame Oil" - }, - { - "selected": false, - "label": "Super Strawberry Jam", - "value": "Super Strawberry Jam" - }, - { - "selected": false, - "label": "Super Strawberry Jelly", - "value": "Super Strawberry Jelly" - }, - { - "selected": false, - "label": "Super Strawberry Preserves", - "value": "Super Strawberry Preserves" - }, - { - "selected": false, - "label": "Super Tomato Sauce", - "value": "Super Tomato Sauce" - }, - { - "selected": false, - "label": "Super Vegetable Oil", - "value": "Super Vegetable Oil" - }, - { - "selected": false, - "label": "Super White Sugar", - "value": "Super White Sugar" - }, - { - "selected": false, - "label": "Swell Canned Mixed Fruit", - "value": "Swell Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Swell Canned Peaches", - "value": "Swell Canned Peaches" - }, - { - "selected": false, - "label": "Symphony Rosy Sunglasses", - "value": "Symphony Rosy Sunglasses" - }, - { - "selected": false, - "label": "Tell Tale Almonds", - "value": "Tell Tale Almonds" - }, - { - "selected": false, - "label": "Tell Tale Asparagus", - "value": "Tell Tale Asparagus" - }, - { - "selected": false, - "label": "Tell Tale Baby Onion", - "value": "Tell Tale Baby Onion" - }, - { - "selected": false, - "label": "Tell Tale Beets", - "value": "Tell Tale Beets" - }, - { - "selected": false, - "label": "Tell Tale Broccoli", - "value": "Tell Tale Broccoli" - }, - { - "selected": false, - "label": "Tell Tale Canned Peanuts", - "value": "Tell Tale Canned Peanuts" - }, - { - "selected": false, - "label": "Tell Tale Cantelope", - "value": "Tell Tale Cantelope" - }, - { - "selected": false, - "label": "Tell Tale Cauliflower", - "value": "Tell Tale Cauliflower" - }, - { - "selected": false, - "label": "Tell Tale Corn on the Cob", - "value": "Tell Tale Corn on the Cob" - }, - { - "selected": false, - "label": "Tell Tale Dried Mushrooms", - "value": "Tell Tale Dried Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale Elephant Garlic", - "value": "Tell Tale Elephant Garlic" - }, - { - "selected": false, - "label": "Tell Tale Fancy Plums", - "value": "Tell Tale Fancy Plums" - }, - { - "selected": false, - "label": "Tell Tale Firm Tofu", - "value": "Tell Tale Firm Tofu" - }, - { - "selected": false, - "label": "Tell Tale Fresh Lima Beans", - "value": "Tell Tale Fresh Lima Beans" - }, - { - "selected": false, - "label": "Tell Tale Fuji Apples", - "value": "Tell Tale Fuji Apples" - }, - { - "selected": false, - "label": "Tell Tale Garlic", - "value": "Tell Tale Garlic" - }, - { - "selected": false, - "label": "Tell Tale Golden Delcious Apples", - "value": "Tell Tale Golden Delcious Apples" - }, - { - "selected": false, - "label": "Tell Tale Green Pepper", - "value": "Tell Tale Green Pepper" - }, - { - "selected": false, - "label": "Tell Tale Honey Dew", - "value": "Tell Tale Honey Dew" - }, - { - "selected": false, - "label": "Tell Tale Lemons", - "value": "Tell Tale Lemons" - }, - { - "selected": false, - "label": "Tell Tale Lettuce", - "value": "Tell Tale Lettuce" - }, - { - "selected": false, - "label": "Tell Tale Limes", - "value": "Tell Tale Limes" - }, - { - "selected": false, - "label": "Tell Tale Macintosh Apples", - "value": "Tell Tale Macintosh Apples" - }, - { - "selected": false, - "label": "Tell Tale Mandarin Oranges", - "value": "Tell Tale Mandarin Oranges" - }, - { - "selected": false, - "label": "Tell Tale Mixed Nuts", - "value": "Tell Tale Mixed Nuts" - }, - { - "selected": false, - "label": "Tell Tale Mushrooms", - "value": "Tell Tale Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale New Potatos", - "value": "Tell Tale New Potatos" - }, - { - "selected": false, - "label": "Tell Tale Onions", - "value": "Tell Tale Onions" - }, - { - "selected": false, - "label": "Tell Tale Oranges", - "value": "Tell Tale Oranges" - }, - { - "selected": false, - "label": "Tell Tale Party Nuts", - "value": "Tell Tale Party Nuts" - }, - { - "selected": false, - "label": "Tell Tale Peaches", - "value": "Tell Tale Peaches" - }, - { - "selected": false, - "label": "Tell Tale Plums", - "value": "Tell Tale Plums" - }, - { - "selected": false, - "label": "Tell Tale Potatos", - "value": "Tell Tale Potatos" - }, - { - "selected": false, - "label": "Tell Tale Prepared Salad", - "value": "Tell Tale Prepared Salad" - }, - { - "selected": false, - "label": "Tell Tale Red Delcious Apples", - "value": "Tell Tale Red Delcious Apples" - }, - { - "selected": false, - "label": "Tell Tale Red Pepper", - "value": "Tell Tale Red Pepper" - }, - { - "selected": false, - "label": "Tell Tale Shitake Mushrooms", - "value": "Tell Tale Shitake Mushrooms" - }, - { - "selected": false, - "label": "Tell Tale Squash", - "value": "Tell Tale Squash" - }, - { - "selected": false, - "label": "Tell Tale Summer Squash", - "value": "Tell Tale Summer Squash" - }, - { - "selected": false, - "label": "Tell Tale Sweet Onion", - "value": "Tell Tale Sweet Onion" - }, - { - "selected": false, - "label": "Tell Tale Sweet Peas", - "value": "Tell Tale Sweet Peas" - }, - { - "selected": false, - "label": "Tell Tale Tangerines", - "value": "Tell Tale Tangerines" - }, - { - "selected": false, - "label": "Tell Tale Tomatos", - "value": "Tell Tale Tomatos" - }, - { - "selected": false, - "label": "Tell Tale Walnuts", - "value": "Tell Tale Walnuts" - }, - { - "selected": false, - "label": "Thresher Bubble Gum", - "value": "Thresher Bubble Gum" - }, - { - "selected": false, - "label": "Thresher Malted Milk Balls", - "value": "Thresher Malted Milk Balls" - }, - { - "selected": false, - "label": "Thresher Mint Chocolate Bar", - "value": "Thresher Mint Chocolate Bar" - }, - { - "selected": false, - "label": "Thresher Mints", - "value": "Thresher Mints" - }, - { - "selected": false, - "label": "Thresher Semi-Sweet Chocolate Bar", - "value": "Thresher Semi-Sweet Chocolate Bar" - }, - { - "selected": false, - "label": "Thresher Spicy Mints", - "value": "Thresher Spicy Mints" - }, - { - "selected": false, - "label": "Thresher Tasty Candy Bar", - "value": "Thresher Tasty Candy Bar" - }, - { - "selected": false, - "label": "Thresher White Chocolate Bar", - "value": "Thresher White Chocolate Bar" - }, - { - "selected": false, - "label": "Tip Top Lox", - "value": "Tip Top Lox" - }, - { - "selected": false, - "label": "Tip Top Scallops", - "value": "Tip Top Scallops" - }, - { - "selected": false, - "label": "Token Apple Drink", - "value": "Token Apple Drink" - }, - { - "selected": false, - "label": "Token Apple Juice", - "value": "Token Apple Juice" - }, - { - "selected": false, - "label": "Token Berry Juice", - "value": "Token Berry Juice" - }, - { - "selected": false, - "label": "Token Cola", - "value": "Token Cola" - }, - { - "selected": false, - "label": "Token Cranberry Juice", - "value": "Token Cranberry Juice" - }, - { - "selected": false, - "label": "Token Cream Soda", - "value": "Token Cream Soda" - }, - { - "selected": false, - "label": "Token Diet Cola", - "value": "Token Diet Cola" - }, - { - "selected": false, - "label": "Token Diet Soda", - "value": "Token Diet Soda" - }, - { - "selected": false, - "label": "Token Mango Drink", - "value": "Token Mango Drink" - }, - { - "selected": false, - "label": "Token Orange Juice", - "value": "Token Orange Juice" - }, - { - "selected": false, - "label": "Token Strawberry Drink", - "value": "Token Strawberry Drink" - }, - { - "selected": false, - "label": "Top Measure Chablis Wine", - "value": "Top Measure Chablis Wine" - }, - { - "selected": false, - "label": "Top Measure Chardonnay", - "value": "Top Measure Chardonnay" - }, - { - "selected": false, - "label": "Top Measure Chardonnay Wine", - "value": "Top Measure Chardonnay Wine" - }, - { - "selected": false, - "label": "Top Measure Imported Beer", - "value": "Top Measure Imported Beer" - }, - { - "selected": false, - "label": "Top Measure Light Beer", - "value": "Top Measure Light Beer" - }, - { - "selected": false, - "label": "Top Measure Light Wine", - "value": "Top Measure Light Wine" - }, - { - "selected": false, - "label": "Top Measure Merlot Wine", - "value": "Top Measure Merlot Wine" - }, - { - "selected": false, - "label": "Top Measure White Zinfandel Wine", - "value": "Top Measure White Zinfandel Wine" - }, - { - "selected": false, - "label": "Toretti Rosy Sunglasses", - "value": "Toretti Rosy Sunglasses" - }, - { - "selected": false, - "label": "Toucan Canned Mixed Fruit", - "value": "Toucan Canned Mixed Fruit" - }, - { - "selected": false, - "label": "Toucan Canned Peaches", - "value": "Toucan Canned Peaches" - }, - { - "selected": false, - "label": "Tri-State Almonds", - "value": "Tri-State Almonds" - }, - { - "selected": false, - "label": "Tri-State Asparagus", - "value": "Tri-State Asparagus" - }, - { - "selected": false, - "label": "Tri-State Baby Onion", - "value": "Tri-State Baby Onion" - }, - { - "selected": false, - "label": "Tri-State Beets", - "value": "Tri-State Beets" - }, - { - "selected": false, - "label": "Tri-State Broccoli", - "value": "Tri-State Broccoli" - }, - { - "selected": false, - "label": "Tri-State Canned Peanuts", - "value": "Tri-State Canned Peanuts" - }, - { - "selected": false, - "label": "Tri-State Cantelope", - "value": "Tri-State Cantelope" - }, - { - "selected": false, - "label": "Tri-State Cauliflower", - "value": "Tri-State Cauliflower" - }, - { - "selected": false, - "label": "Tri-State Corn on the Cob", - "value": "Tri-State Corn on the Cob" - }, - { - "selected": false, - "label": "Tri-State Dried Mushrooms", - "value": "Tri-State Dried Mushrooms" - }, - { - "selected": false, - "label": "Tri-State Elephant Garlic", - "value": "Tri-State Elephant Garlic" - }, - { - "selected": false, - "label": "Tri-State Fancy Plums", - "value": "Tri-State Fancy Plums" - }, - { - "selected": false, - "label": "Tri-State Firm Tofu", - "value": "Tri-State Firm Tofu" - }, - { - "selected": false, - "label": "Tri-State Fresh Lima Beans", - "value": "Tri-State Fresh Lima Beans" - }, - { - "selected": false, - "label": "Tri-State Fuji Apples", - "value": "Tri-State Fuji Apples" - }, - { - "selected": false, - "label": "Tri-State Garlic", - "value": "Tri-State Garlic" - }, - { - "selected": false, - "label": "Tri-State Golden Delcious Apples", - "value": "Tri-State Golden Delcious Apples" - }, - { - "selected": false, - "label": "Tri-State Green Pepper", - "value": "Tri-State Green Pepper" - }, - { - "selected": false, - "label": "Tri-State Honey Dew", - "value": "Tri-State Honey Dew" - }, - { - "selected": false, - "label": "Tri-State Lemons", - "value": "Tri-State Lemons" - }, - { - "selected": false, - "label": "Tri-State Lettuce", - "value": "Tri-State Lettuce" - }, - { - "selected": false, - "label": "Tri-State Limes", - "value": "Tri-State Limes" - }, - { - "selected": false, - "label": "Tri-State Macintosh Apples", - "value": "Tri-State Macintosh Apples" - }, - { - "selected": false, - "label": "Tri-State Mandarin Oranges", - "value": "Tri-State Mandarin Oranges" - }, - { - "selected": false, - "label": "Tri-State Mixed Nuts", - "value": "Tri-State Mixed Nuts" - }, - { - "selected": false, - "label": "Tri-State Mushrooms", - "value": "Tri-State Mushrooms" - }, - { - "selected": false, - "label": "Tri-State New Potatos", - "value": "Tri-State New Potatos" - }, - { - "selected": false, - "label": "Tri-State Onions", - "value": "Tri-State Onions" - }, - { - "selected": false, - "label": "Tri-State Oranges", - "value": "Tri-State Oranges" - }, - { - "selected": false, - "label": "Tri-State Party Nuts", - "value": "Tri-State Party Nuts" - }, - { - "selected": false, - "label": "Tri-State Peaches", - "value": "Tri-State Peaches" - }, - { - "selected": false, - "label": "Tri-State Plums", - "value": "Tri-State Plums" - }, - { - "selected": false, - "label": "Tri-State Potatos", - "value": "Tri-State Potatos" - }, - { - "selected": false, - "label": "Tri-State Prepared Salad", - "value": "Tri-State Prepared Salad" - }, - { - "selected": false, - "label": "Tri-State Red Delcious Apples", - "value": "Tri-State Red Delcious Apples" - }, - { - "selected": false, - "label": "Tri-State Red Pepper", - "value": "Tri-State Red Pepper" - }, - { - "selected": false, - "label": "Tri-State Shitake Mushrooms", - "value": "Tri-State Shitake Mushrooms" - }, - { - "selected": false, - "label": "Tri-State Squash", - "value": "Tri-State Squash" - }, - { - "selected": false, - "label": "Tri-State Summer Squash", - "value": "Tri-State Summer Squash" - }, - { - "selected": false, - "label": "Tri-State Sweet Onion", - "value": "Tri-State Sweet Onion" - }, - { - "selected": false, - "label": "Tri-State Sweet Peas", - "value": "Tri-State Sweet Peas" - }, - { - "selected": false, - "label": "Tri-State Tangerines", - "value": "Tri-State Tangerines" - }, - { - "selected": false, - "label": "Tri-State Tomatos", - "value": "Tri-State Tomatos" - }, - { - "selected": false, - "label": "Tri-State Walnuts", - "value": "Tri-State Walnuts" - }, - { - "selected": false, - "label": "Urban Egg Substitute", - "value": "Urban Egg Substitute" - }, - { - "selected": false, - "label": "Urban Large Brown Eggs", - "value": "Urban Large Brown Eggs" - }, - { - "selected": false, - "label": "Urban Large Eggs", - "value": "Urban Large Eggs" - }, - { - "selected": false, - "label": "Urban Small Brown Eggs", - "value": "Urban Small Brown Eggs" - }, - { - "selected": false, - "label": "Urban Small Eggs", - "value": "Urban Small Eggs" - }, - { - "selected": false, - "label": "Walrus Chablis Wine", - "value": "Walrus Chablis Wine" - }, - { - "selected": false, - "label": "Walrus Chardonnay", - "value": "Walrus Chardonnay" - }, - { - "selected": false, - "label": "Walrus Chardonnay Wine", - "value": "Walrus Chardonnay Wine" - }, - { - "selected": false, - "label": "Walrus Imported Beer", - "value": "Walrus Imported Beer" - }, - { - "selected": false, - "label": "Walrus Light Beer", - "value": "Walrus Light Beer" - }, - { - "selected": false, - "label": "Walrus Light Wine", - "value": "Walrus Light Wine" - }, - { - "selected": false, - "label": "Walrus Merlot Wine", - "value": "Walrus Merlot Wine" - }, - { - "selected": false, - "label": "Walrus White Zinfandel Wine", - "value": "Walrus White Zinfandel Wine" - }, - { - "selected": false, - "label": "Washington Apple Drink", - "value": "Washington Apple Drink" - }, - { - "selected": false, - "label": "Washington Apple Juice", - "value": "Washington Apple Juice" - }, - { - "selected": false, - "label": "Washington Berry Juice", - "value": "Washington Berry Juice" - }, - { - "selected": false, - "label": "Washington Cola", - "value": "Washington Cola" - }, - { - "selected": false, - "label": "Washington Cranberry Juice", - "value": "Washington Cranberry Juice" - }, - { - "selected": false, - "label": "Washington Cream Soda", - "value": "Washington Cream Soda" - }, - { - "selected": false, - "label": "Washington Diet Cola", - "value": "Washington Diet Cola" - }, - { - "selected": false, - "label": "Washington Diet Soda", - "value": "Washington Diet Soda" - }, - { - "selected": false, - "label": "Washington Mango Drink", - "value": "Washington Mango Drink" - }, - { - "selected": false, - "label": "Washington Orange Juice", - "value": "Washington Orange Juice" - }, - { - "selected": false, - "label": "Washington Strawberry Drink", - "value": "Washington Strawberry Drink" - } - ] - }, - { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__recyclable_package_1", - "id": "sales__product__recyclable_package_1", - "options": [ - { - "selected": true, - "label": "true", - "value": "true" - }, - { - "selected": true, - "label": "false", - "value": "false" - } - ] - }, - { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales__product__low_fat_1", - "id": "sales__product__low_fat_1", - "options": [ - { - "selected": true, - "label": "true", - "value": "true" - }, - { - "selected": true, - "label": "false", - "value": "false" - } - ] - }, - { - "uri": "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment_files/sales_fact_ALL__store_sales_2013_1", - "id": "sales_fact_ALL__store_sales_2013_1", - "value": "19" - } - ] -} diff --git a/client/src/test/resources/input_controls_date.json b/client/src/test/resources/input_controls_date.json deleted file mode 100644 index 02730573..00000000 --- a/client/src/test/resources/input_controls_date.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "inputControl": [ - { - "id": "DateStart", - "type": "singleValueDatetime", - "uri": "repo:/organizations/organization_1/adhoc/topics/relativeDateTimeStamp/BEETWENDate_files/DateStart", - "label": "DateStart", - "mandatory": true, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "validationRules": [ - { - "mandatoryValidationRule": { - "errorMessage": "This field is mandatory so you must enter data." - } - }, - { - "dateTimeFormatValidationRule": { - "errorMessage": "Specify a valid date/time value.", - "format": "yyyy-MM-dd'T'HH:mm:ss" - } - } - ], - "state": { - "uri": "/organizations/organization_1/adhoc/topics/relativeDateTimeStamp/BEETWENDate_files/DateStart", - "id": "DateStart", - "value": "DAY" - } - }, - { - "id": "DateEnd", - "type": "singleValueDatetime", - "uri": "repo:/organizations/organization_1/adhoc/topics/relativeDateTimeStamp/BEETWENDate_files/DateEnd", - "label": "DateEnd", - "mandatory": true, - "readOnly": false, - "visible": true, - "masterDependencies": [], - "slaveDependencies": [], - "validationRules": [ - { - "mandatoryValidationRule": { - "errorMessage": "This field is mandatory so you must enter data." - } - }, - { - "dateTimeFormatValidationRule": { - "errorMessage": "Specify a valid date/time value.", - "format": "yyyy-MM-dd'T'HH:mm:ss" - } - } - ], - "state": { - "uri": "/organizations/organization_1/adhoc/topics/relativeDateTimeStamp/BEETWENDate_files/DateEnd", - "id": "DateEnd", - "value": "WEEK" - } - } - ] -} \ No newline at end of file diff --git a/client/src/test/resources/report_execution_data.json b/client/src/test/resources/report_execution_data.json deleted file mode 100644 index 9b7a248b..00000000 --- a/client/src/test/resources/report_execution_data.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "reportUnitUri":"/public/Samples/Reports/1._Geographic_Results_by_Segment_Report", - "async":true, - "freshData":false, - "saveDataSnapshot":false, - "outputFormat":"HTML", - "interactive":true, - "pages":"1", - "attachmentsPrefix":"http://mobiledemo.jaspersoft.com/jasperserver-pro/rest_v2/reportExecutions/{reportExecutionId}/exports/{exportOptions}/attachments/", - "parameters":{ - "reportParameter":[ - { - "name":"sales_fact_ALL__store_sales_2013_1", - "value":[ - "19" - ] - }, - { - "name":"sales__product__low_fat_1", - "value":[ - "false", - "true" - ] - }, - { - "name":"sales__product__recyclable_package_1", - "value":[ - "false", - "true" - ] - }, - { - "name":"sales__product__product_name_1", - "value":[ - - ] - } - ] - } -} \ No newline at end of file diff --git a/client/src/test/resources/report_parameters.json b/client/src/test/resources/report_parameters.json deleted file mode 100644 index 9498e5ac..00000000 --- a/client/src/test/resources/report_parameters.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "sales_fact_ALL__store_sales_2013_1": [ - "19" - ], - "sales__product__low_fat_1": [ - "false", - "true" - ], - "sales__product__recyclable_package_1": [ - "false", - "true" - ], - "sales__product__product_name_1": [] -} \ No newline at end of file diff --git a/client/src/test/resources/resource_lookup.json b/client/src/test/resources/resource_lookup.json deleted file mode 100644 index 39d40d45..00000000 --- a/client/src/test/resources/resource_lookup.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "resourceLookup": [ - { - "version": 0, - "permissionMask": 1, - "creationDate": "2015-06-10 13:01:48", - "updateDate": "2013-10-07 23:58:28", - "label": "1. Supermart Dashboard", - "description": "Sample Dashboard with HTML5 charts, and drill-through tables and gauges in blue theme", - "uri": "/organizations/organization_1/Dashboards/Supermart_Dashboard", - "resourceType": "dashboard" - }, - { - "version": 0, - "permissionMask": 1, - "creationDate": "2015-06-10 13:01:56", - "updateDate": "2013-10-07 23:58:28", - "label": "1. Supermart Dashboard", - "description": "Sample Dashboard with HTML5 charts, and drill-through tables and gauges in blue theme", - "uri": "/public/Samples/Dashboards/Supermart_Dashboard", - "resourceType": "dashboard" - }, - { - "version": 0, - "permissionMask": 1, - "creationDate": "2015-06-10 13:01:48", - "updateDate": "2013-09-19 07:54:50", - "label": "1g. Supermart Dashboard", - "description": "Sample Dashboard with HTML5 charts, and drill-through tables and gauges in green theme", - "uri": "/organizations/organization_1/Dashboards/1g__Supermart_Dashboard", - "resourceType": "dashboard" - }, - { - "version": 0, - "permissionMask": 1, - "creationDate": "2015-06-10 13:01:56", - "updateDate": "2013-09-19 07:54:50", - "label": "1g. Supermart Dashboard", - "description": "Sample Dashboard with HTML5 charts, and drill-through tables and gauges in green theme", - "uri": "/public/Samples/Dashboards/1g__Supermart_Dashboard", - "resourceType": "dashboard" - }, - { - "version": 0, - "permissionMask": 1, - "creationDate": "2015-06-10 13:01:56", - "updateDate": "2013-09-27 16:40:18", - "label": "2. Performance Summary Dashboard", - "description": "Sample Dashboard with Global Map, HTML5 Charts. Includes drill-through on customer table, map, and demographic chart.", - "uri": "/public/Samples/Dashboards/Performance_Summary_Dashboard", - "resourceType": "dashboard" - }, - { - "version": 0, - "permissionMask": 1, - "creationDate": "2015-06-10 13:01:56", - "updateDate": "2013-09-27 16:41:31", - "label": "2g. Performance Summary Dashboard", - "description": "Sample Dashboard with Global Map, HTML5 Charts. Includes drill-through on customer table, map, and demographic chart.", - "uri": "/public/Samples/Dashboards/2g__Performance_Summary_Dashboard", - "resourceType": "dashboard" - } - ] -} \ No newline at end of file diff --git a/client/src/test/resources/servers_under_test.json b/client/src/test/resources/servers_under_test.json deleted file mode 100644 index 2727cbb8..00000000 --- a/client/src/test/resources/servers_under_test.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "http://mobiledemo.jaspersoft.com/jasperserver-pro" -] \ No newline at end of file From d092064fcf4f1a58ce1d1d8f95b0d573abab990f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 12:58:58 +0200 Subject: [PATCH 246/457] Remove redundant api package from hierarchy --- .../sdk/network/{api => }/AdapterBuilder.java | 6 ++-- .../{api => }/AuthenticationRestApi.java | 2 +- .../{api => }/AuthenticationRestApiImpl.java | 2 +- .../sdk/network/{api => }/CallWrapper.java | 4 +-- .../sdk/network/{api => }/ClientBuilder.java | 2 +- .../network/{api => }/CookieExtractor.java | 2 +- .../sdk/network/{api => }/GenericBuilder.java | 2 +- .../{api => }/GsonConverterFactory.java | 2 +- .../{api => }/InputControlRestApi.java | 2 +- .../{api => }/InputControlRestApiImpl.java | 18 +++++----- .../{api => }/JSEncryptionAlgorithm.java | 2 +- .../network/{api => }/LoggingInterceptor.java | 2 +- .../{api => }/ReportExecutionRestApi.java | 2 +- .../{api => }/ReportExecutionRestApiImpl.java | 35 +++++++++---------- .../{api => }/ReportExportRestApi.java | 2 +- .../{api => }/ReportExportRestApiImpl.java | 30 ++++++++-------- .../{api => }/ReportOptionRestApi.java | 2 +- .../{api => }/ReportOptionRestApiImpl.java | 30 ++++++++-------- .../network/{api => }/RepositoryRestApi.java | 2 +- .../{api => }/RepositoryRestApiImpl.java | 23 ++++++------ .../sdk/network/{api => }/RestApiLog.java | 2 +- .../sdk/network/{api => }/RestError.java | 4 +-- .../{api => }/RetrofitOutputResource.java | 2 +- .../sdk/network/{api => }/ServerRestApi.java | 2 +- .../network/{api => }/ServerRestApiImpl.java | 2 +- .../{api => }/StringConverterFactory.java | 2 +- .../android/sdk/network/{api => }/Utils.java | 2 +- .../AuthenticationRestApiBuilderTest.java | 2 +- .../{api => }/AuthenticationRestApiTest.java | 4 ++- .../{api => }/CookieExtractorTest.java | 3 +- .../InputControlRestApiBuilderTest.java | 4 ++- .../{api => }/InputControlRestApiTest.java | 4 ++- .../{api => }/JSEncryptionAlgorithmTest.java | 4 ++- .../ReportExecutionRestApiBuilderTest.java | 4 ++- .../{api => }/ReportExecutionRestApiTest.java | 4 ++- .../ReportExportRestApiBuilderTest.java | 4 ++- .../{api => }/ReportExportRestApiTest.java | 4 ++- .../ReportOptionRestApiBuilderTest.java | 4 ++- .../{api => }/ReportOptionRestApiTest.java | 4 ++- .../RepositoryRestApiBuilderTest.java | 4 ++- .../{api => }/RepositoryRestApiTest.java | 4 ++- .../{api => }/RetrofitOutputResourceTest.java | 3 +- .../{api => }/ServerRestApiBuilderTest.java | 4 ++- .../network/{api => }/ServerRestApiTest.java | 4 ++- .../sdk/network/{api => }/UtilsTest.java | 4 ++- .../android/sdk/test/TestLogger.java | 2 +- .../api/AuthenticationRestApiTest.java | 4 +-- .../api/InputControlRestApiTest.java | 2 +- .../api/ReportExecutionRestApiTest.java | 2 +- .../api/ReportExportRestApiTest.java | 4 +-- .../api/ReportOptionRestApiTest.java | 2 +- .../api/RepositoryRestApiTest.java | 2 +- .../test/integration/api/ServerRestTest.java | 2 +- .../api/utils/DummyTokenProvider.java | 2 +- .../sdk/service/ServerInfoService.java | 2 +- .../sdk/service/auth/SpringAuthService.java | 4 +-- .../report/ReportExecutionUseCase.java | 2 +- .../service/report/ReportExportUseCase.java | 2 +- .../sdk/service/report/ReportService.java | 4 +-- .../service/repository/RepositoryService.java | 2 +- .../service/repository/SearchStrategy.java | 2 +- .../service/repository/SearchTaskImpl.java | 2 +- .../sdk/service/repository/SearchUseCase.java | 2 +- .../sdk/service/ServerInfoServiceTest.java | 2 +- .../auth/SpringAuthServiceBuilderTest.java | 4 +-- .../service/auth/SpringAuthServiceTest.java | 4 +-- .../service/report/ReportAttachmentTest.java | 2 +- .../service/report/ReportExecutionTest.java | 4 +-- .../sdk/service/report/ReportExportTest.java | 2 +- .../sdk/service/report/ReportServiceTest.java | 4 +-- .../repository/RepositoryServiceTest.java | 2 +- .../repository/SearchStrategyTest.java | 2 +- .../repository/SearchTaskImplTest.java | 2 +- .../service/repository/SearchUseCaseTest.java | 2 +- 74 files changed, 173 insertions(+), 157 deletions(-) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/AdapterBuilder.java (94%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/AuthenticationRestApi.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/AuthenticationRestApiImpl.java (99%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/CallWrapper.java (95%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ClientBuilder.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/CookieExtractor.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/GenericBuilder.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/GsonConverterFactory.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/InputControlRestApi.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/InputControlRestApiImpl.java (89%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/JSEncryptionAlgorithm.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/LoggingInterceptor.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ReportExecutionRestApi.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ReportExecutionRestApiImpl.java (83%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ReportExportRestApi.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ReportExportRestApiImpl.java (86%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ReportOptionRestApi.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ReportOptionRestApiImpl.java (85%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/RepositoryRestApi.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/RepositoryRestApiImpl.java (85%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/RestApiLog.java (81%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/RestError.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/RetrofitOutputResource.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ServerRestApi.java (97%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/ServerRestApiImpl.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/StringConverterFactory.java (98%) rename client-network/src/main/java/com/jaspersoft/android/sdk/network/{api => }/Utils.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/AuthenticationRestApiBuilderTest.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/AuthenticationRestApiTest.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/CookieExtractorTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/InputControlRestApiBuilderTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/InputControlRestApiTest.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/JSEncryptionAlgorithmTest.java (91%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ReportExecutionRestApiBuilderTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ReportExecutionRestApiTest.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ReportExportRestApiBuilderTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ReportExportRestApiTest.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ReportOptionRestApiBuilderTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ReportOptionRestApiTest.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/RepositoryRestApiBuilderTest.java (94%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/RepositoryRestApiTest.java (98%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/RetrofitOutputResourceTest.java (96%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ServerRestApiBuilderTest.java (95%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/ServerRestApiTest.java (97%) rename client-network/src/test/java/com/jaspersoft/android/sdk/network/{api => }/UtilsTest.java (95%) diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java index 992f5045..4ba8f4af 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AdapterBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; @@ -32,8 +32,6 @@ import retrofit.Converter; import retrofit.Retrofit; -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - /** * @author Tom Koptel * @since 2.0 @@ -58,7 +56,7 @@ public AdapterBuilder(ClientBuilder clientBuilder){ @SuppressWarnings("unchecked") public AdapterBuilder baseUrl(String baseUrl) { - checkNotNull(baseUrl, "baseUrl == null"); + Utils.checkNotNull(baseUrl, "baseUrl == null"); baseUrl = Utils.normalizeBaseUrl(baseUrl); HttpUrl httpUrl = HttpUrl.parse(baseUrl); if (httpUrl == null) { diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 52863dac..810cc83e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.HttpUrl; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java similarity index 99% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java index a29b1f2b..1e3feb41 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java similarity index 95% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java index e8fbb774..63525ac4 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CallWrapper.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import java.io.IOException; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java index d4793fde..89f2c3e9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ClientBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.squareup.okhttp.OkHttpClient; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieExtractor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieExtractor.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java index 9cf33be8..be71022e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/CookieExtractor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.squareup.okhttp.Response; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java index 21143b6b..811a87cf 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GenericBuilder.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import retrofit.Retrofit; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java index 8a0e0ac9..a35830ee 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/GsonConverterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.google.gson.Gson; import com.google.gson.TypeAdapter; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index af2e254d..f7d396d8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java similarity index 89% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java index 976ec689..5619aa9b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.control.InputControl; @@ -47,8 +47,6 @@ import retrofit.http.Path; import retrofit.http.Query; -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - /** * @author Tom Koptel * @since 2.0 @@ -65,8 +63,8 @@ final class InputControlRestApiImpl implements InputControlRestApi { public Collection requestInputControls(@Nullable String token, @Nullable String reportUri, boolean excludeState) { - checkNotNull(reportUri, "Report URI should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(reportUri, "Report URI should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); String state = (excludeState ? "state" : null); Call call = mRestApi.requestInputControls(reportUri, state, token); @@ -79,8 +77,8 @@ public Collection requestInputControls(@Nullable String token, public Collection requestInputControlsInitialStates(@Nullable String token, @Nullable String reportUri, boolean freshData) { - checkNotNull(reportUri, "Report URI should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(reportUri, "Report URI should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData, token); InputControlStateCollection response = CallWrapper.wrap(call).body(); @@ -93,9 +91,9 @@ public Collection requestInputControlsStates(@Nullable String @Nullable String reportUri, @Nullable Map> controlsValues, boolean freshData) { - checkNotNull(reportUri, "Report URI should not be null"); - checkNotNull(controlsValues, "Controls values should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(reportUri, "Report URI should not be null"); + Utils.checkNotNull(controlsValues, "Controls values should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); String ids = Utils.joinString(";", controlsValues.keySet()); Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData, token); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java index 016eb1f7..0dc185dc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithm.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import org.spongycastle.jce.provider.BouncyCastleProvider; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java index 66355834..4d595694 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/LoggingInterceptor.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.Request; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index 407f68ea..b54fc9d2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java similarity index 83% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java index e693433d..f344aac7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; @@ -48,9 +48,6 @@ import retrofit.http.Path; import retrofit.http.QueryMap; -import static com.jaspersoft.android.sdk.network.api.Utils.checkArgument; -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - /** * @author Tom Koptel * @since 2.0 @@ -66,8 +63,8 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NotNull @Override public ReportExecutionDescriptor runReportExecution(@Nullable String token, @Nullable ReportExecutionRequestOptions executionOptions) { - checkNotNull(executionOptions, "Execution options should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionOptions, "Execution options should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.runReportExecution(executionOptions, token); return CallWrapper.wrap(call).body(); @@ -76,8 +73,8 @@ public ReportExecutionDescriptor runReportExecution(@Nullable String token, @Nul @NotNull @Override public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String token, @Nullable String executionId) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestReportExecutionDetails(executionId, token); return CallWrapper.wrap(call).body(); @@ -86,8 +83,8 @@ public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String @NotNull @Override public ExecutionStatus requestReportExecutionStatus(@Nullable String token, @Nullable String executionId) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestReportExecutionStatus(executionId, token); return CallWrapper.wrap(call).body(); @@ -95,8 +92,8 @@ public ExecutionStatus requestReportExecutionStatus(@Nullable String token, @Nul @Override public boolean cancelReportExecution(@Nullable String token, @Nullable String executionId) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus(), token); Response response = CallWrapper.wrap(call).response(); @@ -108,10 +105,10 @@ public boolean cancelReportExecution(@Nullable String token, @Nullable String ex public boolean updateReportExecution(@Nullable String token, @Nullable String executionId, @Nullable Collection>> params) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(params, "Execution params should not be null"); - checkArgument(params.isEmpty(), "Execution params should not be empty"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(params, "Execution params should not be null"); + Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.updateReportExecution(executionId, params, token); Response response = CallWrapper.wrap(call).response(); @@ -122,9 +119,9 @@ public boolean updateReportExecution(@Nullable String token, @NotNull @Override public ReportExecutionSearchResponse searchReportExecution(@Nullable String token, @Nullable Map params) { - checkNotNull(params, "Search params should not be null"); - checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(params, "Search params should not be null"); + Utils.checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.searchReportExecution(params, token); ReportExecutionSearchResponse body = CallWrapper.wrap(call).body(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java index d648325a..76cfa69a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java similarity index 86% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index 9387b19b..dc6603ad 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -44,8 +44,6 @@ import retrofit.http.POST; import retrofit.http.Path; -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - /** * @author Tom Koptel * @since 2.0 @@ -62,9 +60,9 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { public ExportExecutionDescriptor runExportExecution(@Nullable String token, @Nullable String executionId, @Nullable ExecutionRequestOptions executionOptions) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(executionOptions, "Execution options should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(executionOptions, "Execution options should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.runReportExportExecution(executionId, executionOptions, token); return CallWrapper.wrap(call).body(); @@ -75,9 +73,9 @@ public ExportExecutionDescriptor runExportExecution(@Nullable String token, public ExecutionStatus checkExportExecutionStatus(@Nullable String token, @Nullable String executionId, @Nullable String exportId) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(exportId, "Export id should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(exportId, "Export id should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.checkReportExportStatus(executionId, exportId, token); return CallWrapper.wrap(call).body(); @@ -88,9 +86,9 @@ public ExecutionStatus checkExportExecutionStatus(@Nullable String token, public ExportOutputResource requestExportOutput(@Nullable String token, @Nullable String executionId, @Nullable String exportId) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(exportId, "Export id should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(exportId, "Export id should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestReportExportOutput(executionId, exportId, token); Response rawResponse = CallWrapper.wrap(call).response(); @@ -109,10 +107,10 @@ public OutputResource requestExportAttachment(@Nullable String token, @Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) { - checkNotNull(executionId, "Execution id should not be null"); - checkNotNull(exportId, "Export id should not be null"); - checkNotNull(attachmentId, "Attachment id should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(exportId, "Export id should not be null"); + Utils.checkNotNull(attachmentId, "Attachment id should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId, token); Response rawResponse = CallWrapper.wrap(call).response(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java index 1256ebfe..c40c055d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java similarity index 85% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java index a258e3a3..62693332 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; @@ -48,8 +48,6 @@ import retrofit.http.Path; import retrofit.http.Query; -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; - /** * @author Tom Koptel * @since 2.0 @@ -65,8 +63,8 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { @Override public Set requestReportOptionsList(@Nullable String token, @Nullable String reportUnitUri) { - checkNotNull(reportUnitUri, "Report uri should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestReportOptionsList(reportUnitUri, token); try { @@ -89,10 +87,10 @@ public ReportOption createReportOption(@Nullable String token, @Nullable String optionLabel, @Nullable Map> controlsValues, boolean overwrite) { - checkNotNull(reportUnitUri, "Report uri should not be null"); - checkNotNull(optionLabel, "Option label should not be null"); - checkNotNull(controlsValues, "Controls values should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); + Utils.checkNotNull(optionLabel, "Option label should not be null"); + Utils.checkNotNull(controlsValues, "Controls values should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite, token); return CallWrapper.wrap(call).body(); @@ -103,10 +101,10 @@ public void updateReportOption(@Nullable String token, @Nullable String reportUnitUri, @Nullable String optionId, @Nullable Map> controlsValues) { - checkNotNull(reportUnitUri, "Report uri should not be null"); - checkNotNull(optionId, "Option id should not be null"); - checkNotNull(controlsValues, "Controls values should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); + Utils.checkNotNull(optionId, "Option id should not be null"); + Utils.checkNotNull(controlsValues, "Controls values should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues, token); CallWrapper.wrap(call).body(); @@ -116,9 +114,9 @@ public void updateReportOption(@Nullable String token, public void deleteReportOption(@Nullable String token, @Nullable String reportUnitUri, @Nullable String optionId) { - checkNotNull(reportUnitUri, "Report uri should not be null"); - checkNotNull(optionId, "Option id should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); + Utils.checkNotNull(optionId, "Option id should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.deleteReportOption(reportUnitUri, optionId, token); CallWrapper.wrap(call).body(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java index d09e805d..f653eb1b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java similarity index 85% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java index c1b8521a..7f20cef2 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; @@ -44,9 +44,6 @@ import retrofit.http.Query; import retrofit.http.QueryMap; -import static com.jaspersoft.android.sdk.network.api.Utils.checkNotNull; -import static com.jaspersoft.android.sdk.network.api.Utils.headerToInt; - /** * @author Tom Koptel * @since 2.0 @@ -61,7 +58,7 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NotNull @Override public ResourceSearchResult searchResources(@Nullable String token, @Nullable Map searchParams) { - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Iterable types = null; Call call; @@ -93,10 +90,10 @@ public ResourceSearchResult searchResources(@Nullable String token, @Nullable Ma entity = rawResponse.body(); com.squareup.okhttp.Headers headers = rawResponse.headers(); - int resultCount = headerToInt(headers, "Result-Count"); - int totalCount = headerToInt(headers, "Total-Count"); - int startIndex = headerToInt(headers, "Start-Index"); - int nextOffset = headerToInt(headers, "Next-Offset"); + int resultCount = Utils.headerToInt(headers, "Result-Count"); + int totalCount = Utils.headerToInt(headers, "Total-Count"); + int startIndex = Utils.headerToInt(headers, "Start-Index"); + int nextOffset = Utils.headerToInt(headers, "Next-Offset"); entity.setResultCount(resultCount); entity.setTotalCount(totalCount); @@ -109,8 +106,8 @@ public ResourceSearchResult searchResources(@Nullable String token, @Nullable Ma @NotNull @Override public ReportLookup requestReportResource(@Nullable String token, @Nullable String resourceUri) { - checkNotNull(resourceUri, "Report uri should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(resourceUri, "Report uri should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestReportResource(resourceUri, token); return CallWrapper.wrap(call).body(); @@ -119,8 +116,8 @@ public ReportLookup requestReportResource(@Nullable String token, @Nullable Stri @NotNull @Override public FolderLookup requestFolderResource(@Nullable String token, @Nullable String resourceUri) { - checkNotNull(resourceUri, "Folder uri should not be null"); - checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(resourceUri, "Folder uri should not be null"); + Utils.checkNotNull(token, "Request token should not be null"); Call call = mRestApi.requestFolderResource(resourceUri, token); return CallWrapper.wrap(call).body(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLog.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java similarity index 81% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLog.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java index 6a4460a0..b44079cc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestApiLog.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java @@ -1,4 +1,4 @@ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; /** * @author Tom Koptel diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestError.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/RestError.java index e8bc68fc..51aa3935 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RestError.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestError.java @@ -22,11 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; -import org.jetbrains.annotations.Nullable; - import java.io.IOException; import retrofit.Response; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResource.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResource.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java index 43436934..246998cc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResource.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.squareup.okhttp.ResponseBody; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java similarity index 97% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java index d282ae2c..3b79691b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApi.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java index 294488f1..086fa8ac 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/ServerRestApiImpl.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java index ff3d7cd0..5a25a5cc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/StringConverterFactory.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.google.gson.reflect.TypeToken; import com.squareup.okhttp.MediaType; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/Utils.java similarity index 98% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java rename to client-network/src/main/java/com/jaspersoft/android/sdk/network/Utils.java index 6643ef54..65a11489 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/api/Utils.java +++ b/client-network/src/main/java/com/jaspersoft/android/sdk/network/Utils.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import com.squareup.okhttp.ResponseBody; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java index dd41b4b4..28141e1a 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; import org.junit.Before; import org.junit.Rule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index 8c7be215..f7e27a79 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -22,8 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/CookieExtractorTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/CookieExtractorTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java index 240d7d7d..c37ea643 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/CookieExtractorTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java @@ -22,8 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.CookieExtractor; import com.squareup.okhttp.Protocol; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java index 1ae49354..2ab4784f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.InputControlRestApi; import org.junit.Before; import org.junit.Rule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index cd288da1..eb8e22d1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -1,5 +1,7 @@ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.InputControlRestApi; +import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.test.MockResponseFactory; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithmTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java similarity index 91% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithmTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java index 7edda5dd..e8954a2e 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/JSEncryptionAlgorithmTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java @@ -1,4 +1,6 @@ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java index a0d276c2..a98ef71f 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import org.junit.Before; import org.junit.Rule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index a907ee86..aaafd22b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -22,8 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java index 251fa1ec..30d2f087 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import org.junit.Before; import org.junit.Rule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index 54b71757..2a892fae 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -22,8 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java index a6b7118c..3bf203e7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import org.junit.Before; import org.junit.Rule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 8be884f8..0a958033 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -22,8 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.ReportOptionRestApi; +import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java similarity index 94% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java index 3e73facf..4d68ce07 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import org.junit.Before; import org.junit.Rule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java similarity index 98% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index 00e133b0..1c099cd3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -22,8 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResourceTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResourceTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java index 11653247..7b022499 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/RetrofitOutputResourceTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java @@ -22,8 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.RetrofitOutputResource; import com.squareup.okhttp.MediaType; import com.squareup.okhttp.ResponseBody; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiBuilderTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiBuilderTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java index f70385ec..ef21b8c5 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiBuilderTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.ServerRestApi; import org.junit.Before; import org.junit.Rule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java similarity index 97% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java index 69a69afc..a402c7e6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/ServerRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java @@ -22,8 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.RestError; +import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java similarity index 95% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java rename to client-network/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java index 46d8583c..d38cb8d7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/api/UtilsTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.network.api; +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.Utils; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java index 760ccee6..5dc18a30 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test; -import com.jaspersoft.android.sdk.network.api.RestApiLog; +import com.jaspersoft.android.sdk.network.RestApiLog; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 997e668b..c76c5d88 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -24,8 +24,8 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.TestLogger; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 20c10147..1da4575c 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.InputControlRestApi; +import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.test.TestLogger; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index a82062fd..21df2179 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 1a3edf82..97e1a890 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -24,8 +24,8 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index dc0829d3..cbe612a8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.ReportOptionRestApi; +import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 348e12dd..70cdc0f6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 1f18110a..a6b4b9b1 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.test.TestLogger; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index 46665302..e1f16c70 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api.utils; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; import org.jetbrains.annotations.NotNull; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index af55256c..d88d3fff 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 4026b790..fdc99a23 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -24,8 +24,8 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import org.jetbrains.annotations.NotNull; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 158cb667..c5b39e1f 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 7a8dd95c..5741d321 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index dc95fedc..8709b2da 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -23,8 +23,8 @@ */ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 49171047..b9d80216 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index d362989f..42928833 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 1d3e2b32..5d5559c5 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index bf8008fe..39b4ec3a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -23,7 +23,7 @@ */ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java index a96c0245..e33a81a6 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.api.ServerRestApi; +import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import org.junit.Before; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java index f5f59981..d5470c26 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. + * Copyright � 2015 TIBCO Software, Inc. All rights reserved. * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from Jaspersoft, @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; import org.junit.Before; import org.junit.Rule; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index 894e9375..36182751 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -1,7 +1,7 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.network.api.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.api.JSEncryptionAlgorithm; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import org.junit.Before; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 0f6eb8c6..ed94034e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 712d9f97..01ceb588 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -1,7 +1,7 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 17785cf4..f455874c 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.junit.Before; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 4a2b2cf3..1c38a3ab 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -1,7 +1,7 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.api.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.api.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index a10ae3ef..fc86704a 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index 59f01f27..fd438f30 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index 8e5aaa9d..b2b6f50b 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 46fb8a50..6deed85c 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -1,6 +1,6 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.api.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.service.InfoProvider; From 70d0494ea0e1081bcedfd2a3a43c02d3c42789bc Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 13:09:26 +0200 Subject: [PATCH 247/457] Remove network module. Merge into main artifact namespace --- client-network/build.gradle | 61 ----------- client-network/src/main/AndroidManifest.xml | 31 ------ .../android/sdk/network/RestApiLog.java | 14 --- .../control/InputControlOptionTest.java | 32 ------ .../entity/control/InputControlStateTest.java | 33 ------ .../entity/control/InputControlTest.java | 40 ------- .../entity/control/ValidationRuleTest.java | 32 ------ .../report/option/ReportOptionSetTest.java | 29 ----- .../report/option/ReportOptionTest.java | 34 ------ .../sdk/test/resource/ResourceFile.java | 16 --- client-service/build.gradle | 2 +- client/build.gradle | 22 ++++ .../android/sdk/network/AdapterBuilder.java | 14 +-- .../sdk/network/AuthenticationRestApi.java | 20 ++-- .../network/AuthenticationRestApiImpl.java | 14 +-- .../android/sdk/network/CallWrapper.java | 14 +-- .../android/sdk/network/ClientBuilder.java | 14 +-- .../android/sdk/network/CookieExtractor.java | 14 +-- .../android/sdk/network/GenericBuilder.java | 14 +-- .../sdk/network/GsonConverterFactory.java | 14 +-- .../sdk/network/InputControlRestApi.java | 14 +-- .../sdk/network/InputControlRestApiImpl.java | 14 +-- .../sdk/network/JSEncryptionAlgorithm.java | 24 +++++ .../sdk/network/LoggingInterceptor.java | 14 +-- .../sdk/network/ReportExecutionRestApi.java | 14 +-- .../network/ReportExecutionRestApiImpl.java | 14 +-- .../sdk/network/ReportExportRestApi.java | 14 +-- .../sdk/network/ReportExportRestApiImpl.java | 14 +-- .../sdk/network/ReportOptionRestApi.java | 14 +-- .../sdk/network/ReportOptionRestApiImpl.java | 14 +-- .../sdk/network/RepositoryRestApi.java | 16 +-- .../sdk/network/RepositoryRestApiImpl.java | 14 +-- .../android/sdk/network/RestApiLog.java | 38 +++++++ .../android/sdk/network/RestError.java | 14 +-- .../sdk/network/RetrofitOutputResource.java | 14 +-- .../android/sdk/network/ServerRestApi.java | 14 +-- .../sdk/network/ServerRestApiImpl.java | 14 +-- .../sdk/network/StringConverterFactory.java | 14 +-- .../jaspersoft/android/sdk/network/Utils.java | 14 +-- .../network/entity/control/InputControl.java | 14 +-- .../control/InputControlCollection.java | 14 +-- .../entity/control/InputControlOption.java | 14 +-- .../entity/control/InputControlState.java | 14 +-- .../control/InputControlStateCollection.java | 14 +-- .../entity/control/ValidationRule.java | 14 +-- .../execution/AttachmentDescriptor.java | 14 +-- .../entity/execution/ErrorDescriptor.java | 14 +-- .../execution/ExecutionRequestOptions.java | 14 +-- .../entity/execution/ExecutionStatus.java | 14 +-- .../entity/execution/ExportDescriptor.java | 14 +-- .../execution/OutputResourceDescriptor.java | 102 +++++++++--------- .../execution/ReportExecutionDescriptor.java | 14 +-- .../ReportExecutionRequestOptions.java | 0 .../execution/ReportExecutionSearchItem.java | 0 .../ReportExecutionSearchResponse.java | 0 .../export/ExportExecutionDescriptor.java | 14 +-- .../entity/export/ExportOutputResource.java | 14 +-- .../network/entity/export/OutputResource.java | 14 +-- .../entity/report/option/ReportOption.java | 14 +-- .../entity/report/option/ReportOptionSet.java | 14 +-- .../network/entity/resource/FolderLookup.java | 14 +-- .../network/entity/resource/ReportLookup.java | 14 +-- .../entity/resource/ResourceLookup.java | 12 +-- .../entity/resource/ResourceSearchResult.java | 14 +-- .../network/entity/server/EncryptionKey.java | 14 +-- .../network/entity/server/ServerInfoData.java | 25 +++-- .../type/CustomizedTypeAdapterFactory.java | 14 +-- .../sdk/network/entity/type/GsonFactory.java | 14 +-- .../type/InputControlTypeAdapterFactory.java | 14 +-- .../type/ReportLookupTypeAdapterFactory.java | 14 +-- .../AuthenticationRestApiBuilderTest.java | 0 .../network/AuthenticationRestApiTest.java | 0 .../sdk/network/CookieExtractorTest.java | 0 .../InputControlRestApiBuilderTest.java | 0 .../sdk/network/InputControlRestApiTest.java | 0 .../network/JSEncryptionAlgorithmTest.java | 0 .../ReportExecutionRestApiBuilderTest.java | 0 .../network/ReportExecutionRestApiTest.java | 0 .../ReportExportRestApiBuilderTest.java | 0 .../sdk/network/ReportExportRestApiTest.java | 0 .../ReportOptionRestApiBuilderTest.java | 0 .../sdk/network/ReportOptionRestApiTest.java | 0 .../network/RepositoryRestApiBuilderTest.java | 0 .../sdk/network/RepositoryRestApiTest.java | 0 .../network/RetrofitOutputResourceTest.java | 0 .../sdk/network/ServerRestApiBuilderTest.java | 0 .../sdk/network/ServerRestApiTest.java | 0 .../android/sdk/network/UtilsTest.java | 0 .../control/InputControlCollectionTest.java | 24 +++++ .../control/InputControlOptionTest.java | 56 ++++++++++ .../entity/control/InputControlStateTest.java | 57 ++++++++++ .../entity/control/InputControlTest.java | 64 +++++++++++ .../entity/control/ValidationRuleTest.java | 56 ++++++++++ .../execution/AttachmentDescriptorTest.java | 0 .../entity/execution/ErrorDescriptorTest.java | 0 .../ExecutionRequestOptionsTest.java | 0 .../entity/execution/ExecutionStatusTest.java | 0 .../execution/ExportDescriptorTest.java | 0 .../OutputResourceDescriptorTest.java | 62 +++++------ .../ReportExecutionDescriptorTest.java | 0 .../ReportExecutionRequestOptionsTest.java | 0 .../ReportExecutionSearchResponseTest.java | 0 .../export/ExportExecutionDescriptorTest.java | 14 +-- .../report/option/ReportOptionSetTest.java | 53 +++++++++ .../report/option/ReportOptionTest.java | 58 ++++++++++ .../resource/FolderLookupResponseTest.java | 0 .../entity/resource/ReportLookupTest.java | 0 .../ResourceLookupJsonConvertTest.java | 0 .../entity/server/EncryptionKeyTest.java | 24 +++++ .../entity/server/ServerInfoDataTest.java | 17 +-- .../network/entity/type/GsonFactoryTest.java | 14 +-- .../android/sdk/test/MockResponseFactory.java | 14 +-- .../android/sdk/test/TestLogger.java | 14 +-- .../android/sdk/test/WebMockRule.java | 17 ++- .../api/AuthenticationRestApiTest.java | 21 ++-- .../api/InputControlRestApiTest.java | 14 +-- .../api/ReportExecutionRestApiTest.java | 14 +-- .../api/ReportExportRestApiTest.java | 14 +-- .../api/ReportOptionRestApiTest.java | 14 +-- .../api/RepositoryRestApiTest.java | 14 +-- .../test/integration/api/ServerRestTest.java | 14 +-- .../api/utils/DummyTokenProvider.java | 14 +-- .../integration/api/utils/JrsMetadata.java | 14 +-- .../sdk/test/matcher/HasAnnotation.java | 14 +-- .../sdk/test/matcher/HasSerializedName.java | 14 +-- .../sdk/test/resource/ResourceFile.java | 40 +++++++ .../sdk/test/resource/TestResource.java | 14 +-- .../resource/inject/TestResourceInjector.java | 14 +-- .../test/resources/json/all_resources.json | 0 .../json/cancelled_report_response.json | 0 .../json/dashboard_unit_resource.json | 0 .../resources/json/default_server_info.json | 0 .../test/resources/json/encryption_key.json | 0 .../json/input_controls_states_list.json | 0 .../json/input_controls_with_states.json | 0 .../json/input_controls_without_states.json | 0 .../json/report_execution_details.json | 0 .../json/report_execution_request.json | 0 .../json/report_execution_response.json | 0 .../test/resources/json/report_option.json | 0 .../resources/json/report_options_list.json | 0 .../resources/json/report_unit_resource1.json | 0 .../resources/json/report_unit_resource2.json | 0 .../resources/json/resource_lookup_item.json | 0 .../src/test/resources/json/root_folder.json | 0 .../json/search_execution_response.json | 0 settings.gradle | 2 - 147 files changed, 1108 insertions(+), 922 deletions(-) delete mode 100644 client-network/build.gradle delete mode 100644 client-network/src/main/AndroidManifest.xml delete mode 100644 client-network/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java delete mode 100644 client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java (84%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java (71%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java (92%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java (79%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java (74%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java (76%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java (78%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java (88%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java (87%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java (92%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java (70%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java (85%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java (83%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java (94%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java (84%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java (93%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java (81%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java (93%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java (73%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java (91%) create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/RestError.java (86%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java (76%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java (77%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java (89%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java (82%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/Utils.java (87%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java (82%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java (71%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java (70%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java (75%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java (71%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java (70%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java (80%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java (76%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java (91%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java (75%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java (78%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java (71%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java (83%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java (100%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java (100%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java (100%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java (77%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java (78%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java (71%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java (80%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java (72%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java (65%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java (73%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java (85%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java (84%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java (77%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java (70%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java (86%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java (72%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java (87%) rename {client-network => client}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java (77%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java (76%) create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java (96%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java (80%) create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java (100%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java (55%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java (77%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java (82%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java (75%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java (72%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java (78%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java (80%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java (89%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java (92%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java (90%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java (86%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java (85%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java (87%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java (78%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java (90%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java (78%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java (77%) create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java (85%) rename {client-network => client}/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java (81%) rename {client-network => client}/src/test/resources/json/all_resources.json (100%) rename {client-network => client}/src/test/resources/json/cancelled_report_response.json (100%) rename {client-network => client}/src/test/resources/json/dashboard_unit_resource.json (100%) rename {client-network => client}/src/test/resources/json/default_server_info.json (100%) rename {client-network => client}/src/test/resources/json/encryption_key.json (100%) rename {client-network => client}/src/test/resources/json/input_controls_states_list.json (100%) rename {client-network => client}/src/test/resources/json/input_controls_with_states.json (100%) rename {client-network => client}/src/test/resources/json/input_controls_without_states.json (100%) rename {client-network => client}/src/test/resources/json/report_execution_details.json (100%) rename {client-network => client}/src/test/resources/json/report_execution_request.json (100%) rename {client-network => client}/src/test/resources/json/report_execution_response.json (100%) rename {client-network => client}/src/test/resources/json/report_option.json (100%) rename {client-network => client}/src/test/resources/json/report_options_list.json (100%) rename {client-network => client}/src/test/resources/json/report_unit_resource1.json (100%) rename {client-network => client}/src/test/resources/json/report_unit_resource2.json (100%) rename {client-network => client}/src/test/resources/json/resource_lookup_item.json (100%) rename {client-network => client}/src/test/resources/json/root_folder.json (100%) rename {client-network => client}/src/test/resources/json/search_execution_response.json (100%) diff --git a/client-network/build.gradle b/client-network/build.gradle deleted file mode 100644 index 6f1328b2..00000000 --- a/client-network/build.gradle +++ /dev/null @@ -1,61 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion androidCompileSdkVersion - buildToolsVersion androidBuildToolsVersion - - defaultConfig { - minSdkVersion androidMinSdkVersion - targetSdkVersion androidTargetSdkVersion - versionCode clientModuleVersionCode - versionName version - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - encoding 'ISO-8859-1' - } - packagingOptions { - exclude 'META-INF/notice.txt' - exclude 'META-INF/license.txt' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/NOTICE.txt' - } - lintOptions { - abortOnError false - } - - buildTypes { - debug { - minifyEnabled false - } - } -} - -dependencies { - compile 'com.intellij:annotations:12.0' - - compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' - compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' - - compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' - compile 'com.madgag.spongycastle:prov:1.52.0.0' - - testCompile('pl.pragmatists:JUnitParams:1.0.4') { - exclude group: 'org.hamcrest' - } - testCompile 'org.hamcrest:hamcrest-integration:1.3' - testCompile('org.mockito:mockito-core:1.10.19') { - exclude group: 'org.hamcrest' - exclude group: 'org.objenesis' - } - testCompile('org.powermock:powermock-api-mockito:1.6.2') { - exclude group: 'org.mockito' - } - testCompile 'org.powermock:powermock-module-junit4:1.6.2' - testCompile 'org.robolectric:shadows-support-v4:3.0' - testCompile 'org.robolectric:shadows-httpclient:3.0' - testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' - // In order to test on JVM side we need stock BouncyCastle provider - testCompile 'org.bouncycastle:bcprov-jdk16:1.46' -} \ No newline at end of file diff --git a/client-network/src/main/AndroidManifest.xml b/client-network/src/main/AndroidManifest.xml deleted file mode 100644 index 86e8c078..00000000 --- a/client-network/src/main/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java b/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java deleted file mode 100644 index b44079cc..00000000 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.jaspersoft.android.sdk.network; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface RestApiLog { - void log(String message); - - RestApiLog NONE = new RestApiLog() { - @Override public void log(String message) { - } - }; -} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java deleted file mode 100644 index 2fc85a7b..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.jaspersoft.android.sdk.network.entity.control; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class InputControlOptionTest { - @Test - @Parameters({ - "label", - "value", - "selected", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = InputControlOption.class.getDeclaredField(fieldName); - assertThat(field, hasAnnotation(Expose.class)); - } -} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java deleted file mode 100644 index a744cae3..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.jaspersoft.android.sdk.network.entity.control; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class InputControlStateTest { - @Test - @Parameters({ - "id", - "uri", - "value", - "error", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = InputControlState.class.getDeclaredField(fieldName); - assertThat(field, hasAnnotation(Expose.class)); - } -} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java deleted file mode 100644 index d531b5f8..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.jaspersoft.android.sdk.network.entity.control; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class InputControlTest { - @Test - @Parameters({ - "id", - "label", - "mandatory", - "readOnly", - "type", - "uri", - "visible", - "masterDependencies", - "slaveDependencies", - "validationRules", - "state", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = InputControl.class.getDeclaredField(fieldName); - assertThat(field, hasAnnotation(Expose.class)); - } -} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java deleted file mode 100644 index 9867abeb..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.jaspersoft.android.sdk.network.entity.control; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class ValidationRuleTest { - @Test - @Parameters({ - "type", - "errorMessage", - "value", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ValidationRule.class.getDeclaredField(fieldName); - assertThat(field, hasAnnotation(Expose.class)); - } -} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java deleted file mode 100644 index 25336abe..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.jaspersoft.android.sdk.network.entity.report.option; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; - -import java.lang.reflect.Field; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ReportOptionSetTest { - @Test - public void shouldHaveExposeAnnotationForFieldOptions() throws NoSuchFieldException { - Field field = ReportOptionSet.class.getDeclaredField("mOptions"); - assertThat(field, hasAnnotation(Expose.class)); - } - - @Test - public void optionsFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { - Field field = ReportOptionSet.class.getDeclaredField("mOptions"); - assertThat(field, hasSerializedName("reportOptionsSummary")); - } -} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java b/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java deleted file mode 100644 index 0dd338b5..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.jaspersoft.android.sdk.network.entity.report.option; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class ReportOptionTest { - - @Test - @Parameters({ - "uri", - "id", - "label", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = ReportOption.class.getDeclaredField(fieldName); - assertThat(field, hasAnnotation(Expose.class)); - } - -} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java b/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java deleted file mode 100644 index 819d40b1..00000000 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.jaspersoft.android.sdk.test.resource; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD}) -public @interface ResourceFile { - String value(); -} diff --git a/client-service/build.gradle b/client-service/build.gradle index e352c00c..cef78155 100644 --- a/client-service/build.gradle +++ b/client-service/build.gradle @@ -33,7 +33,7 @@ android { } dependencies { - compile project(':js-android-sdk-client-network') + compile project(':js-android-sdk-client') compile 'com.intellij:annotations:12.0' testCompile('pl.pragmatists:JUnitParams:1.0.4') { diff --git a/client/build.gradle b/client/build.gradle index 8e719477..25f16747 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -10,5 +10,27 @@ ext { } dependencies { + compile 'com.intellij:annotations:12.0' + compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' + compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' + + compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' + compile 'com.madgag.spongycastle:prov:1.52.0.0' + + testCompile('pl.pragmatists:JUnitParams:1.0.4') { + exclude group: 'org.hamcrest' + } + testCompile 'org.hamcrest:hamcrest-integration:1.3' + testCompile('org.mockito:mockito-core:1.10.19') { + exclude group: 'org.hamcrest' + exclude group: 'org.objenesis' + } + testCompile('org.powermock:powermock-api-mockito:1.6.2') { + exclude group: 'org.mockito' + } + testCompile 'org.powermock:powermock-module-junit4:1.6.2' + testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' + // In order to test on JVM side we need stock BouncyCastle provider + testCompile 'org.bouncycastle:bcprov-jdk16:1.46' } \ No newline at end of file diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java b/client/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java similarity index 84% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java index 4ba8f4af..dc1f1c85 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java similarity index 71% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 810cc83e..a8be8279 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ @@ -40,9 +40,9 @@ public interface AuthenticationRestApi { @NotNull String authenticate(@NotNull String username, - @NotNull String password, - @Nullable String organization, - @Nullable Map params); + @NotNull String password, + @Nullable String organization, + @Nullable Map params); @NotNull EncryptionKey requestEncryptionMetadata(); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java similarity index 92% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java index 1e3feb41..f0134885 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java b/client/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java similarity index 79% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java index 63525ac4..29e63efd 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java similarity index 74% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java index 89f2c3e9..bc418b27 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java similarity index 76% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java index be71022e..2e1545b3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java b/client/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java similarity index 78% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java index 811a87cf..2a93fd0a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java similarity index 88% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java index a35830ee..8525487b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java similarity index 87% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index f7d396d8..7e2c8bdf 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java similarity index 92% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java index 5619aa9b..5a33bb8e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java b/client/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java similarity index 70% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java index 0dc185dc..378edc18 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.network; import org.spongycastle.jce.provider.BouncyCastleProvider; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java similarity index 85% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java index 4d595694..ad4719a3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java similarity index 83% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index b54fc9d2..44d69147 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java similarity index 94% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java index f344aac7..3ecccc1a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java similarity index 84% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java index 76cfa69a..9f2402c6 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java similarity index 93% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index dc6603ad..573b2885 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java similarity index 81% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java index c40c055d..44faf10d 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java similarity index 93% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java index 62693332..5a21724f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java similarity index 73% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java index f653eb1b..21e9f8df 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ @@ -43,7 +43,7 @@ public interface RepositoryRestApi { ResourceSearchResult searchResources(@NotNull String token, @Nullable Map searchParams); @NotNull - ReportLookup requestReportResource( @NotNull String token, @NotNull String resourceUri); + ReportLookup requestReportResource(@NotNull String token, @NotNull String resourceUri); @NotNull FolderLookup requestFolderResource(@NotNull String token, @NotNull String resourceUri); diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java similarity index 91% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java index 7f20cef2..f304a05e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java b/client/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java new file mode 100644 index 00000000..ae7f01ca --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RestApiLog { + void log(String message); + + RestApiLog NONE = new RestApiLog() { + @Override public void log(String message) { + } + }; +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestError.java b/client/src/main/java/com/jaspersoft/android/sdk/network/RestError.java similarity index 86% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/RestError.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/RestError.java index 51aa3935..9cc5e035 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RestError.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/RestError.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java b/client/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java similarity index 76% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java index 246998cc..acfaa093 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java similarity index 77% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java index 3b79691b..ceddaf03 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java similarity index 89% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java index 086fa8ac..b834a9d3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java similarity index 82% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java index 5a25a5cc..4964fe54 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/Utils.java b/client/src/main/java/com/jaspersoft/android/sdk/network/Utils.java similarity index 87% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/Utils.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/Utils.java index 65a11489..8c955e5a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/Utils.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/Utils.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java similarity index 82% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java index 040e8cd4..736ed51a 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java similarity index 71% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java index a11b5d29..6a7fcca5 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java similarity index 70% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java index 39829447..99e4c45f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java similarity index 75% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java index 4e2586fe..9b792f47 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java similarity index 71% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java index db14026d..1ad0b264 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java similarity index 70% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java index 2d648e70..c1852a9e 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java similarity index 80% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java index 78d62d6f..4db3cfcc 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java similarity index 76% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java index 4c7d2010..a700813b 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java similarity index 91% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 4b85d2a9..016cd355 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java similarity index 75% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java index 36dc8ff1..acc3b0ca 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java similarity index 78% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java index ab96d4cf..c0f553a3 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java similarity index 71% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java index 0c483306..9597a38f 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java @@ -1,51 +1,51 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.network.entity.execution; - -import com.google.gson.annotations.Expose; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class OutputResourceDescriptor { - @Expose - private String contentType; - @Expose - private String fileName; - @Expose - private Boolean outputFinal; - - public String getContentType() { - return contentType; - } - - public String getFileName() { - return fileName; - } - - public Boolean getOutputFinal() { - return outputFinal; - } -} +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.network.entity.execution; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class OutputResourceDescriptor { + @Expose + private String contentType; + @Expose + private String fileName; + @Expose + private Boolean outputFinal; + + public String getContentType() { + return contentType; + } + + public String getFileName() { + return fileName; + } + + public Boolean getOutputFinal() { + return outputFinal; + } +} diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java similarity index 83% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java index 256a596c..4f693a77 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java similarity index 100% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java similarity index 100% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java similarity index 100% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java similarity index 77% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java index aaa08a87..bfe698ac 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java similarity index 78% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java index e7cc165b..f9f1cab7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java similarity index 71% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java index b46c13d6..43f0fa24 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java similarity index 80% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java index ff186862..59df6651 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java similarity index 72% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java index 324d924d..b1833321 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java similarity index 65% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java index 11c2233c..e0ad0c56 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java similarity index 73% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java index b2320ad5..059b2561 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java similarity index 85% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java index 98bbe2b6..7ca2c3ee 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java @@ -1,24 +1,24 @@ /* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java similarity index 84% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java index 42de94d4..89c23553 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java similarity index 77% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java index a07abaca..a15d0c96 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java similarity index 70% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java index 032b2e0d..720d91f9 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java @@ -1,22 +1,25 @@ /* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://www.jaspersoft.com. + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * This program is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . */ package com.jaspersoft.android.sdk.network.entity.server; diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java similarity index 86% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java index c262ee9e..f556b566 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java similarity index 72% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java index 4bf1cdf9..e5bfb274 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java similarity index 87% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java index e580c6b9..d407f7e8 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java similarity index 77% rename from client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java rename to client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java index 4e3c4a5d..c1e610a7 100644 --- a/client-network/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java similarity index 76% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java index 69c915ac..263a32b6 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.network.entity.control; import com.google.gson.Gson; diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java new file mode 100644 index 00000000..c24342d9 --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class InputControlOptionTest { + @Test + @Parameters({ + "label", + "value", + "selected", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = InputControlOption.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java new file mode 100644 index 00000000..78650ded --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class InputControlStateTest { + @Test + @Parameters({ + "id", + "uri", + "value", + "error", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = InputControlState.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java new file mode 100644 index 00000000..b99ef01a --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class InputControlTest { + @Test + @Parameters({ + "id", + "label", + "mandatory", + "readOnly", + "type", + "uri", + "visible", + "masterDependencies", + "slaveDependencies", + "validationRules", + "state", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = InputControl.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java new file mode 100644 index 00000000..a680c359 --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.control; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ValidationRuleTest { + @Test + @Parameters({ + "type", + "errorMessage", + "value", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ValidationRule.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java similarity index 96% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java index 2cef9ff4..6ba69443 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java @@ -1,32 +1,32 @@ -package com.jaspersoft.android.sdk.network.entity.execution; - -import com.google.gson.annotations.Expose; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.lang.reflect.Field; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; -import static org.hamcrest.MatcherAssert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class OutputResourceDescriptorTest { - @Test - @Parameters({ - "contentType", - "fileName", - "outputFinal", - }) - public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { - Field field = OutputResourceDescriptor.class.getDeclaredField(fieldName); - assertThat(field, hasAnnotation(Expose.class)); - } +package com.jaspersoft.android.sdk.network.entity.execution; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class OutputResourceDescriptorTest { + @Test + @Parameters({ + "contentType", + "fileName", + "outputFinal", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = OutputResourceDescriptor.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } } \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java similarity index 80% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java index ca02fc86..a7b5ec44 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java new file mode 100644 index 00000000..506c59cf --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.report.option; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static com.jaspersoft.android.sdk.test.matcher.HasSerializedName.hasSerializedName; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportOptionSetTest { + @Test + public void shouldHaveExposeAnnotationForFieldOptions() throws NoSuchFieldException { + Field field = ReportOptionSet.class.getDeclaredField("mOptions"); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void optionsFieldShouldHaveSerializedNameAnnotationForField() throws NoSuchFieldException { + Field field = ReportOptionSet.class.getDeclaredField("mOptions"); + assertThat(field, hasSerializedName("reportOptionsSummary")); + } +} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java new file mode 100644 index 00000000..0a37658d --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.report.option; + +import com.google.gson.annotations.Expose; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class ReportOptionTest { + + @Test + @Parameters({ + "uri", + "id", + "label", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportOption.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + +} \ No newline at end of file diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java similarity index 100% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java similarity index 55% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java index a8cde428..11e6bf49 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.network.entity.server; import com.google.gson.annotations.Expose; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java similarity index 77% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java index 6e2b03e6..2720ea1b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java @@ -1,28 +1,29 @@ -package com.jaspersoft.android.sdk.network.entity.server; /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ +package com.jaspersoft.android.sdk.network.entity.server; + import com.google.gson.annotations.Expose; import org.junit.Test; diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java similarity index 82% rename from client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java index 8cd0757f..f14a34ef 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java b/client/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java similarity index 75% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java index 93b72f64..89c4b0e7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java b/client/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java similarity index 72% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java index 5dc18a30..b7074e95 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java b/client/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java similarity index 78% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java index 2654a04c..7f6630ea 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ @@ -29,7 +29,6 @@ import org.junit.Before; import org.junit.rules.ExternalResource; -import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; import java.util.logging.Level; @@ -47,7 +46,6 @@ public final class WebMockRule extends ExternalResource { @Before public void before() throws Throwable { super.before(); - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); // Create a MockWebServer. These are lean enough that you can create a new // instance for every unit test. @@ -68,7 +66,6 @@ protected void after() { } catch (IOException e) { logger.log(Level.INFO, "Failed to shutdown MockWebServer", e); } - FakeHttp.getFakeHttpLayer().interceptHttpRequests(true); } public MockWebServer get() { diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java similarity index 80% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index c76c5d88..3bc324a7 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ @@ -30,10 +30,8 @@ import com.jaspersoft.android.sdk.test.TestLogger; import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.robolectric.shadows.httpclient.FakeHttp; import java.io.IOException; @@ -48,11 +46,6 @@ public class AuthenticationRestApiTest { String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; - @Before - public void setup() { - FakeHttp.getFakeHttpLayer().interceptHttpRequests(false); - } - @Ignore public void shouldEncryptWithPassword() throws Exception { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java similarity index 89% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 1da4575c..6648f2a2 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java similarity index 92% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 21df2179..a7b70a8b 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java similarity index 90% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 97e1a890..426f3ff8 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java similarity index 86% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index cbe612a8..8c6fbb71 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java similarity index 85% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 70cdc0f6..bb7579d0 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java similarity index 87% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index a6b4b9b1..984287fa 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java similarity index 78% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index e1f16c70..9af2fbc3 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java similarity index 90% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java index 6f8fbd53..33d1faa9 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java b/client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java similarity index 78% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java index 281492c8..86c5d783 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java b/client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java similarity index 77% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java index d6fcbb27..6dcc32a4 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java b/client/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java new file mode 100644 index 00000000..0cc5740b --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.resource; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface ResourceFile { + String value(); +} diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java b/client/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java similarity index 85% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java index e4a55a54..50c20142 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java b/client/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java similarity index 81% rename from client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java rename to client/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java index cfd380e8..66ad9c47 100644 --- a/client-network/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-network/src/test/resources/json/all_resources.json b/client/src/test/resources/json/all_resources.json similarity index 100% rename from client-network/src/test/resources/json/all_resources.json rename to client/src/test/resources/json/all_resources.json diff --git a/client-network/src/test/resources/json/cancelled_report_response.json b/client/src/test/resources/json/cancelled_report_response.json similarity index 100% rename from client-network/src/test/resources/json/cancelled_report_response.json rename to client/src/test/resources/json/cancelled_report_response.json diff --git a/client-network/src/test/resources/json/dashboard_unit_resource.json b/client/src/test/resources/json/dashboard_unit_resource.json similarity index 100% rename from client-network/src/test/resources/json/dashboard_unit_resource.json rename to client/src/test/resources/json/dashboard_unit_resource.json diff --git a/client-network/src/test/resources/json/default_server_info.json b/client/src/test/resources/json/default_server_info.json similarity index 100% rename from client-network/src/test/resources/json/default_server_info.json rename to client/src/test/resources/json/default_server_info.json diff --git a/client-network/src/test/resources/json/encryption_key.json b/client/src/test/resources/json/encryption_key.json similarity index 100% rename from client-network/src/test/resources/json/encryption_key.json rename to client/src/test/resources/json/encryption_key.json diff --git a/client-network/src/test/resources/json/input_controls_states_list.json b/client/src/test/resources/json/input_controls_states_list.json similarity index 100% rename from client-network/src/test/resources/json/input_controls_states_list.json rename to client/src/test/resources/json/input_controls_states_list.json diff --git a/client-network/src/test/resources/json/input_controls_with_states.json b/client/src/test/resources/json/input_controls_with_states.json similarity index 100% rename from client-network/src/test/resources/json/input_controls_with_states.json rename to client/src/test/resources/json/input_controls_with_states.json diff --git a/client-network/src/test/resources/json/input_controls_without_states.json b/client/src/test/resources/json/input_controls_without_states.json similarity index 100% rename from client-network/src/test/resources/json/input_controls_without_states.json rename to client/src/test/resources/json/input_controls_without_states.json diff --git a/client-network/src/test/resources/json/report_execution_details.json b/client/src/test/resources/json/report_execution_details.json similarity index 100% rename from client-network/src/test/resources/json/report_execution_details.json rename to client/src/test/resources/json/report_execution_details.json diff --git a/client-network/src/test/resources/json/report_execution_request.json b/client/src/test/resources/json/report_execution_request.json similarity index 100% rename from client-network/src/test/resources/json/report_execution_request.json rename to client/src/test/resources/json/report_execution_request.json diff --git a/client-network/src/test/resources/json/report_execution_response.json b/client/src/test/resources/json/report_execution_response.json similarity index 100% rename from client-network/src/test/resources/json/report_execution_response.json rename to client/src/test/resources/json/report_execution_response.json diff --git a/client-network/src/test/resources/json/report_option.json b/client/src/test/resources/json/report_option.json similarity index 100% rename from client-network/src/test/resources/json/report_option.json rename to client/src/test/resources/json/report_option.json diff --git a/client-network/src/test/resources/json/report_options_list.json b/client/src/test/resources/json/report_options_list.json similarity index 100% rename from client-network/src/test/resources/json/report_options_list.json rename to client/src/test/resources/json/report_options_list.json diff --git a/client-network/src/test/resources/json/report_unit_resource1.json b/client/src/test/resources/json/report_unit_resource1.json similarity index 100% rename from client-network/src/test/resources/json/report_unit_resource1.json rename to client/src/test/resources/json/report_unit_resource1.json diff --git a/client-network/src/test/resources/json/report_unit_resource2.json b/client/src/test/resources/json/report_unit_resource2.json similarity index 100% rename from client-network/src/test/resources/json/report_unit_resource2.json rename to client/src/test/resources/json/report_unit_resource2.json diff --git a/client-network/src/test/resources/json/resource_lookup_item.json b/client/src/test/resources/json/resource_lookup_item.json similarity index 100% rename from client-network/src/test/resources/json/resource_lookup_item.json rename to client/src/test/resources/json/resource_lookup_item.json diff --git a/client-network/src/test/resources/json/root_folder.json b/client/src/test/resources/json/root_folder.json similarity index 100% rename from client-network/src/test/resources/json/root_folder.json rename to client/src/test/resources/json/root_folder.json diff --git a/client-network/src/test/resources/json/search_execution_response.json b/client/src/test/resources/json/search_execution_response.json similarity index 100% rename from client-network/src/test/resources/json/search_execution_response.json rename to client/src/test/resources/json/search_execution_response.json diff --git a/settings.gradle b/settings.gradle index a8972f7e..22e5a762 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,7 @@ include ':js-android-sdk-client' include ':js-android-sdk-ui' -include ':js-android-sdk-client-network' include ':js-android-sdk-client-service' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File -project(':js-android-sdk-client-network').projectDir = "$rootDir/client-network" as File project(':js-android-sdk-client-service').projectDir = "$rootDir/client-service" as File From e3401e9f5b89e5b2cdef233d63c6f8965b22befc Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 13:13:09 +0200 Subject: [PATCH 248/457] Remove service module. Merge into main artifact namespace --- client-service/build.gradle | 52 ----- client-service/src/main/AndroidManifest.xml | 31 --- .../android/sdk/service/Preconditions.java | 42 ---- .../sdk/service/auth/TokenProvider.java | 9 - .../service/data/server/FeatureSetTest.java | 9 - .../service/data/server/ServerInfoTest.java | 9 - .../sdk/service/GreedyInfoProvider.java | 14 +- .../android/sdk/service/InfoProvider.java | 14 +- .../android/sdk/service/Preconditions.java | 50 +++++ .../sdk/service/ServerInfoService.java | 24 +++ .../sdk/service/ServerInfoTransformer.java | 14 +- .../android/sdk/service/auth/AuthService.java | 14 +- .../sdk/service/auth/SpringAuthService.java | 14 +- .../sdk/service/auth/TokenProvider.java | 33 +++ .../sdk/service/data/report/PageRange.java | 0 .../service/data/report/ReportMetadata.java | 94 ++++----- .../sdk/service/data/report/ReportOutput.java | 0 .../service/data/report/ResourceOutput.java | 0 .../data/repository/DefaultTypeParser.java | 86 ++++---- .../sdk/service/data/repository/Resource.java | 14 +- .../service/data/repository/ResourceType.java | 14 +- .../service/data/repository/SearchResult.java | 102 +++++----- .../data/server/DefaultVersionParser.java | 14 +- .../sdk/service/data/server/FeatureSet.java | 14 +- .../service/data/server/ServerEdition.java | 14 +- .../sdk/service/data/server/ServerInfo.java | 14 +- .../service/data/server/ServerVersion.java | 14 +- .../sdk/service/report/ExecutionCriteria.java | 14 +- .../service/report/ExecutionException.java | 14 +- .../report/ExecutionOptionsDataMapper.java | 14 +- .../sdk/service/report/ExportFactory.java | 0 .../sdk/service/report/OutputDataMapper.java | 0 .../sdk/service/report/ReportAttachment.java | 112 +++++------ .../sdk/service/report/ReportExecution.java | 14 +- .../report/ReportExecutionUseCase.java | 0 .../sdk/service/report/ReportExport.java | 14 +- .../service/report/ReportExportUseCase.java | 0 .../sdk/service/report/ReportService.java | 14 +- .../sdk/service/report/RunExportCriteria.java | 14 +- .../sdk/service/report/RunReportCriteria.java | 14 +- .../android/sdk/service/report/Status.java | 14 +- .../exception/ReportExportException.java | 14 +- .../report/exception/ReportRunException.java | 14 +- .../service/repository/CriteriaMapper.java | 0 .../repository/EmeraldMR2SearchStrategy.java | 14 +- .../repository/EmeraldMR3SearchStrategy.java | 14 +- .../service/repository/InternalCriteria.java | 22 +- .../service/repository/RepositoryService.java | 14 +- .../service/repository/ResourceMapper.java | 14 +- .../service/repository/SearchCriteria.java | 18 +- .../service/repository/SearchStrategy.java | 14 +- .../sdk/service/repository/SearchTask.java | 14 +- .../service/repository/SearchTaskImpl.java | 14 +- .../sdk/service/repository/SearchUseCase.java | 140 ++++++------- .../sdk/network/ReportOptionRestApiTest.java | 14 +- .../sdk/network/RepositoryRestApiTest.java | 14 +- .../sdk/service/ServerInfoServiceTest.java | 24 +++ .../service/ServerInfoTransformerTest.java | 14 +- .../auth/SpringAuthServiceBuilderTest.java | 14 +- .../service/auth/SpringAuthServiceTest.java | 24 +++ .../sdk/service/data/PageRangeTest.java | 0 .../repository/DefaultTypeParserTest.java | 14 +- .../data/server/DefaultVersionParserTest.java | 14 +- .../service/data/server/FeatureSetTest.java | 33 +++ .../service/data/server/ServerInfoTest.java | 33 +++ .../data/server/ServerVersionTest.java | 14 +- .../report/ExecutionExceptionTest.java | 24 +++ .../ExecutionOptionsDataMapperTest.java | 24 +++ .../service/report/ReportAttachmentTest.java | 144 ++++++++------ .../service/report/ReportExecutionTest.java | 24 +++ .../sdk/service/report/ReportExportTest.java | 24 +++ .../sdk/service/report/ReportServiceTest.java | 24 +++ .../service/report/RunExportCriteriaTest.java | 14 +- .../service/report/RunReportCriteriaTest.java | 14 +- .../sdk/service/report/StatusChain.java | 14 +- .../sdk/service/report/StatusTest.java | 14 +- .../repository/CriteriaMapperTest.java | 0 .../EmeraldMR2SearchStrategyTest.java | 24 +++ .../EmeraldMR3SearchStrategyTest.java | 24 +++ .../InternalSearchCriteriaTest.java | 14 +- .../repository/RepositoryServiceTest.java | 14 +- .../repository/ResourceMapperTest.java | 24 +++ .../repository/SearchCriteriaTest.java | 14 +- .../repository/SearchStrategyTest.java | 14 +- .../repository/SearchTaskImplTest.java | 14 +- .../service/repository/SearchUseCaseTest.java | 188 ++++++++++-------- settings.gradle | 2 - 87 files changed, 1212 insertions(+), 905 deletions(-) delete mode 100644 client-service/build.gradle delete mode 100644 client-service/src/main/AndroidManifest.xml delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java delete mode 100644 client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java delete mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java delete mode 100644 client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java (81%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java (72%) create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java (61%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java (79%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java (64%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java (92%) create mode 100644 client/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java (69%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java (70%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java (81%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java (76%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java (72%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java (84%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java (78%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java (62%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java (85%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java (77%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java (81%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java (91%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java (86%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java (76%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java (92%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java (78%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java (90%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java (84%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java (87%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java (74%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java (66%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java (66%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java (100%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java (89%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java (88%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java (93%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java (77%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java (84%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java (88%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java (82%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java (67%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java (84%) rename {client-service => client}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java (83%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java (56%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java (89%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java (89%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java (74%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java (100%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java (78%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java (82%) create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java create mode 100644 client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java (84%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java (79%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java (73%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java (67%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java (89%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java (57%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java (83%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java (72%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java (72%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java (75%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java (78%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java (100%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java (83%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java (80%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java (93%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java (80%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java (74%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java (81%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java (85%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java (87%) rename {client-service => client}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java (72%) diff --git a/client-service/build.gradle b/client-service/build.gradle deleted file mode 100644 index cef78155..00000000 --- a/client-service/build.gradle +++ /dev/null @@ -1,52 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion androidCompileSdkVersion - buildToolsVersion androidBuildToolsVersion - - defaultConfig { - minSdkVersion androidMinSdkVersion - targetSdkVersion androidTargetSdkVersion - versionCode clientModuleVersionCode - versionName version - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - encoding 'ISO-8859-1' - } - packagingOptions { - exclude 'META-INF/notice.txt' - exclude 'META-INF/license.txt' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/NOTICE.txt' - } - lintOptions { - abortOnError false - } - - buildTypes { - debug { - minifyEnabled false - } - } -} - -dependencies { - compile project(':js-android-sdk-client') - compile 'com.intellij:annotations:12.0' - - testCompile('pl.pragmatists:JUnitParams:1.0.4') { - exclude group: 'org.hamcrest' - } - testCompile 'org.hamcrest:hamcrest-integration:1.3' - testCompile('org.mockito:mockito-core:1.10.19') { - exclude group: 'org.hamcrest' - exclude group: 'org.objenesis' - } - testCompile('org.powermock:powermock-api-mockito:1.6.3') { - exclude group: 'org.mockito' - } - testCompile 'org.powermock:powermock-module-junit4:1.6.3' - testCompile 'org.robolectric:shadows-support-v4:3.0' -} diff --git a/client-service/src/main/AndroidManifest.xml b/client-service/src/main/AndroidManifest.xml deleted file mode 100644 index 97e28e6e..00000000 --- a/client-service/src/main/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java deleted file mode 100644 index 1c5d4808..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007 The Guava Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.jaspersoft.android.sdk.service; - - -import org.jetbrains.annotations.Nullable; - -/** - * @author Kevin Bourrillion - * @since 2.0 - */ -public final class Preconditions { - private Preconditions() { - } - - public static T checkNotNull(T object, String message) { - if (object == null) { - throw new NullPointerException(message); - } - return object; - } - - public static void checkArgument(boolean expression, @Nullable Object errorMessage) { - if (!expression) { - throw new IllegalArgumentException(String.valueOf(errorMessage)); - } - } -} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java b/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java deleted file mode 100644 index 6513b8de..00000000 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jaspersoft.android.sdk.service.auth; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface TokenProvider { - String provideToken(); -} diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java deleted file mode 100644 index 201f29ac..00000000 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jaspersoft.android.sdk.service.data.server; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class FeatureSetTest { - -} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java b/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java deleted file mode 100644 index b7a81caf..00000000 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.jaspersoft.android.sdk.service.data.server; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ServerInfoTest { - -} \ No newline at end of file diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java b/client/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java similarity index 81% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java index f4b313da..bed3b614 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java b/client/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java similarity index 72% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java index 486f477f..a8242e97 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java b/client/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java new file mode 100644 index 00000000..5924b831 --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + + +import org.jetbrains.annotations.Nullable; + +/** + * @author Kevin Bourrillion + * @since 2.0 + */ +public final class Preconditions { + private Preconditions() { + } + + public static T checkNotNull(T object, String message) { + if (object == null) { + throw new NullPointerException(message); + } + return object; + } + + public static void checkArgument(boolean expression, @Nullable Object errorMessage) { + if (!expression) { + throw new IllegalArgumentException(String.valueOf(errorMessage)); + } + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java similarity index 61% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java index d88d3fff..b496939d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.ServerRestApi; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java b/client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java similarity index 79% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java index 060fdeaa..c473b229 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/client/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java similarity index 64% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java index 8cc1379e..9d390a2b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/client/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java similarity index 92% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index fdc99a23..50511382 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java b/client/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java new file mode 100644 index 00000000..3d3285b5 --- /dev/null +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface TokenProvider { + String provideToken(); +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java similarity index 69% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java index c899056a..076648cb 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java @@ -1,47 +1,47 @@ -/* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.report; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ReportMetadata { - private final String uri; - private final int totalPages; - - public ReportMetadata(String uri, int totalPages) { - this.uri = uri; - this.totalPages = totalPages; - } - - public String getUri() { - return uri; - } - - public int getTotalPages() { - return totalPages; - } -} +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportMetadata { + private final String uri; + private final int totalPages; + + public ReportMetadata(String uri, int totalPages) { + this.uri = uri; + this.totalPages = totalPages; + } + + public String getUri() { + return uri; + } + + public int getTotalPages() { + return totalPages; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java similarity index 70% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java index ec0772b2..a3e1e958 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java @@ -1,43 +1,43 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.data.repository; - -/** - * @author Tom Koptel - * @since 2.0 - */ -enum DefaultTypeParser implements ResourceType.Parser { - INSTANCE; - - public ResourceType parse(String rawValue) { - ResourceType type; - try { - type = ResourceType.valueOf(rawValue); - } catch (IllegalArgumentException ex) { - type = ResourceType.unknown; - type.setRawValue(rawValue); - } - return type; - } -} +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.data.repository; + +/** + * @author Tom Koptel + * @since 2.0 + */ +enum DefaultTypeParser implements ResourceType.Parser { + INSTANCE; + + public ResourceType parse(String rawValue) { + ResourceType type; + try { + type = ResourceType.valueOf(rawValue); + } catch (IllegalArgumentException ex) { + type = ResourceType.unknown; + type.setRawValue(rawValue); + } + return type; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java similarity index 81% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java index c1377b97..28f5f0d1 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.data.repository; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java similarity index 76% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java index 7b81df99..00ddfa42 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java similarity index 72% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java index e11938a2..f27025f0 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java @@ -1,51 +1,51 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.data.repository; - -import java.util.Collection; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class SearchResult { - private Collection mResources; - private int mNextOffset; - - public Collection getResources() { - return mResources; - } - - public void setResources(Collection resources) { - mResources = resources; - } - - public int getNextOffset() { - return mNextOffset; - } - - public void setNextOffset(int nextOffset) { - mNextOffset = nextOffset; - } -} +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.data.repository; + +import java.util.Collection; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class SearchResult { + private Collection mResources; + private int mNextOffset; + + public Collection getResources() { + return mResources; + } + + public void setResources(Collection resources) { + mResources = resources; + } + + public int getNextOffset() { + return mNextOffset; + } + + public void setNextOffset(int nextOffset) { + mNextOffset = nextOffset; + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java similarity index 84% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java index 61ab836b..cda48556 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java similarity index 78% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java index 3141fcfd..bd68f110 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java similarity index 62% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java index b6571ad7..5fc78c80 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java similarity index 85% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index 740fb010..5d123e74 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java similarity index 77% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java index 93f7bac8..649dd682 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java similarity index 81% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java index 4b2a75a5..a3ca1c1d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java similarity index 91% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java index 29812d44..b22eaa8b 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java similarity index 86% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 92f72ba7..7fe48cb9 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java similarity index 76% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index 1c7100af..31547256 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -1,56 +1,56 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ReportAttachment { - private final String mFileName; - private final String mExecutionId; - private final String mExportId; - - private final ReportExportUseCase mExportUseCase; - - ReportAttachment(String fileName, - String executionId, - String exportId, - ReportExportUseCase exportUseCase) { - mFileName = fileName; - mExecutionId = executionId; - mExportId = exportId; - mExportUseCase = exportUseCase; - } - - @NotNull - public ResourceOutput download() { - return mExportUseCase.requestExportAttachmentOutput( - mExecutionId, mExportId, mFileName); - } -} +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; + +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportAttachment { + private final String mFileName; + private final String mExecutionId; + private final String mExportId; + + private final ReportExportUseCase mExportUseCase; + + ReportAttachment(String fileName, + String executionId, + String exportId, + ReportExportUseCase exportUseCase) { + mFileName = fileName; + mExecutionId = executionId; + mExportId = exportId; + mExportUseCase = exportUseCase; + } + + @NotNull + public ResourceOutput download() { + return mExportUseCase.requestExportAttachmentOutput( + mExecutionId, mExportId, mFileName); + } +} diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java similarity index 92% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 0fb5657e..8e12f678 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java similarity index 78% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 703ad6cf..d44281bf 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java similarity index 90% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 8709b2da..ca9926a1 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java similarity index 84% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index 0d2d10f1..48447fda 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java similarity index 87% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index 6fe69752..e82e9556 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java similarity index 74% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java index e956129b..d0683a5c 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java similarity index 66% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java index 2d58685d..40e18226 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report.exception; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java b/client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java similarity index 66% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java index ab697481..b0e6ae2d 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report.exception; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java similarity index 100% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java similarity index 89% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 9b918d17..05848a78 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java similarity index 88% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 93948204..0ad7a7c3 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java similarity index 93% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index 20e75def..55c598a1 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.repository; @@ -57,8 +57,8 @@ private InternalCriteria(Builder builder) { } @NotNull - public static InternalCriteria.Builder builder() { - return new InternalCriteria.Builder(); + public static Builder builder() { + return new Builder(); } @NotNull @@ -116,8 +116,8 @@ public String getSortBy() { } @NotNull - public InternalCriteria.Builder newBuilder() { - InternalCriteria.Builder builder = builder(); + public Builder newBuilder() { + Builder builder = builder(); if (mRecursive != null) { builder.recursive(mRecursive); diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java similarity index 77% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index b9d80216..58525aad 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java similarity index 84% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java index 85b732f8..d82000e6 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.repository; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java similarity index 88% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 519066a7..e28910c8 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ @@ -62,8 +62,8 @@ private SearchCriteria(Builder builder) { } @NotNull - public static SearchCriteria.Builder builder() { - return new SearchCriteria.Builder(); + public static Builder builder() { + return new Builder(); } @NotNull diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java similarity index 82% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 42928833..e5e37ceb 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java similarity index 67% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 3bb056af..f4020373 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.repository; diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java similarity index 84% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 5d5559c5..aec1302a 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java similarity index 83% rename from client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java rename to client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 39b4ec3a..4785e8b0 100644 --- a/client-service/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -1,70 +1,70 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile for Android. - * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see - * . - */ -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.repository.SearchResult; - -import org.jetbrains.annotations.NotNull; - -import java.text.SimpleDateFormat; -import java.util.Collection; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class SearchUseCase { - private final RepositoryRestApi mRestApi; - private final TokenProvider mTokenProvider; - private final InfoProvider mInfoProvider; - private final ResourceMapper mDataMapper; - - public SearchUseCase( - ResourceMapper dataMapper, RepositoryRestApi restApi, - TokenProvider tokenProvider, InfoProvider infoProvider) { - mRestApi = restApi; - mTokenProvider = tokenProvider; - mInfoProvider = infoProvider; - mDataMapper = dataMapper; - } - - @NotNull - public SearchResult performSearch(@NotNull InternalCriteria criteria) { - ResourceSearchResult response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); - SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); - - SearchResult searchResult = new SearchResult(); - searchResult.setNextOffset(response.getNextOffset()); - - Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); - searchResult.setResources(resources); - - return searchResult; - } -} +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; + +import org.jetbrains.annotations.NotNull; + +import java.text.SimpleDateFormat; +import java.util.Collection; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class SearchUseCase { + private final RepositoryRestApi mRestApi; + private final TokenProvider mTokenProvider; + private final InfoProvider mInfoProvider; + private final ResourceMapper mDataMapper; + + public SearchUseCase( + ResourceMapper dataMapper, RepositoryRestApi restApi, + TokenProvider tokenProvider, InfoProvider infoProvider) { + mRestApi = restApi; + mTokenProvider = tokenProvider; + mInfoProvider = infoProvider; + mDataMapper = dataMapper; + } + + @NotNull + public SearchResult performSearch(@NotNull InternalCriteria criteria) { + ResourceSearchResult response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); + SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); + + SearchResult searchResult = new SearchResult(); + searchResult.setNextOffset(response.getNextOffset()); + + Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); + searchResult.setResources(resources); + + return searchResult; + } +} diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 0a958033..f62b7fce 100644 --- a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index 1c099cd3..a99716ea 100644 --- a/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java similarity index 56% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java index e33a81a6..52927c27 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.ServerRestApi; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java similarity index 89% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java index 32649623..23a925c6 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java similarity index 89% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java index d5470c26..ab3337a0 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java similarity index 74% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index 36182751..e3a10aa0 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java similarity index 100% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java similarity index 78% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java index 1e3c0cdb..2df5b88d 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java similarity index 82% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java index 32be5cb4..8d6c7aec 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java new file mode 100644 index 00000000..e8029df2 --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class FeatureSetTest { + +} \ No newline at end of file diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java new file mode 100644 index 00000000..f78833d1 --- /dev/null +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerInfoTest { + +} \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java similarity index 84% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java index 60858e12..a38a4ac0 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java similarity index 79% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java index 06fe40e5..11d76ec5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java similarity index 73% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 524c5793..e3b544b7 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java similarity index 67% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index ed94034e..2dcf21a7 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -1,61 +1,85 @@ -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({OutputResource.class}) -public class ReportAttachmentTest { - @Mock - ReportExportRestApi mExportRestApi; - @Mock - TokenProvider mTokenProvider; - @Mock - OutputResource input; - - private ReportAttachment objectUnderTest; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn("cookie"); - - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); - objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", exportUseCase); - } - - @Test - public void testDownload() throws Exception { - when(mExportRestApi.requestExportAttachment(anyString(), anyString(), anyString(), anyString())).thenReturn(input); - - ResourceOutput result = objectUnderTest.download(); - assertThat(result, is(notNullValue())); - - verify(mExportRestApi).requestExportAttachment(eq("cookie"), eq("exec_id"), eq("export_id"), eq("1.jpg")); - verifyNoMoreInteractions(mExportRestApi); - } +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({OutputResource.class}) +public class ReportAttachmentTest { + @Mock + ReportExportRestApi mExportRestApi; + @Mock + TokenProvider mTokenProvider; + @Mock + OutputResource input; + + private ReportAttachment objectUnderTest; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + when(mTokenProvider.provideToken()).thenReturn("cookie"); + + ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); + objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", exportUseCase); + } + + @Test + public void testDownload() throws Exception { + when(mExportRestApi.requestExportAttachment(anyString(), anyString(), anyString(), anyString())).thenReturn(input); + + ResourceOutput result = objectUnderTest.download(); + assertThat(result, is(notNullValue())); + + verify(mExportRestApi).requestExportAttachment(eq("cookie"), eq("exec_id"), eq("export_id"), eq("1.jpg")); + verifyNoMoreInteractions(mExportRestApi); + } } \ No newline at end of file diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java similarity index 89% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 01ceb588..2cc9b650 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java similarity index 57% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index f455874c..6adefa88 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.ReportExportRestApi; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java similarity index 83% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 1c38a3ab..58b99fc5 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java similarity index 72% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java index e885a6ad..b0791ec7 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java similarity index 72% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java index 445bea36..927695eb 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java similarity index 75% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java index ebb046a3..a2b213e7 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java similarity index 78% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java index 22e9c6c9..12c40f19 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java similarity index 100% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java similarity index 83% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index de1820ed..4c7515f4 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.service.data.repository.Resource; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java similarity index 80% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index 90fb5623..4dbcb123 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.service.data.repository.Resource; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java similarity index 93% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java index e514fd0d..dd892f8e 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java similarity index 80% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index fc86704a..129124cc 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java similarity index 74% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java index cd3ba82b..81582fbd 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java similarity index 81% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index e460afee..0cd047d6 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.repository; diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java similarity index 85% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index fd438f30..ad8d82bf 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java similarity index 87% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index b2b6f50b..a07cbe08 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java similarity index 72% rename from client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java rename to client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 6deed85c..26a64079 100644 --- a/client-service/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -1,83 +1,107 @@ -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyCollection; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class SearchUseCaseTest { - - public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat(); - @Mock - RepositoryRestApi mRepositoryRestApi; - @Mock - ResourceMapper mDataMapper; - @Mock - TokenProvider mTokenProvider; - @Mock - InfoProvider mInfoProvider; - - @Mock - ResourceLookup mResourceLookup; - - @Mock - InternalCriteria mCriteria; - @Mock - ServerInfo mServerInfo; - - @Mock - ResourceSearchResult mResult; - - private SearchUseCase objectUnderTest; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchUseCase(mDataMapper, mRepositoryRestApi, mTokenProvider, mInfoProvider); - } - - @Test - public void shouldProvideAndAdaptSearchResult() { - when(mResult.getNextOffset()).thenReturn(100); - when(mRepositoryRestApi.searchResources(anyString(), any(Map.class))).thenReturn(mResult); - when(mInfoProvider.provideDateTimeFormat()).thenReturn(DATE_TIME_FORMAT); - - Collection resources = new ArrayList(); - when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); - - SearchResult result = objectUnderTest.performSearch(mCriteria); - assertThat(result, is(not(nullValue()))); - assertThat(result.getNextOffset(), is(100)); - assertThat(result.getResources(), is(resources)); - - verify(mRepositoryRestApi).searchResources(anyString(), any(Map.class)); - } +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; + +import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyCollection; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class SearchUseCaseTest { + + public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat(); + @Mock + RepositoryRestApi mRepositoryRestApi; + @Mock + ResourceMapper mDataMapper; + @Mock + TokenProvider mTokenProvider; + @Mock + InfoProvider mInfoProvider; + + @Mock + ResourceLookup mResourceLookup; + + @Mock + InternalCriteria mCriteria; + @Mock + ServerInfo mServerInfo; + + @Mock + ResourceSearchResult mResult; + + private SearchUseCase objectUnderTest; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + objectUnderTest = new SearchUseCase(mDataMapper, mRepositoryRestApi, mTokenProvider, mInfoProvider); + } + + @Test + public void shouldProvideAndAdaptSearchResult() { + when(mResult.getNextOffset()).thenReturn(100); + when(mRepositoryRestApi.searchResources(anyString(), any(Map.class))).thenReturn(mResult); + when(mInfoProvider.provideDateTimeFormat()).thenReturn(DATE_TIME_FORMAT); + + Collection resources = new ArrayList(); + when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); + + SearchResult result = objectUnderTest.performSearch(mCriteria); + assertThat(result, is(not(nullValue()))); + assertThat(result.getNextOffset(), is(100)); + assertThat(result.getResources(), is(resources)); + + verify(mRepositoryRestApi).searchResources(anyString(), any(Map.class)); + } } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 22e5a762..40ae6fdd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,5 @@ include ':js-android-sdk-client' include ':js-android-sdk-ui' -include ':js-android-sdk-client-service' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File -project(':js-android-sdk-client-service').projectDir = "$rootDir/client-service" as File From 9325eac3a9585cfc27aa0b62db6fe082b006725b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 13:16:14 +0200 Subject: [PATCH 249/457] Drop UI module --- settings.gradle | 3 - ui/AndroidManifest.xml | 31 -- ui/build.gradle | 48 --- ui/project.properties | 9 - ui/src/main/AndroidManifest.xml | 31 -- .../sdk/ui/adapters/FileArrayAdapter.java | 236 ------------ .../ResourceDescriptorArrayAdapter.java | 99 ----- .../ResourceDescriptorComparator.java | 53 --- .../adapters/ResourceLookupArrayAdapter.java | 225 ------------ .../ui/adapters/ResourceLookupComparator.java | 53 --- .../ResourceLookupEndlessAdapter.java | 124 ------- .../ResourcePropertyArrayAdapter.java | 134 ------- .../sdk/ui/widget/MultiSelectSpinner.java | 342 ------------------ ui/src/main/res/color/cs_blue_white.xml | 41 --- ui/src/main/res/color/cs_dark_grey_white.xml | 41 --- ui/src/main/res/color/cs_grey_white.xml | 41 --- ui/src/main/res/color/cs_light_grey_white.xml | 41 --- ui/src/main/res/color/cs_orange_white.xml | 41 --- .../main/res/drawable-hdpi/ic_action_add.png | Bin 390 -> 0 bytes .../drawable-hdpi/ic_action_date_picker.png | Bin 302 -> 0 bytes .../drawable-hdpi/ic_action_time_picker.png | Bin 461 -> 0 bytes ui/src/main/res/drawable-hdpi/ic_menu_add.png | Bin 3243 -> 0 bytes .../main/res/drawable-hdpi/ic_menu_logout.png | Bin 4210 -> 0 bytes .../res/drawable-hdpi/ic_menu_refresh.png | Bin 3293 -> 0 bytes .../drawable-hdpi/ic_menu_server_profile.png | Bin 1321 -> 0 bytes .../res/drawable-hdpi/ic_type_dashboard.png | Bin 1636 -> 0 bytes .../main/res/drawable-hdpi/ic_type_folder.png | Bin 960 -> 0 bytes .../main/res/drawable-hdpi/ic_type_html.png | Bin 1410 -> 0 bytes .../main/res/drawable-hdpi/ic_type_image.png | Bin 1534 -> 0 bytes ui/src/main/res/drawable-hdpi/ic_type_pdf.png | Bin 1325 -> 0 bytes .../main/res/drawable-hdpi/ic_type_report.png | Bin 1720 -> 0 bytes .../drawable-hdpi/ic_type_server_profile.png | Bin 1531 -> 0 bytes .../main/res/drawable-hdpi/ic_type_text.png | Bin 1122 -> 0 bytes .../res/drawable-hdpi/ic_type_unknown.png | Bin 725 -> 0 bytes ui/src/main/res/drawable-hdpi/ic_type_xls.png | Bin 1460 -> 0 bytes .../main/res/drawable-ldpi/ic_action_add.png | Bin 230 -> 0 bytes .../drawable-ldpi/ic_action_date_picker.png | Bin 337 -> 0 bytes .../drawable-ldpi/ic_action_time_picker.png | Bin 311 -> 0 bytes ui/src/main/res/drawable-ldpi/ic_menu_add.png | Bin 1536 -> 0 bytes .../main/res/drawable-ldpi/ic_menu_logout.png | Bin 1766 -> 0 bytes .../res/drawable-ldpi/ic_menu_refresh.png | Bin 1386 -> 0 bytes .../drawable-ldpi/ic_menu_server_profile.png | Bin 765 -> 0 bytes .../res/drawable-ldpi/ic_type_dashboard.png | Bin 886 -> 0 bytes .../main/res/drawable-ldpi/ic_type_folder.png | Bin 582 -> 0 bytes .../main/res/drawable-ldpi/ic_type_html.png | Bin 787 -> 0 bytes .../main/res/drawable-ldpi/ic_type_image.png | Bin 848 -> 0 bytes ui/src/main/res/drawable-ldpi/ic_type_pdf.png | Bin 755 -> 0 bytes .../main/res/drawable-ldpi/ic_type_report.png | Bin 907 -> 0 bytes .../drawable-ldpi/ic_type_server_profile.png | Bin 797 -> 0 bytes .../main/res/drawable-ldpi/ic_type_text.png | Bin 643 -> 0 bytes .../res/drawable-ldpi/ic_type_unknown.png | Bin 477 -> 0 bytes ui/src/main/res/drawable-ldpi/ic_type_xls.png | Bin 764 -> 0 bytes .../main/res/drawable-mdpi/ic_action_add.png | Bin 329 -> 0 bytes .../drawable-mdpi/ic_action_date_picker.png | Bin 209 -> 0 bytes .../drawable-mdpi/ic_action_time_picker.png | Bin 234 -> 0 bytes ui/src/main/res/drawable-mdpi/ic_menu_add.png | Bin 1871 -> 0 bytes .../main/res/drawable-mdpi/ic_menu_logout.png | Bin 2293 -> 0 bytes .../res/drawable-mdpi/ic_menu_refresh.png | Bin 1791 -> 0 bytes .../drawable-mdpi/ic_menu_server_profile.png | Bin 925 -> 0 bytes .../res/drawable-mdpi/ic_type_dashboard.png | Bin 1108 -> 0 bytes .../main/res/drawable-mdpi/ic_type_folder.png | Bin 665 -> 0 bytes .../main/res/drawable-mdpi/ic_type_html.png | Bin 1050 -> 0 bytes .../main/res/drawable-mdpi/ic_type_image.png | Bin 1015 -> 0 bytes ui/src/main/res/drawable-mdpi/ic_type_pdf.png | Bin 918 -> 0 bytes .../main/res/drawable-mdpi/ic_type_report.png | Bin 1262 -> 0 bytes .../drawable-mdpi/ic_type_server_profile.png | Bin 918 -> 0 bytes .../main/res/drawable-mdpi/ic_type_text.png | Bin 751 -> 0 bytes .../res/drawable-mdpi/ic_type_unknown.png | Bin 523 -> 0 bytes ui/src/main/res/drawable-mdpi/ic_type_xls.png | Bin 936 -> 0 bytes .../main/res/drawable-xhdpi/ic_action_add.png | Bin 506 -> 0 bytes .../drawable-xhdpi/ic_action_date_picker.png | Bin 15072 -> 0 bytes .../drawable-xhdpi/ic_action_time_picker.png | Bin 14781 -> 0 bytes .../main/res/drawable-xhdpi/ic_menu_add.png | Bin 4073 -> 0 bytes .../res/drawable-xhdpi/ic_menu_logout.png | Bin 5245 -> 0 bytes .../res/drawable-xhdpi/ic_menu_refresh.png | Bin 4100 -> 0 bytes .../drawable-xhdpi/ic_menu_server_profile.png | Bin 410 -> 0 bytes .../res/drawable-xhdpi/ic_type_dashboard.png | Bin 2177 -> 0 bytes .../res/drawable-xhdpi/ic_type_folder.png | Bin 1237 -> 0 bytes .../main/res/drawable-xhdpi/ic_type_html.png | Bin 1877 -> 0 bytes .../main/res/drawable-xhdpi/ic_type_image.png | Bin 2261 -> 0 bytes .../main/res/drawable-xhdpi/ic_type_pdf.png | Bin 1672 -> 0 bytes .../res/drawable-xhdpi/ic_type_report.png | Bin 2199 -> 0 bytes .../drawable-xhdpi/ic_type_server_profile.png | Bin 2031 -> 0 bytes .../main/res/drawable-xhdpi/ic_type_text.png | Bin 1534 -> 0 bytes .../res/drawable-xhdpi/ic_type_unknown.png | Bin 956 -> 0 bytes .../main/res/drawable-xhdpi/ic_type_xls.png | Bin 2008 -> 0 bytes ui/src/main/res/drawable/bs_white_blue.xml | 41 --- .../main/res/drawable/gradient_light_grey.xml | 34 -- ui/src/main/res/layout/file_list_item.xml | 60 --- ui/src/main/res/layout/ic_boolean_layout.xml | 35 -- .../res/layout/ic_multi_select_layout.xml | 46 --- .../res/layout/ic_single_select_layout.xml | 46 --- .../layout/ic_single_value_date_layout.xml | 65 ---- .../res/layout/ic_single_value_layout.xml | 46 --- ui/src/main/res/layout/resource_list_item.xml | 51 --- .../res/layout/select_dialog_multichoice.xml | 31 -- .../res/layout/server_profile_list_item.xml | 50 --- .../main/res/layout/two_line_breadcrumbs.xml | 45 --- ui/src/main/res/values/colors.xml | 42 --- ui/src/main/res/values/strings.xml | 32 -- ui/src/main/res/values/styles.xml | 202 ----------- 101 files changed, 2419 deletions(-) delete mode 100644 ui/AndroidManifest.xml delete mode 100644 ui/build.gradle delete mode 100644 ui/project.properties delete mode 100644 ui/src/main/AndroidManifest.xml delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/FileArrayAdapter.java delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorArrayAdapter.java delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorComparator.java delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupArrayAdapter.java delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupComparator.java delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupEndlessAdapter.java delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourcePropertyArrayAdapter.java delete mode 100644 ui/src/main/java/com/jaspersoft/android/sdk/ui/widget/MultiSelectSpinner.java delete mode 100644 ui/src/main/res/color/cs_blue_white.xml delete mode 100644 ui/src/main/res/color/cs_dark_grey_white.xml delete mode 100644 ui/src/main/res/color/cs_grey_white.xml delete mode 100644 ui/src/main/res/color/cs_light_grey_white.xml delete mode 100644 ui/src/main/res/color/cs_orange_white.xml delete mode 100644 ui/src/main/res/drawable-hdpi/ic_action_add.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_action_date_picker.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_action_time_picker.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_menu_add.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_menu_logout.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_menu_refresh.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_menu_server_profile.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_dashboard.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_folder.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_html.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_image.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_pdf.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_report.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_server_profile.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_text.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_unknown.png delete mode 100644 ui/src/main/res/drawable-hdpi/ic_type_xls.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_action_add.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_action_date_picker.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_action_time_picker.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_menu_add.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_menu_logout.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_menu_refresh.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_menu_server_profile.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_dashboard.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_folder.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_html.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_image.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_pdf.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_report.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_server_profile.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_text.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_unknown.png delete mode 100644 ui/src/main/res/drawable-ldpi/ic_type_xls.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_action_add.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_action_date_picker.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_action_time_picker.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_menu_add.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_menu_logout.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_menu_refresh.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_menu_server_profile.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_dashboard.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_folder.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_html.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_image.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_pdf.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_report.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_server_profile.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_text.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_unknown.png delete mode 100644 ui/src/main/res/drawable-mdpi/ic_type_xls.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_action_add.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_action_date_picker.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_action_time_picker.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_menu_add.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_menu_logout.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_menu_refresh.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_menu_server_profile.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_dashboard.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_folder.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_html.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_image.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_pdf.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_report.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_server_profile.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_text.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_unknown.png delete mode 100644 ui/src/main/res/drawable-xhdpi/ic_type_xls.png delete mode 100644 ui/src/main/res/drawable/bs_white_blue.xml delete mode 100644 ui/src/main/res/drawable/gradient_light_grey.xml delete mode 100644 ui/src/main/res/layout/file_list_item.xml delete mode 100644 ui/src/main/res/layout/ic_boolean_layout.xml delete mode 100644 ui/src/main/res/layout/ic_multi_select_layout.xml delete mode 100644 ui/src/main/res/layout/ic_single_select_layout.xml delete mode 100644 ui/src/main/res/layout/ic_single_value_date_layout.xml delete mode 100644 ui/src/main/res/layout/ic_single_value_layout.xml delete mode 100644 ui/src/main/res/layout/resource_list_item.xml delete mode 100644 ui/src/main/res/layout/select_dialog_multichoice.xml delete mode 100644 ui/src/main/res/layout/server_profile_list_item.xml delete mode 100644 ui/src/main/res/layout/two_line_breadcrumbs.xml delete mode 100644 ui/src/main/res/values/colors.xml delete mode 100644 ui/src/main/res/values/strings.xml delete mode 100644 ui/src/main/res/values/styles.xml diff --git a/settings.gradle b/settings.gradle index 40ae6fdd..2e4a7e06 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,2 @@ include ':js-android-sdk-client' -include ':js-android-sdk-ui' - project(':js-android-sdk-client').projectDir = "$rootDir/client" as File -project(':js-android-sdk-ui').projectDir = "$rootDir/ui" as File diff --git a/ui/AndroidManifest.xml b/ui/AndroidManifest.xml deleted file mode 100644 index 27407f3e..00000000 --- a/ui/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - diff --git a/ui/build.gradle b/ui/build.gradle deleted file mode 100644 index 47e689e8..00000000 --- a/ui/build.gradle +++ /dev/null @@ -1,48 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' - -description = 'js-android-sdk-ui' -version = '1.9' -ext { - PUBLISH_GROUP_ID = group - PUBLISH_ARTIFACT_ID = description - PUBLISH_VERSION = '1.9' -} - - -android { - compileSdkVersion androidCompileSdkVersion - buildToolsVersion androidBuildToolsVersion - - defaultConfig { - minSdkVersion androidMinSdkVersion - targetSdkVersion androidTargetSdkVersion - - versionCode 9010900 - versionName version - } - - lintOptions { - abortOnError false - } - - packagingOptions { - exclude 'asm-license.txt' - exclude 'NOTICE' - exclude 'LICENSE' - exclude 'LICENSE.txt' - exclude 'META-INF/license.txt' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/LICENSE' - exclude 'META-INF/notice.txt' - exclude 'META-INF/NOTICE.txt' - exclude 'META-INF/NOTICE' - } -} - - -dependencies { - compile project(':js-android-sdk-client') -} - -apply from: '../scripts/android-release-aar.gradle' \ No newline at end of file diff --git a/ui/project.properties b/ui/project.properties deleted file mode 100644 index 57478bac..00000000 --- a/ui/project.properties +++ /dev/null @@ -1,9 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# - -android.library=true -# Project target. -target=android-16 diff --git a/ui/src/main/AndroidManifest.xml b/ui/src/main/AndroidManifest.xml deleted file mode 100644 index 27407f3e..00000000 --- a/ui/src/main/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/FileArrayAdapter.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/FileArrayAdapter.java deleted file mode 100644 index d43e00d5..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/FileArrayAdapter.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.ui.adapters; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.text.format.DateUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import com.jaspersoft.android.sdk.ui.R; -import com.jaspersoft.android.sdk.util.FileUtils; - -import java.io.File; -import java.util.Arrays; -import java.util.EnumMap; -import java.util.List; - -/** - * A concrete ArrayAdapter that is backed by an array of File objects. - * - * @author Ivan Gadzhega - * @since 1.8 - */ -public class FileArrayAdapter extends ArrayAdapter { - - private LayoutInfo layoutInfo; - private EnumMap drawableIdsMap; - - @Deprecated - public FileArrayAdapter(Context context, File[] files) { - this(context, Arrays.asList(files)); - } - - public FileArrayAdapter(Context context, LayoutInfo layoutInfo, File[] files) { - this(context, layoutInfo, Arrays.asList(files)); - } - - public FileArrayAdapter(Context context, LayoutInfo layoutInfo, - EnumMap drawableIdsMap, File[] files) { - this(context, layoutInfo, drawableIdsMap, Arrays.asList(files)); - } - - @Deprecated - public FileArrayAdapter(Context context, List files) { - this(context, new LayoutInfo(R.layout.file_list_item), new EnumMap(FileType.class), files); - - layoutInfo.setIconViewId(R.id.file_list_item_icon); - layoutInfo.setLabelViewId(R.id.file_list_item_label); - layoutInfo.setDateViewId(R.id.file_list_item_date); - layoutInfo.setSizeViewId(R.id.file_list_item_size); - - drawableIdsMap.put(FileType.HTML, R.drawable.ic_type_html); - drawableIdsMap.put(FileType.PDF, R.drawable.ic_type_pdf); - drawableIdsMap.put(FileType.XLS, R.drawable.ic_type_xls); - drawableIdsMap.put(FileType.UNKNOWN, R.drawable.ic_type_unknown); - } - - public FileArrayAdapter(Context context, LayoutInfo layoutInfo, List files) { - this(context, layoutInfo, null, files); - } - - public FileArrayAdapter(Context context, LayoutInfo layoutInfo, - EnumMap drawableIdsMap, List files) { - super(context, layoutInfo.layoutResId, files); - this.layoutInfo = layoutInfo; - this.drawableIdsMap = drawableIdsMap; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - File file = getItem(position); - - // reuse views - View rowView = convertView; - if (rowView == null) { - LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - rowView = inflater.inflate(layoutInfo.getLayoutResId(), parent, false); - // configure view holder - ViewHolder viewHolder = new ViewHolder(); - viewHolder.iconView = (ImageView) rowView.findViewById(layoutInfo.getIconViewId()); - viewHolder.labelView = (TextView) rowView.findViewById(layoutInfo.getLabelViewId()); - viewHolder.dateView = (TextView) rowView.findViewById(layoutInfo.getDateViewId()); - viewHolder.sizeView = (TextView) rowView.findViewById(layoutInfo.getSizeViewId()); - rowView.setTag(viewHolder); - } - // fill data - ViewHolder viewHolder = (ViewHolder) rowView.getTag(); - if (viewHolder.iconView != null && drawableIdsMap != null) { - String extension = FileUtils.getExtension(file.getName()); - Drawable icon = getFileIconByExtension(extension); - viewHolder.iconView.setImageDrawable(icon); - } - if (viewHolder.labelView != null) { - String baseName = FileUtils.getBaseName(file.getName()); - viewHolder.labelView.setText(baseName); - } - if (viewHolder.dateView != null) { - String dateModified = getFormattedDateModified(file); - viewHolder.dateView.setText(dateModified); - } - if (viewHolder.sizeView != null) { - String size = getHumanReadableFileSize(file); - viewHolder.sizeView.setText(size); - } - - // return configured view - return rowView; - } - - //--------------------------------------------------------------------- - // Helper methods - //--------------------------------------------------------------------- - - private Drawable getFileIconByExtension(String extension) { - FileType type = getFileTypeByExtension(extension); - int drawableResId = drawableIdsMap.get(type); - return getContext().getResources().getDrawable(drawableResId); - } - - private FileType getFileTypeByExtension(String extension) { - try { - return FileType.valueOf(extension); - } catch (IllegalArgumentException ex) { - return FileType.UNKNOWN; - } - } - - private String getFormattedDateModified(File file) { - return DateUtils.formatDateTime(getContext(), file.lastModified(), - DateUtils.FORMAT_SHOW_DATE | - DateUtils.FORMAT_SHOW_TIME | - DateUtils.FORMAT_SHOW_YEAR | - DateUtils.FORMAT_NUMERIC_DATE | - DateUtils.FORMAT_24HOUR - ); - } - - private String getHumanReadableFileSize(File file) { - long bytes = FileUtils.calculateFileSize(file); - return FileUtils.getHumanReadableByteCount(bytes); - } - - //--------------------------------------------------------------------- - // Nested Classes - //--------------------------------------------------------------------- - - public enum FileType { - HTML, - PDF, - XLS, - UNKNOWN - } - - public static class LayoutInfo { - private int layoutResId; - private int iconViewId; - private int labelViewId; - private int dateViewId; - private int sizeViewId; - - public LayoutInfo(int layoutResId) { - this.layoutResId = layoutResId; - } - - public int getLayoutResId() { - return layoutResId; - } - - public int getIconViewId() { - return iconViewId; - } - - public void setIconViewId(int iconViewId) { - this.iconViewId = iconViewId; - } - - public int getLabelViewId() { - return labelViewId; - } - - public void setLabelViewId(int labelViewId) { - this.labelViewId = labelViewId; - } - - public int getDateViewId() { - return dateViewId; - } - - public void setDateViewId(int dateViewId) { - this.dateViewId = dateViewId; - } - - public int getSizeViewId() { - return sizeViewId; - } - - public void setSizeViewId(int sizeViewId) { - this.sizeViewId = sizeViewId; - } - } - - private static class ViewHolder { - private ImageView iconView; - private TextView labelView; - private TextView dateView; - private TextView sizeView; - } - -} diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorArrayAdapter.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorArrayAdapter.java deleted file mode 100644 index 338817d8..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorArrayAdapter.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.ui.adapters; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; -import com.jaspersoft.android.sdk.ui.R; - -import java.util.List; - -/** - * A concrete ArrayAdapter that is backed by an array of ResourceDescriptor objects. - * - * @author Ivan Gadzhega - * @since 1.0 - */ -public class ResourceDescriptorArrayAdapter extends ArrayAdapter{ - private final Context context; - private final List resourceDescriptors; - - public ResourceDescriptorArrayAdapter(Context context, List resourceDescriptors) { - super(context, R.layout.resource_list_item, resourceDescriptors); - this.context = context; - this.resourceDescriptors = resourceDescriptors; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View rowView = inflater.inflate(R.layout.resource_list_item, parent, false); - - ImageView image = (ImageView) rowView.findViewById(R.id.resource_list_item_icon); - TextView label = (TextView) rowView.findViewById(R.id.resource_list_item_label); - TextView uri = (TextView) rowView.findViewById(R.id.resource_list_item_uri); - - ResourceDescriptor resourceDescriptor = resourceDescriptors.get(position); - - Drawable drawable; - switch (resourceDescriptor.getWsType()) { - case folder: - drawable = context.getResources().getDrawable(R.drawable.ic_type_folder); - break; - case reportUnit: - drawable = context.getResources().getDrawable(R.drawable.ic_type_report); - break; - case dashboard: - drawable = context.getResources().getDrawable(R.drawable.ic_type_dashboard); - break; - case img: - drawable = context.getResources().getDrawable(R.drawable.ic_type_image); - break; - case css: - case xml: - drawable = context.getResources().getDrawable(R.drawable.ic_type_text); - break; - default: - // for an unknown resource - drawable = context.getResources().getDrawable(R.drawable.ic_type_unknown); - break; - } - - image.setImageDrawable(drawable); - - label.setText(resourceDescriptor.getLabel()); - uri.setText(resourceDescriptor.getUriString()); - - return rowView; - } -} diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorComparator.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorComparator.java deleted file mode 100644 index aec89046..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceDescriptorComparator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.ui.adapters; - -import com.jaspersoft.android.sdk.client.oxm.ResourceDescriptor; - -import java.io.Serializable; -import java.util.Comparator; - -/** - * @author Ivan Gadzhega - * @since 1.4 - */ -public class ResourceDescriptorComparator implements Comparator, Serializable { - - private static final long serialVersionUID = 1L; - - @Override - public int compare(ResourceDescriptor object1, ResourceDescriptor object2) { - if (object1.getWsType() == ResourceDescriptor.WsType.folder) { - if (object2.getWsType() != ResourceDescriptor.WsType.folder) { - return -1; - } - } else { - if (object2.getWsType() == ResourceDescriptor.WsType.folder) { - return 1; - } - } - return object1.getLabel().compareToIgnoreCase(object2.getLabel()); - } -} diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupArrayAdapter.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupArrayAdapter.java deleted file mode 100644 index 597efb6b..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupArrayAdapter.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.ui.adapters; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; -import com.jaspersoft.android.sdk.ui.R; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.EnumMap; -import java.util.List; - -import static com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup.ResourceType; - -/** - * A concrete ArrayAdapter that is backed by an array of ResourceLookup objects. - * - * @author Ivan Gadzhega - * @since 1.7 - */ -public class ResourceLookupArrayAdapter extends ArrayAdapter{ - - private LayoutInfo layoutInfo; - private EnumMap drawableIdsMap; - private String datetimeFormatPattern = "yyyy-MM-dd HH:mm:ss"; - - public ResourceLookupArrayAdapter(Context context, LayoutInfo layoutInfo, List resourceLookups) { - this(context, layoutInfo, null, resourceLookups); - } - - public ResourceLookupArrayAdapter(Context context, LayoutInfo layoutInfo, - EnumMap drawableIdsMap, - List resourceLookups) { - super(context, layoutInfo.layoutResId, resourceLookups); - this.layoutInfo = layoutInfo; - this.drawableIdsMap = drawableIdsMap; - } - - @Deprecated - public ResourceLookupArrayAdapter(Context context, List resourceLookups) { - this(context, new LayoutInfo(R.layout.resource_list_item), - new EnumMap(ResourceType.class), resourceLookups); - - layoutInfo.setIconViewId(R.id.resource_list_item_icon); - layoutInfo.setLabelViewId(R.id.resource_list_item_label); - layoutInfo.setUriViewId(R.id.resource_list_item_uri); - - drawableIdsMap.put(ResourceType.folder, R.drawable.ic_type_folder); - drawableIdsMap.put(ResourceType.reportUnit, R.drawable.ic_type_report); - drawableIdsMap.put(ResourceType.dashboard, R.drawable.ic_type_dashboard); - drawableIdsMap.put(ResourceType.unknown, R.drawable.ic_type_unknown); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ResourceLookup resourceLookup = getItem(position); - // reuse views - View rowView = convertView; - if (rowView == null) { - LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - rowView = inflater.inflate(layoutInfo.layoutResId, parent, false); - // configure view holder - ViewHolder viewHolder = new ViewHolder(); - viewHolder.iconView = (ImageView) rowView.findViewById(layoutInfo.iconViewId); - viewHolder.labelView = (TextView) rowView.findViewById(layoutInfo.labelViewId); - viewHolder.descriptionView = (TextView) rowView.findViewById(layoutInfo.descriptionViewId); - viewHolder.dateView = (TextView) rowView.findViewById(layoutInfo.dateViewId); - viewHolder.uriView = (TextView) rowView.findViewById(layoutInfo.uriViewId); - rowView.setTag(viewHolder); - } - // fill data - ViewHolder viewHolder = (ViewHolder) rowView.getTag(); - if (viewHolder.iconView != null && drawableIdsMap != null) { - Drawable icon = getIconByType(resourceLookup.getResourceType()); - viewHolder.iconView.setImageDrawable(icon); - } - if (viewHolder.labelView != null) { - String label = resourceLookup.getLabel(); - viewHolder.labelView.setText(label); - } - if (viewHolder.descriptionView != null) { - String description = resourceLookup.getDescription(); - viewHolder.descriptionView.setText(description); - } - if (viewHolder.dateView != null) { - String date = formatDateString(resourceLookup.getUpdateDate()); - viewHolder.dateView.setText(date); - } - if (viewHolder.uriView != null) { - String uri = resourceLookup.getUri(); - viewHolder.uriView.setText(uri); - } - // return configured view - return rowView; - } - - public void setDatetimeFormatPattern(String datetimeFormatPattern) { - this.datetimeFormatPattern = datetimeFormatPattern; - } - - //--------------------------------------------------------------------- - // Helper methods - //--------------------------------------------------------------------- - - private Drawable getIconByType(ResourceType type) { - type = (drawableIdsMap.containsKey(type)) ? type : ResourceType.unknown; - int drawableResId = drawableIdsMap.get(type); - return getContext().getResources().getDrawable(drawableResId); - } - - private String formatDateString(String updateDate) { - updateDate = (updateDate == null) ? "" : updateDate; - try { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(datetimeFormatPattern); - Date dateValue = simpleDateFormat.parse(updateDate); - DateFormat dateFormat = DateFormat.getDateInstance(); - return dateFormat.format(dateValue); - } catch (ParseException ex) { - return updateDate; - } - } - - //--------------------------------------------------------------------- - // Nested Classes - //--------------------------------------------------------------------- - - public static class LayoutInfo { - private int layoutResId; - private int iconViewId; - private int labelViewId; - private int descriptionViewId; - private int dateViewId; - private int uriViewId; - - public LayoutInfo(int layoutResId) { - this.layoutResId = layoutResId; - } - - public int getLayoutResId() { - return layoutResId; - } - - public int getIconViewId() { - return iconViewId; - } - - public void setIconViewId(int iconViewId) { - this.iconViewId = iconViewId; - } - - public int getLabelViewId() { - return labelViewId; - } - - public void setLabelViewId(int labelViewId) { - this.labelViewId = labelViewId; - } - - public int getDescriptionViewId() { - return descriptionViewId; - } - - public void setDescriptionViewId(int descriptionViewId) { - this.descriptionViewId = descriptionViewId; - } - - public int getDateViewId() { - return dateViewId; - } - - public void setDateViewId(int dateViewId) { - this.dateViewId = dateViewId; - } - - public int getUriViewId() { - return uriViewId; - } - - public void setUriViewId(int uriViewId) { - this.uriViewId = uriViewId; - } - } - - private static class ViewHolder { - private ImageView iconView; - private TextView labelView; - private TextView descriptionView; - private TextView dateView; - private TextView uriView; - } - -} \ No newline at end of file diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupComparator.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupComparator.java deleted file mode 100644 index f67f3ce4..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupComparator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2012-2013 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.ui.adapters; - -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; - -import java.io.Serializable; -import java.util.Comparator; - -/** - * @author Ivan Gadzhega - * @since 1.7 - */ -public class ResourceLookupComparator implements Comparator, Serializable { - - private static final long serialVersionUID = 1L; - - @Override - public int compare(ResourceLookup object1, ResourceLookup object2) { - if (object1.getResourceType() == ResourceLookup.ResourceType.folder) { - if (object2.getResourceType() != ResourceLookup.ResourceType.folder) { - return -1; - } - } else { - if (object2.getResourceType() == ResourceLookup.ResourceType.folder) { - return 1; - } - } - return object1.getLabel().compareToIgnoreCase(object2.getLabel()); - } -} diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupEndlessAdapter.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupEndlessAdapter.java deleted file mode 100644 index b5895abf..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourceLookupEndlessAdapter.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2012-2014 Jaspersoft Corporation. - * Portions (C) 2008-2009 CommonsWare, LLC - * Portions (C) 2009 Google, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.jaspersoft.android.sdk.ui.adapters; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup; - -import java.util.EnumMap; -import java.util.List; - -import static com.jaspersoft.android.sdk.client.oxm.resource.ResourceLookup.ResourceType; - -/** - * @author Ivan Gadzhega - * @since 2.0 - */ -public class ResourceLookupEndlessAdapter extends ResourceLookupArrayAdapter { - - private LayoutInfo layoutInfo; - private boolean keepOnAppending; - private View pendingView; - - public ResourceLookupEndlessAdapter(Context context, LayoutInfo layoutInfo, List resourceLookups) { - super(context, layoutInfo, resourceLookups); - this.layoutInfo = layoutInfo; - } - - public ResourceLookupEndlessAdapter(Context context, LayoutInfo layoutInfo, EnumMap drawableIdsMap, - List resourceLookups) { - super(context, layoutInfo, drawableIdsMap, resourceLookups); - this.layoutInfo = layoutInfo; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - if (keepOnAppending && position == super.getCount()) { - return getPendingView(parent); - } else { - return super.getView(position, convertView, parent); - } - } - - @Override - public int getCount() { - return (keepOnAppending) ? super.getCount() + 1 : super.getCount(); - } - - public int getItemViewType(int position) { - return (position < super.getCount()) ? super.getItemViewType(position) : IGNORE_ITEM_VIEW_TYPE; - } - - public int getViewTypeCount() { - return super.getViewTypeCount() + 1; - } - - @Override - public ResourceLookup getItem(int position) { - return (position < super.getCount()) ? super.getItem(position) : null; - } - - //--------------------------------------------------------------------- - // Helper methods - //--------------------------------------------------------------------- - - private View getPendingView(ViewGroup parent) { - if (pendingView == null) { - LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - pendingView = inflater.inflate(layoutInfo.getPendingViewResId(), parent, false); - } - return pendingView; - } - - //--------------------------------------------------------------------- - // Getters & Setters - //--------------------------------------------------------------------- - - public void setKeepOnAppending(boolean keepOnAppending) { - this.keepOnAppending = keepOnAppending; - } - - public boolean isKeepOnAppending() { - return keepOnAppending; - } - - //--------------------------------------------------------------------- - // Nested Classes - //--------------------------------------------------------------------- - - public static class LayoutInfo extends ResourceLookupArrayAdapter.LayoutInfo { - - private int pendingViewResId; - - public LayoutInfo(int layoutResId) { - super(layoutResId); - } - - public int getPendingViewResId() { - return pendingViewResId; - } - - public void setPendingViewResId(int pendingViewResId) { - this.pendingViewResId = pendingViewResId; - } - } - -} \ No newline at end of file diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourcePropertyArrayAdapter.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourcePropertyArrayAdapter.java deleted file mode 100644 index d9bf9dfc..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/adapters/ResourcePropertyArrayAdapter.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.ui.adapters; - -import android.content.Context; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.TextView; - -import com.jaspersoft.android.sdk.client.oxm.ResourceProperty; - -import java.util.List; - -/** - * A concrete ArrayAdapter that is backed by an array of ResourceProperty objects. - * - * @author Ivan Gadzhega - * @since 1.0 - */ -public class ResourcePropertyArrayAdapter extends ArrayAdapter { - - private int mFieldId = 0; - private int mResource; - private int mDropDownResource; - private LayoutInflater mInflater; - - public ResourcePropertyArrayAdapter(Context context, int textViewResourceId) { - super(context, textViewResourceId); - init(context, textViewResourceId, 0); - } - - public ResourcePropertyArrayAdapter(Context context, int resource, int textViewResourceId) { - super(context, resource, textViewResourceId); - init(context, resource, textViewResourceId); - } - - public ResourcePropertyArrayAdapter(Context context, int textViewResourceId, ResourceProperty[] objects) { - super(context, textViewResourceId, objects); - init(context, textViewResourceId, 0); - } - - public ResourcePropertyArrayAdapter(Context context, int resource, int textViewResourceId, ResourceProperty[] objects) { - super(context, resource, textViewResourceId, objects); - init(context, resource, textViewResourceId); - } - - public ResourcePropertyArrayAdapter(Context context, int textViewResourceId, List objects) { - super(context, textViewResourceId, objects); - init(context, textViewResourceId, 0); - } - - public ResourcePropertyArrayAdapter(Context context, int resource, int textViewResourceId, List objects) { - super(context, resource, textViewResourceId, objects); - init(context, resource, textViewResourceId); - } - - private void init(Context context, int resource, int textViewResourceId) { - mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mResource = mDropDownResource = resource; - mFieldId = textViewResourceId; - } - - @Override - public void setDropDownViewResource(int resource) { - super.setDropDownViewResource(resource); - this.mDropDownResource = resource; - } - - @Override - public View getDropDownView(int position, View convertView, ViewGroup parent) { - return createViewFromResource(position, convertView, parent, mDropDownResource); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - return createViewFromResource(position, convertView, parent, mResource); - } - - private View createViewFromResource(int position, View convertView, ViewGroup parent, - int resource) { - View view; - TextView text; - - if (convertView == null) { - view = mInflater.inflate(resource, parent, false); - } else { - view = convertView; - } - - try { - if (mFieldId == 0) { - // If no custom field is assigned, assume the whole resource is a TextView - text = (TextView) view; - } else { - // Otherwise, find the TextView field within the layout - text = (TextView) view.findViewById(mFieldId); - } - } catch (ClassCastException e) { - Log.e("ArrayAdapter", "You must supply a resource ID for a TextView"); - throw new IllegalStateException( - "ArrayAdapter requires the resource ID to be a TextView", e); - } - - ResourceProperty item = getItem(position); - text.setText(item.getValue()); - - return view; - } -} diff --git a/ui/src/main/java/com/jaspersoft/android/sdk/ui/widget/MultiSelectSpinner.java b/ui/src/main/java/com/jaspersoft/android/sdk/ui/widget/MultiSelectSpinner.java deleted file mode 100644 index 797a1f0a..00000000 --- a/ui/src/main/java/com/jaspersoft/android/sdk/ui/widget/MultiSelectSpinner.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (C) 2012 Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from Jaspersoft, - * the following license terms apply: - * - * This program is part of Jaspersoft Mobile SDK for Android. - * - * Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.ui.widget; - -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.BaseAdapter; -import android.widget.Button; -import android.widget.Spinner; - -import com.jaspersoft.android.sdk.ui.R; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * A view that extends Spinner and allows to choose multiple items. Selected values are displayed on the spinner - * divided by comma. - * - * @author Ivan Gadzhega - * @version $Id$ - * @since 1.0 - */ -public class MultiSelectSpinner extends Spinner implements DialogInterface.OnMultiChoiceClickListener { - - private static final String TEXT_SEPARATOR = ", "; - private static final String TEXT_ELLIPSIS = "\u2026"; - private static final int TEXT_MAX_LENGTH = 100; - - private List items; - CharSequence[] stringItems; - private boolean[] checkedItems; - private boolean[] defaultCheckedItems; - /** - * the text that displays on the spinner if there is nothing selected. - */ - private String defaultText; - /** - * The listener that receives notifications when items are selected. - */ - private OnItemsSelectedListener onItemsSelectedListener; - - public MultiSelectSpinner(Context context) { - super(context); - } - - public MultiSelectSpinner(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public MultiSelectSpinner(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * This method will be invoked when an item in the dialog is clicked. - * - * @param dialog The dialog where the selection was made. - * @param which The position of the item in the list that was clicked. - * @param isChecked True if the click checked the item, else false. - */ - @Override - public void onClick(DialogInterface dialog, int which, boolean isChecked) { - checkedItems[which] = isChecked; - updateState(false); - } - - @Override - public boolean performClick() { - final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - // The prompt to display when the dialog is shown - if (getPrompt() != null) { - builder.setTitle(getPrompt()); - } - defaultCheckedItems = Arrays.copyOf(checkedItems, checkedItems.length); - builder.setMultiChoiceItems(stringItems, checkedItems, this); - builder.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - updateState(); - } - }); - builder.setNegativeButton(R.string.mss_btn_check_all, null); - - final AlertDialog dialog = builder.create(); - dialog.setOnShowListener(new DialogInterface.OnShowListener() { - @Override - public void onShow(DialogInterface dialogInterface) { - dialog.getListView().setAdapter(initCustomAdapter(dialog)); - Button button = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); - button.setText(ifAnyChecked() ? R.string.mss_btn_uncheck_all : R.string.mss_btn_check_all); - - dialog.getButton(AlertDialog.BUTTON_NEGATIVE) - .setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - Button button = (Button) view; - boolean ifAnyChecked = ifAnyChecked(); - button.setText(ifAnyChecked ? R.string.mss_btn_check_all : R.string.mss_btn_uncheck_all); - - if (ifAnyChecked) { - unselectAll(); - } else { - selectAll(); - } - - dialog.getListView().setAdapter(initCustomAdapter(dialog)); - updateState(false); - } - }); - } - }); - dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - checkedItems = defaultCheckedItems; - updateState(false); - } - }); - dialog.show(); - return true; - } - - private boolean ifAnyChecked() { - boolean ifAnyCheckedMask = false; - for (boolean checkedItem : checkedItems) { - ifAnyCheckedMask = ifAnyCheckedMask || checkedItem; - } - return ifAnyCheckedMask; - } - - private BaseAdapter initCustomAdapter(final AlertDialog dialog) { - return new ArrayAdapter( - getContext(), R.layout.select_dialog_multichoice, android.R.id.text1, stringItems) { - @Override - public View getView(int position, View convertView, ViewGroup parent) { - View view = super.getView(position, convertView, parent); - if (checkedItems != null) { - boolean isItemChecked = checkedItems[position]; - if (isItemChecked) { - dialog.getListView().setItemChecked(position, true); - } - } - return view; - } - }; - } - - /** - * Gets a list of items displayed in the spinner. - * - * @return list of items - */ - public List getItems() { - return items; - } - - /** - * Sets a list of items to be displayed in the spinner. - * - * @param items list of items - */ - public void setItemsList(List items) { - setItemsList(items, null); - } - - /** - * Sets a list of items to be displayed in the spinner. - * - * @param items list of items - * @param defaultText the text that displays on the spinner if there is nothing selected. - */ - public void setItemsList(List items, String defaultText) { - this.defaultText = (defaultText != null) ? defaultText : ""; - this.items = items; - - int size = items.size(); - - // init the strings list - stringItems = new CharSequence[size]; - checkedItems = new boolean[size]; - - for (int i = 0; i < size; i++) { - stringItems[i] = items.get(i).toString(); - checkedItems[i] = false; - } - - ArrayAdapter adapter = new ArrayAdapter(getContext(), - android.R.layout.simple_spinner_item, new String[]{defaultText}); - setAdapter(adapter); - } - - /** - * Returns the position of the specified item in the array. - * - * @param item The item to retrieve the position of - * @return The position of the specified item, or -1 if this list does not contain the element - */ - public int getItemPosition(T item) { - return items.indexOf(item); - } - - /** - * Returns positions of the currently selected items. - * - * @return List of Integers (starting at 0). - */ - public List getSelectedItemsPositions() { - List positions = new ArrayList(); - for (int i = 0; i < items.size(); i++) { - if (checkedItems[i]) { - positions.add(i); - } - } - return positions; - } - - /** - * Sets the currently selected items. - * - * @param positions List of indexes (starting at 0) of the data items to be selected. - */ - public void setSelection(List positions) { - unselectAll(); - for (int position : positions) { - if (position < checkedItems.length) { - checkedItems[position] = true; - } - } - updateState(); - } - - /** - * Returns the list of the currently selected items. - * - * @return The list that contains all of the currently selected items, or - * empty list if there is nothing selected. - */ - public List getSelectedItems() { - List selectedItems = new ArrayList(); - for (Integer position : getSelectedItemsPositions()) { - selectedItems.add(items.get(position)); - } - return selectedItems; - } - - public void setOnItemsSelectedListener(OnItemsSelectedListener listener) { - this.onItemsSelectedListener = listener; - } - - public interface OnItemsSelectedListener { - public void onItemsSelected(List selectedItems); - } - - @Override - public void setSelection(int position) { - throw new UnsupportedOperationException(); - } - - public void setSelection(int position, boolean animate) { - throw new UnsupportedOperationException(); - } - - //--------------------------------------------------------------------- - // Helper methods - //--------------------------------------------------------------------- - - private void updateState() { - updateState(true); - } - - private void updateState(boolean notifyListener) { - // refresh text on spinner - StringBuilder spinnerBuilder = new StringBuilder(); - for (int i = 0; i < stringItems.length; i++) { - if (checkedItems[i]) { - if (spinnerBuilder.length() > 0) { - spinnerBuilder.append(TEXT_SEPARATOR); - } - if (spinnerBuilder.length() > TEXT_MAX_LENGTH) { - spinnerBuilder.append(TEXT_ELLIPSIS); - break; - } - spinnerBuilder.append(stringItems[i]); - } - } - - String spinnerText = (spinnerBuilder.length() > 0) ? spinnerBuilder.toString() : defaultText; - - ArrayAdapter adapter = new ArrayAdapter(getContext(), - android.R.layout.simple_spinner_item, - new String[]{spinnerText}); - setAdapter(adapter); - - if (onItemsSelectedListener != null && notifyListener) { - onItemsSelectedListener.onItemsSelected(getSelectedItems()); - } - } - - private void selectAll() { - setSelection(true); - } - - private void unselectAll() { - setSelection(false); - } - - private void setSelection(boolean isSelected) { - for (int i = 0; i < checkedItems.length; i++) { - checkedItems[i] = isSelected; - } - } -} diff --git a/ui/src/main/res/color/cs_blue_white.xml b/ui/src/main/res/color/cs_blue_white.xml deleted file mode 100644 index 6f479151..00000000 --- a/ui/src/main/res/color/cs_blue_white.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/color/cs_dark_grey_white.xml b/ui/src/main/res/color/cs_dark_grey_white.xml deleted file mode 100644 index ae483a93..00000000 --- a/ui/src/main/res/color/cs_dark_grey_white.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/color/cs_grey_white.xml b/ui/src/main/res/color/cs_grey_white.xml deleted file mode 100644 index fde4163f..00000000 --- a/ui/src/main/res/color/cs_grey_white.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/color/cs_light_grey_white.xml b/ui/src/main/res/color/cs_light_grey_white.xml deleted file mode 100644 index 779785f7..00000000 --- a/ui/src/main/res/color/cs_light_grey_white.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/color/cs_orange_white.xml b/ui/src/main/res/color/cs_orange_white.xml deleted file mode 100644 index 6d06afeb..00000000 --- a/ui/src/main/res/color/cs_orange_white.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/drawable-hdpi/ic_action_add.png b/ui/src/main/res/drawable-hdpi/ic_action_add.png deleted file mode 100644 index 61ba66f0154089c4f2b68290ed4b9f2d3e1da6da..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 390 zcmV;10eSw3P)ufB&wzc=6({Q3s8N5WX}pnuZAFkkJq#6helEhMtU!jDa}Rtvz?{+)hGf z5LGaOO5p$h|EuCN3@FbCERijNv;Ca~%+e}^vONn6i#0HpNMch5)c*{arH>KH_Q0ay4thh5>;@X$3PxhH z?`T~{D5OS1Xf%YNAwYJvA5BAq(vYsMt`aLNYY4D3M(IieOYgsb{`^@@_pUS{2a_vL kb{ZnrLPGjR9YiRE0E8FxB@#0}{r~^~07*qoM6N<$f_Md_>i_@% diff --git a/ui/src/main/res/drawable-hdpi/ic_action_date_picker.png b/ui/src/main/res/drawable-hdpi/ic_action_date_picker.png deleted file mode 100644 index eb14c4d813ea1b32eb7614661045cb09490d8a9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 302 zcmV+}0nz@6P)Nklpz5pg5Jgz*;`*>S{g=h+2C8y{mYhlwvj6}907*qoM6N<$f+dB2 AHUIzs diff --git a/ui/src/main/res/drawable-hdpi/ic_action_time_picker.png b/ui/src/main/res/drawable-hdpi/ic_action_time_picker.png deleted file mode 100644 index 96c2b0ed8e7ce065fcc85fd20b0bfd26b68d29c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 461 zcmV;;0W$uHP)U;-wsow?enf7r3l#9wXD;dKp|g+}4(R^PCJW4Q_17vYe~oCquCOA=$Fz zsv?ego@-D8YC%_`S~o{kk^>CBfsP3vzE0ML1jrtA&H(XcZFO9jRuJS*C{tk$1z~=4 zNP+nz8r1<&=Gry-+%Ua^#sp7~Aj1lu+rZdKQH;H)+}xP${o2Gc;u)23S{34{X)VtL zVFdG83~E?r;3F0$_&$SP9sEm%r%uteTxySo3BHe@kHx_67itWi zxKK=quD)c1Z+%?~5aMc9_)>v1K_Ru|FB6)y>7VbD?s zE6~iQ1sbu0HJK%Bom9fQNnN2Lzb3Td9k&fKo3%mAMln=wQ09K2jp72T-=LN5Q)B;s z9vi%Fb`k`c*v~N@*uba~{S!J!r+no~iPR@OosuqYwDaY{ZAxNy00000NkvXXu0mjf DMDWVo diff --git a/ui/src/main/res/drawable-hdpi/ic_menu_add.png b/ui/src/main/res/drawable-hdpi/ic_menu_add.png deleted file mode 100644 index 9e4ef9510b59c5ebb14214867fda35223a005779..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3243 zcmV;c3{>-pP)lyXAsg zsZlUWj5BH~B&m?ZI66cyM#dE(2r8f=D2O}an(ymy%(dy)ulp?|fAp*BdcJ4B?sI?l zJIg({3DMk_C4mr^k2L`okQarxfLuWS1rb+4u7X?z`A5K2kbnH#800F*RgixK{vQ>T zo}M20@ZrNZLPA0Y;phb$V{ydbXi0nV-Gk@PpI73&?8S>0g-x0?If1W_O_(s@UQlV6 zT)fd@(2gBDBAz{amH-<@W8iU5o;-=FuCCVZ+_|IOzkgqQ^yrcH`0-;6=jdjJhK6d* znl;nH!^5@Kty^o+(b0F>v}yANzT1cM{*aWEbiXlR1s%}Vty`lokSTzY1Ss7qDk`+= z*RShf2%tra7FzS>&9$aYn`&WUVH(t;j~fcoo<4o5;Wt`cU7c22TdM<%ii*-Ybm&mg zsZ*yETyyh`88hw%6I9RuEnK)TtZUbRFl7rvz z-vq^Ae(l<|T3mbTo;`bZ1_Dw*0MV^r;2#O6xVTt@)L((Z?BofKxRzB6lB`AuMo4sF zBdjY|uGAtijQbofe3@$UBzGLFRgyu9>Q*#f4b*0XF$QRX z#CL)rAoU+&(8ZwDq&!|w;`o?vI@k2R10ut zPzHpknG6FD1&qE(jjwQf}6DLx#va)6~>G?7tJ_BNf3`0&q#y#%d zy{iKfI85o{QYsuX0|Do!Q>RX)8?-eJ;@GicZzG;0!F@fBO@$;b$J8&1g2JyIIdbH^ z3l}aNZB#&;Hf{O@hAhj=%VVL|01g4EF6GHM3~Y12;Q-0Q}35Z@9|ac5v*YdJR6 z?LczJLGzA4Bbj8U+w$_I=#=*DMC5N@lzfK$59! z8Z!c``N9PY7F;p|1h>gBuGy@vt3slRL`leID|_|om5gHciA}ro(|l480R0v<&pQl) zM)gPmXvYY;24;IC2JtUXfbjpif~?kSW=fK7fIzx&5NTJaT%;H*-v78PBZjgX7pwLf_SbP^z95#3QD!7 zglsmeckkYtow%7}1+87X_EQAC#q7(7dr>`3W|#x4AHY+zL*kHOsuwR_Twomdnl)<% zV=}UFgvmYZP5`eZ%Mxk2p&zvxfjTuaGc(@~WS?SCN=iyP>XNZE)P{O$p{$<`95^r> zDr>G9#hL|!zJnf7B{Iy(xpU_>$YMNy)v8r*4;eCKAQZ%FJy!!Z(tk{Od3h4t=D$rQ zU<1 zH_aYDe*7pj+-vL_~+SbpT#y^muB!Jrb9@390#1xaxB zaKmi4!Il&Vc7_bW0x#hVj6($ z8fkSN0U=8bwo-c^JRN9QYuU54f?ZL$E2CQ}1v$MV2aO`3*cma%B%DTcEAl4r+UT>x| zpiBEy28++nP?3*99hB)o9j`NvA?7tz^FPO~?7`{Nr{~&L zv|~VMb-an0`YQo>Gl;2|1K{Q%w~l2$OEnJtq)mPL^hr5z;6RblXxxkIv<$X$%~teO z3^ydZckix4@@5Yv>n*6cYVzdC!BY@>K~PQ^07YB1HPqF#^kt+Kp@KlCZw89Mtkl%h z25u;TZr!@oVCPlt%}gpqs~133n5b{`>({Rp0NIX-juphgVfXR?I(t?1W@tv+t}Y1$hD_n*+urkD2@6{-4Li#eE7}O7L!8RhsygC*pN7S^ynhE z^J%;Bhv)eO2w9*tmJfxPjV>Itr!+4Wtf)tgLDKF(+jasLtpCL3W1g9Uka;q=tt?yB z>b+#Q*0@1nybkVlDK<9to9KQ<4IMhPL0iQNm`{LsLG*7vMn7n|nf&F3q8N1_UCCg& zq7WB8M7!e@HUZ8X4TUQwAbVvnz?;=vq9Q3)Ez~?~;>3wxoQF1Ni@v- zD|`EP?}KaXn>~B>JWN0nB!bI!f2W@3mx6eql`B``-koyM)$3|j?RqjwefWU8BMijG z-%~YwzDTyTB~aTOXwiTH1AZ`U*svIYvRuvtB}l6m#ey*oCH(Kv^KETbEt?r23rN{@ zV67z2`RLNdGJ=6w-8Hf592o9V1LcjHHEUJ~mNL1ho*&tS+Tb+56(mWw>|oEW25Yl-=ggVI26Z7I>klvb^9q=P#E89n_r_zOTLGzyx0ob>S_(>m zCN4%5$&+a|wzG>+c1)f$X%feDJ`ivMt{{PQ@ZiDMAn#uS(zm!Au?p1clNrWxK;3e- z+OcJ}ijR+9+P{B){y9S~K3ndRI8ju<6(l!DENW3$SojGVW*?!e_%+5EZ=lTn-^*5Z zA*=Z*Q>GLnpz{GK!ZF|faY98oH)w$59(Y!;5BBkA;C&?8osLQYi!oh7`rk5c+_)S7 zio|*O027qHchCWGkZ_$a6qJ4OtY9LPH3WaF(H}0@*3%Nj1DKl#)`yX@zeq?(C`KCR zqj`Mbp%`$2@@EJ^i$NBy#6QmHg37ih6!kjXuRHeGVgRcH)?Cr3$io5c1qNITm#Ib# zbPZjDQdH6xQS?XA}7sL9K9b|6cyWg{okI z_W%bYJp*rbV?a^u{htByF=jUU&s;!Wkh_3fK>m59s~}fFu7dm{;3~*Jer^nM733<& dKLTEU{ci)C6TwFB4KFjTkYaRKbD; z8zS2sdGh3`&9&OaixP?%dMu-Mb&pRWvdg{EGRYapT67 zM%lmWMES-j9Czf%k-*PC{~S1d`g9;IEiI6qo*uYx;esb-zI^!t1qu`h6e&_9P^?(7 zK#3A1QcIUEy|{4U!qa(wM(56*k6j6{avh-2qeqv`n>TMyfawY-<$wI~$3Sv&a^U32 zlYv5o3V8save{ud zn3iitt^qW4>ePHEPMmle$zMakO1pRO4jedezym}|#>K^jz>s#ZB2y&+HgsR0rKF^I z;0mzv<;x$bQl-jk)vH$@)uv6GU#XYFN3H+_YpNpWSd?qNckkYSz$sq5c%W3NQXW%W zKn$460c1egRm?hm{CMEhsZ)WguDa@bKx+HkbIpt8Lh@ zAs~gAX%83!L1v`icGd5!0MZyb#UQ&12>ljNGTHOz&mY0;o_gnlT!gH`L7y?D7{7q&c8Bhj_9~}850p)_FXXNPl?peOqYwXyuBXSC) z90N$;Am{}AOwnDtb_FU{tmrvmDJ(GTG;j&|XRH;%ZA_43DINR|YkDLj)G<>N7# z$|ziu({oyW6B8&r{Zsm7F9CA_Dw2VCh zNT>Xf{;%Kr_U+@9BabXtuwYp=lfLzY=tJ|j?EfPyA<9$`Of)Tq&< zTW-0f1izK+C2=ML+L_E00m#DKFAp>8a(00o&4^z4^{n|K7a(Jkz}mTU=f;&QSKbR) z5oh300W^I0@GdAYX6@Rwfs!RldI_HkjGO!cP$EwIg|=sHvvj&IJ3*Q;?}HL z^W>pJhh7G#Y9yW^)3c<~n53%`%+;$`k6OHVad%m1IN!2oBL+wrGPAUv*{OuRd&!@H zL!IUKH*@a0@4h~@YuB#Kht~m2awNjqJKufx-HjxR<1xK@N*v8UnLiS6Vvsu35M}GEnBwifxi(rE4g0iO7`kEl~O~xb_r1k69e-27q1%^yZtkLNMC-IIu z?s%|%{rUpud%*F^0af#W+me}IL-xBVE1^I9@WY#VuMX^-?XTv^cPe1E-~aT}Pu0yq zi%l*_0tx_+B_t$t+`oVStSbT#?CFF+uPo2b0Gx)KH*fZQ2afa<;63x{r=L!C6&E<%PdIw?Xqg{=_`yp$c{Y)EnogcP z`GEWEM<0DOfp7m!trLHAlZ-l#9Xs|dM<1f?if~vIHb62D6x_dk`}R0RF2897!Aar% z&E2|nD}j>h&8&ED4#L(~86u}H)6`58k18{;&_ zWIWJyz`$zsiV}Igh!wMLyCeuwDm|$unAot)ENp;aPfI>Hi|FNrcFn9na*{yFJgH~T zo_&`sTXwu*!-fj!Qn~|*jo-L&V<;uCI!itSkWK?`*9Hw5$b=GLUKvX~t!|U)21EA< zD)`=jlx852a!iKJZB^ata3h-lQW>&h#fle^byzrN7B)bG2M->AFX*oiiU9)1XIhf4 z4eZ&#|F@X}a<=%Ar9JA_t(ydM zzP53Yt2L~gs$P*DZXzjp@l(SYckH}*^E_5(=Lj1h6itBUk7-t2-{Z6_(#cJ#G;Z9u z*xh&Ez0(!q-FM$@1?&DrMjWsEddHu`sHvvIN*0%yFzpzTsQ06fK6+uxmM!1(>(_6; z!=Q@%-UnL>_&WmTumNw*^5x6l0^p_D0mqXuyARrPg9Z&+!A#UM_9(1dWgdKH6AIh| zozv;^skX{+5Sj(<$Cy+x{lg8*mgwoe)o+$IaO-FMM`y;?J1d(tYxbMw7%bY%*tG?S zpG8Uon7DOw=g#d(HohdgdWQ`VInXWus-c#tg>|dWg9?Aqs#U9J=v-XA?ZpaYDY;0uv0-0LKoLm-J0gM0Ihu>-g z`?4L$A_3?SexyRtqD3<}XA=@dCKA>Mv~S;jM^>{$sD7CLPZX1^EU-e;01B2aC%Cqu zIj_8G3)%Bemm2r|_urq$WVI8}Zhy%l8o(tpIn9Z{x#xor;t)w&1zU-5%`0dwlZYg5 zy#D&@iCF=}I8B)CnFt;4Z+^K9f=MS~QLE>le|{AJow&@H69KuM+o{y^=B)8g$&@Jf z5=pn_nu(#^TLG-+bmkNNGqbh zIm8^mm`TG${Q!>zdWD}ARAYvM|e(w0Uahxm@w^9$|2h(BGpYYe?PM&8}F|s zg0?4N%#z*i_+k5?fddC7An;@QpaEn91_4UPzck7$rDw%KwN(NpTIS%vgC01_iTo@y zfDAN^E5{2nPr`yOB-~T|Adx~;1kio>#{x=V-9<<#es+F*`}jR#9Jq7;2b9<L>cg5zN&zhN8$i6j9tOU0-F4Tc;d2&hY_8P+ zax?eiXnkbJ&m4eK$bYV4HXtNfZ4E8PUv0qD!S?z*c7Kpt$;q)Da=1euv#*iJeKP$v?$aq7QhmXJvy zz&o%03yrEl?uYS3mGJ|MQ097+J^_0K>odH)25XG zVP1_IH9RE&=U$#!NY5z0*8Z(OX@L2LYo08+~p0k#1`S%qac z%m>4%*Q6qM*^8OAqAtr|^R!ILQ7-gGp-s2lc3UzgyY^Cz{Atss-9y*%A=b{mR(Zqk zZ>&4{=9_PpV}kyJ)4q}DUhtV}V$Bo$%&X-vce zYQU*ABIm5rpC~eE|LoMM(^Q_@5srC9%%GrSEQ^_K#>~oFNY1QDrDYkIw1%kj0R7{r zmU|34F$bU~Fc}Zvi?sX9+i!G<=G_5SUFx@J(V`UB4Vkedt9ucdm<@=t?oO+7xajRT z!_a!U7^H|LU&Wb3h<%z&I->O{2b_DEh>?tYqZSPWjM}$ijfHog|9Pf&@7}9dty-0c zlMZztvkO#I0BPx&rusKTkVaaY(qSyJ6;6vlYJ~#Q1x(>HmZ<4<_1l|WA@v-^Z#7u+ zGCw=f(af(+Sz?a1*C;8pB`3H1L6-S+0Xp)(IG)XR{pHFP6+jy3?YG~qiutICR#9xx zVac7l^djFRMu~0st~B16#q3W*_$7q@Py^l-PUQmtH^LD=jIxg~5pkpl9wW8fB*xfg zPycEzwG4CU<3*o?S(7n19C9X5ecITO;0GRS&y&I%-JtNJ6Kt%BNp1Hk%4mP+WpwPUR(Wz6A! zshl1-h_jz}LQVbbfRWiVISP0?5 zZ^znRGVE@w-)nQkj+_9;Gxtc5&FZ~5bLQMmmOYjPv93(WZ*m5ZZOAmgW#G8L*m9D~ z9CyEC(B$T`;Mli$^X6rEH|p&*u5P&kkUqfLdok9yUZri(fx4@l%O=-9*>3|WgK)v^ z!PYf!OvyTi2kP4fgxt5b&OIs8KgjT_d*h)~AP^BPSMk_NSvTp@CEDj2T z+DvOpr4A_|S`08F7-S6)masz>gg^pevCn(wKg^w!B=`RJ4{fLaow;-W<=lI|^WOJ+ zzwdnKL|EaYOavmr_>_%67@%?(5(X#?kUtR#GbqfUFoXOd5N41+{K6U(W>AE*L2RW zhYufq!yg~K-+fORw0!yUL`+O#u+MRA|J`@rS$TPR)}>3AtfHbK>-zQU*6rK3E&jJE zRjOoFsZzy?iHWgdV`HtjxVY^2`1n8a+wx(f6SR8$bQV8*gNL7`N-D6#~%GrAu4jBB{8?gM0Suv2NVB zA=j{7$bf3^=+vnPk{vz|mEJ=yzS6pk29gML-qs0-jsFdi7^6 z$L^|GNC8rmf-Rd03JQK8aCob>&KOVxi1UO!d3;YtM-JDnT{|CbDn_g;0dRFhIe~%S zk1KWJs^{9klspBLPU+LhlPB|FZNIf^*KTz+dKZmC22g5hYNg!V+)to;zg@d_+2GuF z-+eYX0!8j+q7=aFCweXG*|TS6!-frG_?}B7%f;R+(&B*KRk_9hP(3v4sS_to^ge(7 zd^?zV2P8!~Ctw2c*s)^=ckI~l=<(yn&$$?XxlKX_(2^xfl6jMhGBPr3w^H~vY*9WF z0O&d{GOd6A{u>)LY7_^6nOJxNfNqv$DfdK@D>d7@ckh@pXU-&XMhh4L?Ifgu9xrDFgNW;Mu+lJ-b1|Y zNG2vZ0J0NFxjQarsm;E9`{wrU-TU*|vuFR^&GYTF!)?RT+G#q0HcV;SwCPU}(vE0Q zw8OQ&>esK|vrGwMV9^o3eU-dleK%{?>5+ zX&YA)NG26PtG_u>5(Hx9%<2{#Yx0+Ppej~PPrYln|AZ& z&8v^@y+B_takf=xm-gu}uIAJu{YIuezjf=@f1NO4!k2FPFl|B(kh61)uL*N5c`>NG zwgiRIw3!Adv8oIZ^6d#Qd6hk{Gb}P;UqA^UBJ98(J$jsE=D)qXKAivi0%*>hIjsrX zv9G=M+D`e}>qRA#^nahVsGg2XB?C^1!PVJZSnkOG-@&Xz4(emr2nfLo(RjXLV3 ze_sGW^~o6e7J9RasYS}`ufMM8LWLhn7(e>xqsIUx1s3%{TdD{kGv_m<5i?JNMSp4E zzWrnZ#$iD8lwJD;=pUy~pZ*z>MAc<-q4{*)*ka!DwF*ax4#<|P;bJc$)UOa29#m#+ zsshgX5ijvKPdxF&7hSt{-Rsq^paGgYcWykLoj`O6p{fc>Fn9Fjioz|pm7_9weQlUOJtuueeNAV=+CnllFIzcF0AX2zpDt(^)|Ur z8q!W)0 z>UI2{0W@pYtno}EW-7gx{+Jv@%rU9Gu7OhMUclUlcppQ|o4~p)qzA5N({2VeZQ8Ut zDJdzQ^~KGzgJsZXXiP5wW6B#Qi!~)s0YnLQUWX1HzHHN`O&m#GX5G4VcR&2_!$ock zbK3?s|4=Ug-Aluk)o9{+(u`ua_m|hsGeFa)Pp?U?agyj2EB7)0DgSULXn|GHz0_-- zT(xS|>GBK-=6@xOGiT2H6!4$YB7sU9B&^5Cu2)b!_+aeVvA+BD3=nUuAA?^@f@o1C zR4L&GOsY~cK{NV8c%9R>ZQBW~{%23)BP{>bCOG{hr$I!cg(~9SBCOK@V zBvsW+vk<97k)Uvs`PU3qPQG9{YGbf{2g9HtxJ~qsAw#Z{2%d$~2dV6(P$YX z`%UU3CCCTVK}4{i4RsE1>eQ)?VeNW~bL}XjiY@=Pbj^PouxU0qSk~mplY`2E)Td{F zbQ6WDZjV3y_yOuXm-QW1H36s$a-MjJv<@?)HcK(AZRMj2$?w1a{>Q<-P2GpfbmFoG zF>XtJ*#<|sSP2&|Vr}llkt0VIk|g?CX$=aXyA6=cdL){(MB7?)81|SgEXugity>8D z(v~e-PMSDzqNn1$s)yuLuV`Hj_o=~(g}pebd7zoen@9?i=XUPgc_SJAw@FD!XZ*a7 zkO8EKf~)XkDv`~&cI4}$3_4MBJ4H?bA?BE6Y_p0INLI5E>jBR{ z|9l+J{?cph=WgQ)8H3EjRb`~yu>oOjqFS+8A~vfGW@m=}(-cHNnr(L4X{G_|kZX!@ z3fr2~NoSN+h&6I0v(|5Rrtv)ock53{wJI*Q6A(SQaA_|+bNh-uYq?s0nFT;SL!v9Nl!zLgF?)&3W(c!DN!u)v!(US|hyu)AHEPrdS>>QY z0MY2KE6=>IqXKoSO{{5Y9b5WodmkPH13v5k`+88<7rTPy(Vovhe^WA+&VP7%PQcI(#dW9rP2+8Dt- z`$Hkf_e7*i14#>tgy?Q$zQ3Y=+>M!j8w5Dg4TAzn;9+#_Q_82C0H-qAbUpw~NW}P_ zigZ~T08rXF);u#avpa6rk%D^zrXh)dl>oD<0ho5$7s8BOMEEp`WfmFxVG_Swi8a7v zbN>+-quuxwepILim1jLbNIU8x+VKFR&jQGf^RPy{&WgAe0F;DR1+j}2vBqC!fGBSe z|L_0*M;Y|L0Dc&ta^6xHpfEuG968LOFoVJj@`pf}LH_UyYfzX$VFvj_Aj}|t_=Pp7 b9Q^(T7XRL|?^&iC00000NkvXXu0mjfs;)wt diff --git a/ui/src/main/res/drawable-hdpi/ic_menu_server_profile.png b/ui/src/main/res/drawable-hdpi/ic_menu_server_profile.png deleted file mode 100644 index 5db9daeb0dc8ddae5c2d84b6eeade115e00519be..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1321 zcmV+^1=jkBP)dxL@OdI zp7pM?vzaT6ytcf%vuDpe_p!5qQmMqWRkompKm()!(g10IG(Z|44Uh&%n+8Y&N5WtW$i z(bLn@IogiXPYI{b5pbfKUs_uF*4*429~~WKp-_kg0)e{G2OwQtU9pps6ZY`%@NQ*g zW!-ZOip65_&dyHO+S*(m<;D|}r)5yJ9TU#4@ zdV2DvNLzscdoW=PH<<+2dU<)_gKGtyOU%P_0AX?hjK;=Bh;*){r6mX2yJdHGcdS?} znl%2HgXaJObA(&rjy^sOuw(V$H`em+`H;w~@J1Y~q_xAQ|0|bVGu}Zj@ zHIoKN)tXFF`BsA<(hzH z-{1dsW#uwyS;Ip{65=dsx4#`5ZdGO#+|MW$i-u^<`IbSrK#ERD8O;KtXk^I6(!O^w zbRW@$L>QMTGa$~$gU~tfH9!{^7kGS=kp+l^drGubd<{@67DMPxUteEK^_-&7C})rF zU5v^SHZn3&QKTzr5Coc{nIRrG`xYP+wB%k%85b)*a{fO=dVhbPFJF=AUyJAeLqkKn zX!SKf=qZz{Y|4r>>5!pJv096bkB~>fN?~&LFfidU|@6@hOvB67!}g z!8EOpxs~Wi%NpDSf-B=<_%H2;eN5liVn;_uypJs_(r~fC!9m`b^SwwD8#ZN@&y^c# zyioPMNKZ^mz{N}%!3Enez$CZVL;iCHq31(cbkc@M&r&u$=lgaC+Nw0N&>@*jniynS z#o4zmc5rYYy;KIS1(!sj+ttFg#`9fBog_EZ8X$nv;g@GS{<^bhG3Cc#6Z6lXnWmh zfC5el+s4L5hCssWP|0nz|zfV63V fG(axcPXPu1Ym)6)Zs=pc00000NkvXXu0mjfP2XtA diff --git a/ui/src/main/res/drawable-hdpi/ic_type_dashboard.png b/ui/src/main/res/drawable-hdpi/ic_type_dashboard.png deleted file mode 100644 index 1bcf84537c05774dd9addb190e5b0e02e4b4ec77..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1636 zcmV-q2AlbbP)2OwFhDC(stf=X0CDz02oaRyqBT(ac`YN{1iNNYh5 zNmD25*0I<7HM}>wYwwrWAx23md92ZXy_tDmzxUpZIZ7#cnj24^@-`A+B)~|3kpTPK zME~aGYabMOQCbpn<0W3o5su>yB*T!mRHxIfto(3Y3kksS!ujmvbZPAPiv+HO6U2il zfNhnG#>RQLy%82b%oel786wZj5(xwVi4LaEP>1kxp%`-^9yBgwWx|VD6bEhP4^XLX zYn0mi!ETY`gc2tR0fllNj}Zac|HHBjK$`gSS&fA*FnJ|6HU-xrSWySMHN|Mw0fhE~ zAmvMpA&7LR-uTEfwSDvc?JpNYb2rx6c;rD0@I;dYaJhGIChyt<%>Yy-3m_FperAry zQ^$$bdd%jxnw#(;TLP_?r9;O6cbT4|jMklmnCW>%geT%8VSom0F_6K5-vM}nTp(h8 zg3<69iD?{qg%?G5&N49G{p`#R=I_r_%mUPLdy>ClJ5hNL%rBuEF#pbs9j@A)mI`18 z(y-vU0U+TOGvia`Jb(+e z3+_>DJ**K!TL=GkB1)o3b1uO{+5N_m=ij>QF=bs{`TqKRqIFYv3V@h;hVt)v@59v- z&ls1dpM#8jlo*YN!~owm9&dmnlgKz4__mNz^{2B3lV0OxkzX}FPiY8tjdR~72g z1jDLSJjUX^)oBvL+K8Cn1EOPBu{<$b8Y|g<`}#sk1_-Z}?n2#gHy{%SX=n(X;b#)b zq8^Qd7})%~Xku0d44gW9(GR1w2S47ZrLL90Qz#P;0!%2ZB>=exXt&4Sqd**BAS0Ir zd5o|!+4l;|Ou#^RtpOGwiPdNnJYde6V;Wa&y-6(aeYnE2uCQ9C{e%U26$+(aX?dcYaza7gODg}aNCMBr_X&{ z#)OFXEN5n<5=hzQYgg4MXlX&3JmS?hc6axNB15=jS1~v47HaSv>wN)$jM~LohtW`% z26ue^j*8j_bTgz?pT=hpm4RzBOYNi@O-f`KRivpCBr`F+Kj%KE4Cp(=Ks;w)vJqv_ zF!p`j%qQOmEue+!mV?|JM~eyI*w!NKir%+Py(BmV*QXEW$(9N{cDJ6~ZvLSuRlhAm zEMF2amIp%NP<&Zt<=0PMS9X20_+MIMWm&_rA%E;NZr=YF0U%dsdv>@BDPQeq>k4iU z-6D+)*Bz?dyZ*Mir>E19fvaY-uGwbWi_5#_9_Og;`SJRnKYgR>k5((j)|%!Rok&r) z)9&Ed%JQ|d>YfXL?f&hr)a`#(=GyhuMXS9H(ar9bB7-{6;+VO+*UqTJ@G$flx?cZF zb1eOW)oN6;6VvBKx$r91Fc6()u@oTPb4*%;QbdJla|ddjMN8k-*g?RMjT`;ZJrZCf iz(|0R0K>F@1sDL6K%l$1l7p@Q0000 z@5}oJ8mOJl^aJ!Y_K_C`(oF7o_uO;tebs~z(9J6XUA}q%dI0`+0J`5lb7!yJkH%9s z^>_-jXtdRL+MJSGw6Z?OoDBfZ13&y}VYVXx+MhCd==9Zsks4g;%N~Wq!5l;kv!xdb z3>X8qE8ofk8(-c6tE`6rnA_V7Xpv~f=pTf{$T%d156iz>dm|nQr*1}o0B7|p&=3H7 zUjrC$#E3&QmTWzE?*uf6=rPdEKG1aIAJhPzpoT$IpW8keJ@(v44FGpH13!1BN zn}T-^0OK(1fdW2;13(qAnEUG_S^wdIQDvbplmlgS?9}A~O6D|bKdR6W#L~lFF{`o! zB|tV-!Cm|Q;N8=i`8oi(bCVyCule{;7WsPs4NUhGMI8i4Y0iMT6>xs8jK6t2Rj#3s z9`Da5Mq6W&i;Qu5Jx*LOwPeXfXJaV6H@|tO5za8h4}8rX`IyrRdCtqA3WV5b}Q!rL-vP zK(sSX{*|_x1OQ-ks}4AN0jTN5f(K9tCA5T6IxXE;C~9URkU}y8u7gyfpsE$Tnz>|J*AJ=OPBfCyl^0LYjU6m>Rx{WuvpKiJhkEMDEEGT%i(*rmyl@ByfISf>j#m%f zT&&Wv8l5>8f`aqD*bT5nxGJ8Yt;;ZVv`wCXgU05j?psKftpI>Lm}O#-!AV~ zB9&(W-x}~HGqP##%*IMJa&rx@7I&}Q`Rn;q_SltJX0*NU2=?b@uC#RTQmH8b-L!gN iv-SY=0Cf5KEx-V)U@fSiCJUJW0000Cb`^@271!VB{%1O=lst1@ArMhgb>urgF`(&g#CVe z@Y!=QPE-))1@BiTB)z$|lz=sk-~8@sx+4I1MUDD~jw3-0dcS|$)Zvy8`~xc!b8oEv z`Sk~h4gd%s|Ivq$GI-2$0Jf25cd7pfJ*btbbC=QetFIL$j6qUuiz8q?BfEX%i;-iQs8mKPj@l{Tsr1m>uAzSJnLh3O9@p5wzTnqM7 z6z=uq@G<8)6od@sq>h~g5X%wQ0E&k~I_d*u5cQhIJP(=}E^1<7ZxBLr4b(5@St=_f zG&^OR2IPfYeRwKv(AS52!{hUlFI`Oi`uXdr_5hR}t|R*|3f)+JYq7N#PPx%Q*+y;e z0br~>@y;5_{{08b$~2+Dv;7iZd}Hj@=OrJq%|g@pRxaa01Ej`` zJVyXrOZKy?m0@P@whw@?52_1$T^f7rp{Wz^j@#YZKXK{Aq@sszLvX19M0(hS%1NwO zO^8&Yklm|JZ0WX{uT)Rn9FXi97XJ9KFLVf?gN?1xr(V!F$+r%CC4S@EYLwO3XeTA zAA8d>QtL3A!Tq3iRu6{GFxc?pi99KB*^Lv;`kttN}bpiI9?%T z?rc-ePunI`o>q||NV9V2DDvMwfjCKK&qOuEnrKw6CmNvimXa;8Z*UhdT4>Pc*FRgN zeH_-ydF-_>)#lz=B4&vO6VfQsrNM9h5BCPd?S zQJZ+~O`VhdGrXk4iD_u0t^#Z)akf-af{jK5H55^X9)O&%gQ&g3ch&}}9mc(XkyV#7 zC}3h4@H`JTosWVe%+gLDEn+~Ex|PpF2~k|r_oify%AyO2s+y#QHnB|FHJBBYKCM{C zHejy}$RL5D1vagNGizcX2;U8KZFxbTK7R!^fote{dj(WWWDXoM`P2Jzl_)fIb}5E2 zr!{Wkk%o;u>eN;to8*WR6@2|HLa|BAPRRrzOh@F<2;w0+)vWCT0I^d*`ENS@xK5A0DVe2AJhpz QDgXcg07*qoM6N<$g5{8wsQ>@~ diff --git a/ui/src/main/res/drawable-hdpi/ic_type_image.png b/ui/src/main/res/drawable-hdpi/ic_type_image.png deleted file mode 100644 index 23a4397d73e35b336e3f08e88949f059dfeab38d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1534 zcmV}--v zvbo1LX{tU9^$#$iBJ`;dQ52MJgd&Jwq7Q;ECW=T4CFw&SWfeh05DPx~uxsBG+XP=* z=wek2ZO!J=&0c2a_0V|gmyMeg_LPtAY|c6J`>yBrou!O1@+1$AJmI6IKudv^ z0xboOb_kUZLoZ%j+RvRe6B&0ukFfNw8;>1foNPa>vvImT6;k2_b4*os)uuQb-Ml zVlbA5MJV{tY`hw!yl#gxEu|}BLyWFD;Oa87_|=VfpPu*n`8+;&^ZbtdnNU+NYwSE7OOsOO@2Yg&m!iivX zm;^feb)X1$$6ot*>h`w_D|^LMSB0>KyU8b)4PFUjczdovD^Wot zQlv-6aFQc2+`}<_Tu=c#?4u5p_JcWE+t9PgQ*V4Wxfe`6bh^IGae|nTwH`eLFH?Ha z@?nVeJ(Nk9!b<@X>>AM3zOh9JD>#rOyX@jVAqYcRi{f{LhcE+AXraN=$%zY>;-we! z9+-SXs4P3~VuTli8s9NMZf$f{jgs^<6(it9Ik)E-LKo z#qkm-6oc>h#OawU1ZYH>I`68%RHuNQ7(3<7s?f`_*&mijv=l2*!u@wnpg7P1T?EkR z6#v4x%a^~7i9M;kxyAh-i|*{j&syvnW`vGn*kO!fZZqAq%iX&_UQHL)R#R3kTOw9_>D~RrVyWfJuQpEs z97b+)rm*!eV-~XIn~MXZ$3146e!YJ0r!UgE2Y*iG*Zx_t^4p~@$&GgSiDlv1shgj_ zls+g9+UU=$qvzk(pe>w*R`WeR5YkH5^1GeZEW=Fms+rqbTE6mn=Fom0IMD6czkfro zyFG7YGxJh=6q@w5=Xo)pLv_-D+iPX&kpV-kFwxb@^ k0xbnv3bYhxWc(+<0D0Ey4p8ByN)s zw@uoRQYZwdZ-@)HLU5!AAt73-I1)6X2#7)I4K9>H|+;0MHYTgn;bp1SX2%!I2MOVfy7^TLCaZKrg5usqF|xafXDl z3q-XI)b9P^;OiGan|OZMJ`!{Dr}WwO)7mH|fb8{yXV0N==0${nI0K)F`w)a$k@S-Q`1tHWhzX*am7(>NPvfhEble`_^4WK7RKZ$LS z1D5d>pY1$L_Ve;a;Ypkz5N0^l0MT*|Scb2D2W3E$6M=)_Bd^WIno6Su<10bfe{gOj zxt>oLxeVypbd_4902b5!`(K(4&wn%$Zwvsh;DAG#?`r%E85OU+^0DSTP>xx{cHkqyf6RhO1YXmUd_M70?2V&Md4R93Ja#EbPdoT}?*k*3uDRC8=Nk6_w_=|= z!vR5ZfvcmtuC>IGCPE0xIl9%2&l>NSYTs1$LTl~k8z6Cs2Q7urj0cKUk}^=sL&#{} z1KT!)c!h4^4%C57AhDqtdajVCTkHWNpV6vzjXQIp9RLmvwyGU_A2~iIx;4qWpT3bHTmer|mD=g-c@ z3Eb-EnD*mToNctDSwI1_n}=%3Pgx7iL~b9eVc7 zi)zoo(Fab?1j%?{rpgT78-5qkf84}WnWcK8Eq*;=V)E6W=aMJZE-Y-ff!4Y@_!$_myF>(d;l_ky55aQ(?A#x>p zGO=d!QLR8Sb_|e1KTHiL?m78(2)K-Evzj(>d=oiPY%h&$dL0E~m}?$&=n`**)j>2k^II8jG1}^2ZNH%vwQ> zyrlRxED{?JAw!SrnST>(*|lb@Vys6nmi^{v-qQhsn+VIa`HxSRvP*ttspfO)O6xmf zZYyh{z{5`mvGV$9*b1!0mU2k_a`|(uAplrWqe#3EN`Tu1S4&!AolW`l6aGwneEQKbI;fB{La}jAq3pbLxH<|XpO$u z^z^~3q8n*NO#raYzgXDz1h)$5OJARzYiA$U$c57Tj^xa>Bbh|c05DbWxB#W41y;EJ z=LEM)W50iOdc5NnP!mZo2S*__yag1^=(qs+`73}H0LIkp_7^^aUp_fJ-cbQSQ9wZ< zv{Vl$y4i67)a3zOrAyVwVIQBn5m$rdePGNWp^Gu zH+fg05K}bJyZa%vVQXX|{xdMj6g8F*8Z`Hzs=0-2oxE^l+eH0SPoDawHBITJ(7Srw zc&fUQ`wqqw(7XD|?)2(8nEhb?cx(ZL69dATwpHBy`0?`-`D>TKE-XjZu)by;bdB5( z2?x0C@aA&3v*wpfV zu7;e?-2J-@Y*r3zDZ~^CksXikLe5k)9gMy~^wYkYmqqdMvik^+g7}=UOEbKb2VP3} zp;kA*Tz5};$DuRXpFe(aDw+Tu_mSomFo&w2L)7yeB9a6dRBhE&=*q3q)WtI|O@%Ms z8^eV}MN4I2xK*6~_UJBO5bt{Zi`EjC*)5FT^>nRhS7_)a5A1&j@6j@f+JrY*GZ!b1 z?TP3@b(?VexyRo4a(DjPC9sPtkqwZ*Af^LX1fcshqYvX=`S5pJ#dd%%g4RrUdt~5ogV-C)(Ff*>J@(4tjFb2>SZC*`gp|k>RmaqN> z`RiBYXLIccq&98^rAx0QDE8f(PX(@h;`n({uE&iwV6;saq6}JGoQM4UALZi zb+bt976fHu#?r)*h-MH~2whu~9I5wYf`QyBu)e^`Oi|TP4L0XOc*x3h-6DVV`?vPa z(ETGXPflRQJfWrfoQzq|V0n2T5WYPfntYO)TOuH@pi)kNFl6;7cx)6BJ`H&5;l<0p zLTYHU?Bao@wTK?>es*zb;)hfF0^h#l@YxgQx)IPQamGU-2t*;&n%m#JH4k?05NgN@ zMha1vh=f}pm3h7;9y)j$N{jv=rWOl+A3u?SV|Y==eQJ1+;~t^`KN9sX7q!n)>(U$; zg#;?W--a>d_acOQMYe!X8+BUs_h!Jq-dogQrM4`+(Itjk6eDUyWWdJp8YV9 z!OGv4z*@fPKN#kRb#P{I_KaA95wp?SJZ}k31 zTnNHr04lvxTT%y_)I}idW{Ly!yJXM=~wjzx1 zto3NnOVP^`sIp0*hEVDDxKLOlPK4Yy;X;^&*^h5O6S(cpW1kBRg$w(6OKXjXyC+jr zJ@?>&cV%&(=v$AOvYY;vQH-SQyeT@Bo&&(}O3zYDo%atrg*p*87gcyMpWF8Qd&ouu zg4lUBtagapW>yXK+o3cD>aZkSvdlzMMx2FOgao4ulMrc-%Fybw4xOg;RlcKY8Oiwr z*r1U%~oG1dot!+|hK!qdCrCo&P72Rc6R zkgREcS#&xN+>x?APCdYJNRCwCdT1#&mRTMt+o{8hwZd@mQ zq;XiF0;QNWi(29#Ap}Z(K>`sVRYb)rkXTd|5&|SJ60oR5P$IEmftnwHL?jlhkPM=T zf}$pE(l$-V+mEql=5p?gQ+Z4tcRY7exY0% zH7-kfcTQ9^5CkD|!Ej?sPQ$!1_uYpx2R$boW`Tj{#)p-z#5E%`2zvT7$VLwck{rDP zwgpyo3u>#2BiFyWG}EyKB+V!qeOZW~IR|R84?GKqM_>U5&;lTLB`@PNgaUeZR!?x;FUm$iJBJm^v1_enS6BQL@m-wVn*L9liedIlv-pDxxA!pj2W z!EQ*ZHbxOy)C@#Rn|};T5~%TBx(+7`w8emcV5aq+1~t(KQKcb4R`61RkZ4>8B#OvQ zRF0TW@UTFO5+2DaV2~kGtVJa@GG4tXXAKAw=Cqimq-7^;uCLtu~A#Sg^Sfe?KvJw;Gvh__RWz-BwY%D1d_CER_7M* z;ee5&)tM4cMTP^k>ce$-A+b+>m!E5i41!HMLIy2*Oq2m;#6Usp`XmC4D7%V;x$rk; zh}B5hwembtbc!#ZAvMAI&W0BQ{^SuVjrwAMSFqakq`A4Avnrd2>KW=bS#$kv-Zslv zMxMl2=w;ep#u$JIXamWktK@;Y3a$187)Jjerr;%rg5Pg>A~CmG7X??4v{5$ex)cgd zEkWJKZ5|NdrGV413lYbeB9^(}xIVqVFm}D#8o;BtR@Pfj;Gcy8`FXuMZLZ&&ZS1Vk zT6)iCexEG(=1*R{dO=H_$SPQoap6K?G(ZKQwzdS-l?5OOdQ4Q}-kj?~lm`jGp{Q@K zi36h253VqJ92|LX1%_VnTR@2=-JSO`DA#%*cnr|aT36o?=&63@4WPoyMmGkzz_eyy zHX5w9f&wCHNstr}n2jbC5!7{_Q1}!7>L=|tBn)^-Gd!2$69b)RAyL*!YO;Sr#>~PBgrcP6upUU#?I%(6g@QE| z?1Iy%&RW&&eSz%y)wg`}^AnSpdeuB3YzHa9OUeL)wg_u0w=f2lz_HkXth{&wVy7Mj zNik>>ic<`9m`3qCMO6O4=INOiUT+7oT#z+o7UzKu( zs1ij<888b?VOCk7$5X5ufR);)DC=2)<{^f!1TN}>wMfkA#?}h5(e-_U_{KNy`R0$0 ze|iBkSC*z&qkctyTK+#nByhdoO#8{QSXi hxR*Wt>*F5*1^^KVo3H%0)7bz3002ovPDHLkV1l{Z$YTHi diff --git a/ui/src/main/res/drawable-hdpi/ic_type_text.png b/ui/src/main/res/drawable-hdpi/ic_type_text.png deleted file mode 100644 index 06cd82cdf3a30ec684167a5eafa98556e6ed5cc1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1122 zcmV-o1fBbdP);$;8my;#G9$&!HWbBMK5jq0JT=S z{YtuDGtO+9reC|6Z8vrb9he=+zTLdvyx;qnydX*`9Oi-HkPmhH2c4IP25>^}!iolf zB+`^ZVRmwKtR?_OJ9fi3d8$uKwE$8Q^62k5IkpG^0HgIZB-^_ItGYA*h--;a2rvfB zK&Z(S;DoVl8%UnG&P(E~vDG#yA=Sqe^`W9CGmL(WdLgdG-{DwU&ng1(+>MVBLVZZp zdXqiCBpBOqF;HMvK;v8kJ927~Ue z{P^szdb$k~$D2WGYGuA30)Tqp6c?d1_Z2Mj_m2A??_bOJ42||P3coR0Iy0)#5Nc6e zL;Jj2TF!=YlbN4_&M$@&H)XeTOfrzYjq+rfIZFd;g*&r z?4>#IeL)C-Z(frBaPN{3_i04>?4VJNQF!&ZU@!mW!9*;KQqRpg%L|c;l# zonT!?zC^Z{QbM9?bZ?1FG7Hd6Wpx;KXiN`iO>Ka+l(Wi$zgO+K!9Y-zY{yAJz=sS_MUK@Ed#ji4MOti*W5dp`HuQ zstMM@Pq3Hff!Kb_HTUiHlm5C}fYD@}DLbX5n*B~b=RNN$bLx0jN&Gzwyq0PO)o5hO oJG>KL_%9ZaZ5;Z4tNasS03(Pk1g)u82><{907*qoM6N<$g3QnZz5oCK diff --git a/ui/src/main/res/drawable-hdpi/ic_type_unknown.png b/ui/src/main/res/drawable-hdpi/ic_type_unknown.png deleted file mode 100644 index bdbce3031cde76c3055eeabde6486fac1bc3fa5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 725 zcmV;`0xJE9P)g)JPuaK)p%P@|3u5c4-yL9i(OPVLj{ zr>(8*L&7LjyLjtOaqq#iZe>4+!;J$FKh{X++m}Tdi20AN9@dRVz;R0`R_9PYa0HYU zj00$Y{R|xe5aM{Ju0FztCpYUx0f16a4T6;`puA`tfb(-rAB+p9G=oxg-dni$67QBS z)y*YwmswqUC23s_69>G!OGo;cw{Z7G!%7t*l!4FeL3#FgWDuE=Q9_+qAT|M@`j$A2 zMsq?a_>SFuI^CHLL?{6DCkIsGhOy5&6kr-eY4)gh=JxZ()*{f`T_$9M)7Nv1uMtA} ziQNOyY{Zk%0fmNUycTzzZK*)4NYREA?!QvY3n=b8R6Bir*?a%^S~D7e4WTyfzTQ*% zqPeir~@|VfWnAAmQqMr!67!4gjy@3R#V6h22InaVssUH|{r2w0s13P|*=MDi5M!voD&9@yAU=c5-w1{j3cy^zX0g8cqYJoaAH z%0i~L>p%K2qVQXaj-zq7O-vSH(%xZD_Pf~I>00000NkvXX Hu0mjf2^~ci diff --git a/ui/src/main/res/drawable-hdpi/ic_type_xls.png b/ui/src/main/res/drawable-hdpi/ic_type_xls.png deleted file mode 100644 index 6022b7689e49c4015e071f6026124d3050db3300..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1460 zcmV;l1xxygP)_)Z~P z#Jx~(U|b|S3JmDw9KZj87BF_v;fkhB&X=x0p4x8bF( zdH~~79RSI4NMBxy4E9C@p3o!&7*iP{D9YP%>ML|(;BB9(00@!gXsW4~AE8V;(gLNZ#FT5S+yWIO|+ z$$O~la!@4zX&0=5Q2V&&JsUt6!4umBL2hCG8VFg#7+Tw;^gDoew9$%;cJM^!rQkzy zAZ`4Hb2X2Q{qp)o!GSq}K`7z01&E?^AZ_^l@4yPEaKgUNd+42^U|ur1YWzkJ>MvQA zVsa`OkrFE?6<^Mhi}VPRsq^4l1K#UjpBl^!fV_bN8r6IggYRRb2DiTQx%@n^9-V@OIYZ+WehOyuqX zIUW15HXI;n7O_^_wywn-$s>f&x<(hf@!914^wu}6d!e}Y%MU@~3=fJ5As-K{Wl5|+ zMGqk5=yNs1}3kZ^J^MHv%h{Xk}T)rZ1udU`he1C)I59A&zj2w zW6h(X*pK}oI7d2bB{Ej+&%SFE-OXBTE@M@50IqR!<#ir|y)kO8ZRvjG#OE%}IWT>7 zAOuZFh&J)9Egk)SXgIpL3a6;!E0viJRxZ4&3;@YK3(^a^5(i@WipY3hdt|)7Jrw`v zwns)%fHCof;lT3Tj1R)d#hS~zX@eOXFxQZPE2 zJ2_izxVi0<(Z<&I_<{g%JpGCQr0awP0}VLk6wZ9xnyr`KZ2dm`u|N7{TS;np!9(c{ zy}Husn8Ds8aJIUhf&hSKBuE>02p!HRCF3GNkiq7*Px=2>vRRd^r}p`FMF7V8-UyAJ zJ=O&w`M4~BH?0*;%{kyW{Hh;RM$nZyLSwxr1`nPd5CPB#kP;i^0hLJ`Uw^=N*0nf$ z6D5}xGUW-SH{yF;&Bp>`H^1xd#UC%uOn9YuJpwU^X_^NdPaP3JyGKC+MO|rC!&vX@ z3UMKRM?j5Q6N`5|OSh*)+F%VE9ZiZNt=#z&Noyk$sH@zd`S{*2$SohA{~N`{zpyC? zlqt$u%G_h;y`pv=APAfX+yu?W(#Ef<(k&l&;XKGEe6Nqmse~IiqWs3dTFR9~g;#26 zK00yfLvi1cj~Xae-^!Ruor+>1IePt@(;>|>@m?`k$YRd^->D O0000=g*&CjLTxY1{oV0=K~GU25ANwc;)Qbvy(=$ zL7;$TVqy|P4g+BLr~vuwP_duDaJqvm|L@Amm0 z``UYVIp=utJiiprA{GPp!=qeZB-F0`#0VB*B0_QQ>18Z8iLPi9cMQgDa;?&4#Z^W_aVy5eHwNP| zxnUEd5j!ynq{3)z!sY}C4RslKuf3zj`gS~E{dx}?=yq(fLyPtM_X}Kb8Q^M j=5EdCfLZ)YZ0_M5)sK(pYC~{A00000NkvXXu0mjf-|dtJ diff --git a/ui/src/main/res/drawable-ldpi/ic_action_time_picker.png b/ui/src/main/res/drawable-ldpi/ic_action_time_picker.png deleted file mode 100644 index 2a23d6b6f8c40842b11e04785bca32b166c2dfae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 311 zcmV-70m%M|P)%Zah(Q4!ib7&G$1_a}!6i631T<$5HHp|tceP;;QXy9{o117mOA;wT20}-%P+}#C zMK7D;_e3IV;J4WKC8s2tL2ao%uB|o(Td)J87O{->#YT0<9(_V5+<;+&SjgQpe6f_Y z02dOQ6H_pdymtdwC{-0_Bz7f^R!nlzuR?UP1Go`ih4O~G7&)x@E^8l`Z8|R3W$X6) z9Ymb%4`ir*8OW7uAUzrLeousw633&>J3m@gF(RA)eItE8wkHpt@*(veioE~;002ov JPDHLkV1lSkdXxYF diff --git a/ui/src/main/res/drawable-ldpi/ic_menu_add.png b/ui/src/main/res/drawable-ldpi/ic_menu_add.png deleted file mode 100644 index 6a243d0e4027e732c5728c65f809314fead9ba2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1536 zcmV+b2LJhqP)`>tMJH{ZrgFlcQexl3Cc24=8AQc5u}EF~F2ur)ImGF-zKGyg15`U<)eo%cbtU=`wg(}4pAo{x@> zem^86WY5~#+IDm^SCwVihOr5JygEHS-99id@E1PYg8>T$NSB?Rosp1`(6G9?niUon zrbU+w27{#4Y6&9&Oj=o4k?eN6^zh+B2j&gjxpSvxXlUqnmui013KU3NTwHv_>2!V? z85tQK6%{3!OeRUE(@7eQM(Jz>0))~X4u`b3xG3Gbch9!8v~;|ur{_ydarh(h3zU_W zrAl_-Cc)i%f6s| z0$D5;U0Pb&hj>5}LZyK^lF?{XLL@*oDnuA|f>9}k5aE+%XJ?%NI|8V$eJSM&NG>QS z*b^QeZjFzRH;XWdd=aX|#KhPTK0EGZfS9nT86k3qkYEfSp{Ay$?vIa;XJ5E*fjQ-| z0=)vIq@);;#Jy1Eb%aU@6V;$H>J}Rt`(ja1(XSjkckbLiEPREb5>14VN-ZobNHa4t z=g*!!`<|=%Hbu`HkX%wyvO6?1^a|9`o6Tl-nAA^jg(ah+qT)A>pFDYTFD}2R^GeJY zi4FyqMn^|?_xASE5;m#i5vZ`RP!CmFpw0&j6-#@gGF*s@AZabfjvc$k`}+F&{d&Fr zvZy`}@Jf;+pBk)IYwh*x*Edz2M<7&|F+Dx~Cxl}^y@sJ;&JYSY3zJD;+?8 za`D>QT1#SL;t29i=3FYsFcCt84%R^+YhPdA8vz6D+OY3HxKUSEw-fg~ULI@S6w+p9X3k)z zQIua)6s{AE=wsm2sZ*0sC0)4LWALx{geahMr;D(!Of(Wz zM5$?RV`F2=l@I2Iajaw@Z)kKRSllQMO;!qFcojgHv!|)4X+!|wyGz0%s4f;)Y(nHBu6B&=IDGi< z1m*>1jIQ|W+S=N>P_l2+_SwXtsRo>zo69_N=FDY&UtV7RDir$>4)69Z0Vl!*Uu!>f z=ukQCHUsyqKr^Z+mQ|#F2@}exlbN3hh@6>0ULAol-}-|I7)U_%_xC@Gm-gcTdJEmi z7cVL%s!l*KbTGmtgy}oHY1ZcD-<5ALrt6CDpQT)cSknaRn?B7p2e1*T#= z2IDN@`v}!d0A1d)Wy?1J;a?($w*=k@6O=;gAG^T#Cy}p@>PjUPJG0*z42XEX-+vvR mcJW`1Jq7Zo?o);QDfADYJ|t44+-VU20000kt diff --git a/ui/src/main/res/drawable-ldpi/ic_menu_logout.png b/ui/src/main/res/drawable-ldpi/ic_menu_logout.png deleted file mode 100644 index 9853e8516500b563f8038ba4e481b0ab0cefbb97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1766 zcmVWnzkm9G;zMnL`yLhE~A+*pmW8V!?{Ea zZJVLlK&Hl&m^lklbQRGurW6Cq7kuqzmRIj}-|yj`Fum7%h5m@qg@<$QInQ~X&-49# zf4}FE2`|`B_JZ*UFM+H@~sra)4B!p`q_MJ3Hqa z42JEFj*dz+!OqT3P$(3H5sXHoFf%hFJbwIGc=YJeEc&$#4i09uw6t6Wl-?G#Yz0z9 zM@MV*di_@}E-sFM6722m1(ixAD3wY9s)%zDhz+U<=u0SJbaZs`$&)8v*Vfj4k1o^J zpsWII+O$dK>+5?01EqL)c*vccoJ1J4S}k5BFiD~5>1knVYD(aB9+dIn!-s`u&YU@F z4Qfds!ua|5X`w)#r>Cc!$}mI@4h{nD4S?wa$R&8_uE|5|aNU7WZJwN*RG^7)RBB{o z#0a&%tgfyuUJ7a{AX!92L?C?93}rM3l?bzP zIuVF%XlO_`Ffj08U0vN@mW*x@$ji&iJ|rZh5gM8Zg_aOv81GAzbX3`t;Z6O?7)EoTd>N@P)AAM z(7XWa?CtH{j>+`t>FK*MK@wE>qNb*1h$G`0PlT@$Auc<0>Qp14)~{dRfj$8YAAL1G zKCbWU>)QrDT{owaSs;W$?e6Yg1a*?=n-wcoFkJM^_L!KMjw45o?74sceii(qfdc;k zVh4ecb(fK4KKMV0MMRgDmexa!_wa2iN`XQ$JiK)5!i5Vtw{G29R0_-j1qTP)`TP5~ zu3EKfD{Bqw3<}|&2?+@wz#od+w{N##@EuHVu6%54tOxfpnB4~<6*Ca68KL^LxVU(_ zyu7>};9CjAZvb@h{Q2{{Yz9JRsZj*)Kp`)x!<2?P1qTlv%%lwTwC}(9iyu{71kfv#OgEzpK@1U&A+xP6K8`h7c(V3kxp-gnkT$BsXpk&$r?CJ$gyB@hjN`0(LS z^sy~u1VVOvgVle)CACtxav@uV>2@| ze@jhG-HGp;0iz%gGZtaaPD@KG0MNpsYW_?OAQ=?e$a4)gNHz8*0TT&0O5DIi??R;+ z)R!7W@~j|zRR-hH zQkRvLodrlZcWst_h5{MVjQc%+V#+EoD7TQOKYYhiqyaEWgtQU;Ll{~%)+Yc~r=+CB z;JZaBFJ|Gww3Gf*C2R?A!WV5Q_b!Cup2V61^Zt$1CRbEcTr&6lp+kp)pkyh&@k2pn zU1B+4aUDkzY>SGDGONy#Kqi%xm6er=Smh7MGCAuFH%Nlv-hdRofsnN$4C3(vp?wwM z3Iwn}-pL6;)ANdE1Xx0ReEct#)UgUQ59%lYvIxav1XG(^1_8Mp&|@r~tT8k#k114! zo?%0nj0jm4Hs5a-hS;XUxUds_QB_qH513<6$XSA+ucZA+Tpel=ePY^-#Ul$~CXk8R zxVX5Vt-;u&&^%A6>g(&@K>FtbVmIJa(ovNKkv}TLYD^F)qlZ!rIBDkY-Mg2bdB*&f zyleGLy&!{lAX5X(2RrtDfCQq(tb=ddO#Q|XvO7@e3jA_5JUqM?&u7dPz~=%qKLc^k z^d{i^MR6-&V+EcyS7$7NNY9t0khQ^{$NQH+)>M3{kTr$=150v?QfMwifdBvi07*qo IM6N<$f;3J@ng9R* diff --git a/ui/src/main/res/drawable-ldpi/ic_menu_refresh.png b/ui/src/main/res/drawable-ldpi/ic_menu_refresh.png deleted file mode 100644 index e19d1c332ca89bb90ef0e0e6f10183075cf063e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1386 zcmV-w1(o`VP)H=Xf1-kmjZQ3D&IFMbHJRhcE*Cc9837V45Y8Y!*A!b(fK1|zLt4v9nP zhrBBy(ua+<+G-6M{UBxrmXM;Mt}g3%9Y-B?rssc{0V!wZoFdr31BWv@=e+OlJpbqa zyzg-A5j(g?jE9{81**uILjR>gG7PT3DaGkk+Ktc0I1fE%p!xsy{XZ$0EFmF5t<&iY zZnyinqobpATq8XrZ%L)nIsE=;c(ahYZ)9IYygx)s8oW1)M|BvUa#-Rz?UK;BUyNOI1362 z;(_Q2W!T~2ApU z__4USIK8{O`&T^g`s)~ef$(5Ra&q!lDwXO28JGML6BA=DDk?GtlAgZr>+Aajelk+o z;3c-Yx;lZ+E;K~&`1p9v^z`()C?F^#X=-YE0lp~<4i3JEE_yICGxJ1UU7cUqy_4WR zS#)&t&+wI&3=frfqvOR|QN}AM;l3!KlQ;MF_NoDN9;*E$M4j5&+RIR<1U`EjepAAO zdX-jP8-vwhYSXT91k?0_U~iRyXc(vIy*b(#DFz7HwU2sOz=!4)Cr{+0MMQ4>gpFy zQ-{X(38d9(6Q-rK=?#o~ zBub&Qw6yTNyu1a-u15Q^-Q8WjQ}DKn2*sO_yj_f1)F9}(*D%gPd3pJSD1}ge30m|G z1Y&?6Fubp)!E$`0>2q4Gb@Z0shy}fMsjl)vIFUWvu&d$!hnwgnNyGfr% zz}4O}Q4pZ|0rV=xKY`JLiAf2<2B7-{h1O1l3bB;RqzdhuXlH=s<4#IS%Inw}1l*_z z0wSoXsi}~Oi3tmGs02{_wt|9=d_{)$9<&I&mNz8F*#Pw$puW*)G(Fhz?)XY%QC%iPS|~z4gXkxaWMyTAf3d{GL|VQ1pF(0m symN|HNC@n|x#tWhka}kd{qGd|6T{h?LrL4ftN;K207*qoM6N<$fHq)$ diff --git a/ui/src/main/res/drawable-ldpi/ic_menu_server_profile.png b/ui/src/main/res/drawable-ldpi/ic_menu_server_profile.png deleted file mode 100644 index 8ca629b45473fe7a13ca84b703bd6477b62c7a88..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 765 zcmVRiOV614s*F&fKjRah5vc&a5y}pKfr`0H9YL~dgF4r+%~dhwOWlu zqfy3NqPT(f`#ro=N~O{ffAg5lW@8?YheaY0u|O1dZQ^7y$*fi@cMfef8_kjNcq|?W zkHunXr_bGf`*=Lg7K;T$?){LPwV?l{Rv{qO>-8$=FFc1ZAv~r9UU^G-r9F6eiX!^T1R>Gy zF+|fy4jBT1_gMJcpxhKamD(}D^u-C}g-)3SL4<}02h#KC(ng~Z^yzWAT&jqMzBPb% zyWKL$g{;pZ3`kGPYe3K>62Q77Nw41PQN?elX*bcKYd|O9R5qJ^Q&O7Erb1($Z<0gr z0YQcP{eC@{%e}dPQEo}7W5}~F1HzSras?N#e^-Y7phF;I%f1YVl9^4XQ%#@F1rsL@ z^$);EaG^Pb$@J&aC_1<=$+R`GbKp~dXc6~ah#LqVVzFysKk3Zld_Gst-(w7ksO{ZYxNDVfj~ejJ2Xz*R|ie{hb~zPX-@3&T_TatYTGp+ vy{r)Q?@T763j6A~e@fqh?m(Zg{{jpEql%q_o+l5G00000NkvXXu0mjf9GFx0M;XIO z%o|QOP+vqKrB7=D=?f6G>Xy^{we)V*>OMf^xyqLhvzieDZrV88`ZVT>s~=xOtY;8# z5~xbNMS#e7`HH}I>nb%ge&Hr?p2osYm!94(QqEhifQ^GGM13twh9EHCZIme2SXl0v#>hTl;YhgDVMRSZ||0vV+WQ5~y#%Z$x0UL7^Mn@93Wh0*sWWk_c6l7=& zY~c!IWR~U%f*KGTC531ac-{kaR6!V4o;;2E=V?}=R#64T!h+wZgI{0Ado5U%0uCoD z0vtxHLlYP0yAGx^PX8hGa`o#Xcxx+QbnXMqibu0)?io?9V*e`kIm(VS#;yDS;nr|3 z^+9~#Fu5rI;_AtYt zQ;DDkz9^7)MPnV03R8I-TN3v`S{;CFn*$JcvNZ8{Y04{HnqVQ4s9hXAe13)jyS|LS}2{@$e`)*{!a{zMOWfrM=u_T{z$-}ZyE_;7Bjw!D;eSHG9Z zH8OIEsu$(53)zXOKVh()ev?r$IyThiqj-C3GQX2??Ego9yZ9}@05n#`ZY=cd5&!@I M07*qoM6N<$f|+-iUjP6A diff --git a/ui/src/main/res/drawable-ldpi/ic_type_folder.png b/ui/src/main/res/drawable-ldpi/ic_type_folder.png deleted file mode 100644 index 6c65ce7e1aa302add0a2173cf64741d5dbe77d97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 582 zcmV-M0=fN(P)0zm+Qm-}!#Gdfo-+P5_j%nh9o7i^k`n>(QZ zAju#jh>~m%r%R;SRNe(8t%2Yye93~t$n3g#v9qYZNmMA!c)FL9xq)$Qcns8RKKx(C zfYXM*`mfW6Ods!z$J+Vo+ex1w=M z^|wmCKH4_8ivYfPtR0Iw2e UjKHX%l>h($07*qoM6N<$f~GeF$p8QV diff --git a/ui/src/main/res/drawable-ldpi/ic_type_html.png b/ui/src/main/res/drawable-ldpi/ic_type_html.png deleted file mode 100644 index f4491d3e0a448353c236e0297d869f174094246e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 787 zcmV+u1MK{XP)JOks1AfHH4w=o=wBSs8vyz9r0{EDt3fKS`yKGFx1%{wEsFH$+|}xrw~tH5 z=We)I&U4-Pz&M|0C}hME5tKz3EHPrsn6Kc1Ptcf8347LFES3fW;E-Z015L$cS2L|; zRL$Y0J+GN|8FX}*5Lli!Oq0yR=874DZphN(Q$*YwzGqU-Ta#SN|{H9=QBc5-qM z6_;@k6<&mWS*Lfme_Zs|#`iYeWEha(ep{kB1QB(3hv%&78O({nPG76Y#*eSm{Q0f) z`OTx+!Lw-W%z1>Ia=Dp~TR$#31P!<6yko9px>GjrKRP6c~-SN$AyFdah7`Qpj?sR9f-}m14zBhvzV`x8zg!XytJAuM)htA%h2xA*d3QT*$ z$ykv6_-eux1XxxlNnNU6ji(S+$lefm#Tl5c2m)C%snOht%mbZBQnf7eeU~x+UvMeL zvW;aK1*J6_NhCqkYAlJg`ZRwWd42cPT;+@2`!6YyB>U~7{<&J{y$@#kRI}bu&D7>1 zgI;h8#OxK8qnBM*@6q3jS*P$V=kyFeAE-s}YhfPczbpt0ff>1og9rTbd1_**{oD{O zt^9O&^d!-Qv}DWViJ>QUHG(zwD=Ot(fx)ph5HLZ40w(@l7b|%x`aejEwx^PFVVfckuEX1nRfUz)o7I=KNWui^%jjhyZ>Ogv9 z8OW% z(iGf;2ozmbbrBHHkoSp3n<)h0NUCm0DuK)_AgH5c`NwqOdu#;DN`$p#2B0}o<6snIE# z?{4SRz?4iE(rqFLd~Y@=7LdR8hi?_@Z7)IF^N296wXeqJm7^AZgIi8sqMh4W>6VN zuRRJ@5%X{^E+Qe2myO3+SZHX=WkY6C<;_Fd>Ig)TkxC?e15xF z8}&}MMsV`NoQS4RgON!20&v^SoW1t#jobN^`}q1nZPy5>5r$A|0>XIwh~4}Sgld-H zUL||&NpAJ|-Ay2LTS$ZeWf~Bq$j_lnN2fwy9!OiUiEJf%_3_k>0LUsR+64D?g!&XJ zXQAY=KFFh~u@nuAt3Ub?&g;BuFSwnS0%2wZ%>74a@TE2qKzgH$bDsc|eIiIHcQ&BA zz9tD!ASk7=0MfYM2v`U`PNo&Lg!UO1aoB+(-lNH91e9t(BMJYF20?QWw3DUxLQ=%N zzXCx1`79b585yjOS*n}Ze6;c5<$P)K(!HXr7(!V?aCe!zT?-#)WqG0wpiXgHj>Z9O z{QQz}+pWCH31#`o%lGea&z(n0^7k}GzQmnQhTH9)j=T>Nf%HfV$H3TkNHq|5ZFRr$ z?6&gqO#Y$J!tpX1x3oxN8p9enP3bO81dkqFEPR_H}%M}F8V5Kd~a^_q#Ru*qm11A|bNevfCVfe~v{m98>gw!-v zm*#4xt`sfdb_;>Z^vJo3GlVfUvZ)b4{&n!|HsC;0Ge(akf$Er(uA}Z{L&_09&>6_r zcdx1=BVdME(c>v)OeR`ZhZeP9P${@vdOO3QxDRy93fZhP;Cf5)$X^+g)aM z&x!3^E~enDz4NVR_w9T0W{w$S;D26n^ySLU2kSCl1Sb8d78?~m()}KEKD=t57Q;pv zT)nkwW-ea?@7&x}0P(?YHR^7^k9&L7FYlhV&txF{0CJTD2r7$H0Yu#&z=S9pt=F&L zU8`=sdECwf0LFl$JWO~^J?L*4)khstXbVy2ULLrY1MU~VE0)T+^2Jn;F#wVaPXl@o ztqk_NORBdAX(k}1-fYFj;?3sFpPhG1YR{^h&DC}~13E4)z}pJr9NBoO0LTCs(B`V6 z~EAz2rGKEp*Mkx?{i#{SnyP9_l)#N@Dvi(DmnDGLA`T@XMvBz@r@Itj(2(Z@l@ z_fJmE3W&S{Y>+|RX`lnq?hK-P_feFg)aNTgNj33WWM&;4(o z!7t4N7FURKp^EnH8ZJ>H#xek0rtLtxHjUG{#spS3)&(TMgS}s9#{$K4aK6LQ&IaYd zX9&QuU1Xe#08jO{zw^@q_@#>V_mG*3Bc^c&pBq#M_T5t0CtQ=U+J8NRE2kP}!`+lz)AMD)0xus(nZA)pPL>pX6d}X%6 zCvA5EVCa84z@7Nh+U?fz{g)wj+ohr3l9(_VW9z1=aV^Th$a{U# zfhpb84Rpl1EX>;38xLO_nV$hl;PSl}#w(VA=K>_e@bo4et~v9IX5~wQsiy>Ui$@je z&78*#h5aZ|Ldo+q&n0S)KVokynPu8kwNxBoGdpw}d&eJtE`sBh0M3dUjo@r1Yy_Ns~002ovPDHLkV1j5YqWb^< diff --git a/ui/src/main/res/drawable-ldpi/ic_type_server_profile.png b/ui/src/main/res/drawable-ldpi/ic_type_server_profile.png deleted file mode 100644 index 8d91407f54255541c9520657148451d263305e21..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 797 zcmV+&1LFLNP)G3!W^knL82pD%GLoP7&{;W2#H@QAYv!6 zeaAaHB=Jw|+0U--R<#ZY5axA+Dh)w3CJHm1F~+Q0bvFM3>>Syg0sm6 zL|HWyV;;1F$AD;sSs_9l?p0Vq1_UCb5sgnbcCMeUPkZo%d#~z}R;Xd_V&BAYl*|v+ z?OC&BcW)Q0Zyyr%r0^^ClZB&Jy1iAizP<;y+sQN_Y59?EssYL{0E)#Uw-jTcB`P{F z&&@O-5UD8Xb4Aq4iXeapJ!$OTxj1zW&aXeOgQwT94ATwp9570O_U$F}#%9_6-a?4} zP61J2DK}sAt1mqQgoi`K1XvYiWfjW~%OJbih@xTjDO@khK+rHEVyW(50Ew41^(OQc z-DaL=;;e-^C=)f0xg!}6K@b6;CnEPs)h0Kt=TxZE=d&W z%e2?w&j3okhes^QkFoPjA%R-r5Dj<*A}s40=vn3NuP@-*f5JIXbwfRHG$6?IDxyR0 zlOo_fL7g75rXB7Bq;~4|IhSQcz=oyDM?zwE{Pjq5xPFCEmZ%dmFrbRWw&xTwY{sx& zG0bU1mA zb3l;d%*egOOF@hh_+L8~I2x-52vKG6x b{1adR!P;s6i2WGK00000NkvXXu0mjflKX0F diff --git a/ui/src/main/res/drawable-ldpi/ic_type_text.png b/ui/src/main/res/drawable-ldpi/ic_type_text.png deleted file mode 100644 index e5ae70c48593a7fc6e78632262c1b6beb513fd34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 643 zcmV-}0(||6P)h+4 z3FujHQ3QKyFW#kJKo1@T1A_PwdMX}7=qX>ILJ<^C6~wE&Lq!jYX$^`rkr)%*B>Ubt zZ})ApZI(!McVO6E-n{wE{AS*p)esT#6f=IQU%$O+*cDGN*z~3Sr(0wnw>KKc01UhA zm6y-2+O@Nw8D?mNocB<0!qYrWHyusalU`^|FcblqBCQ#oW*A{`$b;DobjyZ`+FIVf3NB zNN?}pSO2B|{cCFm;M3EGY);!r4yPJ%nreCQVyj0FHUluXs}U9VJk%%yzSu#Vk02t7 zh<8-nBW4PqC=p6kT`~he$UOt<9L0Z5HGpa7{H2TjjUt?OP)-?OqE+LACb9*Ht_r1b zU9#&UbyX;hY0I<*kmpIJN#W2`Tc~@E_Rbsn?zJ0o6yCIJ?q;=q5sIhIsc|ZA>k0hs zv>Stiy=Lp#qu#;*?#ep-1e83pR0Z2{p?IbaR%MBH=to7K41a)sxDTV=H@5%$abw{O dvXDOl3;=?gT^hwEF8crg002ovPDHLkV1j#tCP@GQ diff --git a/ui/src/main/res/drawable-ldpi/ic_type_unknown.png b/ui/src/main/res/drawable-ldpi/ic_type_unknown.png deleted file mode 100644 index c3d4d48836bda66ead14da14c29a4f9f5028543f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 477 zcmV<30V4j1P)h|V?m-LVu}iCniAVM4n#o^a3pNWks{kU z_dKo@#25pWL$ANA?;J$B-36qZQimDI59u<6>Fs6QvdONTmZZ#qCjkQiI0$* zfVFG1_9+rEDz6Jw0A-4(IuAgl2h}~KDn+7`)y9j65&y@;A>_V*7gB zGBek6ZxU;38t;G=yl@GbJ9EBszH`3sVoE7m&n2&Zux0nLyrlOaBCA3HsPCQd>s9pr z*$unXIbL1C$oOg6lNv>8Z&C=rt1RW*;^I@U`YpHc=#u@%3Wyp(dU6;=V2dnw=?lU{ zHfZ4IGm}?yFK?b)0YZK&31dVg8DXGEWD`k&q;#b9r;ONeCZ9Pvo9zk!tRhYu4TLu3 zzm)e(Pi$&|T*)M(CEVyU|k`5UsQk+^$T8z^;>OxV_q)D&>LS#guz2ZVcVS5l($t-)y zC<^?)0)YRy7p<_3iL*yQbT+6j4S$_Bg$s{otfsA;GGKzHU_1+N9$viFu}58Pp!m7q zRZ4SUXs{c$U;A!)ZrNNuU!3==WiUK{$H>H)@z4Mtt-BUhRHPaMx8FXw>@c5_Bg-R5 z6zzqwA$eTu8#L5-zZDu_XxF|pWN!dXdpJALc;;2V41@*ap98TmUz!iy15Bhj;P^TO z8p}-1PBF!Ta~>W&I5So+eYHWcSsHkb?^eJjltSn!+MGLNe#qakwjY=_;JtLkNcX6?>m) z$9K!fua!BKpPoOkI#ML5T3(4Kn}Hz+148X282|hk>jUOs{H)a%b}uNg#Ls*>186-c uIXbyq8fg#qKmsSS-R$hl z&bGwR{1MId4OIX$2!df%Rdv2;nk zs{(^B(=_G7{~U6guASL~pCoz)vb{01KRDdNuImnL+pe#cJkJ@fg8S2oZ5=8-nNo@^ b3EBZ3i3PD45K!2S00000NkvXXu0mjfxWI~e diff --git a/ui/src/main/res/drawable-mdpi/ic_action_date_picker.png b/ui/src/main/res/drawable-mdpi/ic_action_date_picker.png deleted file mode 100644 index 07c23848ce71516ba10b5ebccfecc35dbb8c0dcf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjGdx`!Ln>}Potn#aK!Kyp*312) z#$1(MmED1g=MKHd&N=j3ee3c~JPi>XjEif;G1Y8oTm{Yw4>D*K2&bCHqF_)2%SW-8XOc{SVjP{nUO3gHp2Tg%zK;E&|=i;OXk; Jvd$@?2>=f#REq!r diff --git a/ui/src/main/res/drawable-mdpi/ic_action_time_picker.png b/ui/src/main/res/drawable-mdpi/ic_action_time_picker.png deleted file mode 100644 index 407be1d089ec0244f5ad74266d7aae990c577fa9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gj8$DedLn?0V4ddoIpuq7~<)P=H z#U+zA&Ngp0yybNr5aj-Mx&3|@ovtn9gPiK3KP-gH(<>mP*GT)_qx*lW*N+bqwIF#R582zWyL@9sY zIn~zN%t!pczGj_rv|W$US8x~WEQMX`Uhw!yv)-JedCkN%U$nb*+n&&z%(BzBzfNo1 ioSKp+`K#VOS}&G2q*C@#^$ein89ZJ6T-G@yGywoDsajtE diff --git a/ui/src/main/res/drawable-mdpi/ic_menu_add.png b/ui/src/main/res/drawable-mdpi/ic_menu_add.png deleted file mode 100644 index 7d98f5809bb8187ce06d3e4d005ecdd7532bd51d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1871 zcmV-V2e9~wP)JmxCP}NTty&qFRAAPm;g()M zc2^Wzf2=U@ z8)IT(!f=b=;9!BEm~ri?UQeGs6<|d0NidHdJrX@VJ;MNds;Q~z%d1zfj(G#bD*(v) z%gE%}sHmva*w|Pta7aVDnRN+*KzK2589dp5#IzgW#e)YA#K6G7O#oS2UtfQ7rXXev zAUivIHKcGpAtAv609w!lz*`0{0jR-90Azq57(8zR>F@6s9UUExIdkT`Z?#(goC$~- z0m#eCTaL*ZlarGz)H-#p2G5Mktjnhih5%GHR1lODYooQbwHtNxR!vP!lcyj&29Teh zAB^DtPD)C8DIy|5goK1>0LXxm<_S!_m~Eq)AOi#dBM^gwgW}%3dre(kT`S;H<2g;j#wn%KU-2RDJcTrjlve) z-Q5*7o2|%a05)yfv=o$ITfBI21Sp=gNWIg@2?4;GnVFfZ27m&s@9XQ!Gzv!%9@nXKNqbLVI3JBJS+u0hS@xMGd(5(I07 zEVQ?`J1$?ooM^Y(N2defmVqr>wtRuiS4KxiPwL*)fOHz?s%zc7d-oIx9XfQV7Im}1 z$YRy;_&sX@audVD!+FP#AOFED0NcWa3)eIIbR2yKq4!DalwOa?e}aTQRVPLuXCfmb z*Qo%QaR#a{YC02HK;hS)IB{ZwDF6uM3f$*4seN@Y$Y~t5dLCIDRP--8J3DP)?vna0 z0(l#Y-zTy^;(q`W1+9Mo*-UXKvcOsZfIp5MJNAYt0MK#^tTV+(`(VUgSXj8!U7=0) zKY+C$<0*O;oc&S@YUc%00QT

p%@ygsy9DZ{Uj935ZM7Z%CxC-Y+`4t^BG?#K zS%`~^vz|P8@`CysR`d7JB1~}<1RcI?*|N9cPJu?_gZbaKZQJ&yDG8y-tjKh>(FAmg z`}gl_zAd{=P6lf|hwswWi3x8Xq5j7hAwsgCf?Jey3h1cU^d|p|rF#OPv_SZo}{E)rE|#%DuC`h+*BGH*VZW z0h8uh2?l|#unJqhJR=s=%=2Ame_xB%Ax8(G9+Jsq)-~##n;)aS1b@R;^*d}`KX>PF zZY9J4AcquWob9~Ps*ayh14fKb>IXc2ngPFjK(G}`ePNHNf8K~x7s;RvI}!lhi5qpwi5J@t9stOG$|&pdJplcyxw-ju%;(!JB`1I^ zUc{o)2oUi`Ak=doTB|H>G9dTRuG(pWL}S>2EoB-k*W<%3k7_`rvbwr@B~B!M#W6@c zPZIQ(+*vVrSs&6e8NAVkh9?|Y4>};vcXM-duX`dL`Ob_1@WaZ=$|V+yS5R!) zPD;J>&ZIhy`X0gXU<~rQ*4x{=4y(1>J+K~}R{%JOvnCE8h(Z*1B##QE=G|qGh0N29 zdGqG=gQ<$!w{Mqts(GIQkOS4#)g>XIub}g_*hN_=D;6Hhbc0sWw8IYO{+{t#f+;9d^dB;bzVdyv#1z;xjG51yA0_%D!)SBJSi zXTVJMeDST%81O|f-i+Y~;7!(i`Hi0eUuM&rvHT2plQmy{^DpQI(q7wqf1m&W002ov JPDHLkV1gGYYo-7I diff --git a/ui/src/main/res/drawable-mdpi/ic_menu_logout.png b/ui/src/main/res/drawable-mdpi/ic_menu_logout.png deleted file mode 100644 index 162f4f752c965950f501f1df0ff9ebb754ed59d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2293 zcmV^Eif%1W5DF(TU=Vv^8_%N9fKQb~B zH99&Pp!+^PK105~zMX!4e(y6HZr;3E)zHu|;HB~H`v)@-wpFaJbyCmEuAk8mWu;A}YmMmGJK%G5%_G92BCI0^iFy&bF z)s&Q!kDWo()zv+Lr(OVH7DPTP=@?Ilz`c9->;S)d_38&VZru31yD{N5f%NqBl6mvy zWfQPAcn!%#p9FIs^7ska<>zT>X(JO^ucoHPmu&R|WcFi%H&nnyM4uW2wsq^)tKu2x;1+?LoSY;i&=?aF!`T52eM>t0cO6N53*hg%bD)_6kuM;**W26M7n-1!CoqD= ze?v%cRY^&S%b<3PKxSrU4bn-Kbfj~WX^>4XfSxnpckbL7KtQg$eEITkk-$S|LP*eW z*|KHdB=GBxA3r{%dm_QdIph?kEG17UKE|X}TUl9|=E^8838bc`21iClUM1^<3%tqo zk`9u}+qiM#&vXc>)t|%vfHb~@Mc+tBNchIVg9k@-k58ZG=H}nwvGqvpFYNO*Ql_2v z&zw2)LnKoq`Is6Z5@e;GuCA^nwY9Z(CnDjJ!1uU9Lqku7goHSBuMGj;44}_R^8gG4 z;JLYT=RT`>DpF*dvygaRbGi2#*=d7{U4MVSb^G@1x48El>jo7Q5dH@w5=_+=8O`hK z>)ZYdF0Tk|-@d&jDk>^f+Lz{4q;x?lAFCJYdwzcYOZ;D^oUZ$l0)RxMUiSgM4#Kwd zWaTk0W*sm!Ec+4b?n%&CrPjWWS!kSnOI=`yC+VZ z_@Y-H$ji%XBX!0Y?Q1i>e~f3AId3eTCnY6SlLlWvyEXw0U8dj>OBQ>*+SJsPZsNo2 zfu%3w!6%Ft=gmz(GwgT947gwMNm7yXxzPf_cP-+775a78D7Ye3^a6U ztp?UFCq-@@4_pfvxmNewQcSzz7>mvD>z7TRef?#Ne3! zJOttScXsXCwbCmI6&Dv*BbgVSH&%+H=_(-o?bqf6`W7C-ZT9=rZSP6j_RU1T(Z1mQJ3m4X^8dK@j+%?C=#Vt1t zqB)D0_%7M5#47@5HJFF>R%8=tf>`NMsgkz$00a)}e;!2qc}A#5>tDh3b%1y1T-gZ{ zHApdq*!UB@|2iIw>{bE-`)Sh;Da9(?Iu*(;9{yul>s>3MLwLZbAow=vyRwUNw4~75 z+Ik0zucM#&t04i1wGgNu-&O;}Z^eog>sfcsfTxdo2CLV{#>UQ(d{k@9voy)zG!Ial zC$hfoxva#RME4j^kMj-^2-0s;DTxh{=)h{v8xpP#H1`D_Z@mWiXteI=a&;dG4$uod zO?UggtNq*}piQc(s$NFNxq9?-?pH*jt*xz}04^c`f2x?6=ul}M1N?|U&Re{AafrY> z_gQ*WC4P!CGBUpJ3cTAM&_pEQPyTKs`#k0R0HW4+tnt!k3t%dlUI~$ZIRgOrXZW4T zoJ{7#sXr2M^;qTwfU+3b=soJmD$aB3HH+IG5SY@^(s(k%c}PSl4ouUgpw@3ah!E^* z0dUf27kcg)i<@v{7Kyce$n|=5w)Jj$B&AOM27D)btjW&Kb}1cW9FGWSQCV5pmjQ5w zf;3O^F%Kc;6^VImVt#9ldG#Wo2CVr{Sw}LW0Nw)p#;seo{@ESrOqzfek}~yXqJ{#M zq?XzFU5}BMh$&;)I;9U1P=Pm%ogpJBQSh1opGJ1FE4wF`#~v`7EAJzLqX5gMCIskh z!g%n`1jdul+YNI65JXFn;2x7&Jpu1g5dXK0c{!_xk$i}3AVY;pR?1Y03wcJDtS!AO z!$>ZC_CfY_MjJwKt#v96 P00000NkvXXu0mjf-eXme diff --git a/ui/src/main/res/drawable-mdpi/ic_menu_refresh.png b/ui/src/main/res/drawable-mdpi/ic_menu_refresh.png deleted file mode 100644 index a6567242713a7d09ff0cb6b18c8d6f283ec65d78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1791 zcmVb*36Rldr0BLFp4Ip3zl||N(t>5?3*Gx^ydv69}Oy(swZNOs`Odjd zBfRF9<~6rpumX715wu3Y8UYJEV5N|S4z&33HI0B?uRr+W#fuM@mX>y41T8NwyRNLP zXmHKi+S)#{x3}+faB%pxrl#fx{I+7T^;lp{0Hmj<>*wa?itOy{!d+cmHO|h?!iEhS z1bi251Q@|+Gzzn`v%>WBw6L(SFyQ3m^mToG{a2O(u?Rp)N=hhRs@c8lLNkl8Bp`oG091vy!$jZu!ou8jKY~H-t zopeD2MB_QUy}bo^RRBd65rs(@MXq}Qto_u~lrT0nCIUjPh;pJ&u<@cLWfAaKQc1n zHZd_F0$^?sL|GEo{>sYAdul+a29TVbe0$55ExYJtCMvz}>+4I;-vP(oq>qq(3)1r2s|bQF#E z@bD0jz=rnr_Ec=VsAOZzvx$m|szxGbG7lsW0L8p0tgWs6^3b6}E+HWyNoUWVtyyhN zRR9VL3wz-CZREPd`{3Z!hK4#&dU>(X(RfA!RQ)qAFK?UNeu{G- zJ3Bi8I)1mMrDa%dQMvzfb8~$nBO^~k0OFrNf9^p3v-p`-Yf$Lov17+{a%(9D0RDG? zqajeA(`Xq=&Ye5AAh)>O|7an00Yo`Gz6Xk=VKVb#1W*$Sjvqf>F1Lmv0Put_c>fTb zbYc&K@b}~M$>!$fCbRNzG*Wv^8nGQlG;W}+I0CtQWUf&d`R^o0%(hG7*r#ysw zHY49YRjP8b5kN1}f#h<75e?WNVR(4>O{wURMm;?}cZP+0&#pg{HTmPV?YY>5HjN_Tg6TyJl$Q3;jU zjdpf+HX`|x+1X0!#`A@zr)N=qetwyfbrezP<%OUUS77h~R!=Gs6hjyt9pxGKH&8(j zObdm=1LwWEF&VfAqptES!T(wMG-Is*4WsX z2*ZjIfgPZa4eJGyn_yToD3jznDa4Z&K0km6l&7VoRlU+Tb1z4Sv;wzvNaURuS{Ua} zy~n&MMB^bo-v?d32VJgNYPhtwMHEs^*mZco3Sb?as%lAV1XQ_e9VS~NuntaDwWKuy hs@$~>lVAG?{0&{Pi(Vp>$)ErL002ovPDHLkV1j?IO@sgd diff --git a/ui/src/main/res/drawable-mdpi/ic_menu_server_profile.png b/ui/src/main/res/drawable-mdpi/ic_menu_server_profile.png deleted file mode 100644 index b074c8cbfca40c317bac2bbd2ec6a58a755f7c89..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 925 zcmV;O17iG%P)N!$aS-#^_=uW^@iBESw#a~2ZMDb1Eokly zc)ROVovu3F(amNv_LWV~zPM=sGyoa^4Z#03qsT|8RO*r*-}mfGA)n7T4i12vztHRT zzjQj?UcH}Ar$6ZN?ce|cfk4t~wKA{Q%LvF`od5XvV4Y6qBA3fur_<^3K>@hkZsu~i z7(nbR3#X^2%xpHZUaxofJzz4Kl*OvSEGa7}q5*v+1?Dh3k8F&|&XKN1ds1s)~ zvLps|qJzH2DDNUDw}yOIfrZU>4`l&JSb5VSr~@QSu7S7jYgGssTsid{QS(kzrSa8sY0M4=8{&0cm_Nkk5WO1zid+g z4u=Dg?vm3k?ldF`r=-*jAaalt+oT>q>9<$(TB7d(BukFpV-7yAvRglu_w&dilA^5LutkcSAH< z`J4G^u7oqOQ~;Z#yIQS+LgjT;XqiG%wa~i7ATy{B%&5+&9ZS>^cfj z17v3oVix8AuLk03gCP(e96rkB|x_wLO3g;CcoJ8q6tjRk<|) z5@`+40@7Gb!{fl;?RKvr*j5=LkIMnfhsHb(nh=00000NkvXXu0mjf6t1TS diff --git a/ui/src/main/res/drawable-mdpi/ic_type_dashboard.png b/ui/src/main/res/drawable-mdpi/ic_type_dashboard.png deleted file mode 100644 index d783e4d0e2c6b30c2904c84e352e665b44e301ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1108 zcmV-a1grarP)2QY)YPe75`#RfhAjTC`mDYn@l3n9E?l}NTgkVTN3O*SlSE2~H->Xn5M z0SAPX2amyHJg@HR+*|#sHW;v&*bAtcnx5{isdMVwb8pu$&+}kA8;5Of9|>$b0i8Yu zhE8X>(KM}@Exx6s18k^KoEfZR*6_&m~!v;@GWIW-HVmNVynjdH3&fL8| zzD(a=+`A3dj*J91bW`F)1aK&^kR+%Jr}kC?^_N93+Pc8%8Ib3~sir-rc0_M(k9>qO z&xPY_#lOL5N&9mLI57cQz0$**)cTK(;Hu0FX2Xqkz+?=w> zR2#aUUZK(obIPT8GyMs0G__Qv zR?gqK`t3qIKIkIAQa#}JBs)JvO)$IrAl3D0az)B-d`XzibR&jn56fbokLK|&k|!3DQzbFt5Gc$%r2wh-s7#ybouJ|B z$%N`k?)`LOLCUp}2?KMhN++^FO+z&c)O!RU z+`TbrCrrBzBasDRAyQ4~x$Z2+auH*@?3PQ*!mR^CPmr{3Wi?XUbL&M0Y>`SW$I2?N z@p@6sn#kw@P80OJ2xj0)OXTv5s8=)i6blPg4$pxji36uDPog}) zv7A%ZFvIjS2rJ{~$IgPYR>ZKiea7W=_L?k^`R_)Z>-wnKxl2w)%(?EDS2-~O1f`Y* z-|3jbRAoql$+7-6gP~b1JQwI28fReWaPAmO%>qx!ZKkKtY`s`&dmy&?`!*&+Lj*&d zhydp8EXtW9X~PW(Nw4X~|FIR38Gu-`66amE<%hoc(bKIqKO~!Izl{&EhU^JfA1&GS z)#rZxt}CY-cH!C$+mu$GJw91m`KO3^t<;4#bwOiKHjKcdTR+&9r;qd1=YQFvT8^KX zuj@k4nEdSvU%rz9Y_osO4xYZ8Gg`a9&`c{U4a;~~F>S07KmUGlcvD+B_VK^r2T$NX a0R{lbWvIkzpQgqD0000Uim1* ztxvBXJ*@-4+Hb`o)f-`@6u%7Ol|c({7+C5*oB0*dVDnUvbxdG+vWB|u&dh4~xm zUg=%}ZJs&$N*Ul5gPG z=Z|b>;{iLMKoJ^9K30NZV}8%xU&k)&R8!D#N) z;>q5G2Q1qGH*ArymcWhLW&selCjb=6Z4`VBQR-`>0EZJ(08ni(8)>KND41P)52fob zfJl&!aysJ*Nd9JGGuj=lry4*jp;KV8t7#?3$@rL5$ohJn2g}?hsiZ6ckUW)qFVAY_ zPWay`kjYd4GGKz^y@8g#4kHUz8mSJTu1SKV)+B5P&o&*~MgB}niCBOpU zUlI(pcaN{7B?@pRbqNSS83ZUjlzw@;!SdBm$1pz^nCQr=4>^FTDWvIK;?e-6chv+ z8)HO_hh9Ck8|CEDcoPBfqA?o1dJql<6BXjcXH-0E0(dZ*m=ynm9*kZzfSy#M1$nf) z-5I~xEqy@SWor}IW}2OL=bPVtkKgwj%osyEd5N2U2=|>I6y(4FkyV6=;NK!+Nt!k9 zQ8TSCynT@L4S+~;L~ZSgt8HNFdUqmp7BX0AN8vQe!J> zXg`3&h9>_2tPCQe3@@VSM354_=f;iC&#qMjLAC(k16+??BQ*?I2QL9(L~3id9tVMFc3}`#87z%VcB7j0N(V9Gf3DzY|kMlR@oPcp@lnGRaw+GPw zcmN|I5Og;x^8z%RLEbsA5r0Z+;&;qHf><#}JOC8Ru$B;bXDO`?fNd_rdhhQA01(bI z+nS|T8rh~?cL2~UO8NrcX+1#D4qs(cwae&d(9Mi*?;g)~#m2N2j;(EbKnygZz@Giiy`Th; z($enS0|=}%?=`f}LuhVh9M8R;Fyy8-r05+n9tifk)A10b$Iyl0%IW33mMuL_}&N*;i&<=kdcKTvjUc?(gM%wc?ba+z~S z1YE`w6H#-$;7uY-96oz15jlA&5$+p~dWHZtH?nI>4q;?hQM-beKnQ@HJoD9c5T74j!>0UBQ8f;GCW=&LUi-5lCJaz?yj|=gG+3Mx;8_b6VhargNcY_ z&}{*JFj2MoH=|r~S5883EkBg-+7{Gc-2q^4MMRx4vePU1V@h2^khOMK75o!m07@Vo UM4g83EdT%j07*qoM6N<$g4xy3O#lD@ diff --git a/ui/src/main/res/drawable-mdpi/ic_type_image.png b/ui/src/main/res/drawable-mdpi/ic_type_image.png deleted file mode 100644 index bf29558e6645a799a4a30c1f6115ace0162ab587..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1015 zcmVt{MGrTqUD z&4L_E#vLSXO(1dQ!cZ4(To4Vxg$7cz zd|Em)-uI^Mbm)lGR9MJMZf7zxz30ri_uRfRnx?^iE*AEA9T3=e0zCO>86F9;f-TC~ zUBGbso&ak~W^7^RL7bwo93QqMTAo|g%c0YAfXB=DSptz^O|0lCQXcHnGIUN3V|OB^WbVcLSK+!d5UAWfJ{S; zTu}9+nkh=qd_oQ@sr6aT<_Ou`zUfjGNUwf}%*IbWcMi+2p+-q)cq11k@SzK`AXZF^ z4IN&otrw)$o>1_{i&%+$Z;4@6KrM(I_#lG2yfLx91Ei*-;P5qq;PQd9rd946ow6j+ zJa|6XG9(Ah_|_P#sRy>P^Pe1zperc2i1i~*p>u)(w5uD$x-LvF^){WxZ6g z%sbt)XlJk6-v=IlAl7y1VMKQtTZEB!fgzD`V27SDpj}chwg<0}3z-Y^ZmCAv;#E)2YadUOG5( zjEe^h3j(U+Vh%?LSzh!2@j3;=h2BR68JTlR6Xcq;0-9ztNj8XNIHC!5);2o~IZRAI z2{<{|-&BR1^h80DU)fwUVVDT$^|6lK&RSX~%2%}@$!C=`=haI9+d7ni0X$A*Qfoys z;je#u(i;QW+$I+oB_ND6tP80>!-iN+2&r2s$Y7Lh^MQSZxhV$4GL;~&f=0bg8jyUU zTnaD<%y0tDox?Fopek`Kvqd%u`R*hS{)^2C1;)2WtT@Hl&9=P%<|_>c3{|9*_3rL4 zQlw>7&u@|Gy(nriHTAYO;}HQlN;P<;vXQ128pLOF&s3+ z7NxY^-5K9(fg)52Td>hdrqg{pJM-J$d-Hy83FjOd+2m@*6PNFfQN;^Hl3gvznQd^} zjAdq%GqvWDY79iL3~^tJ4ssyu3V>Z$i(C2JJh!b|pI?s}2WCL>1i;^Z3cQg{R{%<@ z-=LWL3RG67yYEfG$K;@KAOM1T$r}LKA9BY)X&t1(8mPfz;L+Om1VO7ikvpBc?3>RM zDuWtsfu_#02qKx-KLFTR2GO*Pa4fer*QxEloh69LWw++F88#tMit)7=A;iJCF6 zxjE+yT%JQ?daV!LZt~DvLysy)0MfPmyq3+fKSdc|mK^S_{! z)nkCM6f;XsNvDk*64@WjE*T>!#w^1T7OhPe;-UmJ$NtF} zF)(lqH5lo~jj;}hhsie+&>BJ3sJzo?GU7eA9)+7xz>9!sMi$(8>b{q70zlfyd&xOoZ_(k?$Tvyei1 z(K}T5Jcm?8my8GL(|r$hjFa(yCJ|L-p#5TBFOg8q@ED0e6OoUD50Q9|taUEo~rY|HQ7>|KyZif10rJ$@hfk4ysg27uoL{V6r sr76-NIkxR_yO0NKef9sB<6i;{0DkYl6---SYXATM07*qoM6N<$g3FbgiU0rr diff --git a/ui/src/main/res/drawable-mdpi/ic_type_report.png b/ui/src/main/res/drawable-mdpi/ic_type_report.png deleted file mode 100644 index 9335e459dbda917a11d5a2aec6e78ae718a45446..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1262 zcmVBHpEMP;BDi#Pq z5bvr{T<78OJnrS3nXzNXi9K;udabJ&-Oo)jN z)JoNL6ga7Fz@>5L;+5NQZ|!pZSOzf0LF5V`?U{)Tht(J|!N^N~h5q!DtT%BQ}DidsXOHgYC^h=yZgUHIsn@ zsr#@uzFuCaW+C3I*S~a`kQMAmVzEm6@mre^?miq?hp^J4kqH7cpz_)cS9_a(Lgej? zh9Fl&9tt1ne zM?`^+87-s*KpPYCJc0!R1SL2oG71qz0%2>IAhAEr#*gwq9K&O}4*l9U@4mu1TYpsv zDiwGXYfa3A4Sa7Xzn%2J+rYInmjMEmdLRRfqfR@1wtoEq47-Gq`y4QPx{2dog&4Xz z6)*}>VHL_GR+%{f87d{6a>L*HhoXiQ5DnL5OkgWI=)~WXFqKF|^U$PrGzZefDh#R$ zMFqdF3M=o#2c=oByGGL|-G@7xSWT^SlID~@NWL;=$MRv}EJtzx+qWN9V(Gka>EmX8 z?i`qySV(wMy!N#t%>xMCh6*~h$lFFv^gOUAVQPsBd3+CaTl>N9SfrFdVpwu620YL; zIN2LHXn-5Gw^2XZsScP43|2-V>ZxJ>uv^_c+2hkMji1 zWUYw0Cl00Q#&@+h;tcun2cPNT^>Od5>9&RU?p{L=tWZkMEX4;QAfolx1v`KI2-fV` zArj)6%EJ4fYQOm}hUsovo>|D9xfq5_^+1}8h7IeJWWRYI3yj$T4$vM(jz)J=QL56y zHqik)o*PfX{r?ody>#`HO6!;JsmLr5mM^|_v$Fg5&q-W!{>%%DA60P9A-$*bao;+Q zFQbNI__3}5i#WEV89TlZal>*gEX%YCLFT7v$j!~3!9yj;T!BJsi4;%drqD=}U~rW0 zxgiy^f!C`SBwloQHV9zA0BIG#K6O6ER~XiQ1;mKi7EswvcL>6l=9x~yj>fbq_U;!4=l=;X Y0P?qf(ZA_W?f?J)07*qoM6N<$f*F%gIRF3v diff --git a/ui/src/main/res/drawable-mdpi/ic_type_server_profile.png b/ui/src/main/res/drawable-mdpi/ic_type_server_profile.png deleted file mode 100644 index b8e7375ac32ea8b25e1bf13ce452844d66e63101..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 918 zcmV;H18Mw;P)((y*C;n!hT-nULPJld#R)uX4P=~K(`$FMC)S_6m;7s09qda z5ZG=jP?Er~J+O;qum(!RzTUUahGnaHfM1$n@b@~4cUMS50LIjJ*7aHPP(?Q^H2}Oa zNIPJ0RDV4;aVPITpSu2J+8G(I*u_yXM!9}*U(`1@K0vg+DP2b(0rK7XJv@E;B{sjk zhu!ThWdL?z7&7`%5ddw@CD6!#_Fx%wYm&>MZUNH*(<`RyD4Vcj#kywND~4MH0~2)( zG-H;2Uy%iw(1c`rU`bSevoMw0gp>2D)9&ba#VU-bN`B9Kd0p6o1Z7^FHm|e10^b|w&OnxWLconc;bsJ+DY3tmEJOEO$VQv zfvE_9br_K4KVpNJsv%4M0?nTPe9d?nhJ-}AP8SAH*5_+)Z=IQu_JV7V(H-%dsd0#S2dc55%Av!5e0vJ{hnNc<5wP3sXs{9F~$Dt0)SySdG!&tHzg9# zsVeQF>Ht`cC2^2uxF#5HNTT*k)ZD6?ULnwJS9m(& sC1wr`cI(l#xYb+~j*a_$JpV1g0Dsnq=69cm#2W735cJ^^BZ38_Q~7A8g}3VeYSu`nQ2h#eOdR?LDxg4Pm)Bn%A+SvKdOyEj2$pzFi#> zAgP+J9hs}Bg%Thslbrj&7Zbp;3QA!Xw9*N{N|vppHYGtV=(ua7>+#>5j4mlzMoJTk zB;C$p&~5?=y5Srle2zWqqNLnD?*k{q zNHJphApy^?%o~5)G8V2rxRouGo+;BsT~c!Z@~^nVLPUg`zWZayIX7qPJ$O4?>`lGc z$X_pCup1k%7M(8}R^U0DtXM#p5tIN!UVU-xlr4G~`;TL0hy%8i42>vzyK=*Betc7P zzkY(iYex~FT!i)V`e`FZC`F8Dd-w3>s#~`#-))Q#5Oh{Y`{hnZNJ==ym}hSr-R3uO z5VG`G@mmdRw13KDBos0Vd6fCi_q*QCwk{N~`DD44bmg<2-ZR<7j7Y;+WuzY~Bpmx% zisSk3;RlYNq$FVX?b9K!w+r;Qg7VJ<(0&@yK8X|v^xr&Y-X|0TbZqHOJ_{hN7y!Dr z|LJ7`q#Of4)69ZU0MA6)8>wwUjPw6L4Z__bl-gkwGU$`ohb_PpA4G#iX<#fY)hfvf zV2uWEFc5Fu1OkvG|CInVt~s4ObAAReu3$;lQAR1t`RPioI0w1nF=1m8v|HfTHw~w5 zt+DSvllmRw^ZFxu@)$tqIBUa}NnoL7#Z5I-`qLcvJdWB)<1vK4gluoYUv0iJ25b7Q|fi9m}8UGMY@r@D6cu(jh z_pxnTEpXmDGv}D=h~dG9K(vjpP?!XK7R`+BB0m; z7I`s>7Q)FMm06&=5qbGjDL}wS1XR|FnR_9==bXOvBLax(-}4Uv1^`>9HjmZ3qs{;T N002ovPDHLkV1i#v=Q;oY diff --git a/ui/src/main/res/drawable-mdpi/ic_type_xls.png b/ui/src/main/res/drawable-mdpi/ic_type_xls.png deleted file mode 100644 index 9f823e3bd4149f3c2dc32ff4bfe1a69784019d6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 936 zcmV;Z16TZsP)G$w__qlV%?K)47oYU{x$C%Ac#q!7JZ6TIL7kc5L` zQc5Va-JS96Qlv#}VH;9)lgaGveEsJ4-u&Jhjxh$ce7OAp9KU=!N<<5AykKflMzuK8 z^8Tf_V^gL8_^u8x#pMOTR&NS`wzUydGiwQ^sp0w8L-BHb_uV2d+raAX083N5DFC_j zcgU`N10qPV&b#9l zB7juy0(<*e1ThvmH~=V21l1RvO{vZWwl)OO|2qisCjyKKn7P9C)VmOaRz+CLBzud5tGLaKKmWcQj6Th^LGbQqv}= z8UUkohURmIq}C)H*E}Eis{kD9y5Z$SDMolHygdDUu`O_O62t7v<>?nw?ZI0Kl-WUi zPyXtEsn3t?LqxJT@g&S*QW7nDWGf+D`7p7_%hsga&^pp_?ZE(Qx>sM^$Qu+#KyGX+ z(N-eL3CY>|NpYPRRa(4}(|ys9iDS6ODK%}F2=W4|TL3@1cLhf>Vt#2dV@=5oo^!lt zNm4c2je@XP6$ARS{O(yw-CR%d7CVTxhGcQj0mAP&!8C~fQ>a2CXx>RiRe#k0JYBt^ z!bC}Z;v%^!iFTfg*ZoXYWBHBL;N181>Q|s@E-omJNy*Wi!lARsPDHdhM?XKkA2sg-9Py)Fhrdib zHXQF%@1rm;%HBfjFlN5G-SynB5d9#C3y1IopmVY?E45uuPk`ewnsMkN9ETec zjT$c-MtC5`g$2KX0>Q*{=K_Nl5;Q};kPC`P9s!*p<6n`lth|3yJ|RJh6C%cQo!Xfgw@Yf2G0%-+I(_F08Y8F15AEV5>@B3b_ z*9&DSCshH*aSn&W;ohX?@coVFdDo=`VB7W)8rz=KoT4cA?RNW$0DLhZb%aO(j=3TQ z(xlM{(Fk!cKqDkb8f~F8ftF>Rsj9l38yp~I9}2; z&Bhrm#|wSn-B|dwYr1gWmcV0U(0)!&O+4E+1^XTym--t>T&%9^s{oPt*9u(dAc~^r wELX`3NGbr{CPdB=01@_NoFxThuqcw_6Tl$>K-_Xl0ssI207*qoM6N<$f~z#);Q#;t diff --git a/ui/src/main/res/drawable-xhdpi/ic_action_date_picker.png b/ui/src/main/res/drawable-xhdpi/ic_action_date_picker.png deleted file mode 100644 index 33e96272cff2006392cc495ea5394e5e3d061f03..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15072 zcmeI3--{bn6vuD3#oAq~qC#tnFs2CBI+-8IY&K((+HP8R!PIq|((QxTo0*%<&}3$u znQgLpkZo1O7ex_KQS4u!fjFE@SZ+Mm) zSdJ}(y13%31o=cFEYv@`_tkLwg>1jej#89b*p-x|ER9Msjed^1;?<)|GYyH`;F#-xRwPFl1SIy01`_o~l&1P6{+cAR>lv&t5F2!+{M z;lY!ZZ8}YVe@=qYgQ*?}ks=OAfiA_gC}%`OeqI zL{%;;s-BwBQ_}}zwXYG2gc`JOOdQ}%sl;PrI;Npl9j}3dg4MvwL~`xroHQ7WMfO*d zKI_ySk6sojq;k@z;aFC*!t{CD53p^J`C@?%BrVI-Wi3<9V8akGHfKcDOe-SJl9Y%Q z!%WGVlG2QH1hG_#rw>UN9b+ZzlCHE#rA?VinwlZXmFbK~NScT^Q%#FRCRG_%HEd?h zo^&jINcsuSqB|U}$6~^(|GOnd$PAU5vwXTPS7YmyuG(l1J5HY2INEd6t!OWDvFDSp z)AEU4tMxap{@xVkL>;SRBizLbM%W01QrIv$xU7C=H_aNJz|B$a=*QB>*J##=J+_-V zI#I}Y1>dO#P3)0F%XC5fMT2()H)cTPoD}Z%b?ZNv03Vw+9S2UoQOT(P`t-b%djaQF7AI*r0MJekp9g`brd^ zQDu72M-+N=Q{!%!dWxMIcf-^{<_X&h3Tn3+7>;Fye~+C#{5XA*BZX;AOKCX?4#SKE zt3~QdMT>5>ez=9CXSzAiF*5PgxWt&Fo7kDE*fUquew|VJL`NScrT)|8P-pfxuABK| za7Q;&6=?Ay00`UUxY&Gvm*WCJ*e1ut<^#MO7XZRGIW9II;N`dg5Vpy2vH1Wm#|40} zO^%Dr2Y5Ly0EBIFTx>qT%W(l9Y?I?+^8sFt3jkr892c7p@N!%L2;1bi*nEJO;{rg~ zCdb9*1H2p;0KzsoE;b+F<+uP4w#jj^`2a7+1%R+kj*HC)csVWrgl%$MY(ButaRDG~ zljCCZ0bY&^0AZUP7n=|8a$Eoi+vK>|e1MnZ0zlX%$HnFYyc`z*!ZtZBHXq>SxBw8g z$;34|ct4Za^rg%uefzQ!JVM{@M1nE5SVE}%077feA#`J%o_|1Sg}xH{<7tHSHxb(9 zy!Q0vqcrx_`Qo8+>)KD>Dz~o*x4rP4+OAx^*sgrpp19}Sw#oIq=bnFd$NqEQ|NQ%1 zC$4-`)PA#etrfm#PrSZ=&*vYbKXUJVI^|rOqB>;F+Dgk@Mo-EUciwm5{ME$|G&)?{ zR(s>+t-?ds(;pcNzg~Rnso;KuE`4=rJF4%zFtr7Jc>N-MY4zSmFQMJ Wze7I!%HA~1M)OCG72iL6`uv}tr%%xU diff --git a/ui/src/main/res/drawable-xhdpi/ic_action_time_picker.png b/ui/src/main/res/drawable-xhdpi/ic_action_time_picker.png deleted file mode 100644 index 68d5de0bc902e8e965ff9440401c0ec674c0acfb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14781 zcmeI3Z)_7~9LJvxg0e9|Ai)rfmrf!E+WXUWYtObYR$z;E%re;a3a)ogw`1+y(Yw)Z zDijR@Dia72{tF}|f{Aa47$GVm`a+GoAilta5J^ZtP>f0fQPk(!u6@?EJYsnHT+;Qo z=lTA=zvn*BpWd6>($T)8u4ZNp0HCg|H55VLoc(!p0{YukeRmW3nrO84m;lsHvp-c} z@BSwM@J?4dyRGi<3!I+(1)>JK=Y z?Sf2qxPxiYlaTSaJWiPtc&5qc;yn#Mo}b4E9Peg%jum`Po);UMM81*9Uyfi6iu_3> zCPqSw^X1Tg0Y{%@86wN3QYlx;?b4IIEbsIASWaLC!HE=3b5OISv{N(db0#A`A!y1; z)v#1uV{Bh3st;HJhr=#ZxbpXvFbahqtjj&7MVulr*8e(*ll>tyVa^3TKm@lijhRB-^K0 zP_{P$M1V)N7Kc^H%%`dUcLH<%SbF6esXnMx+)X*3tfaDosmH98l!VQ_Xh9G*c+PNi zMya!(wNLxFI(h|@5T0tRSt)v;tvQOIFaj*PH9Kk#GXotSVulFH&xircXlRot?1zZJ(sYB2b0m0T-X2)IVj%I zLpH|kXc3$SF{ZePh;RYLh0`F$6c-T@E}*z@8pN35A|k>C6cL`1lN;=*YVV~UH22p3RXI1OSX>-tgA%6VFUMEAh`~c14b@R@m7m#~a)47=QJG5ASRnUIAA0++LB{ zd`DP0-S^{?s?}GPPm#bg_hOrX)_(b zz15k_wsC(foK&@K&G2JWeC*Qb#mM{-FQy zzb}KunZDuqm%cv|edO93zN@!~PR@Dn^09Y!w|i>0*1Wj&Pxs_Y^=q$inN!<82RlES du`e(IL?``x`0aID5KaKv7PW^ySh(ude*y3EA8!Bv diff --git a/ui/src/main/res/drawable-xhdpi/ic_menu_add.png b/ui/src/main/res/drawable-xhdpi/ic_menu_add.png deleted file mode 100644 index c9cecb4ae0c8efd167f5ced9b83bc19fae9d6e10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4073 zcma)`^KL!)7TBBY!O*P_AQYZJ6WRa>xAsdzGNF3ON6n6Y>lO&kSr-%mJw+z zF$h_*?<11zKi_x%m;V>f{hV{3^Srt5bA6ucdSYa#O;5u?0|21c)zP?fcBB70RPeJp zn;mo=07R9phN?-h-G&V%?tIsU$s6quN-7_oHYO+OE8W!wmS1S#)WvC@j{48@67o`E zSC*h{skA~xAXPO6R_Tk%>~7ECpJ+GRM^W-pMs>4`9~|F5-5(BHTYSH=mGTnqzcTpp zTJ}%+JrM;3h22CJu^gLni}#ELg}j;xSTcd2;Sd(=3wW^~F4xjWtrV7*mk%_D?k$JV zqMc@@qMXSU*7cjYUGz`8;20J$tBgn6Uj+|QgOQZZ%I0rO%1Y7%^kUP})75d#+F^Vs zujv-9hJZDen`B6>1Y|ZYh&*N66tc6}n5?+_PhcA2I#{CnzUP@p3YPF!+_*@iQ?MYI zSL3N5bxL+tTtUN*UBp3pvxSM?&J8q}qg)~~o4dhpsn0n3L)lyN zcM*ti6_jXSmISEv7!|+3{E6j5)5_3om3*V7;NNj2Hse9NHB39Ej5_1&R0l+2*6C|9 z1hqWdnHaKlapJeFdG^a4pT)?dQS2{tB$V0)_T+X*h;tG6qm(;e%^H{DH$0*f$XVIYB4lV2u_)S4w93^;FEIq z$36Zlh>{vpE(w`jHt~lPYA3yg>-EzSxrti=3$gSU4+tF+1Ww>^@~b0Go~PaIkaYL< zP5w!OzjIUAtwp``V(FVX8MorTakMe_Kh3&*LgWeCn+)3DLbRgQmnQUo9{N{78 zF74h0Bw%zmYsV_TwW@Q!FT8SONr6Y&J-X>rtfMRaq7|Pj8|AL|+Av>{nxi02pW)yq1C@w#Y!a{l~SB%90+R z?|;io#*GBzgvaKxYwFsJJ2O&c%eeG$Mw^|Y$Exp-1s=$ItO*0$iEgQL@@w}ikk-0T zcCugX9Gap#rTPtmU3$KJtg*(Wzmi_;tN*~M`j}KM|2D*bXxhX;(=AlC7M+uRk~H<3 z4s)h5!D50pRnP@DGBvEOX$Bj7oggZSU;Odj@pf*rO8CJaMXK=6fzt41KE3mz$J-%) z*T?1rZx@u;hwg2L8g}8xA#l_?yJjsklR!R;QOVf7p*gkfkWLZW#H&`I)j0BjS#6C& z9x+FETNnC+|2qZZh=>!=%OuvVYA=QMgXQnVUE-vWoT}y}!O`$MY3zm!TWXA}1}(_O zQ-C~vUw3~3(S-*m@X)>`Y+u5k&2#t*62KWaEm$=opLFibdhR8)8;CeOZE4C@8ODa;Y9wzsB;k*eI^#~KvCO<+UI0|pE2Wj zwZt!rr;{qEMJd|79uyS7K`?NVT83Yb=O7G(p&-ClcZj;Cge8pyN6iax*|x;)?$Xt3 z9KIXSsffdkYv_YRlR%u$XX_Pn2FV=S9U4JX)q1;q4;5ieovCjbbgAvQ&mfC1i9uRo)cx7c}H~bv>=SQC|bi|u7 zO?i<;8PE}j*fWJPj%-Ga(LvGYqH~Zumv2bl@5vZ%p^&`Sj&+Pb>;T=5KC>Ga{iyRJ zl^UP5&nVFhW(4x9EH|YRGD;DAt8eB+fX;E*mZ`Sc%cA)URjpDl^RgS!JK zML(lhD{c=XX2^6F7`T_KH`lq#QU{dM!`$E0kK^_sog8@p1tr%C_4$<56CfB;QA zL2H(f*2G<~Awy;4C@=dF4zBs%ApJJA46Bh=k%e59K;K=rb4pVQl7ZBd+bK7?uG%>k z*>}`yt-~W+^erYz2F@P{Ol0&E6<##w2CnyY-P#$* zV-T^|3%S=A=2GJu#^si*py+6;w!EL5hF~! z?J=}&Sym+4;jsg@IhF4mRq$@xi%m~j8IHlfqf|camU?s>g}DpS#se6fzq4;HIwV&w z1DOJyYvp0y?cFfVlekx7nV^-Qq;Aj7L>&&Jqy`T!Rn=e!6xiLA2WQ?Zv?J+HoSXjy zr1`V!_oCmUmA1Kr^ctpEYUct;!16jroYvI^{!BKxR{QRQezNMTBv*>tsjCcLWnHkg1;{TQ2g79U? z5$n;@CcX&p1>&0M#Q7Ihh}BU=x)1Ji>_AfeF&?tx)=Rp|oOb9{VxH^TPkPVf1V&*Pk z+09xDzz*V8mpj3NT1_^tLK;_F=g^rDhjTd^c<`qqJQNNBKKd^7On0#Nm+-wX8{~h` zlv+}C&3i2R@40*0R`lySHyp26W>Dg5y>&9Xdf7bV499~pTRR5XFZLA&D~7(@1#o(f zj58S)OBmS&n*}*IYxJ~pRWBYP1r7Z>zjoF+ll_+m3WIi6hqK11#RAwgDWd3M_Lpu1 zu7@~H#GXy^z<45<21Q^G!q!%{^+^q#^WkzB4zSQaxkMZ=K2phQO*JR%v&LdaTA!78 zC6U zGf7V8;`qMIi#knJ1F+T=t zbi5mSlwrs~>^I_U+!b9lUWpe5vTS`LeNmGUw3gKy@5_5wJg4R@!3f1J3U3Q=8;fm) z{U{T;p3TO<@d@XI{JydW1YwEx{YvEl*u-4f{Y2L_cy&`Naa1^wt(VezW5>wTI=;E| z@kZaMSLg)Y`y1dfFvyO9Z5aH6S&5T2wZyEq8r{d##DtekoK1PDB%K=0d-WyM&F}p1 zfnX@D&m2FazAv*HDJ?^6%}#5Vmk*Sx)b$nLfX7r?aJM}9>!=v8T8rAdS-&w$1DF!I zyFF;S{%*e1%W_9Eb+H_~A1^b-vFvjhH(Fk2$i{9Zia*!cel%P4OW9iElP6~o;N>Yn z&1Rx#t=bd>2k%j;h?n0pDoIbQ?sTSt(&QcAOxdYeT%ZN|q#QX9D`>or_W*q%(=YqR zq%O_H*a#HO67nR;Gn_Z#+a}^S+o&s@J%lIPd!T}FGJBXtXxadGAxe^| zvnsSgN?(UhvO%29mi@)utxLn%30hOHtJlON51CsP9v?E69Fx0SRU&QpZ;mT*hk|l& z5P7P6mT_TF@P9(=j0|PiCFKDO0523~cDAD6|BpO;YF`%Fx%bLLm2?*2fv%>ZMx`1$ F`hPEImc9T0 diff --git a/ui/src/main/res/drawable-xhdpi/ic_menu_logout.png b/ui/src/main/res/drawable-xhdpi/ic_menu_logout.png deleted file mode 100644 index 2c725e32b69a56bae82740684814c7af32b9aa4c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5245 zcmb7I9&0Ua#^wnW%sw zQ_)KYtpExE|FFwv+g6zk?NtJYvZ+y<`{oKlDDL^SVHptacm6(Ly+4W(&`nX>Fuvus;N?ZoQx9MGSJzQ0=-v!Y##x-4zNeR z_ki2O!zsLJ6?$d5;O%(U*<RPEmRI2{lL@k305ojmmiA+wtZ|O-SvwdYS-SuQIwA ztDH|26jc@!8kf?K=QUQYU!er+DgkiT;^X3q-WKc+mdSZH!gt9vkoZ<34lySQQ< z(k=udVd?$6dSZvmbNd&57yIxidmMZLeY9PY``1P!@Ho4 z@$&^4?@zKX7Fk9fUfQS};5YY3fR=2pZcoOg4H{2*IG1vqDW}weMp1(-f!Cl_jKCp& zDS7KkNA4xrJiaMr=)-m`=C2=~zKw#i4tOJREyURhtDvCzar<~g@Xk|e?A2T7->D*X zX6P(LZdAD1r%vNn&xK|jal5eDCjKKHJsp@oBc&IpIPMdpa>16(kq>_yf&VW6m)Y%n zon;s_UD%RXdJir3OaM4sXfmx(>YE65p7I!nO9-2IJ#hj*Spc4fNiGo)Ab|&zt5RN8t$X(a9+XI48wi@eKHpnB_(C{vKTH4Q^>}}_Lf;uN!F?N1!FYsP_Td#w z)zY=P;qXOo$v>8zD8qWIq2mt-1U1Or-M!w;%0<*}VpWdjeHR(%zNHJSs|mO&K7WE@ z^OrvI`GquRvML#2+dFtepC`iy*yR9O&xB7larpMZ_8|#%9$Tn!2y3-jtLs{E0g7$% zlABA0P9R<);o33T9I9h*yw}9?+p$2!FSP%?G++!^8TA8y#jG(hXvVnl9U#g;vvEDy zP*^wyoCe^KgEC|ul7$+l{fl|F3Dy~6RMoVVYjT*?3U*1X*~$Z}+dbiye~W<`@2#|X zYz4v+zpndt`(GZbAE|bSEjcFpXK1^sKA=zvQ6K32OsFqUuc#;h2tRRO47ulQHL z20iLST{XazH1KH=FwBMv;x7UxKyb30)Y3LgT*W=#f07bH%bEORiC>1wHyzeWk@(Df zN01iE<0Su<`R!94{kI5V5aPBRaObw%?&)~7+F@9o_2Ww^v0&$+Vqv+ZeXvVU6u8mz z@yq<|OK>i@Wyq3qccsfuP{BBk+CPJcQdda^gZ#vzl*y97;rSS|i!{=m=vO2v{#P}Y zCDFnx^iIJ%dHQ}^M^q~JH$U_peNVct?bFi?#TKWJ$i0`p=sxBuoL+Rm2sf?9~G;7G0Q*qgaR3DoKjrY;M0GzJ0^e|au$E}`Xyf^ zENmlixS*QD3<8dzRPvAsOmS_@DU1(u>G5x3=U!lOdBqth1{7eCwaagN5I`+6z@PjO zw3yI;k><8yrrPd+_PnV?7h+U;Xs#~`6r-!Pz|O*$lF%SF`EcVfaMx!JxHj3`-eUV& zv8IYDHTtNPj7cg6n#oyc+;?`XSE7|Y(4Go-^3caP}TMOYZG-svTKHF@3BVv=@o5)jgMP} zp+Ox7NIxF7jR!#9vWB;@yf^!tfAQb5w_U0twqMETwEBtZPY(=pEEPgyBLOp*iDL2j zRlI$%BUv#?Z_>=O*PO^h-f5{HM|#g%+`F1(V=q;cVActuNM&u-#jfI5r%fUXPNxYG z)W?OTHjjv$M_}_i48e?}2JUS4m-mwD7uJFti}WvLw;O~cw66HYGKpq$?N(BQ{4BK4 z7r9el)t7l&3|QGJ^@JeUuF{Efrid--4reK7)cl?{Pm7{w|9cff2Ekvt`juXCV+JYU z#gd0M+(9r)=Y~%e$#8PzWhO&eywAGQ{cgV2!dCSALHFHln2M30le7?&tbT-usR$b5 zU4c|)H>1E3+22q$tLHVBvjT_{uq!WJr$8EWN-B1Ll^mQCZ7j+}0k1!X?pRA-ZY1G9 zX3Ot~L9Q?nuFg4o=qRq6w(cq z5~DA2xYu$_j1U)-knnypflcP4W@Cikgli+HBQ^TAkl5f$3#zA&&REu;V_3K66omM1 za2E&Cf_78ilw!-ZZf@cw7js)VvCZ>D4pPeG9<2dBMjo!c%6*t`(nq;eFbyml{yFpf zDKfph#L_-Di{>YZ&}~fF>yi~39^m%~^1y`9@+yi|m8tkNiVrc13-yb;zTuq2fHaBeyYnY}YO`gkCo1p~3bLAC|>@~=)> zo}~+#2UL`3WK0R@foc~6t%Ic-AU~aWapw%Ln}Et!E>SRzm`^X=uIWd6W8K?r)UGqT z)PpdNPelqMBO!a9$C2V2JZ4<<4E$Kat!BuSxdCK@kae|cD2eOt#iZEpPiF5}WS+E9 zP`MUSJa~9vRPzX7`op$S)uvAyex|3-xI-+tX!Zqc^1WT(c}s0>Djjxn{uV&wUwvd- zedH*&S*S)RVl(;%ueAj$#*3kg253wuOCHz^RdW4$_8126sK*;}Hb>1dS|D)8XkAA0 z7Ar13P1bhbFhottXac5}NLW@JIZBrA_HuH#YDfh+7A0fOUDGjO6akjCfpB$FHOxLm zpMkRt-hr3{uxp^6njOjqyfK#RCv252uV67r6$HJ!ta(jlE#A;W_2mb()In0DOj4p{ zxP-Coqd}J3_~P@pk|8Ak=Pt8^vvF5J<)Cy+KX`S9Nas!tbUiWozC~34<w{n!Lh4&GwQFJRaiO z0hW=9Q5-}lr$w}Ilu*hm)Z~b8PPum<*HmDqdR%)ASXRd7WD=mmZx~x zsTXh-{mgvV^|6(SKI zu_If{vX_x2^?CglKalh*`$ZG~2{J;oLqgsPO*~Xy?AA-+I4w!n*fX{`Y1wS)Tt)BItQx&6mO_SAF;>%nBumr>m9?g41 z_ojP$x@25<)Rcxnf*DAp$d*R~+sSzMZJbSY|+Wzq(3lSLlJpE=c9&6b`@e9 z)K@g)Q!`Hg&Kc3(c1MsIxGt#xUbHjq@H{!aLfmQLLkd8gveJP^25Nf;wcp$Cx>ym( zJmEKLt^_~3TYa)CJIGVfN>2(*dYaK@ix1R(airiOYzASEj@pMWHe2hmA|!`Bin5-?RyzCtIP-T8fV+zt=%d%`RT= z%DPqZ0t!h@^benTpar_c{u*a6YYdq^g-ib;Wp$o;R6$F#{8E|{1WTQ{E*vHNEBCOd zycQ8_Cwud8nbTu{UACEi%2XcYqIuSQps;Gk0Qc|-vl$!vQXX{`NH@vqfll_2*9rdKx;Xo0&?D8g zEM|+>z4HoSuB%UK(4LnDc9R7^Fm(rLH(yZL7|Ar4;v2&{>zbHofhC_u@@@!aHdn)E z7egpkV$mdvpc6BFI2V*V-+4dL6;Iu`uL7fzDf5234rB@W{ncR;h}SQeNC&0n`9}bW zyUQn;fNDaP1T!H^3K)*dw8^A5vKhYzz3`%P4>R^I#^R6h;@IYIx1$EQhcE8M{35cc zCh4uex_6pkrBU$GZM6!AG!~>E_~pr;I;--uAwKbTk9}E{ZU!pdF-~A{PLdOG;hWRoR&&`qp0^-mvcYcXPOwZgI}D` zs$^IJ*6ieYos9esY!>SFEhgGRn>vKzyJ;m|&4+RjF_T`V2cbvUHc)v>D z7+g@&KK2I3?kagZdkQc7H{&s-6a?!ty%m~26Ou%~{*8@2%e(Se&T;v0r)e=nryF;& z%naaLomfsTah@S?U8d0?kE+6(-~1-t@zj0tyYPqLg9El>1{?vq7LF6SP9aVyt*d9A z1edM?|E(daZ)or|ct_L0hMEO?XGPtoeIt})MQ`zEK1m>4SL5_xOCV&B5n#ySX+ zwlmY=qr4vH=h3w*mnP-ZGtq8L{XC>PV#e8jW~gYvo3h1YIY4qY_<}@{ihlYjcO^v| zo882Yl_tU^aY;w-Pk785czBiMO<8Ad);|&n!%DeHfVcaHX`WTAl6fjlUcqTL^uty( z`3H8w-As18#lT_z!wVpARzaW=pRtoUMib|vi_mCY7U0pj?W zqFrRUD|(sKQrp7@h19t+Mj3eTj|@Lm}&W+Rn0M3t?!LB*n_t-83hB{934|-nZ?j^k^G2s3l_`UGozl8}+rQQ{ippj_rhnd9zT}3)h_IPu&Ir<%|#+S}&I+_oqgdWr} zw=rrwL%$n)D?s6qmM+Z>;H{)ls$>tnLdS}# zT5tGLFVjSSDjxyI6W|xHKi?cMk-h5D(>V}EkHunz844fg<~m&onE568^6O7o3JN*8 zTeJJE5!gn`Y5eO^2eywm`sFXSqLH6AeC^ryFYV#Slik51IZ9;D!oK;_s3G7*H9wn` zlGr1eM&suKwS6-qBaE)`t;Lo>Z3VzLSR5A?^*C2FhA`_vigsyQ(pV!*&>DK?tv(bP zGD4fr1-B%Zv`1eKiz!BA~#o4ojGo zk*RbVA`YerX}{U~H39d{_LYm>(!wp%j6pVXN=iz0hSuY)6^rmk*juQ?RS*Va4(aL^jNxPBHZ<%W z%7ES;FVX*}`4XwUbtXhfg{3wX!0<@c_1stVrCFzdw~sef(}i_A!l&@Idf?ammyxiR zpoJC=s{UB>O|w4NPr)w|OQa^H4xPl6(~F@dY0=hQ^R@2n`|kB-tU$WcW2&cnGisVE zOV+W2A#lvE_M=h?-}qlC>>)ouVU8F@H9;Sf>j%eAb?WpP3!Le%2ugw#zx+y&gQGnIsxzigNflP}!1+nO@S$pEc-wDsw z+Q*BuLu97$^6EZFq#i6Pq(nEWg@bEC2x$gXo-m|uH`JTo6RccU&_1%6y8H-kK%3+D zbZf1@H)lgo^oqN`8#e+aCHl8c;wM8{`@YRz1$Qs4r6%+PC-tGMHAUoy0QN<+ARAN|OK`zoCf2Z3sY(7(yof?Ge~p8!NC+ zzVD$KwhZfhQs%^+$g0^V;`LNj)GL{AhM7?7u@+=2CtQP~QAiHvwj6v_C9spEE-7LX z#r|*aPHXUDEM&+F{&08TIb_iO>^{R~aP89TBRV<{Lzii0);3emxZ>jC9m|h+w|*{* zXOH^IX)UF_slJ#YJm9Vv$S-ZfH!3i-3FWX^RaJ2+9qqidmb5y`w zcEuzyr1$Cf1NT&=)@vAZ3|9g>$TSB4ldlJ{GE#T`GBzP!iy8HZSZ*C8|E}C*TV$U->R@ zOeQJ0HnD#4@CW5jLj2=E5$R#oZ0!Md?n5hihWfT z9b%HS9nHL%kZ)I&pHQ@G;Uoxc^d`-SiB zBI?73sW(bGFH+nP{(T&S?3AQKogV$Zxj_z0T=U2)&p9L?*@>V-$M|(0{(6DcX_c6r zgLl{8dY6xziBi`62}c)3C~)3WPgOgMU~bIy5xrJ@KN~@r3E-8#0dgaF5W_$j&nBn9 z;x$sqWW>?IEaFHcr;@{yO3RX~a=Tc%u2|;JRP=^Hxu6)s^=T?)s1oxS?!fJ&B(++7 z3+Zvqv@fT>pkHfrIz6!#crSY-ND^>xKxdzRGa@e~Zz}hrgnjJXmw@P;lsx#YAA5c` z8Vr1M)1q0Ev{_#ITYExb_eGJH*Q%q}(liz$KDo4) zj7+gW&XWO!9qr_+(aD+Pxq2~2>Pu|7i>GfM17@OTB=qzE7@ik^PvgZB77En z`^Xz}Gv|wBZ~mffV$q;~?1RV6ivT{VjvH(DS$e}6d3E*?_B}!#ngg#XMU6d{IT8cd(49F z|1Ts`Huxr~Ks!w4ehOk|Rc3I{NaW{D*ZO90FM15_($*mz^9NH_%yr%mY?G=Pw=9Q7 zJJ^2y<|r-EGtZU}EB6|7zZ=jLrhP!qQ&Hjy%o?)brG8ZB?{@ZUnQB$Vm(P=imAvSO zV&5_xF{4(wFrr{Vrn`rt49U`g)wi<@Hk-&j2`p5xi1d0V>2lk2R!;hTO-I`hidPJf z|D&^+0RIA09WmtW?e2OMrilMb)QzQjq+V`mwu*?47d8k1^@jDCV^u3 z>yn}(Vpf25()%5FTu0v8>k zI=Fs~&7D8cl3G=C-sAigal}}l|vlVl`TnoNMQoMLIaKXNtQGR3Mm2InO_0Q?& zQj(sbX-aqKNwVeK->R`7Lsy7uPC`I~RWkO5yOW|pa-i5LBW6ZyxFmS7S!9R z%-ZG0DLR5$+J4T4JpxI>#dV0OXd=zm&ZW_<`j6+ZTRP|-dHT zv1!Z|Uh)Xk8(du0^eJWQjNHSlj}X8yJUAFrhpez({*dS-zF4VWkM%0jp7c#7gA5() zI}I7j4Y?h)P{zUKO|}$|COXsCFsP2Dy`rlu%K|x+7i;LJn#$zae9C~={8wtYCG9UXT6*ajU;+ diff --git a/ui/src/main/res/drawable-xhdpi/ic_menu_server_profile.png b/ui/src/main/res/drawable-xhdpi/ic_menu_server_profile.png deleted file mode 100644 index 6f4c4739ec0889b4b650e10e00d2b6fd223791a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 410 zcmV;L0cHM)P)zu1g2E2`>j-XuY~TnTfeq@B)Wq;3)Lv`pz2w3VgnPYr?`T6TrHp*WF7h17lAF4& zJHe&0n3sUK)O9`nOaPK^;KCg&ZVs_GAtCNa9l5H!*FBJJzKO$dp&44ldwp&O(IXsdhy5B7=z18G8G`SK#^$6tv+Ye%0*MH#?Fgj#wrXx;=wOoNN2(2-vpPRarWtz9a3HU zlhn7KLhz=c%+3OUi@cofP#LdC*wpIxp~JR0@U;saUp^ugL(h@3(?mIYvAs`_NCUv( zIF1bi!jGIZK3Pzvu0SB0^*xuV)gCmq))=rBg5(EGpJNpcB078z^0w`MPXVA55tMPF zOkD;r&-tFksO=L|tr4~K0syLou-6Nqh#VA)!+F_e?{NstSIa8GwBfY5aGp#i$%)e;+P-F(s#Gd8R~M^G2CV zmeyc|NdpPf$F}W4>~lQcXp~uxWjaUWpaF;$z)4T#3mAm8RK`^64;tHR1WD5jqc6v|YL3sf0F-@2_=)keS7e>9p`k};K zeND00J*c^#OBF!=3-}-axx^K-%-ivb&vCA8Tg9Y4RLtr_#b^W%iaNuBJh!>Tvj>!3w!6-NQ>SR^kc(Az0^=8~A7Kwtu`pvDxT4tMr@k`p6W)8p zJsxRBOT{!$F-xrnKGdY}Jp`!DZ9PJgFe+vb!iokE9!HzUx6a}0qX$28gXU~oZoO_F z&pxx0Q0#H2SifT(Smry4l?KSXx0I9a@498)ZG+?TkmKFLsmcYc8^EbZ4ZUb#71B47 zJ~lE>eR_c8d0r0|%=o;R$=;PG&J$kF_^X(%;#4eZ`|en5o4rRVg@E@|vMV@axA-K#>Zvxj$b9$x2FkaeTJ z=NzN$Id_>u0(RTht0h~F+I+SGX~Y~(9n0`9hEYRZMWPO$+VoNG7$nue*rWRVFM>fD z%DPkCV~U~@6I4ZmMAQB3-!fE|ePb&>eMC~v=hgvEXBw3l5>XgQaU9F5F1ZT)in|a=D0$Iq|qzcI;7kA*B#;o27_18joB0 z_3QVSJpqc+-uUEuw|ru0^%rsUOh;*Tm<=LmNO^XOSlsUiq(}Gegdyqht-SiM4G=Gu zMkX(GJUkqBgJ``}-+aPS9%|}wt62Dk%Td|@2`jv;luSd-3G@ia9>^7Jui)x5EO*#R z>tHR`U#!^4Y3)0+QDf_Ke9J+H)WIgRjfrzyViN;E?klvgB>Jsh-dtsiFNrlogezE1xZqW4=yO1tH>BM3qM(fB?Q-m(K+#pp z(7!P1j$Z3zG`8r2e8>Wj5(EYRaG1?eI1op4C_v};Vd1~JJtG3r$;(ig?iiK3X9 zxGiL|voP&uIYG(;P}d=b%CVInt!aqKGqoN9pR58fE7Z_da4~`bVCdCdf)5BVTE-`+ zLCb;%F0LhiKWNA@p8%8ql(Yn(1fT?<1fb*6{uf{Xd#9ip<~U>B00000NkvXXu0mjf DC~z8+ diff --git a/ui/src/main/res/drawable-xhdpi/ic_type_folder.png b/ui/src/main/res/drawable-xhdpi/ic_type_folder.png deleted file mode 100644 index 79aadee5aebf78ffc960762e69b8b19122ddca41..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1237 zcmV;`1S5^((XBc-{-YxK?UScAtHwy3gpjd?^6_eE8Mz0G+$^$+gn_^6JcM z7of6y7F@sl!ap3!z18ma-iGqhnaKengP`;xeCx{R7k~fu%jg(@bZ-{C#2m+kU}n*{Ciy;2QbB-m zXQi{fb&X!G9T|}B#{}JU zhDz+2N8o(ogYJJbT|uZKZ4`vEpEfZSkd~QCEKv}c7{uA-m2Rabid#RfM?Dvl!@X!` zlZ4XBOcYVZA*y(Vb1sBgOKgw>7!?^ubGTYPVw3|&v<6mR#7^ooj9e05RJeGi~QF6eRl!QtXUOOF7OGQz6EKT!>ht^{IDiX124gv4hVh$j3uqG*}!75qQqjgv&AV{`=C{Rm2R)28A zFke9^H>hZB&?5yY9>-u1)BjJz&7f)e)2Y=hwZg&Y}za_PTBN=$zu(0N%wU3VmXzStndc3oJQ#@}+CZh(^f<1|c6;M5pou`+x zI5_s}aq@@#VgU=t0vVgdbzXcco1f7&$P585~00000NkvXXu0mjf<-SPq diff --git a/ui/src/main/res/drawable-xhdpi/ic_type_html.png b/ui/src/main/res/drawable-xhdpi/ic_type_html.png deleted file mode 100644 index d9cd39992e404b3a4bf4a29a70f1ffbd5dd0d5c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1877 zcmV-b2demqP)$8-+4V_dOiYLgm}uyWlB$W92Yle6twAN4NMZ~iA!!NvLZZY66B8epzL|(- ziBCo@RRcy6vDnMrX6E?+XS>tc?rnCN=}wn9u$}H)&iUs%-+wv(`AZpNBxtpp5I_(B z6aeI9lbqhT^_fv7MSF>$gxW4NGxUjT7mtrW{Pd9&p)~%-cW0*B4iJLVvn@fC*v7U4 zWMt?0Q4B?isDvhWz4Si$^^0RuZ3Re>LmZs&z}B_{q%Yhn$|NZ;aqCEAAU?V0wX@`x zQ?I%XQj<1_@&E1rEQcn7D8a-Hkm%+|0Hn`H+6d4RIKDuryirjmDzH1cdAI8ztx+$= zRvZx|iKx8;9He0vL0Xe4#wu_soAbT>;5C zKzx>%PizpYJ88=x-9M9>W>5*Ic77^sQI&gW8Azu`Rs|sD7xt8)RQtXXNYPCkq_$aV-3mC zS|?AsyP8L#7-K$Bv(*zq^0RPt49eleJ6|RjZvRG%>|Bc^Wa*pVeDb!t0M)VqtDPs7 zVk zlZ>?MD(0U+(U&%eRm*k;4C-74xgIED$q80flnMvddNcLhjH5+OP@~u&a}Yof02Bb^ zi$HN`-@zCWgapsS5IS>9yHH`|hV~yy;YJ;ybQZ3s;d=~zFFr$QBd5aq9NPaP+%Ld$ zf|ZWHb@_s}VjS$V>OD^6^d^#~LP834UzWT3Fj+MLXT~e&sDv-$2A!y=DC|@4Jt2rP zf2L9KC({eOPcalZDTTXJ@ZkwDY}*eU-FE%!kE|CJWc8BV-5-}iUGT+H0_s#wPXK~h zB{*nw(=J{cShcfIltc%25V>oe^<9LQz-LP5YBeLfP<$rROG5pdNqGGhLM54>E6m+Z z!C?x2AKZ5^uJ&$-<2Y*UAv-{h<@AU_6lade(RKV-^%ha))vzcawwZ4~(}-=~>hYr& zQzEboL8DZd_~BS`ymBH$g6!d}lhj!_6@z>C+5kx4^T<@CcLQ9fv1aA;*hn{srt9pT z-Me;$EdF(!v&AfAs|RrWe6bH^8k(u+5ww&guqY=*H45xfX5o4oufwr+R9#wk zMPGk8lKba2Da_vmdy~h=yjH|+E&Sl+uP)U@Cmws_9A^rZRj^OMKv7H^`7AN>830Ic zQch3O9c=k06%G#{Ih9=e`vx&`3)UT2i-T&$>H=7TkTsYKhFde5o}C{9qe}!ent;=q zD2KR;Q9`GIiAhvoT4rmUjp0c?sI;8NjXNc_F)k=7%<}RE98w>v-|JJG)m1}#so$03 z&uPP>XV4abJyB9S4~-KM*dwYDu6}yvza+OaVbEP7Na3C&dO}!aa^njVlh!kH#TQ^Lj^Qdm_R21!F#Y3u&sKP# z;nCA$p}tMEy@!2Qq=p(Yd-4g5c0Q{a*~NquiKUdD^?XMZ)Hwaq2hY#$dig^FDpwAK zgE2fY(#)m;=sBvj%$?u4O=9(4zLDUpR9?3P5EyD53lx|MAw(>JECS}Hi{NEAgYDxv z8p9hmU({><&orwCd%4A$-l?Jw#vCQH0H8Dv3!q}U*6j5KMm zdB|)kavy!zT=ey?PNcUVcz2c+au6_r%K{r`W*4*)Ks7fKxTzElKl;k2$;CT2tw`Ov zY?|l){QlgO`(BLH^FYMG-dTe_s;~%{nKlZU6si+O+CQH-z*USD@-@<@rQ*#cZwq#6 zWw{I3wrQ7*G@Aj>F@ZC|q`X%37E_-fAK#)XCrguQ2u9pFK zT=9YzYq5^P$CDyX^1v~ug}+(t6au+k#Q8uHC|IlpON{`a0HC(E{{fB36(75+r5@IfupqgQ`DTCfJ$~OeBkFk`Nm}*J= zB>*J=B>*J=UC_qbe@wpr#~CUsMM=>Jl`bZB9_No2|M~ao-fz0cq$l71c$OKNifWD# zbvR2Trd~*ZxMLH0`(@$jSASVJq(PuHpXu2tGBkOYC;$+Za zp&7i@IC5@h>FK!x$bdj(T%HKzO4tE5-u}@&0`fqhb=PgFNF`SGxFf>pX*CyI1m|ub zH_?GEdwq_u_j~B|Ov;p!Hj*nDxv3JWHf1c>vjaJTjQxm-d3{YRT6Ci(gw2X(j^|V3 zH;FoQx!BxVBlVyEGuPZ)1;=lnMncj5T{}DJZd%fQJ;=E>a8#|LUwSK_nYcsr+!T<| z6k!>&2+#eCbGzKyS_gA;PX{Ct2A}{ws1xGdZl{#aNUHt_!AVcNL-Z@tgh6NpvPD>G zgru%qFQNYe>QJ_KUSX1Wg4hIj*Fly$s3hfOE&asEP3JRHcZtykj(=T-P-g8Gv$L~oi+iEo)+L_Cf@BuHZ{n%N8WP= zdtHMUE6TeGDMgkxOR2FNK;dtJR*W6wIYHDI?nN2^IbH>hLSy4+3-i4o z&+f?vknzWFTAQnLb`6}qWA_PQp~Jj)@L&jlaQ0Yw1f8wOZ-5L6(+SI)WJM$T<%v9K z(Ibz$h33XDgo8Hp1V>g%N@lc}8oLgGU}HJyl(dyS3dDhHo-Xj~z95bKmsUq+gf~JL)NWa(?LyZVE$rvKW*!54qk9@~nyKHZ70FiW&e43y+^C&wl zWFt5zo9@fT?<|!8kY;8i#wrjf3XS#WKq2aFPT7l~K>;o7&L2JpVrLeGLms;YgE9Tk z9Ao_q`%_R8#&48xm7&gg*{*GxlFV?`MdWnA#Cyn=1ijF+QwZo2@J(}#wdZALcN;)* z!&q4OC?;4isI(4YTrgldm=di33FM^5Z&bRAj|XcOx0U{wt(-@?_DER6c1gGl$J!v>zF8wDyd-+A$@)oPHROU zLs`PJ4TAoRpf3u|gS^*9*^6C@j``8=gD$cob&%QNafDBxMNTM#M!9>TKOB<|7UmBW z$UAo{8)D3Z5A$9qqIJd~3Q$5mPM8lFeY&PFtgCwSl6vJQBKEIn6FkOPwBmPtaQwyqUL?&;> z9wIMnJxClp`R|`@PTC@zn}U9~?T<+S+EXCcS>SH#L)`UnVK;E@r+WPHL1pQ6<4)_L zUE8w6c9x601<&&=ZZ{t8JM?z4bmQKqGwG|hins%d$}CFv(~_)+HLBBEN`~3TwXq+0 z#9bq}SK!+(e!tiepeXImN1wNc&smlpt>7A!C~BQTbDMQs%~)`7Z7cv+gUldIE*8G+ zJpcXxAX%vz*$Gi}_t)c31)ys4p-TE4P%In&&2>x`zSeX6)v~7))s_jiIV0C zq2qCsiL!AFVl3hIE1rY~p$}*^Nz;09ulZ`ZDh7HIlmSc&WT8xyEyfU6lVVjMp+qim zb}VamWwFp$U-CiXZL0`zADp8Ml!Y=;w!i1mi$#Hs4^StW=zp4D$PhZ;g zEwR4dUX+XDfIhKrl!3BPrjQ+FL-2{2*gj}Bni_!g%MTCgFP>d*Su17KrZ~3PK_A!` z_KAI?43s5g#%<6n9yq$3g#ouVSI}uLwzk&ifIvP}hO-|sJ@bL2XtQDwFenx9yamvX zuesfP>@;>3?X7hHWrf%~8$|4Fblrih@*bN>kG=One<9T0k0|RIu|mo+qv8{O&q|7( zmt!d8 diff --git a/ui/src/main/res/drawable-xhdpi/ic_type_pdf.png b/ui/src/main/res/drawable-xhdpi/ic_type_pdf.png deleted file mode 100644 index f8381530cbb975036c31f483d9dced7e57020dec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1672 zcmV;326y?1P)zUtv-~apOVN3`?{3w42903Q! z0X6fGYCUn^@l!-{bR$8rw!P6rO9vOOeja%2`FDI6WAD}t*xKDQ3n9ve6ts(ZQeL=2tpmjF z5;2Jek%~9XfCS+-G%*uusR!jawewM=MWxQcIwS{#+tB#dAqn*bmr1;*fKr9?z>{c! z>!6-AekIgoK*U7RMGSAQR((+6mY64P4U$k#Xqko(+2lP{v=K8;%4*X1bf|e6WRkfx zvW13VLDYqN4?sFyJEZzT3=y-bbX}PP;|1Vk z-6ZLhSv;u1bVJJ>NP>~O3(0n8(=}15H?qvJjD}g-rt?6!$)69N# z78f!hAVLbpK^#yyAKGC{`SquH?m?Byd#*th8F7)`7KNfI0g+O(og5JNpxQl1O9$z$ zirmJ5opNBlN3qJx0Y|_AaX=;-i0koJbJ7Y+eT! z+uWOVK6}xKoZ384Iwt1y%HxjM(;x{uI+CTE4swHA0OFvxFL1DowSv%+D&fbz6 zLl2C8iZaR7sq|WG;?7UsvUhu*efQFd-!7k;qagyXvkg!12wwYSI8bP#Ov)X-CnQ^!m+oYRm-P*r5LV^v z%rDY(?My3NW%%{nXgIcXE4Uv0OW$zm?DMjIN{UgTXHtnGn;T!A7)h+$iC_R?aSi&P ze(R!hb7jBT&g6iy!;nm-=$*CY2wMN=0qc+;S@aJESh-~+sM1SbF@FE{SIK`@n2plC zTL+7Us&=LfvHY@qVP)<HD_0pUFYJ=NGlE5BVc~s5P6p8kfZ~ z>7cg0iePXVsZp;YkmZ8ZV+0U%%)YVHtwY9`W+CFfZBQdFTel;v^?`^ St4JLH0000EV7zQwWA1%CH}=efV)fjwP3rSQ>~d zPt2e#qqS&M4_7Ut@ev{NI;GY+H4Ol21#av4&&B&jio&)_&b7l zXgb7_Gic(ph~F;OI+jEQSdwxUn1*!XWh{4v#epIS1j!p9rjuyrbz)429+^^id<-N7 zEots@7QaJ~=wj_vc#zJ71@*?H0ZR%A(%Awi0+7xgK!QP1ynUT^{JcK~t$uQo#YVXE z^-s}Uqofp+SZayUHjx#FxY%Vfr}5ci5&?3rwzaWhR7?2L6a&z448(ujlG>fW)}qOQ zVkuPcZ*dhbdU!3b(Fx0f`GYFzqoT3bYcxC`nca;|uKp#ASSr zO=2wLAW;N~wn2)_#aL&uoH~63hk)zZdG?moIrj1SeMlDrZxcR&Y>ek&rcp4e`vuJ8 zL9XlvYr$-Rq{YOf8cr;MgZqjH(db<4F1lD=LgpFB&N~cdHS17&y#dX`9bTFVTzEr} zBGW;?eD+>}y}tYDcM;WmVg)TTpVwKSR&~2Zy06C5`$lROtX2c4(ZW%-g4-cAAK=SM zq)NK<^p9v*EItD)!l?*?9Uvr#g*Xy~n$DpG8zc8&Hfn3(UCib9;M*cCZTtyJG7}9z zC=MAggb)Yo(pV)Cw3+jv`tYOSe3m-~T};6lPG7qPiA!%sm1;1p#nXjB3Mc&cu!Tb& z-@>IDz4gTYK@yxr6*YxA7S5t4*6ws&Oo)=Ebh0Xn;_^K~xtJ5pfBrs?p0~gF;Z$IO z0iP;~Og|%r2M9cs^zOr7PX$0My!T%u@z#zs2GqD72n=vYgg715I=t%Vo~K{!gZD0jz2Vz zhlMS7oXwhluw->g^M0bwWUbAQQ%R4kgQgbb6{SUw)ik~`8`Xl@sNnlf;3p(6Yw@BS zPx(qLN3kIRF$l(DL99Ah-+m6&*H6H#S3B9Z$~SK%F5d(xsoKZ()H00+)Mx~4ZlJv>SeK+@t6Yc-upzE4}_y+UJe6VUR!FElZ; z6w6&@uOfva9h-|e_vPL{rB>Fc9p>xX&k$Je^(`%Xk&9X-krwG=IY;bUn z^b2noEvJ3|1odn0J&Z+d$?~A6V{JD}J5c%WZ)lahi*~G{$l?_%(+CubwC^$OjDZ>U z_&dMtfJ;00d7-m$+?OTLp0)%gs}oK0SrmTx)RlL@#5Bdz#bOCyIi28okPo3qhq!YP zb>P;H8_VNE*3;-V3BN%ac#sw@6uoxZ_x(m~{v9C6b!x{Ri|p5oT8IR#YWB7h9w0xt zSTObp&SFst)v!YG*a+N(8tquvz$EuB8Clkf)v7;eZ@B8ZgQTcM#wtWn9ouOOMVD#< zY9PyK-ZPQnIa_+A8a;gp%;p8nlhNF0?7v!V?7if5pW_5FISYKBPii)Jo0hrXD(|kc z8d9(Ra!po8>`SnVIlBiFlLiX9`qncr>g7H$sn1=+cUfQU^c#?wH5-*Y0*^Xq*9V{m z=($T`bFraP-|mNwf7cDLY=Gzzed!2VR@>$JZY{7AgmeEGo)=g-mTl{08NH_krPyYB z%@(B3whjVT3t|;VpE0OkMT^lvKGwzD&ar<#>N!JiR?&hN^F>>b+YYn-L}0kIAN?Ha z*?%~aKf^9|RPJEOvY#7X2$Aw!R61-56_CyQAhGC3(2;N$IIP^kZb)JJ$}qS@$W`GhbY<`vc|RoON0F*D>8boynF;LAA6Ma%sj}f z+@Z%s)4Yf2Dq3Dk=ko39Voyaeo<5$fQO{{J)vR0HIgj8{9;j8#$2e71xsM>5_h2ze zQuvN{ULfm<1?~MfZQU{QIjk^`af96{IG}@w3|cA&@>Sgz%@YKf-NiV59mFnzUBEE9 z6?Km7d}e)pF(rb--$wE=EIpqL5l%OfM{7aR*JDoHhNc!2tp!c@C<2-OFL+ZI3w8W2 ZzyO|6L}ZBrs4V~h002ovPDHLkV1mpq5%>TA diff --git a/ui/src/main/res/drawable-xhdpi/ic_type_server_profile.png b/ui/src/main/res/drawable-xhdpi/ic_type_server_profile.png deleted file mode 100644 index 292b607693f8444f8e41fe8f00645447f95c971a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2031 zcmVCcd;pqY>f*g;zCw(8MPbioWnfefFV!@<9?^h#D|z zOOXHmY`fd;?##|y&z)Zs_IAnRCwfedpd8jt~OvvH9TI4r1V- zfrIa+c~L$qsF6`Y4ktK42=YBtJ&#>wxCPX9w*QZ9$K?Mg%k_JZ2k59lo5c#I&9 zgMfMnh-rY5=uJq`r6+sKMUw25JNHG1TnbIv2uj7Y^1iL&FL4< zOpY>(AYPJ(Bupu(V;k_Y3dHhDixhdZmD-H958>Y?nM4pLNPvZzrdhC~<_Xbc+0H70 zI2x{;fDePSa=RsA8=O5@9@?YrAU8wwWEDbYO+%kB^%8(-2ISH6N3hZRz= z5f#)TWJ3)iMtN4xEsPcCZ-Y_F`|5{lUmdrd-~aKYVKvpCmSd?371?kPj2uLu>Kg*< z8MtYbLCej<%AFgOu?8Z5s4W!M#c&4(ld#S|qzNg8uA_9mT*yOtWhoF2qP9?*-10Qh zsUtRCTg^9BV?4oDW;Lj$4z17YAkw18HNhtbZ9WnxSVwqN^-h_p+p+V|`?m9PM|Xnb z-M3*HNHM4jTaM?4#BgjX)V&L&Xd)Q=1&cG%ou| zR5vPN%eM8lvPH2?co0=MG`0LrFK2c)#)H~YqwOHSwHUEUF=9>|rPTxFLJnEAzcuK} z`PXdcUpn{Wlo*PQRO^sWQiH7FSM{f=)X<^0bRSl3{|S12!RKde@1Uib3`F|(fSTF? zlzyzghi0gGFp4WsTD%L|(t|*x2DJsns_VvHV@#UZF=;z=Ycg_eW-D_owwZ&12=D$n z2yB^jTddl!=nd=?V2GF0DJh!t-9NkEIB7dC#gf#fwW{D3ldjWaRiz;$q+0 zS|JeeBgi2@n<~4$E}oj`DsmqQ4Gu&#jz)!pQ;X;p6)&!BQ8k=l9>Kh|Uq%g*|L0Pp z7CM`Bk+OD7&o6RX_Wp(P>M{_+pt~tqQ!DP*mgkbl#WIwaA%nGFgO!8G21ebyKYB5L zfi~rrW`3PmeK?DCZxu{pW_~*Ta^~l;L)qoot3MR8_rO4gZ}d6fMI&gVw<)K~{lZixM%MfJon-O6|aZLl0Wi z*~vPB?1-ZO&?10jbO%)k#W&8^*hzfRVk}Y&i!4S&mUywZ&v9vv16l8j z0UQ6Ax^_y-EleAQWh-@_c3k`Vy}G#mcS*gHehRQ-?A}kG}j6OqUMQbMs&%d)6Y+M-;PYmd)u7 zk1FpGRNo^4Jvm!`ddV{IYW?vSQH>3Aq5=f#5An4~Z?-q@g?l9VsFLght3~0U2HCHr z06iDPqgbuCvqe#iI!5i>4su7A`?WdV;zqnE`b-qpN0G-7gvpS>N1o+D@?fzF%&!q4 zKZ#=FqHjx>FPBcCwwksMJ~>FS-@f^vZtnRHza0}J6y`hXV4gJT_=|g(*9r*nx1czW zFt2MaVg3&Y^)v(K84^WOHo#cTA_MgUs}u|zTDsM6VsDqQgf=Hu1lzkU+MM-<3=qDYCIlGtt? z#PT2-tpil_@|P&G9T)Jr>Csxlc#U|mP+(Hb)C&`(?EUF-e$i2iUB7s`Zf@W4@iDqj zCu20$pL+A7<;s94nh5iyg*#A0s5i^*V1DK9Ul5^fSK2(QE%>dPVzg0aYDKUPVYzgW zQOsK%0Wa!g13hUr5mbSBWrXfhIC0R91Mk?wydYOzo%6jX4ZuWda1`c~y_I)i-NHPk z72THyg!x)KTUKgNHLoNQ=HuI313(q#oe)ls)jY7+7JCfy?$@rsJb8j#YB`wK3KQDW zgK6C%%-{I_v%0yx$G#YoW2q7P3VVGNwP=b_fl3cvQbkW(qS)%azbiKvwt;!(YMv2_ z(Ws#<4}-$I%XWuR$Xk@b+GFz@#aIoF7sf?3mX%^DM=)>Kw3njEbmf~O?q4Km>>xP< zv5F`*q;&RMuQ9oWd5U0Sq@xL9m5|J%LrGr4Jk|>OsT~sQ^e7^EuzjJ9-h-2MoO<+` zw?3VT?tCsy`z-*i_Wcerd*%G=>^_e}hrY6SSkEtHD{awM`hEwYHXn8ziH+2f!8boj zhk6FjDjnUUysWIf8_EUNF<8?kO|5k9m(Smx^~FK|r_pxM7UMqw1^|-Dai6F$cUk}d N002ovPDHLkV1lqm-k1OY diff --git a/ui/src/main/res/drawable-xhdpi/ic_type_text.png b/ui/src/main/res/drawable-xhdpi/ic_type_text.png deleted file mode 100644 index f8b8aac8d2dc3ce8184bb4e0fe3985dad177a2d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1534 zcmVd$CyH0!q#K4)nvjn;^mon(GCaW0)=Qd<-y_srI+CnghcKi%%lvb$gY`b>zDRrz0 z^<2Q$CH|Xw-76xiJ4$Y{AnQ2*5@LO*S8~mI(WxJS=i2AqB+EpW4MJp`S}G7lTas0M z1%KmfIa+}H-K%@wvl?4?vt_$}2u`gEPU8eT#{_CyfPgWey2hvzGcZ1X7c%)bK*Adj z+B}@ktnR_dUq6F={BJirl3bQl9f+*r+-gbI$C#EbY7_ad)$wUulx*NdQTnjrtY3Vu z>N(bXk3V|5wEXEeU>^Jf&Pf$qvj(1R0%uN(MHd+4Sxv~y%(ExGeD1*rfm1&Q^VQ!7 z)NVIG`0zwlI0(ofz5tSzt!R_^V)oX;Y9>FwrsfQz^%-(S3}WEe&En&a-zl?~$IqUE zjm$yQx&X$o8@oQck9I>-1VConCkL!=;(eBKvv+oMW7d$+3Hbp@5dnua>+r?312f>B zk=0GkHUzBfHfu#>_D{$r;2=fm#c<+{PH@_*7Kg^nooQr!_xJM2^ItwOt1m9-V{m{v zb;xr|k3PJ+8Nsc#Iu+>cIYO8qG6))bmCeTPpJirxr&`!U52fCd(XQ@T&5eG~>$kU_ zk6xHRNNhF_%NZe&}E@>2(B{ z{s8)4*%9Tk-$=lphZgf-=RKKNr_8*zEzIedCI!ppF(_oz`*Gu5X)uEV>JQK}9SWmg z?eP(aQRRoP%5S~@`G$449}J*BzWZYRrtJCr`rxzmbi*v_4YMl@)B10v_((p_!srA7 z)Zs(??N(m8(>W}7QWF~jgMyj~jmX5pjvsvuf`~LIHX=pjlt_`L z5vg=i85Cuz5eo)|A^{Z&6ii)8g08AKDxpeVlf85V<5H$Sp&J|;VgsTWJVSnL8th$v7T&euMvNT=H! zvD@yT-9jxgK8=HtU}E$dztu=$s?nWjP@(auiQU9hg8(s357ts4Dkjv;6KR@oCWLC_(KoIP!DLU3XtE!N7&d|^))3o1w_%qpY&ljt!BQIvlGBdPKX|g8VLsBIvYgQceKg;qBb?l z7$7vCtmg{)^zH9)K0}gKAS10oJ=Ou;`65U%nu7W+0$xH85^unXhDjc*`tP&Y1Iflr`uZ_qdBqKTWvYT87L5|IJ}%rMt`2?&aX zfqNyl!#RYXA(NZSH|Kok`|h1UD5ZdLacBs^^e|?fuzlxYLAT>i4Lbou*Oi&L@40!e zRe$Guod<;I2bB5;wC4d(f39&(-WJ6G(o7qonHNMl88c zh?ei3R}Xsa=G-6&0Yo$%%vciajVze)lsepCTHt&;0nIoEE47u1B(9d*)zf^dax4|3 z%g;fCfNn;?PTxqaZSRz0ncOa;1b$_glR@lK^dF;lHDWlY{wKolh*)69*IA0wGW#~~ z3^IudW|9FR2{PbIJDue`PzFgL1p|m{B|3OlCWYuQl}7X9AQ>!^Hm;}GcMK$&ch1B> z3QY!$bJ9d634jznfFy$yPJkqWWCW{qI;eBSIEaoq*+ugk=OhATQR?Kus0*pma$ zZw_QHDjD11d?=kgKf*w=I7mc$MRaqob@s93HfzkU_$ypu|0p*ron?N~C~|ku{CZS! z8$aX-#Xq0wNX5D4M|ioJ+?H^_iu}0w<)|cqgZ|c7S>=o25JVIJtXIULL=BRtjC4*R9xY zbSnpDA`R5{79OY9ao&eg2We)c-?Ag?n?mDwt)H@%I}~g4Ovtb@6J9vfjEJb!7++5e z-yYhm--P>O(v-AvB_>mm%kW|dP*BqvJ{A%did01$C|=$>?bQJYyVz`!Utyt$Bn?<%OAv}Hye5q$ zCa!~UUo0RCq1C_;bMt65u+3wM{Vz99Q3qixY*vRilA~G05c6W##W2u|EzrdX{tF&p eiHXE70R{jB>Q`@$tn_>U0000LL{7b-4{xB-WFapRkt~F61#%wc2O*CoCBl1i)Oav3P8;r!LWHb7QiJEo) z_=gZ&3>pbAiVO%3q3FiC^>O^2+it9TwVmC1VfSp!vU_`bPe1qf`=0Ob+;b_6F;d&a zjZy)rfK)&k2UPmp4$SIJh~|ZicNm95t_xr8c9uN*x|O0R%jNHnHcsdH*reVBaI(rQ zh!+bo4k#SxmH#q=9x=SuU0J)Y>d%&U?HL6`bAk*v)gSXrGa#&>?83v*oXC9;;b!GXnmQyp+0;@DAv`L25@;hOM^a3a z>RUY1r$GuS`tcMxLeWfAxC;SNU22e$Pcej*rqU^m927NTbgOGl8WKC*S1piEJvFrHuJ~N*=b!JPX5l@?)P{LAf+n~3ss>HUNEPXa!YC>d5FT%~ zQw5|(Q1THJ4!OvxilK!Av#F^Is8m2IAQjL<52)zrO%{q~L~_d)n(wOjxG&Lu*arVo z7I|(5QDcso@LVf4iioDIG|OAaqwC;}xguFt7zqwm$BwZuysm>Y=8y?67i@ASz7U&jj9_qc22mvEVt6gNeF~pB zfab4zukqr^y$$IGl$HflSG}!`jMnJY70yRSX{lw&_K)j_;jx@sBNm8;xr>mo^a_Gssnk{7@! zBoSkeFJB^~TzZ0za)QJg^W^o2I5gM{aQtNZnf)8Qy*+=lhx+`8(Hg|6x)!VAG-#+@ z_-c=Hq3ysLMx(Pp`dBH3Lo^5}=tko&j%U1Ms~4Q~?IfaYkgis83ppGPv{h`|({!%& z{dTf1woclvSdkvt`fp#cLz?|6%qc;9Rv!6gJ}6UMe^ZySAzO|hW{9rgw8TmvY5^3oH8BVDI=zv!Q^2u|{r z_LUz$_YL}QtQx#`%SR3XO+&_#CCD`YNvok`k(|juN--_Jdu&ee_CM|IN$Qq5J>1D4O*Wan|OSMMtyJrJe;_b}Cnc z%*!`eAiW%<(=@O10|Aj}1|t|f<(nMU=f80I<1;L^sa*4lm#m;~J}`yED#&(W$&RDo ziLxB5Hme@&1ktKm*z8qg1cAHtkWLB^{xrwCKr`Bji39&43Av9s#wt*9aLmirTZ*mQ zu*Q_%0lMZMx$o?e?f$MqTN?Urbjya3)te+mrWjmZCuhjE00^?=&3nrAd}IHu%l5$E zJ$@VxA>K3xjNC!%X#J6Y50Yez4HN`8pItT9ElmUTQ`xKXA z=4I<72=O{iPBG%ed_RhW~7oNUcTAs1uq1pLKc)EN1SJm?r=tn)Yw8xhLgZ0OXRVuNH~5; zOJp$688f2Jimkg#L2qoVU?5BBWH6D?VAPR=gQpqZernfhuc81IKDAEb^rlWot4>l~ z1DrAS(7@g6c7S7(0mhzM1ikV>Y2qRgLxZ8DAhLZ1@YGJMn?NvUXpKkW;({ z3SSEu3}USlM$cw|lXf4Z&IhT0R6r^q#RCGP<^}n}Kv#LhW q$#Bt diff --git a/ui/src/main/res/drawable/bs_white_blue.xml b/ui/src/main/res/drawable/bs_white_blue.xml deleted file mode 100644 index 482a8af2..00000000 --- a/ui/src/main/res/drawable/bs_white_blue.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/drawable/gradient_light_grey.xml b/ui/src/main/res/drawable/gradient_light_grey.xml deleted file mode 100644 index dd51b7cb..00000000 --- a/ui/src/main/res/drawable/gradient_light_grey.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/layout/file_list_item.xml b/ui/src/main/res/layout/file_list_item.xml deleted file mode 100644 index 1b78b62e..00000000 --- a/ui/src/main/res/layout/file_list_item.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/ui/src/main/res/layout/ic_boolean_layout.xml b/ui/src/main/res/layout/ic_boolean_layout.xml deleted file mode 100644 index 7e2b24a7..00000000 --- a/ui/src/main/res/layout/ic_boolean_layout.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - diff --git a/ui/src/main/res/layout/ic_multi_select_layout.xml b/ui/src/main/res/layout/ic_multi_select_layout.xml deleted file mode 100644 index 911290c7..00000000 --- a/ui/src/main/res/layout/ic_multi_select_layout.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - diff --git a/ui/src/main/res/layout/ic_single_select_layout.xml b/ui/src/main/res/layout/ic_single_select_layout.xml deleted file mode 100644 index 7cada83d..00000000 --- a/ui/src/main/res/layout/ic_single_select_layout.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - diff --git a/ui/src/main/res/layout/ic_single_value_date_layout.xml b/ui/src/main/res/layout/ic_single_value_date_layout.xml deleted file mode 100644 index eed82910..00000000 --- a/ui/src/main/res/layout/ic_single_value_date_layout.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/ui/src/main/res/layout/ic_single_value_layout.xml b/ui/src/main/res/layout/ic_single_value_layout.xml deleted file mode 100644 index 2a8bff63..00000000 --- a/ui/src/main/res/layout/ic_single_value_layout.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - diff --git a/ui/src/main/res/layout/resource_list_item.xml b/ui/src/main/res/layout/resource_list_item.xml deleted file mode 100644 index febfb2c0..00000000 --- a/ui/src/main/res/layout/resource_list_item.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/layout/select_dialog_multichoice.xml b/ui/src/main/res/layout/select_dialog_multichoice.xml deleted file mode 100644 index 40034a85..00000000 --- a/ui/src/main/res/layout/select_dialog_multichoice.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - \ No newline at end of file diff --git a/ui/src/main/res/layout/server_profile_list_item.xml b/ui/src/main/res/layout/server_profile_list_item.xml deleted file mode 100644 index de98fb54..00000000 --- a/ui/src/main/res/layout/server_profile_list_item.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/layout/two_line_breadcrumbs.xml b/ui/src/main/res/layout/two_line_breadcrumbs.xml deleted file mode 100644 index a4fd7532..00000000 --- a/ui/src/main/res/layout/two_line_breadcrumbs.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ui/src/main/res/values/colors.xml b/ui/src/main/res/values/colors.xml deleted file mode 100644 index 3f16d15a..00000000 --- a/ui/src/main/res/values/colors.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - #0480ba - #ff790b - - #1abafc - #ffac0b - #b7cb2d - - #333333 - #7d7d7d - #949494 - #e7e7e7 - - #ff0000 - #8ec2ef - \ No newline at end of file diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml deleted file mode 100644 index 89c37cec..00000000 --- a/ui/src/main/res/values/strings.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - Check all - Uncheck all - - diff --git a/ui/src/main/res/values/styles.xml b/ui/src/main/res/values/styles.xml deleted file mode 100644 index 0e962390..00000000 --- a/ui/src/main/res/values/styles.xml +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 5f22baf0124db2a72cd90d5f973a205f261ef8b7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 13:39:05 +0200 Subject: [PATCH 250/457] Updating release script --- build.gradle | 11 +---------- client/build.gradle | 4 +++- ...ase-aar.gradle => release-artifact.gradle} | 19 ++++++++----------- 3 files changed, 12 insertions(+), 22 deletions(-) rename scripts/{android-release-aar.gradle => release-artifact.gradle} (68%) diff --git a/build.gradle b/build.gradle index a8772052..895a832d 100644 --- a/build.gradle +++ b/build.gradle @@ -6,26 +6,17 @@ buildscript { mavenLocal() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' - classpath "com.github.dcendents:android-maven-plugin:1.2" } } subprojects { group = 'com.jaspersoft.android.sdk' - ext.clientModuleVersion = '1.10' - ext.clientModuleVersionCode = 9011000 - - ext.androidMinSdkVersion = 9 - ext.androidBuildToolsVersion = '21.1.2' - ext.androidCompileSdkVersion = 21 - ext.androidTargetSdkVersion = 21 + ext.clientModuleVersion = '2.0-SNAPSHOT' repositories { jcenter() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } - maven { url "file://${System.getenv("ANDROID_HOME")}/extras/android/m2repository" } } } diff --git a/client/build.gradle b/client/build.gradle index 25f16747..d955cdb2 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -33,4 +33,6 @@ dependencies { testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' // In order to test on JVM side we need stock BouncyCastle provider testCompile 'org.bouncycastle:bcprov-jdk16:1.46' -} \ No newline at end of file +} + +apply from: '../scripts/release-artifact.gradle' \ No newline at end of file diff --git a/scripts/android-release-aar.gradle b/scripts/release-artifact.gradle similarity index 68% rename from scripts/android-release-aar.gradle rename to scripts/release-artifact.gradle index f31a6d4f..b3790919 100644 --- a/scripts/android-release-aar.gradle +++ b/scripts/release-artifact.gradle @@ -1,4 +1,3 @@ -// ./gradlew clean build generateRelease apply plugin: 'maven' def groupId = project.PUBLISH_GROUP_ID @@ -7,20 +6,19 @@ def version = project.PUBLISH_VERSION def localReleaseDest = "${buildDir}/release/${version}" -task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) +task clientJavadocs(type: Javadoc) { + source = sourceSets.main.java.srcDirs options.encoding = 'ISO-8859-1' } -task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { +task clientJavadocsJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' - from androidJavadocs.destinationDir + from clientJavadocs.destinationDir } -task androidSourcesJar(type: Jar) { +task clientSourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' - from android.sourceSets.main.java.srcDirs + from sourceSets.main.allJava } uploadArchives { @@ -47,8 +45,7 @@ task generateRelease << { generateRelease.dependsOn(uploadArchives) generateRelease.dependsOn(zipRelease) - artifacts { - archives androidSourcesJar - archives androidJavadocsJar + archives clientSourcesJar + archives clientJavadocsJar } \ No newline at end of file From d4e61d8bd5c8644c3aea1e79f2042a589f0392c0 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 15:37:15 +0200 Subject: [PATCH 251/457] Introduce core module --- client/build.gradle | 48 +++++++------- core/build.gradle | 62 +++++++++++++++++++ .../android/sdk/network/AdapterBuilder.java | 0 .../sdk/network/AuthenticationRestApi.java | 0 .../network/AuthenticationRestApiImpl.java | 0 .../android/sdk/network/CallWrapper.java | 0 .../android/sdk/network/ClientBuilder.java | 0 .../android/sdk/network/CookieExtractor.java | 0 .../android/sdk/network/GenericBuilder.java | 0 .../sdk/network/GsonConverterFactory.java | 0 .../sdk/network/InputControlRestApi.java | 0 .../sdk/network/InputControlRestApiImpl.java | 0 .../sdk/network/JSEncryptionAlgorithm.java | 0 .../sdk/network/LoggingInterceptor.java | 0 .../sdk/network/ReportExecutionRestApi.java | 0 .../network/ReportExecutionRestApiImpl.java | 0 .../sdk/network/ReportExportRestApi.java | 0 .../sdk/network/ReportExportRestApiImpl.java | 0 .../sdk/network/ReportOptionRestApi.java | 0 .../sdk/network/ReportOptionRestApiImpl.java | 0 .../sdk/network/RepositoryRestApi.java | 0 .../sdk/network/RepositoryRestApiImpl.java | 0 .../android/sdk/network/RestApiLog.java | 0 .../android/sdk/network/RestError.java | 0 .../sdk/network/RetrofitOutputResource.java | 0 .../android/sdk/network/ServerRestApi.java | 0 .../sdk/network/ServerRestApiImpl.java | 0 .../sdk/network/StringConverterFactory.java | 0 .../jaspersoft/android/sdk/network/Utils.java | 0 .../network/entity/control/InputControl.java | 0 .../control/InputControlCollection.java | 0 .../entity/control/InputControlOption.java | 0 .../entity/control/InputControlState.java | 0 .../control/InputControlStateCollection.java | 0 .../entity/control/ValidationRule.java | 0 .../execution/AttachmentDescriptor.java | 0 .../entity/execution/ErrorDescriptor.java | 0 .../execution/ExecutionRequestOptions.java | 0 .../entity/execution/ExecutionStatus.java | 0 .../entity/execution/ExportDescriptor.java | 0 .../execution/OutputResourceDescriptor.java | 0 .../execution/ReportExecutionDescriptor.java | 0 .../ReportExecutionRequestOptions.java | 0 .../execution/ReportExecutionSearchItem.java | 0 .../ReportExecutionSearchResponse.java | 0 .../export/ExportExecutionDescriptor.java | 0 .../entity/export/ExportOutputResource.java | 0 .../network/entity/export/OutputResource.java | 0 .../entity/report/option/ReportOption.java | 0 .../entity/report/option/ReportOptionSet.java | 0 .../network/entity/resource/FolderLookup.java | 0 .../network/entity/resource/ReportLookup.java | 0 .../entity/resource/ResourceLookup.java | 0 .../entity/resource/ResourceSearchResult.java | 0 .../network/entity/server/EncryptionKey.java | 0 .../network/entity/server/ServerInfoData.java | 0 .../type/CustomizedTypeAdapterFactory.java | 0 .../sdk/network/entity/type/GsonFactory.java | 0 .../type/InputControlTypeAdapterFactory.java | 0 .../type/ReportLookupTypeAdapterFactory.java | 0 .../sdk/service/GreedyInfoProvider.java | 0 .../android/sdk/service/InfoProvider.java | 0 .../android/sdk/service/Preconditions.java | 0 .../sdk/service/ServerInfoService.java | 0 .../sdk/service/ServerInfoTransformer.java | 0 .../android/sdk/service/auth/AuthService.java | 0 .../sdk/service/auth/SpringAuthService.java | 0 .../sdk/service/auth/TokenProvider.java | 0 .../sdk/service/data/report/PageRange.java | 0 .../service/data/report/ReportMetadata.java | 0 .../sdk/service/data/report/ReportOutput.java | 0 .../service/data/report/ResourceOutput.java | 0 .../data/repository/DefaultTypeParser.java | 0 .../sdk/service/data/repository/Resource.java | 0 .../service/data/repository/ResourceType.java | 0 .../service/data/repository/SearchResult.java | 0 .../data/server/DefaultVersionParser.java | 0 .../sdk/service/data/server/FeatureSet.java | 0 .../service/data/server/ServerEdition.java | 0 .../sdk/service/data/server/ServerInfo.java | 0 .../service/data/server/ServerVersion.java | 0 .../sdk/service/report/ExecutionCriteria.java | 0 .../service/report/ExecutionException.java | 0 .../report/ExecutionOptionsDataMapper.java | 0 .../sdk/service/report/ExportFactory.java | 0 .../sdk/service/report/OutputDataMapper.java | 0 .../sdk/service/report/ReportAttachment.java | 0 .../sdk/service/report/ReportExecution.java | 0 .../report/ReportExecutionUseCase.java | 0 .../sdk/service/report/ReportExport.java | 0 .../service/report/ReportExportUseCase.java | 0 .../sdk/service/report/ReportService.java | 0 .../sdk/service/report/RunExportCriteria.java | 0 .../sdk/service/report/RunReportCriteria.java | 0 .../android/sdk/service/report/Status.java | 0 .../exception/ReportExportException.java | 0 .../report/exception/ReportRunException.java | 0 .../service/repository/CriteriaMapper.java | 0 .../repository/EmeraldMR2SearchStrategy.java | 0 .../repository/EmeraldMR3SearchStrategy.java | 0 .../service/repository/InternalCriteria.java | 0 .../service/repository/RepositoryService.java | 0 .../service/repository/ResourceMapper.java | 0 .../service/repository/SearchCriteria.java | 0 .../service/repository/SearchStrategy.java | 0 .../sdk/service/repository/SearchTask.java | 0 .../service/repository/SearchTaskImpl.java | 0 .../sdk/service/repository/SearchUseCase.java | 0 .../AuthenticationRestApiBuilderTest.java | 0 .../network/AuthenticationRestApiTest.java | 0 .../sdk/network/CookieExtractorTest.java | 0 .../InputControlRestApiBuilderTest.java | 0 .../sdk/network/InputControlRestApiTest.java | 0 .../network/JSEncryptionAlgorithmTest.java | 0 .../ReportExecutionRestApiBuilderTest.java | 0 .../network/ReportExecutionRestApiTest.java | 0 .../ReportExportRestApiBuilderTest.java | 0 .../sdk/network/ReportExportRestApiTest.java | 0 .../ReportOptionRestApiBuilderTest.java | 0 .../sdk/network/ReportOptionRestApiTest.java | 0 .../network/RepositoryRestApiBuilderTest.java | 0 .../sdk/network/RepositoryRestApiTest.java | 0 .../network/RetrofitOutputResourceTest.java | 0 .../sdk/network/ServerRestApiBuilderTest.java | 0 .../sdk/network/ServerRestApiTest.java | 0 .../android/sdk/network/UtilsTest.java | 0 .../control/InputControlCollectionTest.java | 0 .../control/InputControlOptionTest.java | 0 .../entity/control/InputControlStateTest.java | 0 .../entity/control/InputControlTest.java | 0 .../entity/control/ValidationRuleTest.java | 0 .../execution/AttachmentDescriptorTest.java | 0 .../entity/execution/ErrorDescriptorTest.java | 0 .../ExecutionRequestOptionsTest.java | 0 .../entity/execution/ExecutionStatusTest.java | 0 .../execution/ExportDescriptorTest.java | 0 .../OutputResourceDescriptorTest.java | 0 .../ReportExecutionDescriptorTest.java | 0 .../ReportExecutionRequestOptionsTest.java | 0 .../ReportExecutionSearchResponseTest.java | 0 .../export/ExportExecutionDescriptorTest.java | 0 .../report/option/ReportOptionSetTest.java | 0 .../report/option/ReportOptionTest.java | 0 .../resource/FolderLookupResponseTest.java | 0 .../entity/resource/ReportLookupTest.java | 0 .../ResourceLookupJsonConvertTest.java | 0 .../entity/server/EncryptionKeyTest.java | 0 .../entity/server/ServerInfoDataTest.java | 0 .../network/entity/type/GsonFactoryTest.java | 0 .../sdk/service/ServerInfoServiceTest.java | 0 .../service/ServerInfoTransformerTest.java | 0 .../auth/SpringAuthServiceBuilderTest.java | 0 .../service/auth/SpringAuthServiceTest.java | 0 .../sdk/service/data/PageRangeTest.java | 0 .../repository/DefaultTypeParserTest.java | 0 .../data/server/DefaultVersionParserTest.java | 0 .../service/data/server/FeatureSetTest.java | 0 .../service/data/server/ServerInfoTest.java | 0 .../data/server/ServerVersionTest.java | 0 .../report/ExecutionExceptionTest.java | 0 .../ExecutionOptionsDataMapperTest.java | 0 .../service/report/ReportAttachmentTest.java | 0 .../service/report/ReportExecutionTest.java | 0 .../sdk/service/report/ReportExportTest.java | 0 .../sdk/service/report/ReportServiceTest.java | 0 .../service/report/RunExportCriteriaTest.java | 0 .../service/report/RunReportCriteriaTest.java | 0 .../sdk/service/report/StatusChain.java | 0 .../sdk/service/report/StatusTest.java | 0 .../repository/CriteriaMapperTest.java | 0 .../EmeraldMR2SearchStrategyTest.java | 0 .../EmeraldMR3SearchStrategyTest.java | 0 .../InternalSearchCriteriaTest.java | 0 .../repository/RepositoryServiceTest.java | 0 .../repository/ResourceMapperTest.java | 0 .../repository/SearchCriteriaTest.java | 0 .../repository/SearchStrategyTest.java | 0 .../repository/SearchTaskImplTest.java | 0 .../service/repository/SearchUseCaseTest.java | 0 .../android/sdk/test/MockResponseFactory.java | 0 .../android/sdk/test/TestLogger.java | 0 .../android/sdk/test/WebMockRule.java | 0 .../api/AuthenticationRestApiTest.java | 0 .../api/InputControlRestApiTest.java | 0 .../api/ReportExecutionRestApiTest.java | 0 .../api/ReportExportRestApiTest.java | 0 .../api/ReportOptionRestApiTest.java | 0 .../api/RepositoryRestApiTest.java | 0 .../test/integration/api/ServerRestTest.java | 0 .../api/utils/DummyTokenProvider.java | 0 .../integration/api/utils/JrsMetadata.java | 0 .../sdk/test/matcher/HasAnnotation.java | 0 .../sdk/test/matcher/HasSerializedName.java | 0 .../sdk/test/resource/ResourceFile.java | 0 .../sdk/test/resource/TestResource.java | 0 .../resource/inject/TestResourceInjector.java | 0 .../test/resources/json/all_resources.json | 0 .../json/cancelled_report_response.json | 0 .../json/dashboard_unit_resource.json | 0 .../resources/json/default_server_info.json | 0 .../test/resources/json/encryption_key.json | 0 .../json/input_controls_states_list.json | 0 .../json/input_controls_with_states.json | 0 .../json/input_controls_without_states.json | 0 .../json/report_execution_details.json | 0 .../json/report_execution_request.json | 0 .../json/report_execution_response.json | 0 .../test/resources/json/report_option.json | 0 .../resources/json/report_options_list.json | 0 .../resources/json/report_unit_resource1.json | 0 .../resources/json/report_unit_resource2.json | 0 .../resources/json/resource_lookup_item.json | 0 .../src/test/resources/json/root_folder.json | 0 .../json/search_execution_response.json | 0 settings.gradle | 2 + 215 files changed, 89 insertions(+), 23 deletions(-) create mode 100644 core/build.gradle rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/RestError.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/Utils.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java (100%) rename {client => core}/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java (100%) rename {client => core}/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java (100%) rename {client => core}/src/test/resources/json/all_resources.json (100%) rename {client => core}/src/test/resources/json/cancelled_report_response.json (100%) rename {client => core}/src/test/resources/json/dashboard_unit_resource.json (100%) rename {client => core}/src/test/resources/json/default_server_info.json (100%) rename {client => core}/src/test/resources/json/encryption_key.json (100%) rename {client => core}/src/test/resources/json/input_controls_states_list.json (100%) rename {client => core}/src/test/resources/json/input_controls_with_states.json (100%) rename {client => core}/src/test/resources/json/input_controls_without_states.json (100%) rename {client => core}/src/test/resources/json/report_execution_details.json (100%) rename {client => core}/src/test/resources/json/report_execution_request.json (100%) rename {client => core}/src/test/resources/json/report_execution_response.json (100%) rename {client => core}/src/test/resources/json/report_option.json (100%) rename {client => core}/src/test/resources/json/report_options_list.json (100%) rename {client => core}/src/test/resources/json/report_unit_resource1.json (100%) rename {client => core}/src/test/resources/json/report_unit_resource2.json (100%) rename {client => core}/src/test/resources/json/resource_lookup_item.json (100%) rename {client => core}/src/test/resources/json/root_folder.json (100%) rename {client => core}/src/test/resources/json/search_execution_response.json (100%) diff --git a/client/build.gradle b/client/build.gradle index d955cdb2..e9bf1236 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + apply plugin: 'java' description = 'js-android-sdk-client' @@ -10,29 +34,7 @@ ext { } dependencies { - compile 'com.intellij:annotations:12.0' - - compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' - compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' - - compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' - compile 'com.madgag.spongycastle:prov:1.52.0.0' - - testCompile('pl.pragmatists:JUnitParams:1.0.4') { - exclude group: 'org.hamcrest' - } - testCompile 'org.hamcrest:hamcrest-integration:1.3' - testCompile('org.mockito:mockito-core:1.10.19') { - exclude group: 'org.hamcrest' - exclude group: 'org.objenesis' - } - testCompile('org.powermock:powermock-api-mockito:1.6.2') { - exclude group: 'org.mockito' - } - testCompile 'org.powermock:powermock-module-junit4:1.6.2' - testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' - // In order to test on JVM side we need stock BouncyCastle provider - testCompile 'org.bouncycastle:bcprov-jdk16:1.46' + compile project(':js-android-sdk-core') } apply from: '../scripts/release-artifact.gradle' \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 00000000..9e13a089 --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +apply plugin: 'java' + +description = 'js-android-sdk-core' +version = clientModuleVersion + +ext { + PUBLISH_GROUP_ID = group + PUBLISH_ARTIFACT_ID = description + PUBLISH_VERSION = clientModuleVersion +} + +dependencies { + compile 'com.intellij:annotations:12.0' + + compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' + compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' + + compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' + compile 'com.madgag.spongycastle:prov:1.52.0.0' + + testCompile('pl.pragmatists:JUnitParams:1.0.4') { + exclude group: 'org.hamcrest' + } + testCompile 'org.hamcrest:hamcrest-integration:1.3' + testCompile('org.mockito:mockito-core:1.10.19') { + exclude group: 'org.hamcrest' + exclude group: 'org.objenesis' + } + testCompile('org.powermock:powermock-api-mockito:1.6.2') { + exclude group: 'org.mockito' + } + testCompile 'org.powermock:powermock-module-junit4:1.6.2' + testCompile 'com.squareup.okhttp:mockwebserver:2.5.0' + // In order to test on JVM side we need stock BouncyCastle provider + testCompile 'org.bouncycastle:bcprov-jdk16:1.46' +} + +apply from: '../scripts/release-artifact.gradle' \ No newline at end of file diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java b/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java b/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/RestError.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/RestError.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitOutputResource.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/Utils.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Utils.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/Utils.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/Utils.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOption.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlState.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRule.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptor.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/ExportOutputResource.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookup.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookup.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceSearchResult.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoData.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/CustomizedTypeAdapterFactory.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/InputControlTypeAdapterFactory.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportLookupTypeAdapterFactory.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ResourceOutput.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/ResourceType.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java diff --git a/client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java similarity index 100% rename from client/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollectionTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlOptionTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/InputControlTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/control/ValidationRuleTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/export/ExportExecutionDescriptorTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSetTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKeyTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/server/ServerInfoDataTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParserTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/ResourceMapperTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java b/core/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/MockResponseFactory.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java b/core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java b/core/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/WebMockRule.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java b/core/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasAnnotation.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java b/core/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/matcher/HasSerializedName.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java b/core/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/resource/ResourceFile.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java b/core/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/resource/TestResource.java diff --git a/client/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java b/core/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java similarity index 100% rename from client/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/resource/inject/TestResourceInjector.java diff --git a/client/src/test/resources/json/all_resources.json b/core/src/test/resources/json/all_resources.json similarity index 100% rename from client/src/test/resources/json/all_resources.json rename to core/src/test/resources/json/all_resources.json diff --git a/client/src/test/resources/json/cancelled_report_response.json b/core/src/test/resources/json/cancelled_report_response.json similarity index 100% rename from client/src/test/resources/json/cancelled_report_response.json rename to core/src/test/resources/json/cancelled_report_response.json diff --git a/client/src/test/resources/json/dashboard_unit_resource.json b/core/src/test/resources/json/dashboard_unit_resource.json similarity index 100% rename from client/src/test/resources/json/dashboard_unit_resource.json rename to core/src/test/resources/json/dashboard_unit_resource.json diff --git a/client/src/test/resources/json/default_server_info.json b/core/src/test/resources/json/default_server_info.json similarity index 100% rename from client/src/test/resources/json/default_server_info.json rename to core/src/test/resources/json/default_server_info.json diff --git a/client/src/test/resources/json/encryption_key.json b/core/src/test/resources/json/encryption_key.json similarity index 100% rename from client/src/test/resources/json/encryption_key.json rename to core/src/test/resources/json/encryption_key.json diff --git a/client/src/test/resources/json/input_controls_states_list.json b/core/src/test/resources/json/input_controls_states_list.json similarity index 100% rename from client/src/test/resources/json/input_controls_states_list.json rename to core/src/test/resources/json/input_controls_states_list.json diff --git a/client/src/test/resources/json/input_controls_with_states.json b/core/src/test/resources/json/input_controls_with_states.json similarity index 100% rename from client/src/test/resources/json/input_controls_with_states.json rename to core/src/test/resources/json/input_controls_with_states.json diff --git a/client/src/test/resources/json/input_controls_without_states.json b/core/src/test/resources/json/input_controls_without_states.json similarity index 100% rename from client/src/test/resources/json/input_controls_without_states.json rename to core/src/test/resources/json/input_controls_without_states.json diff --git a/client/src/test/resources/json/report_execution_details.json b/core/src/test/resources/json/report_execution_details.json similarity index 100% rename from client/src/test/resources/json/report_execution_details.json rename to core/src/test/resources/json/report_execution_details.json diff --git a/client/src/test/resources/json/report_execution_request.json b/core/src/test/resources/json/report_execution_request.json similarity index 100% rename from client/src/test/resources/json/report_execution_request.json rename to core/src/test/resources/json/report_execution_request.json diff --git a/client/src/test/resources/json/report_execution_response.json b/core/src/test/resources/json/report_execution_response.json similarity index 100% rename from client/src/test/resources/json/report_execution_response.json rename to core/src/test/resources/json/report_execution_response.json diff --git a/client/src/test/resources/json/report_option.json b/core/src/test/resources/json/report_option.json similarity index 100% rename from client/src/test/resources/json/report_option.json rename to core/src/test/resources/json/report_option.json diff --git a/client/src/test/resources/json/report_options_list.json b/core/src/test/resources/json/report_options_list.json similarity index 100% rename from client/src/test/resources/json/report_options_list.json rename to core/src/test/resources/json/report_options_list.json diff --git a/client/src/test/resources/json/report_unit_resource1.json b/core/src/test/resources/json/report_unit_resource1.json similarity index 100% rename from client/src/test/resources/json/report_unit_resource1.json rename to core/src/test/resources/json/report_unit_resource1.json diff --git a/client/src/test/resources/json/report_unit_resource2.json b/core/src/test/resources/json/report_unit_resource2.json similarity index 100% rename from client/src/test/resources/json/report_unit_resource2.json rename to core/src/test/resources/json/report_unit_resource2.json diff --git a/client/src/test/resources/json/resource_lookup_item.json b/core/src/test/resources/json/resource_lookup_item.json similarity index 100% rename from client/src/test/resources/json/resource_lookup_item.json rename to core/src/test/resources/json/resource_lookup_item.json diff --git a/client/src/test/resources/json/root_folder.json b/core/src/test/resources/json/root_folder.json similarity index 100% rename from client/src/test/resources/json/root_folder.json rename to core/src/test/resources/json/root_folder.json diff --git a/client/src/test/resources/json/search_execution_response.json b/core/src/test/resources/json/search_execution_response.json similarity index 100% rename from client/src/test/resources/json/search_execution_response.json rename to core/src/test/resources/json/search_execution_response.json diff --git a/settings.gradle b/settings.gradle index 2e4a7e06..f06be087 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,4 @@ include ':js-android-sdk-client' +include ':js-android-sdk-core' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File +project(':js-android-sdk-core').projectDir = "$rootDir/core" as File From f1cfe5be8693f7073eb4383ecd966616d726adaa Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 3 Nov 2015 15:41:13 +0200 Subject: [PATCH 252/457] Update copyright all over project artifacts --- build.gradle | 34 +++++++++++++++++-- .../execution/OutputResourceDescriptor.java | 1 + .../ReportExecutionRequestOptions.java | 14 ++++---- .../execution/ReportExecutionSearchItem.java | 14 ++++---- .../ReportExecutionSearchResponse.java | 14 ++++---- .../data/repository/DefaultTypeParser.java | 1 + .../sdk/service/data/repository/Resource.java | 1 + .../service/data/repository/SearchResult.java | 1 + .../sdk/service/report/ExecutionCriteria.java | 1 + .../service/report/ExecutionException.java | 1 + .../report/ExecutionOptionsDataMapper.java | 1 + .../sdk/service/report/ReportAttachment.java | 1 + .../sdk/service/report/ReportExecution.java | 1 + .../sdk/service/report/ReportExport.java | 1 + .../sdk/service/report/ReportService.java | 1 + .../sdk/service/report/RunExportCriteria.java | 1 + .../sdk/service/report/RunReportCriteria.java | 1 + .../android/sdk/service/report/Status.java | 1 + .../exception/ReportExportException.java | 1 + .../report/exception/ReportRunException.java | 1 + .../service/repository/InternalCriteria.java | 1 + .../service/repository/ResourceMapper.java | 1 + .../sdk/service/repository/SearchTask.java | 1 + .../sdk/service/repository/SearchUseCase.java | 1 + .../AuthenticationRestApiBuilderTest.java | 14 ++++---- .../network/AuthenticationRestApiTest.java | 14 ++++---- .../sdk/network/CookieExtractorTest.java | 14 ++++---- .../InputControlRestApiBuilderTest.java | 14 ++++---- .../sdk/network/InputControlRestApiTest.java | 24 +++++++++++++ .../network/JSEncryptionAlgorithmTest.java | 24 +++++++++++++ .../ReportExecutionRestApiBuilderTest.java | 14 ++++---- .../network/ReportExecutionRestApiTest.java | 14 ++++---- .../ReportExportRestApiBuilderTest.java | 14 ++++---- .../sdk/network/ReportExportRestApiTest.java | 14 ++++---- .../ReportOptionRestApiBuilderTest.java | 14 ++++---- .../network/RepositoryRestApiBuilderTest.java | 14 ++++---- .../network/RetrofitOutputResourceTest.java | 14 ++++---- .../sdk/network/ServerRestApiBuilderTest.java | 14 ++++---- .../sdk/network/ServerRestApiTest.java | 14 ++++---- .../android/sdk/network/UtilsTest.java | 14 ++++---- .../execution/AttachmentDescriptorTest.java | 14 ++++---- .../entity/execution/ErrorDescriptorTest.java | 14 ++++---- .../ExecutionRequestOptionsTest.java | 14 ++++---- .../entity/execution/ExecutionStatusTest.java | 14 ++++---- .../execution/ExportDescriptorTest.java | 14 ++++---- .../OutputResourceDescriptorTest.java | 24 +++++++++++++ .../ReportExecutionDescriptorTest.java | 14 ++++---- .../ReportExecutionRequestOptionsTest.java | 14 ++++---- .../ReportExecutionSearchResponseTest.java | 14 ++++---- .../resource/FolderLookupResponseTest.java | 14 ++++---- .../entity/resource/ReportLookupTest.java | 14 ++++---- .../ResourceLookupJsonConvertTest.java | 14 ++++---- .../service/report/RunExportCriteriaTest.java | 1 + .../service/report/RunReportCriteriaTest.java | 1 + .../sdk/service/report/StatusChain.java | 1 + .../sdk/service/report/StatusTest.java | 1 + .../repository/SearchCriteriaTest.java | 1 + gradle/wrapper/gradle-wrapper.properties | 24 +++++++++++++ scripts/release-artifact.gradle | 24 +++++++++++++ settings.gradle | 24 +++++++++++++ 60 files changed, 396 insertions(+), 199 deletions(-) diff --git a/build.gradle b/build.gradle index 895a832d..15d67c9b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + buildscript { repositories { jcenter() @@ -20,13 +44,17 @@ subprojects { } } -apply plugin: 'java' // ensure clean is also triggered for root build folder + +// ensure clean is also triggered for root build folder +apply plugin: 'java' apply plugin: 'build-dashboard' buildDashboard { reports.html.destination = "build/" } -test.reports.html.enabled = false // just clean up dashboard from not generated reports -test.reports.junitXml.enabled = false // just clean up dashboard from not generated reports +// just clean up dashboard from not generated reports +test.reports.html.enabled = false +// just clean up dashboard from not generated reports +test.reports.junitXml.enabled = false diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java index 9597a38f..a94f8e8d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptor.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java index 5035ec11..2da9cad9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptions.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java index bf5515e9..074ca53b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchItem.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java index de3ff8b4..94b89191 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponse.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java index a3e1e958..94a4b400 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/DefaultTypeParser.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.data.repository; /** diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java index 28f5f0d1..5107d2d8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.data.repository; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java index f27025f0..4e5abf48 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.data.repository; import java.util.Collection; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java index a3ca1c1d..b33d8d45 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import org.jetbrains.annotations.Nullable; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java index b22eaa8b..29d51896 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 7fe48cb9..b9e63c6f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index 31547256..9db85a47 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 8e12f678..b04fcd52 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index d44281bf..e614a332 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index ca9926a1..3a0763bf 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index 48447fda..8b9c8416 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index e82e9556..252d2f6f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java index d0683a5c..197702d6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; /** diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java index 40e18226..3b521434 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report.exception; /** diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java index b0e6ae2d..84d00d8c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report.exception; /** diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index 55c598a1..7b1c15b7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.repository; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java index d82000e6..6f9afd9c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.repository; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index f4020373..dc61a0b2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.service.data.repository.Resource; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 4785e8b0..8013785c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java index 28141e1a..225baa54 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index f7e27a79..b353d174 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java index c37ea643..dae9b752 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java index 2ab4784f..ba2cf4b9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index eb8e22d1..ca764395 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.InputControlRestApi; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java index e8954a2e..2294b251 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java index a98ef71f..4c19e895 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index aaafd22b..c5339434 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java index 30d2f087..04b23ecf 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index 2a892fae..24f98e26 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java index 3bf203e7..06d27569 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java index 4d68ce07..06a9bd1b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java index 7b022499..22d514cb 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RetrofitOutputResourceTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java index ef21b8c5..9f704863 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java index a402c7e6..f772c006 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java index d38cb8d7..62bb2ce2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/UtilsTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java index 2a5ff2a6..58539c37 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/AttachmentDescriptorTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java index 0a99b72f..614edb57 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ErrorDescriptorTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java index f4a7efd4..6b84cf56 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptionsTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java index d04939f5..47aa0fc0 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatusTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java index ca75a564..6772be7d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ExportDescriptorTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java index 6ba69443..43e5bac8 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/OutputResourceDescriptorTest.java @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java index aa59a581..38d996a1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionDescriptorTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java index 3f8364a1..4dbf772e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionRequestOptionsTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java index c552e274..1abed202 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/execution/ReportExecutionSearchResponseTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java index 2548322e..0c999715 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/FolderLookupResponseTest.java @@ -1,24 +1,24 @@ /* - * Copyright � 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java index 0f7752af..2bd31f53 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookupTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java index cb5f839a..b40ebdcf 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/resource/ResourceLookupJsonConvertTest.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * - * Unless you have purchased a commercial license agreement from Jaspersoft, + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java index b0791ec7..3562d4af 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java index 927695eb..74e1a1fc 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java index a2b213e7..3d5642fd 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import org.mockito.invocation.InvocationOnMock; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java index 12c40f19..80bd61b3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusTest.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.report; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index 0cd047d6..f7adda4d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -21,6 +21,7 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ + package com.jaspersoft.android.sdk.service.repository; import org.junit.Rule; diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db85616c..7fff648c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,3 +1,27 @@ +# +# Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. +# http://community.jaspersoft.com/project/mobile-sdk-android +# +# Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, +# the following license terms apply: +# +# This program is part of TIBCO Jaspersoft Mobile SDK for Android. +# +# TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with TIBCO Jaspersoft Mobile SDK for Android. If not, see +# . +# + #Wed Feb 11 18:44:30 EET 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists diff --git a/scripts/release-artifact.gradle b/scripts/release-artifact.gradle index b3790919..29bf033c 100644 --- a/scripts/release-artifact.gradle +++ b/scripts/release-artifact.gradle @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + apply plugin: 'maven' def groupId = project.PUBLISH_GROUP_ID diff --git a/settings.gradle b/settings.gradle index f06be087..cf99081d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,27 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + include ':js-android-sdk-client' include ':js-android-sdk-core' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File From cf4592479b1142ecf2cf0a6f98aa97c5761b9bd6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 5 Nov 2015 13:59:12 +0200 Subject: [PATCH 253/457] Implementing spring case for JrsAuthenticator --- .../android/sdk/service/auth/AuthPolicy.java | 27 ++++ .../android/sdk/service/auth/AuthService.java | 36 ----- .../android/sdk/service/auth/Credentials.java | 9 ++ .../sdk/service/auth/JrsAuthenticator.java | 27 ++++ .../sdk/service/auth/SpringAuthService.java | 145 ++++-------------- .../sdk/service/auth/SpringCredentials.java | 137 +++++++++++++++++ .../sdk/network/RepositoryRestApiTest.java | 5 +- .../service/auth/JrsAuthenticatorTest.java | 37 +++++ .../service/auth/SpringAuthServiceTest.java | 20 ++- ...erTest.java => SpringCredentialsTest.java} | 57 +------ 10 files changed, 282 insertions(+), 218 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java rename core/src/test/java/com/jaspersoft/android/sdk/service/auth/{SpringAuthServiceBuilderTest.java => SpringCredentialsTest.java} (58%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java new file mode 100644 index 00000000..27d1b2f7 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java @@ -0,0 +1,27 @@ +package com.jaspersoft.android.sdk.service.auth; + +/** + * @author Tom Koptel + * @since 2.0 + */ +interface AuthPolicy { + String applyCredentials(SpringCredentials credentials); + + class Default implements AuthPolicy { + private final SpringAuthService mSpringService; + + private Default(SpringAuthService springService) { + mSpringService = springService; + } + + public static Default create(String baseUrl) { + SpringAuthService springService = SpringAuthService.create(baseUrl); + return new Default(springService); + } + + @Override + public String applyCredentials(SpringCredentials credentials) { + return mSpringService.authenticate(credentials); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java deleted file mode 100644 index 9d390a2b..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthService.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.auth; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface AuthService { - @NotNull - String authenticate(); -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java new file mode 100644 index 00000000..4510f0e3 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.auth; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class Credentials { + protected abstract String applyPolicy(AuthPolicy authPolicy); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java new file mode 100644 index 00000000..0850facc --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java @@ -0,0 +1,27 @@ +package com.jaspersoft.android.sdk.service.auth; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class JrsAuthenticator { + private final AuthPolicy mAuthPolicy; + + @TestOnly + JrsAuthenticator(AuthPolicy authPolicy) { + mAuthPolicy = authPolicy; + } + + public static JrsAuthenticator create(String baseUrl) { + AuthPolicy policyImpl = AuthPolicy.Default.create(baseUrl); + return new JrsAuthenticator(policyImpl); + } + + @NotNull + public String authenticate(Credentials credentials) { + return credentials.applyPolicy(mAuthPolicy); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 50511382..0bf43a88 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -29,7 +29,6 @@ import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.util.HashMap; @@ -37,63 +36,61 @@ import java.util.Map; import java.util.TimeZone; -import static com.jaspersoft.android.sdk.service.Preconditions.checkNotNull; - /** * @author Tom Koptel * @since 2.0 */ -public final class SpringAuthService implements AuthService { +final class SpringAuthService { + private final AuthenticationRestApi mRestApi; - private final String mUsername; - private final String mPassword; - private final String mOrganization; private final JSEncryptionAlgorithm mEncryptionAlgorithm; - private final Locale mLocale; - private final TimeZone mTimeZone; @TestOnly SpringAuthService( @NotNull JSEncryptionAlgorithm generator, - @NotNull AuthenticationRestApi restApi, - @NotNull String username, - @NotNull String password, - @NotNull String organization, - @NotNull Locale locale, - @NotNull TimeZone timeZone) { + @NotNull AuthenticationRestApi restApi) { mEncryptionAlgorithm = generator; mRestApi = restApi; - mUsername = username; - mPassword = password; - mOrganization = organization; - mLocale = locale; - mTimeZone = timeZone; + } + + public static SpringAuthService create(@NotNull String baseUrl) { + JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() + .baseUrl(baseUrl) + .build(); + return new SpringAuthService(algorithm, restApi); } @NotNull - @Override - public String authenticate() { - String password = mPassword; + public String authenticate(SpringCredentials credentials) { + String password = credentials.getPassword(); EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); if (encryptionKey.isAvailable()) { - password = encryptPassword(mPassword, encryptionKey); + password = encryptPassword(credentials.getPassword(), encryptionKey); } - Map params = prepareOptionals(); - return mRestApi.authenticate(mUsername, password, mOrganization, params); + Map params = prepareOptionals(credentials); + return mRestApi.authenticate( + credentials.getUsername(), + password, + credentials.getOrganization(), + params); } - private Map prepareOptionals() { + @NotNull + private Map prepareOptionals(SpringCredentials credentials) { Map params = new HashMap<>(); + Locale locale = credentials.getLocale(); + TimeZone timeZone = credentials.getTimeZone(); // For Locale.US it will produce "en_US" result - String locale = mLocale.getLanguage() + "_" + mLocale.getCountry(); + String localeAsString = locale.getLanguage() + "_" + locale.getCountry(); // Result could be "Europe/Helsinki" - String timeZone = mTimeZone.getID(); + String timeZoneAsString = timeZone.getID(); - params.put("userLocale", locale); - params.put("userTimezone", timeZone); + params.put("userLocale", localeAsString); + params.put("userTimezone", timeZoneAsString); return params; } @@ -102,90 +99,4 @@ private Map prepareOptionals() { private String encryptPassword(String password, EncryptionKey key) { return mEncryptionAlgorithm.encrypt(key.getModulus(), key.getExponent(), password); } - - public static class Builder { - private AuthenticationRestApi mRestApi; - private String mUsername; - private String mPassword; - private String mOrganization; - - // Optional - private Locale mLocale; - private TimeZone mTimeZone; - - public Builder username(@NotNull String username) { - mUsername = checkNotNull(username, "username == null"); - return this; - } - - public Builder password(@NotNull String password) { - mPassword = checkNotNull(password, "password == null"); - return this; - } - - public Builder restApi(@NotNull AuthenticationRestApi restApi) { - mRestApi = checkNotNull(restApi, "restApi == null"); - return this; - } - - public Builder organization(@Nullable String organization) { - mOrganization = organization; - return this; - } - - public Builder timeZone(@NotNull TimeZone timeZone) { - mTimeZone = checkNotNull(timeZone, "timeZone == null"); - return this; - } - - public Builder locale(@NotNull Locale locale) { - mLocale = checkNotNull(locale, "locale == null"); - return this; - } - - /** - * TODO experimental API consider before release - */ - public Builder withDefaultApiProvider(@NotNull String serverUrl) { - mRestApi = new AuthenticationRestApi.Builder() - .baseUrl(serverUrl) - .build(); - return this; - } - - @NotNull - public SpringAuthService build() { - ensureValidState(); - ensureDefaults(); - JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); - return new SpringAuthService(algorithm, - mRestApi, - mUsername, - mPassword, - mOrganization, - mLocale, - mTimeZone); - } - - private void ensureDefaults() { - if (mTimeZone == null) { - mTimeZone = TimeZone.getDefault(); - } - if (mLocale == null) { - mLocale = Locale.getDefault(); - } - } - - private void ensureValidState() { - if (mUsername == null) { - throw new IllegalStateException("Username should not be null"); - } - if (mPassword == null) { - throw new IllegalStateException("Password should not be null"); - } - if (mRestApi == null) { - throw new IllegalStateException("Rest api should not be null. Either set it or call useDefaultApi(url)"); - } - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java new file mode 100644 index 00000000..20ba743b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -0,0 +1,137 @@ +package com.jaspersoft.android.sdk.service.auth; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +import java.util.Locale; +import java.util.TimeZone; + +import static com.jaspersoft.android.sdk.service.Preconditions.checkNotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class SpringCredentials extends Credentials { + private final String mUsername; + private final String mPassword; + private final String mOrganization; + private final Locale mLocale; + private final TimeZone mTimeZone; + + @TestOnly + SpringCredentials( + @NotNull String username, + @NotNull String password, + @NotNull String organization, + @NotNull Locale locale, + @NotNull TimeZone timeZone) { + mUsername = username; + mPassword = password; + mOrganization = organization; + mLocale = locale; + mTimeZone = timeZone; + } + + public static Builder builder() { + return new Builder(); + } + + @NotNull + public String getUsername() { + return mUsername; + } + + @NotNull + public String getPassword() { + return mPassword; + } + + @Nullable + public String getOrganization() { + return mOrganization; + } + + @NotNull + public TimeZone getTimeZone() { + return mTimeZone; + } + + @NotNull + public Locale getLocale() { + return mLocale; + } + + @Override + protected String applyPolicy(AuthPolicy policy) { + return policy.applyCredentials(this); + } + + public static class Builder { + private String mUsername; + private String mPassword; + private String mOrganization; + + // Optional + private Locale mLocale; + private TimeZone mTimeZone; + + private Builder() {} + + public Builder username(@NotNull String username) { + mUsername = checkNotNull(username, "username == null"); + return this; + } + + public Builder password(@NotNull String password) { + mPassword = checkNotNull(password, "password == null"); + return this; + } + + public Builder organization(@Nullable String organization) { + mOrganization = organization; + return this; + } + + public Builder timeZone(@NotNull TimeZone timeZone) { + mTimeZone = checkNotNull(timeZone, "timeZone == null"); + return this; + } + + public Builder locale(@NotNull Locale locale) { + mLocale = checkNotNull(locale, "locale == null"); + return this; + } + + @NotNull + public SpringCredentials build() { + ensureValidState(); + ensureDefaults(); + return new SpringCredentials( + mUsername, + mPassword, + mOrganization, + mLocale, + mTimeZone); + } + + private void ensureDefaults() { + if (mTimeZone == null) { + mTimeZone = TimeZone.getDefault(); + } + if (mLocale == null) { + mLocale = Locale.getDefault(); + } + } + + private void ensureValidState() { + if (mUsername == null) { + throw new IllegalStateException("Username should not be null"); + } + if (mPassword == null) { + throw new IllegalStateException("Password should not be null"); + } + } + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index a99716ea..ece36534 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -43,6 +41,7 @@ import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -218,7 +217,7 @@ public void searchEndpointShouldHandleMultipleResourceTypes() throws Exception { public void shouldSearchResources() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - Map params = new HashMap<>(); + Map params = new LinkedHashMap<>(); params.put("limit", 100); params.put("offset", 100); restApiUnderTest.searchResources("cookie", params); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java new file mode 100644 index 00000000..34c6f34e --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java @@ -0,0 +1,37 @@ +package com.jaspersoft.android.sdk.service.auth; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; + +/** + * @author Tom Koptel + */ +public class JrsAuthenticatorTest { + + @Mock + AuthPolicy mAuthPolicy; + @Mock + Credentials mCredentials; + + private JrsAuthenticator mJrsAuthenticator; + + @Before + public void setupMocks() { + MockitoAnnotations.initMocks(this); + mJrsAuthenticator = new JrsAuthenticator(mAuthPolicy); + } + + @Test + public void testAuthenticate() throws Exception { + mJrsAuthenticator.authenticate(mCredentials); + + verify(mCredentials).applyPolicy(mAuthPolicy); + verifyNoMoreInteractions(mCredentials); + verifyNoMoreInteractions(mAuthPolicy); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index e3a10aa0..61ff05cd 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -69,6 +69,7 @@ public class SpringAuthServiceTest { TimeZone mTimeZone; private SpringAuthService objectUnderTest; + private SpringCredentials credentials; private static final Map sOptionals = new HashMap<>(); @@ -82,14 +83,17 @@ public void setup() { MockitoAnnotations.initMocks(this); objectUnderTest = new SpringAuthService( mAlgorithm, - mRestApi, - "user", - "1234", - "organization", - Locale.US, - mTimeZone + mRestApi ); + credentials = SpringCredentials.builder() + .username("user") + .password("1234") + .organization("organization") + .locale(Locale.US) + .timeZone(mTimeZone) + .build(); + when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn("cookie"); @@ -102,7 +106,7 @@ public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { when(mKey.getModulus()).thenReturn("m"); when(mAlgorithm.encrypt(anyString(), anyString(), anyString())).thenReturn("hashed password"); - objectUnderTest.authenticate(); + objectUnderTest.authenticate(credentials); verify(mRestApi, times(1)).authenticate("user", "hashed password", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); @@ -113,7 +117,7 @@ public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() { when(mKey.isAvailable()).thenReturn(false); - objectUnderTest.authenticate(); + objectUnderTest.authenticate(credentials); verify(mRestApi, times(1)).authenticate("user", "1234", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java similarity index 58% rename from core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java index ab3337a0..5a051bc7 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceBuilderTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java @@ -33,17 +33,13 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; - /** * @author Tom Koptel * @since 2.0 */ -public class SpringAuthServiceBuilderTest { +public class SpringCredentialsTest { - private SpringAuthService.Builder objectUnderTest; + private SpringCredentials.Builder objectUnderTest; @Mock AuthenticationRestApi mRestApi; @@ -54,7 +50,7 @@ public class SpringAuthServiceBuilderTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new SpringAuthService.Builder(); + objectUnderTest = SpringCredentials.builder(); } @Test @@ -73,14 +69,6 @@ public void builderShouldNotAllowNullPassword() { objectUnderTest.password(null); } - @Test - public void builderShouldNotAllowNullRestApi() { - mException.expect(NullPointerException.class); - mException.expectMessage("restApi == null"); - - objectUnderTest.restApi(null); - } - @Test public void builderShouldNotAllowNullLocale() { mException.expect(NullPointerException.class); @@ -96,43 +84,4 @@ public void builderShouldNotAllowNullTimeZone() { objectUnderTest.timeZone(null); } - - @Test - public void serviceShouldThrowIfBuildWithNullUsername() { - mException.expect(IllegalStateException.class); - mException.expectMessage("Username should not be null"); - - objectUnderTest.restApi(mRestApi); - objectUnderTest.password(""); - objectUnderTest.build(); - } - - @Test - public void serviceShouldThrowIfBuildWithNullPassword() { - mException.expect(IllegalStateException.class); - mException.expectMessage("Password should not be null"); - - objectUnderTest.restApi(mRestApi); - objectUnderTest.username(""); - objectUnderTest.build(); - } - - @Test - public void serviceShouldThrowIfBuildWithNullRestApi() { - mException.expect(IllegalStateException.class); - mException.expectMessage("Rest api should not be null. Either set it or call useDefaultApi(url)"); - - objectUnderTest.username(""); - objectUnderTest.password(""); - objectUnderTest.build(); - } - - @Test - public void builderShouldCreateServiceWithDefaultApi() { - objectUnderTest.username(""); - objectUnderTest.password(""); - - SpringAuthService service = objectUnderTest.withDefaultApiProvider("http://localhost/").build(); - assertThat(service, is(notNullValue())); - } } From 96a6b6c888df27c9dc169f145bb2ae1b38d166f7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 5 Nov 2015 14:10:47 +0200 Subject: [PATCH 254/457] Add JrsAuthenticator restApi factory method --- .../android/sdk/service/auth/AuthPolicy.java | 13 ++++++- .../sdk/service/auth/JrsAuthenticator.java | 18 ++++++++- .../sdk/service/auth/SpringAuthService.java | 7 ++++ .../service/auth/JrsAuthenticatorTest.java | 39 +++++++++++++++++-- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java index 27d1b2f7..239ccbec 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java @@ -1,5 +1,9 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; + +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -14,7 +18,14 @@ private Default(SpringAuthService springService) { mSpringService = springService; } - public static Default create(String baseUrl) { + @NotNull + public static AuthPolicy create(@NotNull AuthenticationRestApi restApi) { + SpringAuthService springService = SpringAuthService.create(restApi); + return new Default(springService); + } + + @NotNull + public static Default create(@NotNull String baseUrl) { SpringAuthService springService = SpringAuthService.create(baseUrl); return new Default(springService); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java index 0850facc..92a696d8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java @@ -1,8 +1,12 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import static com.jaspersoft.android.sdk.service.Preconditions.checkNotNull; + /** * @author Tom Koptel * @since 2.0 @@ -15,13 +19,23 @@ public final class JrsAuthenticator { mAuthPolicy = authPolicy; } - public static JrsAuthenticator create(String baseUrl) { + @NotNull + public static JrsAuthenticator create(@NotNull String baseUrl) { + checkNotNull(baseUrl, "Base url should not be null"); AuthPolicy policyImpl = AuthPolicy.Default.create(baseUrl); return new JrsAuthenticator(policyImpl); } @NotNull - public String authenticate(Credentials credentials) { + public static JrsAuthenticator create(@NotNull AuthenticationRestApi restApi) { + checkNotNull(restApi, "Authentication API should not be null"); + AuthPolicy policyImpl = AuthPolicy.Default.create(restApi); + return new JrsAuthenticator(policyImpl); + } + + @NotNull + public String authenticate(@NotNull Credentials credentials) { + checkNotNull(credentials, "Credentials should not be null"); return credentials.applyPolicy(mAuthPolicy); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 0bf43a88..b0195b32 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -53,6 +53,7 @@ final class SpringAuthService { mRestApi = restApi; } + @NotNull public static SpringAuthService create(@NotNull String baseUrl) { JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() @@ -61,6 +62,12 @@ public static SpringAuthService create(@NotNull String baseUrl) { return new SpringAuthService(algorithm, restApi); } + @NotNull + public static SpringAuthService create(@NotNull AuthenticationRestApi restApi) { + JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); + return new SpringAuthService(algorithm, restApi); + } + @NotNull public String authenticate(SpringCredentials credentials) { String password = credentials.getPassword(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java index 34c6f34e..ca5fbb95 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java @@ -1,7 +1,11 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; + import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -18,20 +22,49 @@ public class JrsAuthenticatorTest { @Mock Credentials mCredentials; - private JrsAuthenticator mJrsAuthenticator; + private JrsAuthenticator authenticatorUnderTest; + + @Rule + public ExpectedException mExpectedException = ExpectedException.none(); @Before public void setupMocks() { MockitoAnnotations.initMocks(this); - mJrsAuthenticator = new JrsAuthenticator(mAuthPolicy); + authenticatorUnderTest = new JrsAuthenticator(mAuthPolicy); } @Test public void testAuthenticate() throws Exception { - mJrsAuthenticator.authenticate(mCredentials); + authenticatorUnderTest.authenticate(mCredentials); verify(mCredentials).applyPolicy(mAuthPolicy); verifyNoMoreInteractions(mCredentials); verifyNoMoreInteractions(mAuthPolicy); } + + @Test + public void factoryMethodShouldNotAcceptNullBaseUrl() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Base url should not be null"); + + String baseUrl = null; + JrsAuthenticator.create(baseUrl); + } + + @Test + public void factoryMethodShouldNotAcceptNullApi() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Authentication API should not be null"); + + AuthenticationRestApi restApi = null; + JrsAuthenticator.create(restApi); + } + + @Test + public void authenticateShouldNotAcceptNullCredentials() { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Credentials should not be null"); + + authenticatorUnderTest.authenticate(null); + } } \ No newline at end of file From b90b6a6d0fb5a2692329aad0e59a1813a0a23549 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 10 Nov 2015 09:06:45 +0200 Subject: [PATCH 255/457] Remove transitive dependencies --- core/build.gradle | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index 9e13a089..822a2a5b 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -35,11 +35,7 @@ ext { dependencies { compile 'com.intellij:annotations:12.0' - - compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' - - compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0' compile 'com.madgag.spongycastle:prov:1.52.0.0' testCompile('pl.pragmatists:JUnitParams:1.0.4') { From 7ae3e545e0e407e0d595127c5c23a4353754bc06 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 10 Nov 2015 09:42:59 +0200 Subject: [PATCH 256/457] Remove spoungy castle dependency --- core/build.gradle | 1 - .../sdk/network/JSEncryptionAlgorithm.java | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index 822a2a5b..25515bea 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -36,7 +36,6 @@ ext { dependencies { compile 'com.intellij:annotations:12.0' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' - compile 'com.madgag.spongycastle:prov:1.52.0.0' testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java b/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java index 378edc18..9ce6844c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java @@ -24,18 +24,18 @@ package com.jaspersoft.android.sdk.network; -import org.spongycastle.jce.provider.BouncyCastleProvider; - import java.math.BigInteger; import java.net.URLEncoder; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; import java.security.Provider; import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.RSAPublicKeySpec; import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; /** * @author Tom Koptel @@ -52,8 +52,7 @@ private JSEncryptionAlgorithm(Provider provider) { } public static JSEncryptionAlgorithm create() { - BouncyCastleProvider provider = new BouncyCastleProvider(); - return create(provider); + return create(null); } public static JSEncryptionAlgorithm create(Provider provider) { @@ -64,7 +63,7 @@ public String encrypt(String modulus, String exponent, String text) { try { PublicKey publicKey = createPublicKey(modulus, exponent); - Cipher cipher = Cipher.getInstance("RSA/NONE/NoPadding", mProvider); + Cipher cipher = getCipher(); cipher.init(Cipher.ENCRYPT_MODE, publicKey); String utfPass = URLEncoder.encode(text, UTF_8); @@ -72,8 +71,16 @@ public String encrypt(String modulus, String exponent, String text) { return byteArrayToHexString(encryptedUtfPass); } catch (Exception ex) { - throw new RuntimeException(ex); + // Oops we failed to cipher text remove original + return text; + } + } + + private Cipher getCipher() throws NoSuchAlgorithmException, NoSuchPaddingException, NoSuchProviderException { + if (mProvider == null) { + return Cipher.getInstance("RSA/NONE/NoPadding", "BC"); } + return Cipher.getInstance("RSA/NONE/NoPadding", mProvider); } private PublicKey createPublicKey(String modulus, String exponent) From 9c41146c695967f55bbdb1dd465fc7a04d0e40aa Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 10 Nov 2015 10:08:42 +0200 Subject: [PATCH 257/457] Add equals/hashcode implementation for SpringCredentials --- core/build.gradle | 1 + .../sdk/service/auth/SpringCredentials.java | 37 +++++++++++++++++++ .../service/auth/SpringCredentialsTest.java | 7 ++++ 3 files changed, 45 insertions(+) diff --git a/core/build.gradle b/core/build.gradle index 25515bea..f4914d26 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -37,6 +37,7 @@ dependencies { compile 'com.intellij:annotations:12.0' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' + testCompile "nl.jqno.equalsverifier:equalsverifier:1.7.5" testCompile('pl.pragmatists:JUnitParams:1.0.4') { exclude group: 'org.hamcrest' } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index 20ba743b..c3bb10c9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -68,6 +68,43 @@ protected String applyPolicy(AuthPolicy policy) { return policy.applyCredentials(this); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SpringCredentials that = (SpringCredentials) o; + + if (mUsername != null ? !mUsername.equals(that.mUsername) : that.mUsername != null) + return false; + if (mPassword != null ? !mPassword.equals(that.mPassword) : that.mPassword != null) + return false; + if (mOrganization != null ? !mOrganization.equals(that.mOrganization) : that.mOrganization != null) + return false; + if (mLocale != null ? !mLocale.equals(that.mLocale) : that.mLocale != null) return false; + return !(mTimeZone != null ? !mTimeZone.equals(that.mTimeZone) : that.mTimeZone != null); + } + + @Override + public int hashCode() { + int result = mUsername != null ? mUsername.hashCode() : 0; + result = 31 * result + (mPassword != null ? mPassword.hashCode() : 0); + result = 31 * result + (mOrganization != null ? mOrganization.hashCode() : 0); + result = 31 * result + (mLocale != null ? mLocale.hashCode() : 0); + result = 31 * result + (mTimeZone != null ? mTimeZone.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SpringCredentials{" + + "mLocale=" + mLocale + + ", mUsername='" + mUsername + '\'' + + ", mOrganization='" + mOrganization + '\'' + + ", mTimeZone=" + mTimeZone + + '}'; + } + public static class Builder { private String mUsername; private String mPassword; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java index 5a051bc7..02e39e01 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java @@ -33,6 +33,8 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import nl.jqno.equalsverifier.EqualsVerifier; + /** * @author Tom Koptel * @since 2.0 @@ -84,4 +86,9 @@ public void builderShouldNotAllowNullTimeZone() { objectUnderTest.timeZone(null); } + + @Test + public void testEqualsHashcodeContract() { + EqualsVerifier.forClass(SpringCredentials.class).verify(); + } } From d14b65561655a8a666ed057e938a7048e72caf67 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 10 Nov 2015 10:43:10 +0200 Subject: [PATCH 258/457] Refactor server components.Move to standalone package --- .../sdk/service/GreedyInfoProvider.java | 79 ------------------- .../sdk/service/auth/JrsAuthenticator.java | 2 +- .../sdk/service/auth/SpringCredentials.java | 2 +- .../service/{ => internal}/Preconditions.java | 2 +- .../sdk/service/report/ReportService.java | 2 +- .../service/repository/RepositoryService.java | 2 +- .../service/repository/SearchCriteria.java | 2 +- .../service/repository/SearchStrategy.java | 2 +- .../service/repository/SearchTaskImpl.java | 2 +- .../sdk/service/repository/SearchUseCase.java | 2 +- .../service/{ => server}/InfoProvider.java | 2 +- .../{ => server}/ServerInfoService.java | 10 +-- .../{ => server}/ServerInfoTransformer.java | 4 +- .../repository/RepositoryServiceTest.java | 2 +- .../repository/SearchStrategyTest.java | 2 +- .../repository/SearchTaskImplTest.java | 2 +- .../service/repository/SearchUseCaseTest.java | 2 +- .../{ => server}/ServerInfoServiceTest.java | 2 +- .../ServerInfoTransformerTest.java | 5 +- 19 files changed, 23 insertions(+), 105 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => internal}/Preconditions.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => server}/InfoProvider.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => server}/ServerInfoService.java (89%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => server}/ServerInfoTransformer.java (95%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{ => server}/ServerInfoServiceTest.java (97%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{ => server}/ServerInfoTransformerTest.java (95%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java deleted file mode 100644 index bed3b614..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/GreedyInfoProvider.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; - -import java.text.SimpleDateFormat; - -/** - * Always make call on server - * - * @author Tom Koptel - * @since 2.0 - */ -final class GreedyInfoProvider implements InfoProvider { - private final ServerInfoService mServerInfoService; - private final String mBaseUrl; - - @TestOnly - GreedyInfoProvider(ServerInfoService serverInfoService, String serverUrl) { - mServerInfoService = serverInfoService; - mBaseUrl = serverUrl; - } - - public static InfoProvider newInstance(String serverUrl) { - ServerInfoService service = ServerInfoService.newInstance(serverUrl); - return new GreedyInfoProvider(service, serverUrl); - } - - @NotNull - @Override - public String getBaseUrl() { - return mBaseUrl; - } - - @Override - @NotNull - public ServerInfo provideInfo() { - return mServerInfoService.requestServerInfo(); - } - - @NotNull - @Override - public ServerVersion provideVersion() { - return mServerInfoService.requestServerVersion(); - } - - @NotNull - @Override - public SimpleDateFormat provideDateTimeFormat() { - return mServerInfoService.requestServerDateTimeFormat(); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java index 92a696d8..99f5d370 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java @@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; -import static com.jaspersoft.android.sdk.service.Preconditions.checkNotNull; +import static com.jaspersoft.android.sdk.service.internal.Preconditions.checkNotNull; /** * @author Tom Koptel diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index c3bb10c9..fb2277ae 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -7,7 +7,7 @@ import java.util.Locale; import java.util.TimeZone; -import static com.jaspersoft.android.sdk.service.Preconditions.checkNotNull; +import static com.jaspersoft.android.sdk.service.internal.Preconditions.checkNotNull; /** * @author Tom Koptel diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Preconditions.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/Preconditions.java index 5924b831..1c47c5ce 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Preconditions.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Preconditions.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal; import org.jetbrains.annotations.Nullable; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 3a0763bf..ad4aef47 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 58525aad..7328c3fa 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; /** diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index e28910c8..55e71bff 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static com.jaspersoft.android.sdk.service.Preconditions.checkArgument; +import static com.jaspersoft.android.sdk.service.internal.Preconditions.checkArgument; /** * @author Tom Koptel diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index e5e37ceb..b76e9558 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index aec1302a..cabdd958 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 8013785c..f48666be 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java index a8242e97..a8e34024 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoProvider.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java similarity index 89% rename from core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index b496939d..27b9bed4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; @@ -47,16 +47,12 @@ public final class ServerInfoService { mTransformer = transformer; } - public static ServerInfoService newInstance(ServerRestApi restApi) { - return new ServerInfoService(restApi, ServerInfoTransformer.getInstance()); - } - - public static ServerInfoService newInstance(String baseUrl) { + public static ServerInfoService create(String baseUrl) { ServerRestApi restApi = new ServerRestApi.Builder() .baseUrl(baseUrl) .build(); - return new ServerInfoService(restApi, ServerInfoTransformer.getInstance()); + return new ServerInfoService(restApi, ServerInfoTransformer.get()); } public ServerInfo requestServerInfo() { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java similarity index 95% rename from core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java index c473b229..0e43463b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -41,7 +41,7 @@ private ServerInfoTransformer() { // single instance } - public static ServerInfoTransformer getInstance() { + public static ServerInfoTransformer get() { return InstanceHolder.INSTANCE; } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 129124cc..ada4a00f 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index ad8d82bf..12ccee23 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index a07cbe08..d4a619fc 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 26a64079..ab9604b9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.InfoProvider; +import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java similarity index 97% rename from core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java index 52927c27..23990ab6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java similarity index 95% rename from core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index 23a925c6..04550e53 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -22,12 +22,13 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.server.ServerInfoTransformer; import org.junit.Before; import org.junit.Test; @@ -57,7 +58,7 @@ public class ServerInfoTransformerTest { @Before public void setup() { - transformerUnderTest = ServerInfoTransformer.getInstance(); + transformerUnderTest = ServerInfoTransformer.get(); mServerInfoData = PowerMockito.mock(ServerInfoData.class); when(mServerInfoData.getBuild()).thenReturn("20150527_1447"); when(mServerInfoData.getDateFormatPattern()).thenReturn("yyyy-MM-dd"); From b11f1533d5aed8861f226e55472a21af52f2eb18 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 11 Nov 2015 10:48:25 +0200 Subject: [PATCH 259/457] Fix javadoc errors --- .../jaspersoft/android/sdk/network/InputControlRestApi.java | 5 +++-- .../android/sdk/network/ReportExecutionRestApi.java | 4 +--- .../java/com/jaspersoft/android/sdk/network/RestError.java | 4 ++-- .../android/sdk/network/entity/export/OutputResource.java | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index 7e2c8bdf..13180211 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -41,8 +41,8 @@ public interface InputControlRestApi { /** * Returns input controls for associated response. Options can be excluded by additional argument. - *

- * ATTENTION: Exclude flag works only on JRS instances 6.0+ + * + * ATTENTION: Exclude flag works only on JRS instances 6.0+ * * @param token is a key API sends to authorize client * @param reportUri uri of report @@ -63,6 +63,7 @@ Collection requestInputControlsInitialStates(@NotNull String * Provides values for specified controls. This API helpful to * delegate cascading resolving for the server, also should handle non-cascading cases * + * @param token is a key API sends to authorize client * @param reportUri uri of report * @param controlsValues map of {control_id: [value, value]} associated input controls metadata * @param freshData whether data should be retrieved from cache or not diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index 44d69147..e4e9d885 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -56,9 +56,7 @@ boolean updateReportExecution(@NotNull String token, @NotNull String executionId, @NotNull Collection>> params); - /** - * TODO: API is broken requires investigation before release - */ + // TODO: API is broken requires investigation before release @NotNull ReportExecutionSearchResponse searchReportExecution(@NotNull String token, Map params); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java index 9cc5e035..e1b2e143 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java @@ -65,12 +65,12 @@ static RestError unexpectedError(Throwable exception) { this.kind = kind; } - /** HTTP status code. */ + // HTTP status code. public int code() { return response.code(); } - /** HTTP status message. */ + // HTTP status message. public String message() { return response.message(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java index 43f0fa24..d123184f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/export/OutputResource.java @@ -44,7 +44,7 @@ public interface OutputResource { * Client responsible for closing stream * * @return raw stream of bytes of corresponding file - * @throws IOException + * @throws IOException that refers to network error. E.g. missing network connection */ InputStream getStream() throws IOException; } From 5543b8b40512f82f15161bf16a206a6c188f0d5f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 11 Nov 2015 12:42:55 +0200 Subject: [PATCH 260/457] Enforce Java 1.7 source/target compatibility --- core/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/build.gradle b/core/build.gradle index f4914d26..838f41cd 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -27,6 +27,9 @@ apply plugin: 'java' description = 'js-android-sdk-core' version = clientModuleVersion +sourceCompatibility = 1.7 +targetCompatibility = 1.7 + ext { PUBLISH_GROUP_ID = group PUBLISH_ARTIFACT_ID = description From 3f648d7482f39255177a3bc844e9c2a59e3a5f65 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 12 Nov 2015 11:43:36 +0200 Subject: [PATCH 261/457] Extracting integration tests in submodule --- core-integration-tests/.gitignore | 1 + core-integration-tests/build.gradle | 32 +++++++++++++++++++ .../network}/AuthenticationRestApiTest.java | 4 +-- .../sdk/network}/InputControlRestApiTest.java | 8 ++--- .../network}/ReportExecutionRestApiTest.java | 8 ++--- .../sdk/network}/ReportExportRestApiTest.java | 8 ++--- .../sdk/network}/ReportOptionRestApiTest.java | 8 ++--- .../sdk/network}/RepositoryRestApiTest.java | 8 ++--- .../android/sdk/network}/ServerRestTest.java | 4 +-- .../android/sdk/util}/DummyTokenProvider.java | 2 +- .../android/sdk/util}/JrsMetadata.java | 2 +- .../android/sdk/util}/TestLogger.java | 2 +- settings.gradle | 1 + 13 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 core-integration-tests/.gitignore create mode 100644 core-integration-tests/build.gradle rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network}/AuthenticationRestApiTest.java (96%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network}/InputControlRestApiTest.java (93%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network}/ReportExecutionRestApiTest.java (95%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network}/ReportExportRestApiTest.java (94%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network}/ReportOptionRestApiTest.java (92%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network}/RepositoryRestApiTest.java (91%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network}/ServerRestTest.java (97%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util}/DummyTokenProvider.java (97%) rename {core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util}/JrsMetadata.java (98%) rename {core/src/test/java/com/jaspersoft/android/sdk/test => core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util}/TestLogger.java (97%) diff --git a/core-integration-tests/.gitignore b/core-integration-tests/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/core-integration-tests/.gitignore @@ -0,0 +1 @@ +/build diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle new file mode 100644 index 00000000..79582690 --- /dev/null +++ b/core-integration-tests/build.gradle @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +apply plugin: 'java' + +dependencies { + compile project(':js-android-sdk-core') + testCompile 'org.hamcrest:hamcrest-integration:1.3' + testCompile 'junit:junit:4.12' + testCompile 'org.bouncycastle:bcprov-jdk16:1.46' +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java similarity index 96% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index 3bc324a7..ef8c04c9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; -import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.util.TestLogger; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Ignore; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java similarity index 93% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index 6648f2a2..b2c7abf3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -22,14 +22,14 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.util.DummyTokenProvider; +import com.jaspersoft.android.sdk.util.JrsMetadata; +import com.jaspersoft.android.sdk.util.TestLogger; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java similarity index 95% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index a7b70a8b..aa95ab0d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -22,16 +22,16 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.util.DummyTokenProvider; +import com.jaspersoft.android.sdk.util.JrsMetadata; +import com.jaspersoft.android.sdk.util.TestLogger; import org.jetbrains.annotations.NotNull; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java similarity index 94% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index 426f3ff8..f99dc7b4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; @@ -32,9 +32,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.util.DummyTokenProvider; +import com.jaspersoft.android.sdk.util.JrsMetadata; +import com.jaspersoft.android.sdk.util.TestLogger; import org.jetbrains.annotations.NotNull; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java similarity index 92% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 8c6fbb71..2a4a3ffb 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -22,13 +22,13 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.util.DummyTokenProvider; +import com.jaspersoft.android.sdk.util.JrsMetadata; +import com.jaspersoft.android.sdk.util.TestLogger; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java similarity index 91% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index bb7579d0..0f07b2ea 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -22,15 +22,15 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; +import com.jaspersoft.android.sdk.util.DummyTokenProvider; +import com.jaspersoft.android.sdk.util.JrsMetadata; +import com.jaspersoft.android.sdk.util.TestLogger; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java similarity index 97% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java index 984287fa..c9297a0d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import com.jaspersoft.android.sdk.test.TestLogger; +import com.jaspersoft.android.sdk.util.TestLogger; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/DummyTokenProvider.java similarity index 97% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/DummyTokenProvider.java index 9af2fbc3..ac2aee66 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/DummyTokenProvider.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api.utils; +package com.jaspersoft.android.sdk.util; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/JrsMetadata.java similarity index 98% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/JrsMetadata.java index 33d1faa9..43268b47 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/JrsMetadata.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api.utils; +package com.jaspersoft.android.sdk.util; import java.net.MalformedURLException; import java.net.URL; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestLogger.java similarity index 97% rename from core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestLogger.java index b7074e95..0ce41a0c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestLogger.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.test; +package com.jaspersoft.android.sdk.util; import com.jaspersoft.android.sdk.network.RestApiLog; diff --git a/settings.gradle b/settings.gradle index cf99081d..6d311942 100644 --- a/settings.gradle +++ b/settings.gradle @@ -24,5 +24,6 @@ include ':js-android-sdk-client' include ':js-android-sdk-core' +include ':core-integration-tests' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File project(':js-android-sdk-core').projectDir = "$rootDir/core" as File From 084c604624822a37ba4d8ecfb238a311d11c4019 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 12 Nov 2015 12:15:46 +0200 Subject: [PATCH 262/457] Initial setup of gradle-properties-plugin --- buildsystem/integration_env.properties | 25 +++++ core-integration-tests/.gitignore | 1 + core-integration-tests/build.gradle | 28 ++++- .../android/sdk/network/ServerRestTest.java | 1 - .../android/sdk/util/IntegrationEnv.java | 61 +++++++++++ .../android/sdk/util/TestResource.java | 100 ++++++++++++++++++ .../src/test/resources/.gitignore | 1 + .../src/test/resources/.gitkeep | 0 8 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 buildsystem/integration_env.properties create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestResource.java create mode 100644 core-integration-tests/src/test/resources/.gitignore create mode 100644 core-integration-tests/src/test/resources/.gitkeep diff --git a/buildsystem/integration_env.properties b/buildsystem/integration_env.properties new file mode 100644 index 00000000..3cf11b19 --- /dev/null +++ b/buildsystem/integration_env.properties @@ -0,0 +1,25 @@ +# +# Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. +# http://community.jaspersoft.com/project/mobile-sdk-android +# +# Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, +# the following license terms apply: +# +# This program is part of TIBCO Jaspersoft Mobile SDK for Android. +# +# TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with TIBCO Jaspersoft Mobile SDK for Android. If not, see +# . +# + +test.server=@server@ \ No newline at end of file diff --git a/core-integration-tests/.gitignore b/core-integration-tests/.gitignore index 796b96d1..9fbb0c04 100644 --- a/core-integration-tests/.gitignore +++ b/core-integration-tests/.gitignore @@ -1 +1,2 @@ /build +gradle-local.properties \ No newline at end of file diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 79582690..07d1810e 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -21,12 +21,38 @@ * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'net.saliman:gradle-properties-plugin:1.4.4' + } +} apply plugin: 'java' +apply plugin: 'net.saliman.properties' dependencies { compile project(':js-android-sdk-core') testCompile 'org.hamcrest:hamcrest-integration:1.3' testCompile 'junit:junit:4.12' testCompile 'org.bouncycastle:bcprov-jdk16:1.46' -} \ No newline at end of file +} + +task prep() { + def resourceDir = file("${projectDir}/src/test/resources") + def env = 'integration_env.properties' + requiredProperties "server" + outputs.file new File(resourceDir, env) + doFirst { + copy { + from file("${rootDir}/buildsystem/") + include env + into resourceDir + filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.filterTokens) + } + } +} + +compileJava.dependsOn prep \ No newline at end of file diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java index c9297a0d..9ddd830f 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.util.TestLogger; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java new file mode 100644 index 00000000..8405e3f8 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util; + +import java.io.IOException; +import java.util.Properties; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class IntegrationEnv { + private final Properties config; + + private IntegrationEnv(Properties properties) { + config = properties; + } + + public static IntegrationEnv load() { + Properties properties = new Properties(); + try { + properties.load(TestResource.create("integration_env.properties").asStream()); + return new IntegrationEnv(properties); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public String getSetver() { + return config.getProperty("test.server"); + } + + @Override + public String toString() { + return "IntegrationEnv{" + + "config=" + config + + '}'; + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestResource.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestResource.java new file mode 100644 index 00000000..410568f6 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestResource.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class TestResource { + private final File mResource; + + private TestResource(String fileName) { + if (fileName == null || fileName.length() == 0) { + throw new IllegalArgumentException("Resource name should not be null"); + } + ClassLoader classLoader = getClass().getClassLoader(); + URL url = classLoader.getResource(fileName); + File file = new File(url.getFile()); + if (!file.exists()) { + throw new RuntimeException( + new FileNotFoundException("Resource on path: " + file.getPath() + " not found") + ); + } + mResource = file; + } + + public static TestResource create(String fileName) { + return new TestResource(fileName); + } + + public String asString() { + return readFile(asFile()); + } + + public InputStream asStream() { + try { + return new FileInputStream(mResource); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } + + public File asFile() { + return mResource; + } + + @Override + public String toString() { + return "TestResource{" + + "path='" + mResource.getPath() + '\'' + + '}'; + } + + private static String readFile(File f) { + StringBuilder sb = new StringBuilder(); + try (BufferedReader br = new BufferedReader(new FileReader(f))) { + String sCurrentLine; + while ((sCurrentLine = br.readLine()) != null) { + sb.append(sCurrentLine); + } + + } catch (IOException e) { + System.err.println("I/O Exception:" + e.getMessage()); + return null; + } + return sb.toString(); + } + +} diff --git a/core-integration-tests/src/test/resources/.gitignore b/core-integration-tests/src/test/resources/.gitignore new file mode 100644 index 00000000..102b6fc9 --- /dev/null +++ b/core-integration-tests/src/test/resources/.gitignore @@ -0,0 +1 @@ +*.properties \ No newline at end of file diff --git a/core-integration-tests/src/test/resources/.gitkeep b/core-integration-tests/src/test/resources/.gitkeep new file mode 100644 index 00000000..e69de29b From 779cca77ccb38b80a1d382d48f8f02823e1794d7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 12 Nov 2015 12:54:04 +0200 Subject: [PATCH 263/457] Parametrize 'ServerRest' test with dynamic env --- core-integration-tests/build.gradle | 5 +- .../android/sdk/network/ServerRestTest.java | 103 ++++++++++-------- .../android/sdk/util/IntegrationEnv.java | 12 +- .../android/sdk/util/jrsEnvironmentRule.java | 51 +++++++++ 4 files changed, 124 insertions(+), 47 deletions(-) create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 07d1810e..8c9af5f4 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -35,8 +35,11 @@ apply plugin: 'net.saliman.properties' dependencies { compile project(':js-android-sdk-core') + testCompile 'org.hamcrest:hamcrest-integration:1.3' - testCompile 'junit:junit:4.12' + testCompile('pl.pragmatists:JUnitParams:1.0.4') { + exclude group: 'org.hamcrest' + } testCompile 'org.bouncycastle:bcprov-jdk16:1.46' } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java index 9ddd830f..0340cd18 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java @@ -26,89 +26,106 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import com.jaspersoft.android.sdk.util.JrsEnvironmentRule; import com.jaspersoft.android.sdk.util.TestLogger; -import org.junit.Before; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.runner.RunWith; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class ServerRestTest { - private String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; - private ServerRestApi apiUnderTest; + @ClassRule + public static JrsEnvironmentRule sEnv = new JrsEnvironmentRule(); - @Before - public void setup() { - apiUnderTest = new ServerRestApi.Builder() - .logger(TestLogger.get(this)) - .baseUrl(mobileDemo2) - .build(); + @Test + @Parameters(method = "servers") + public void shouldRequestServerInfo(String baseUrl) throws Exception { + ServerInfoData response = createApi(baseUrl).requestServerInfo(); + assertThat("Failed to receive server info response", response != null); } @Test - public void shouldRequestServerInfo() throws Exception { - ServerInfoData response = apiUnderTest.requestServerInfo(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestBuild(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestBuild(); + assertThat("Failed to receive build info response", response != null); } @Test - public void shouldRequestBuild() throws Exception { - String response = apiUnderTest.requestBuild(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestDateFormatPattern(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestDateFormatPattern(); + assertThat("Failed to receive date format info response", response != null); } @Test - public void shouldRequestDateFormatPattern() throws Exception { - String response = apiUnderTest.requestDateFormatPattern(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestDateTimeFormatPattern(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestDateTimeFormatPattern(); + assertThat("Failed to receive date time format info response", response != null); } @Test - public void shouldRequestDateTimeFormatPattern() throws Exception { - String response = apiUnderTest.requestDateTimeFormatPattern(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestEdition(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestEdition(); + assertThat("Failed to receive edition info response", response != null); } @Test - public void shouldRequestEdition() throws Exception { - String response = apiUnderTest.requestEdition(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestEditionName(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestEditionName(); + assertThat("Failed to receive edition name info response", response != null); } @Test - public void shouldRequestEditionName() throws Exception { - String response = apiUnderTest.requestEditionName(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestVersion(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestVersion(); + assertThat("Failed to receive version info response", response != null); } @Test - public void shouldRequestVersion() throws Exception { - String response = apiUnderTest.requestVersion(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestFeatures(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestFeatures(); + assertThat("Failed to receive features info response", response != null); } @Test - public void shouldRequestFeatures() throws Exception { - String response = apiUnderTest.requestFeatures(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestLicenseType(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestLicenseType(); + assertThat("Failed to receive license info response", response != null); } @Test - public void shouldRequestLicenseType() throws Exception { - String response = apiUnderTest.requestLicenseType(); - assertThat(response, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestExpiration(String baseUrl) throws Exception { + String response = createApi(baseUrl).requestExpiration(); + assertThat("Failed to receive expiration info response", response != null); } - @Test - public void shouldRequestExpiration() throws Exception { - String response = apiUnderTest.requestExpiration(); - assertThat(response, is(notNullValue())); + private ServerRestApi createApi(String baseUrl) { + return new ServerRestApi.Builder() + .logger(TestLogger.get(this)) + .baseUrl(baseUrl) + .build(); + } + + private Object[] servers() { + return sEnv.listServers(); } } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java index 8405e3f8..a91f746e 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java @@ -32,6 +32,7 @@ * @since 2.0 */ public final class IntegrationEnv { + private static final String PROPERTIES_FILE = "integration_env.properties"; private final Properties config; private IntegrationEnv(Properties properties) { @@ -41,15 +42,20 @@ private IntegrationEnv(Properties properties) { public static IntegrationEnv load() { Properties properties = new Properties(); try { - properties.load(TestResource.create("integration_env.properties").asStream()); + properties.load(TestResource.create(PROPERTIES_FILE).asStream()); return new IntegrationEnv(properties); } catch (IOException e) { throw new RuntimeException(e); } } - public String getSetver() { - return config.getProperty("test.server"); + public String[] getServers() { + String serverProp = config.getProperty("test.server"); + String[] servers = serverProp.split(","); + if (servers.length == 0) { + return new String[] {serverProp}; + } + return servers; } @Override diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java new file mode 100644 index 00000000..f1aacd3e --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util; + +import org.junit.rules.ExternalResource; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class JrsEnvironmentRule extends ExternalResource { + private IntegrationEnv mIntegrationEnv; + + public Object[] listServers() { + String[] servers = getLazyEnv().getServers(); + Object[] result = new Object[servers.length]; + for (int i = 0; i < servers.length; i++) { + result[i] = new Object[] {servers[i]}; + } + return result; + } + + private IntegrationEnv getLazyEnv() { + if (mIntegrationEnv == null) { + mIntegrationEnv = IntegrationEnv.load(); + } + return mIntegrationEnv; + } +} From 61e3d81aadca590f579adc9a155f30a65f8288db Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 12 Nov 2015 14:10:53 +0200 Subject: [PATCH 264/457] Add support for authorized servers --- buildsystem/integration_env.properties | 3 +- core-integration-tests/build.gradle | 2 +- .../sdk/network/RepositoryRestApiTest.java | 55 +++++---- .../android/sdk/util/IntegrationEnv.java | 20 +++- .../android/sdk/util/jrsEnvironmentRule.java | 27 ++++- .../exception/AuthenticationException.java | 39 +++++++ .../rest/exception/ClientErrorException.java | 35 ++++++ .../util/rest/exception/HttpException.java | 82 ++++++++++++++ .../rest/exception/ServerErrorException.java | 35 ++++++ .../sdk/util/rest/token/Authorizer.java | 52 +++++++++ .../sdk/util/rest/token/Credentials.java | 52 +++++++++ .../util/rest/token/SpringCredentials.java | 93 ++++++++++++++++ .../sdk/util/rest/token/TokenFactory.java | 104 ++++++++++++++++++ 13 files changed, 567 insertions(+), 32 deletions(-) create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/AuthenticationException.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ClientErrorException.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/HttpException.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ServerErrorException.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Authorizer.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/TokenFactory.java diff --git a/buildsystem/integration_env.properties b/buildsystem/integration_env.properties index 3cf11b19..d2e367b4 100644 --- a/buildsystem/integration_env.properties +++ b/buildsystem/integration_env.properties @@ -22,4 +22,5 @@ # . # -test.server=@server@ \ No newline at end of file +test.servers=@servers@ +test.credentials=@credentials@ \ No newline at end of file diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 8c9af5f4..1bc98d20 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -46,7 +46,7 @@ dependencies { task prep() { def resourceDir = file("${projectDir}/src/test/resources") def env = 'integration_env.properties' - requiredProperties "server" + requiredProperties "servers", "credentials" outputs.file new File(resourceDir, env) doFirst { copy { diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index 0f07b2ea..6d662123 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -24,43 +24,30 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.util.DummyTokenProvider; -import com.jaspersoft.android.sdk.util.JrsMetadata; +import com.jaspersoft.android.sdk.util.JrsEnvironmentRule; import com.jaspersoft.android.sdk.util.TestLogger; -import org.junit.Before; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.runner.RunWith; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Tom Koptel * @since 2.0 */ +@RunWith(JUnitParamsRunner.class) public class RepositoryRestApiTest { - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); - private RepositoryRestApi api; - - @Before - public void setup() { - if (api == null) { - api = new RepositoryRestApi.Builder() - .baseUrl(mMetadata.getServerUrl()) - .logger(TestLogger.get(this)) - .build(); - } - } + @ClassRule + public static JrsEnvironmentRule sEnv = new JrsEnvironmentRule(); +/* @Test public void shouldRequestListOfResources() { ResourceSearchResult resourceSearchResult = api.searchResources(mAuthenticator.token(), null); @@ -74,10 +61,22 @@ public void shouldRequestReport() { assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } - +*/ @Test - public void shouldRequestRootFolder() { - FolderLookup folder = api.requestFolderResource(mAuthenticator.token(), "/"); - assertThat(folder, is(notNullValue())); + @Parameters(method = "servers") + public void shouldRequestRootFolder(String token, String baseUrl) { + FolderLookup folder = createApi(baseUrl).requestFolderResource(token, "/"); + assertThat("Failed to root folder response", folder != null); + } + + private Object[] servers() { + return sEnv.listAuthorizedServers(); + } + + private RepositoryRestApi createApi(String baseUrl) { + return new RepositoryRestApi.Builder() + .baseUrl(baseUrl) + .logger(TestLogger.get(this)) + .build(); } } \ No newline at end of file diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java index a91f746e..905e84f5 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java @@ -24,6 +24,9 @@ package com.jaspersoft.android.sdk.util; + +import com.jaspersoft.android.sdk.util.rest.token.Credentials; + import java.io.IOException; import java.util.Properties; @@ -50,7 +53,7 @@ public static IntegrationEnv load() { } public String[] getServers() { - String serverProp = config.getProperty("test.server"); + String serverProp = config.getProperty("test.servers"); String[] servers = serverProp.split(","); if (servers.length == 0) { return new String[] {serverProp}; @@ -58,6 +61,21 @@ public String[] getServers() { return servers; } + public Credentials[] getCredentials() { + String serverProp = config.getProperty("test.credentials"); + String[] credentials = serverProp.split(","); + if (credentials.length == 0) { + credentials = new String[] {serverProp}; + } + + Credentials[] result = new Credentials[credentials.length]; + for (int i = 0; i < credentials.length; i++) { + result[i] = Credentials.Factory.create(credentials[i]); + } + + return result; + } + @Override public String toString() { return "IntegrationEnv{" + diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java index f1aacd3e..0bed02bf 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java @@ -24,8 +24,14 @@ package com.jaspersoft.android.sdk.util; +import com.jaspersoft.android.sdk.util.rest.exception.HttpException; +import com.jaspersoft.android.sdk.util.rest.token.Authorizer; +import com.jaspersoft.android.sdk.util.rest.token.Credentials; + import org.junit.rules.ExternalResource; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.3 @@ -37,7 +43,26 @@ public Object[] listServers() { String[] servers = getLazyEnv().getServers(); Object[] result = new Object[servers.length]; for (int i = 0; i < servers.length; i++) { - result[i] = new Object[] {servers[i]}; + result[i] = new Object[]{servers[i]}; + } + return result; + } + + public Object[] listAuthorizedServers() { + String[] servers = getLazyEnv().getServers(); + Credentials[] credentials = getLazyEnv().getCredentials(); + if (servers.length != credentials.length) { + throw new IllegalStateException("Test environment configured improperly. Servers number should equal credentials"); + } + + Object[] result = new Object[servers.length]; + for (int i = 0; i < servers.length; i++) { + try { + String token = Authorizer.create(servers[i]).authorize(credentials[i]); + result[i] = new Object[]{token, servers[i]}; + } catch (IOException | HttpException e) { + throw new RuntimeException("Failed to configure token for server " + servers[i] + " abort test execution", e); + } } return result; } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/AuthenticationException.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/AuthenticationException.java new file mode 100644 index 00000000..66794854 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/AuthenticationException.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.exception; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class AuthenticationException extends HttpException { + private AuthenticationException(int code, String url, String response) { + super(code, url, response); + } + + public static AuthenticationException create(String url, String response) { + return new AuthenticationException(401, url, response); + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ClientErrorException.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ClientErrorException.java new file mode 100644 index 00000000..6d6eef42 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ClientErrorException.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.exception; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ClientErrorException extends HttpException { + public ClientErrorException(int code, String url, String response) { + super(code, url, response); + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/HttpException.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/HttpException.java new file mode 100644 index 00000000..2b7b8d7b --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/HttpException.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.exception; + +import com.squareup.okhttp.Response; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public abstract class HttpException extends Exception { + private final int mCode; + private final String mResponse; + + public HttpException(int code, String url, String response) { + super(createMessage(code, url, response)); + mCode = code; + mResponse = response; + } + + private static String createMessage(int code, String url, String response) { + String line = "==================================================="; + return String.format("\n\n%s\nRequest %s failed\ncode: %d\nmessage: %s\n%s\n", + line, url, code, trim(response), line); + } + + private static String trim(String response) { + if (response.length() > 100) { + return response.substring(0, 99); + } + return response; + } + + public int getCode() { + return mCode; + } + + public String getResponse() { + return mResponse; + } + + public static class Factory { + public static HttpException create(Response response) throws IOException, HttpException { + int code = response.code(); + String url = response.request().urlString(); + String body = response.body().string(); + if (code == 401) { + return AuthenticationException.create(url, body); + } else if (code >= 400 && code < 500) { + return new ClientErrorException(code, url, body); + } else if (code >= 500 && code < 600) { + return new ServerErrorException(code, url, body); + } else { + throw new RuntimeException("Unexpected response " + response); + } + } + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ServerErrorException.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ServerErrorException.java new file mode 100644 index 00000000..bde8f35b --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ServerErrorException.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.exception; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ServerErrorException extends HttpException { + public ServerErrorException(int code, String url, String response) { + super(code, url, response); + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Authorizer.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Authorizer.java new file mode 100644 index 00000000..4dd748f6 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Authorizer.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.token; + +import com.jaspersoft.android.sdk.util.rest.exception.HttpException; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class Authorizer { + private final TokenFactory tokeFactory; + + private Authorizer(String baseUrl) { + if (!baseUrl.endsWith("/")) { + baseUrl += "/"; + } + this.tokeFactory = new TokenFactory(baseUrl); + } + + public static Authorizer create(String baseUrl) { + return new Authorizer(baseUrl); + } + + public String authorize(Credentials credentials) throws IOException, HttpException { + return credentials.delegateSelf(tokeFactory); + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java new file mode 100644 index 00000000..7b5bb0e9 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.token; + +import com.jaspersoft.android.sdk.util.rest.exception.HttpException; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public abstract class Credentials { + protected abstract String delegateSelf(TokenFactory factory) throws IOException, HttpException; + + public static class Factory { + public static Credentials create(String data) { + String[] items = data.split("\\|"); + String type = items[0]; + if ("spring".equals(type)) { + return SpringCredentials.builder() + .setUsername(items[1]) + .setPassword(items[2]) + .setOrganization("null".equals(items[3]) ? null : items[3]) + .create(); + } + throw new UnsupportedOperationException("Test could not create credential of type: " + type); + } + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java new file mode 100644 index 00000000..1268a727 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.token; + +import com.jaspersoft.android.sdk.util.rest.exception.HttpException; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class SpringCredentials extends Credentials { + private final String username; + private final String password; + private final String organization; + + public SpringCredentials(String username, String password, String organization) { + this.username = username; + this.password = password; + this.organization = organization; + } + + protected String delegateSelf(TokenFactory factory) throws IOException, HttpException { + return factory.create(this); + } + + public String getOrganization() { + return organization; + } + + public String getPassword() { + return password; + } + + public String getUsername() { + return username; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String mUsername; + private String mPassword; + private String mOrganization; + + private Builder() { + } + + public Builder setUsername(String username) { + mUsername = username; + return this; + } + + public Builder setPassword(String password) { + mPassword = password; + return this; + } + + public Builder setOrganization(String organization) { + mOrganization = organization; + return this; + } + + public SpringCredentials create() { + return new SpringCredentials(mUsername, mPassword, mOrganization); + } + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/TokenFactory.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/TokenFactory.java new file mode 100644 index 00000000..aaacecf5 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/TokenFactory.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.token; + +import com.jaspersoft.android.sdk.util.rest.exception.AuthenticationException; +import com.jaspersoft.android.sdk.util.rest.exception.HttpException; +import com.squareup.okhttp.FormEncodingBuilder; +import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.3 + */ +final class TokenFactory { + private final String mBaseUrl; + private final OkHttpClient mOkhttp; + + public TokenFactory(String baseUrl) { + mBaseUrl = baseUrl; + mOkhttp = new OkHttpClient(); + mOkhttp.setFollowRedirects(false); + } + + public String create(SpringCredentials credentials) throws IOException, HttpException { + FormEncodingBuilder formBody = new FormEncodingBuilder() + .add("j_password", credentials.getPassword()) + .add("j_username", credentials.getUsername()); + + if (credentials.getOrganization() != null) { + formBody.add("orgId", credentials.getOrganization()); + } + Request request = new Request.Builder() + .url(mBaseUrl + "j_spring_security_check") + .post(formBody.build()) + .build(); + Response response = mOkhttp.newCall(request).execute(); + + int statusCode = response.code(); + if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request + return extractCookie(response); + } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request + String location = response.headers().get("Location"); + if (location == null) { + throw new IllegalStateException("Location HEADER is missing please contact JRS admin"); + } + HttpUrl url = HttpUrl.parse(location); + String errorQueryParameter = url.queryParameter("error"); + if (errorQueryParameter == null) { + return extractCookie(response); + } else { + throw AuthenticationException.create(request.urlString(), response.body().string()); + } + } else { + throw HttpException.Factory.create(response); + } + } + + public static String extractCookie(Response response) { + List parts = response.headers().values("Set-Cookie"); + return joinCookieParts(parts).toString(); + } + + private static StringBuilder joinCookieParts(List parts) { + StringBuilder stringBuilder = new StringBuilder(); + Iterator iterator = parts.iterator(); + while (iterator.hasNext()) { + String cookie = iterator.next(); + stringBuilder.append(cookie); + if (iterator.hasNext()) { + stringBuilder.append(";"); + } + } + return stringBuilder; + } +} From 6bc6d34cf500ccdc92da6e2ef2c757d7353f65ef Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 12 Nov 2015 14:59:14 +0200 Subject: [PATCH 265/457] Separating server configuration from properties file --- buildsystem/integration_env.properties | 3 +- core-integration-tests/.gitignore | 4 +- core-integration-tests/build.gradle | 8 ++- .../android/sdk/util/IntegrationEnv.java | 37 +++++------- .../android/sdk/util/jrsEnvironmentRule.java | 42 ++++++++------ .../android/sdk/util/rest/dto/AuthConfig.java | 58 +++++++++++++++++++ .../android/sdk/util/rest/dto/Server.java | 50 ++++++++++++++++ .../sdk/util/rest/token/Credentials.java | 15 +++-- .../src/test/resources/.gitignore | 1 - 9 files changed, 165 insertions(+), 53 deletions(-) create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/AuthConfig.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/Server.java delete mode 100644 core-integration-tests/src/test/resources/.gitignore diff --git a/buildsystem/integration_env.properties b/buildsystem/integration_env.properties index d2e367b4..b46a21fb 100644 --- a/buildsystem/integration_env.properties +++ b/buildsystem/integration_env.properties @@ -22,5 +22,4 @@ # . # -test.servers=@servers@ -test.credentials=@credentials@ \ No newline at end of file +servers.config.file=@servers.file.name@ diff --git a/core-integration-tests/.gitignore b/core-integration-tests/.gitignore index 9fbb0c04..fb098b18 100644 --- a/core-integration-tests/.gitignore +++ b/core-integration-tests/.gitignore @@ -1,2 +1,4 @@ /build -gradle-local.properties \ No newline at end of file +gradle-local.properties +servers-local.json +integration_env.properties diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 1bc98d20..19fe470a 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -46,7 +46,7 @@ dependencies { task prep() { def resourceDir = file("${projectDir}/src/test/resources") def env = 'integration_env.properties' - requiredProperties "servers", "credentials" + requiredProperties "servers.file.name" outputs.file new File(resourceDir, env) doFirst { copy { @@ -57,5 +57,11 @@ task prep() { } } } +task copyConfig(type: Copy) { + def resourceDir = file("${projectDir}/src/test/resources") + from file("${projectDir}/servers-local.json") + into resourceDir +} +prep.dependsOn copyConfig compileJava.dependsOn prep \ No newline at end of file diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java index 905e84f5..3282c927 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java @@ -25,9 +25,15 @@ package com.jaspersoft.android.sdk.util; -import com.jaspersoft.android.sdk.util.rest.token.Credentials; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.jaspersoft.android.sdk.util.rest.dto.Server; import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.List; import java.util.Properties; /** @@ -37,9 +43,11 @@ public final class IntegrationEnv { private static final String PROPERTIES_FILE = "integration_env.properties"; private final Properties config; + private final Gson mGson; private IntegrationEnv(Properties properties) { config = properties; + mGson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); } public static IntegrationEnv load() { @@ -52,28 +60,11 @@ public static IntegrationEnv load() { } } - public String[] getServers() { - String serverProp = config.getProperty("test.servers"); - String[] servers = serverProp.split(","); - if (servers.length == 0) { - return new String[] {serverProp}; - } - return servers; - } - - public Credentials[] getCredentials() { - String serverProp = config.getProperty("test.credentials"); - String[] credentials = serverProp.split(","); - if (credentials.length == 0) { - credentials = new String[] {serverProp}; - } - - Credentials[] result = new Credentials[credentials.length]; - for (int i = 0; i < credentials.length; i++) { - result[i] = Credentials.Factory.create(credentials[i]); - } - - return result; + public List getServers() { + String configFile = config.getProperty("servers.config.file"); + TestResource rawConfig = TestResource.create(configFile); + Reader reader = new InputStreamReader(rawConfig.asStream()); + return mGson.fromJson(reader, new TypeToken>(){}.getType()); } @Override diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java index 0bed02bf..0706c4fd 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.util; +import com.jaspersoft.android.sdk.util.rest.dto.AuthConfig; +import com.jaspersoft.android.sdk.util.rest.dto.Server; import com.jaspersoft.android.sdk.util.rest.exception.HttpException; import com.jaspersoft.android.sdk.util.rest.token.Authorizer; import com.jaspersoft.android.sdk.util.rest.token.Credentials; @@ -31,6 +33,8 @@ import org.junit.rules.ExternalResource; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; /** * @author Tom Koptel @@ -40,31 +44,35 @@ public final class JrsEnvironmentRule extends ExternalResource { private IntegrationEnv mIntegrationEnv; public Object[] listServers() { - String[] servers = getLazyEnv().getServers(); - Object[] result = new Object[servers.length]; - for (int i = 0; i < servers.length; i++) { - result[i] = new Object[]{servers[i]}; + List servers = getLazyEnv().getServers(); + Object[] result = new Object[servers.size()]; + + for (int i = 0; i < result.length; i++) { + result[i] = new Object[]{servers.get(i).getUrl()}; } + return result; } public Object[] listAuthorizedServers() { - String[] servers = getLazyEnv().getServers(); - Credentials[] credentials = getLazyEnv().getCredentials(); - if (servers.length != credentials.length) { - throw new IllegalStateException("Test environment configured improperly. Servers number should equal credentials"); - } + List servers = getLazyEnv().getServers(); + List result = new ArrayList<>(); - Object[] result = new Object[servers.length]; - for (int i = 0; i < servers.length; i++) { - try { - String token = Authorizer.create(servers[i]).authorize(credentials[i]); - result[i] = new Object[]{token, servers[i]}; - } catch (IOException | HttpException e) { - throw new RuntimeException("Failed to configure token for server " + servers[i] + " abort test execution", e); + for (Server server : servers) { + for (AuthConfig config : server.getAuthConfigs()) { + Credentials credentials = Credentials.Factory.create(config); + try { + String token = Authorizer.create(server.getUrl()).authorize(credentials); + result.add(new Object[]{token, server.getUrl()}); + } catch (IOException | HttpException e) { + System.out.println(e); + } } } - return result; + + Object[] resultArray = new Object[result.size()]; + result.toArray(resultArray); + return resultArray; } private IntegrationEnv getLazyEnv() { diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/AuthConfig.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/AuthConfig.java new file mode 100644 index 00000000..2a010796 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/AuthConfig.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.dto; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class AuthConfig { + @Expose + private String type; + @Expose + private String username; + @Expose + private String password; + @Expose + private String organization; + + public String getOrganization() { + return organization; + } + + public String getPassword() { + return password; + } + + public String getType() { + return type; + } + + public String getUsername() { + return username; + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/Server.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/Server.java new file mode 100644 index 00000000..75cb7956 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/Server.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.dto; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class Server { + @Expose + @SerializedName("auth_config") + List mAuthConfigs; + @Expose + String url; + + public String getUrl() { + return url; + } + + public List getAuthConfigs() { + return mAuthConfigs; + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java index 7b5bb0e9..5418c7d9 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.util.rest.token; +import com.jaspersoft.android.sdk.util.rest.dto.AuthConfig; import com.jaspersoft.android.sdk.util.rest.exception.HttpException; import java.io.IOException; @@ -36,17 +37,15 @@ public abstract class Credentials { protected abstract String delegateSelf(TokenFactory factory) throws IOException, HttpException; public static class Factory { - public static Credentials create(String data) { - String[] items = data.split("\\|"); - String type = items[0]; - if ("spring".equals(type)) { + public static Credentials create(AuthConfig config) { + if ("spring".equals(config.getType())) { return SpringCredentials.builder() - .setUsername(items[1]) - .setPassword(items[2]) - .setOrganization("null".equals(items[3]) ? null : items[3]) + .setUsername(config.getUsername()) + .setPassword(config.getPassword()) + .setOrganization(config.getOrganization()) .create(); } - throw new UnsupportedOperationException("Test could not create credential of type: " + type); + throw new UnsupportedOperationException("Test could not create credential of type: " + config.getType()); } } } diff --git a/core-integration-tests/src/test/resources/.gitignore b/core-integration-tests/src/test/resources/.gitignore deleted file mode 100644 index 102b6fc9..00000000 --- a/core-integration-tests/src/test/resources/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.properties \ No newline at end of file From 966017fe72c4a975fedfe3bf247dd0ded6ce7b0e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 12 Nov 2015 15:58:45 +0200 Subject: [PATCH 266/457] Add report listing run configuration --- buildsystem/integration_env.properties | 1 + core-integration-tests/build.gradle | 2 +- .../sdk/network/RepositoryRestApiTest.java | 25 +++-- .../android/sdk/util/IntegrationEnv.java | 4 + .../android/sdk/util/jrsEnvironmentRule.java | 25 +++++ .../rest/resource/ResourceRepository.java | 105 ++++++++++++++++++ 6 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/resource/ResourceRepository.java diff --git a/buildsystem/integration_env.properties b/buildsystem/integration_env.properties index b46a21fb..9cb5c553 100644 --- a/buildsystem/integration_env.properties +++ b/buildsystem/integration_env.properties @@ -23,3 +23,4 @@ # servers.config.file=@servers.file.name@ +run.report.count=@run.report.count@ diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 19fe470a..4eff1416 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -46,7 +46,7 @@ dependencies { task prep() { def resourceDir = file("${projectDir}/src/test/resources") def env = 'integration_env.properties' - requiredProperties "servers.file.name" + requiredProperties "servers.file.name", "run.report.count" outputs.file new File(resourceDir, env) doFirst { copy { diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index 6d662123..d345c140 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.util.JrsEnvironmentRule; import com.jaspersoft.android.sdk.util.TestLogger; @@ -47,21 +49,20 @@ public class RepositoryRestApiTest { @ClassRule public static JrsEnvironmentRule sEnv = new JrsEnvironmentRule(); -/* @Test - public void shouldRequestListOfResources() { - ResourceSearchResult resourceSearchResult = api.searchResources(mAuthenticator.token(), null); - assertThat(resourceSearchResult, is(notNullValue())); - assertThat(resourceSearchResult.getResources(), is(not(empty()))); + @Parameters(method = "reports") + public void shouldRequestReport(String token, String baseUrl, String reportUri) { + ReportLookup report = createApi(baseUrl).requestReportResource(token, reportUri); + assertThat("Failed load report data", report != null); } @Test - public void shouldRequestReport() { - ReportLookup report = api.requestReportResource(mAuthenticator.token(), "/public/Samples/Reports/AllAccounts"); - assertThat(report, is(notNullValue())); - assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); + @Parameters(method = "servers") + public void shouldRequestListOfResources(String token, String baseUrl) { + ResourceSearchResult response = createApi(baseUrl).searchResources(token, null); + assertThat("Failed to perform search lookup", response != null); } -*/ + @Test @Parameters(method = "servers") public void shouldRequestRootFolder(String token, String baseUrl) { @@ -73,6 +74,10 @@ private Object[] servers() { return sEnv.listAuthorizedServers(); } + private Object[] reports() { + return sEnv.listReports(); + } + private RepositoryRestApi createApi(String baseUrl) { return new RepositoryRestApi.Builder() .baseUrl(baseUrl) diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java index 3282c927..d352f73d 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java @@ -67,6 +67,10 @@ public List getServers() { return mGson.fromJson(reader, new TypeToken>(){}.getType()); } + public int reportExecNumber() { + return Integer.parseInt(config.getProperty("run.report.count")); + } + @Override public String toString() { return "IntegrationEnv{" + diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java index 0706c4fd..584e74dd 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.util.rest.dto.AuthConfig; import com.jaspersoft.android.sdk.util.rest.dto.Server; import com.jaspersoft.android.sdk.util.rest.exception.HttpException; +import com.jaspersoft.android.sdk.util.rest.resource.ResourceRepository; import com.jaspersoft.android.sdk.util.rest.token.Authorizer; import com.jaspersoft.android.sdk.util.rest.token.Credentials; @@ -70,6 +71,30 @@ public Object[] listAuthorizedServers() { } } + return toArray(result); + } + + public Object[] listReports() { + List result = new ArrayList<>(); + for (Object o : listAuthorizedServers()) { + Object[] pair = (Object[]) o; + try { + String token = String.valueOf(pair[0]); + String url = String.valueOf(pair[1]); + List reports = ResourceRepository + .create(token, url) + .listResources("reportUnit", getLazyEnv().reportExecNumber()); + for (String report : reports) { + result.add(new Object[] {token, url, report}); + } + } catch (IOException | HttpException e) { + System.out.println(e); + } + } + return toArray(result); + } + + private static Object[] toArray(List result) { Object[] resultArray = new Object[result.size()]; result.toArray(resultArray); return resultArray; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/resource/ResourceRepository.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/resource/ResourceRepository.java new file mode 100644 index 00000000..a78dc6ce --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/resource/ResourceRepository.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.util.rest.resource; + +import com.google.gson.Gson; +import com.google.gson.stream.JsonReader; +import com.jaspersoft.android.sdk.util.rest.exception.HttpException; +import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ResourceRepository { + private final String mBaseUrl; + private final String mToken; + private final OkHttpClient mOkhttp; + private final Gson mGson; + + ResourceRepository(String token, String baseUrl) { + mOkhttp = new OkHttpClient(); + mGson = new Gson(); + mToken = token; + mBaseUrl = baseUrl; + } + + public static ResourceRepository create(String token, String baseUrl) { + return new ResourceRepository(token, baseUrl); + } + + public List listResources(String type, int count) throws IOException, HttpException { + HttpUrl url = HttpUrl.parse(mBaseUrl + "/rest_v2/resources").newBuilder() + .addQueryParameter("forceFullPage", "true") + .addQueryParameter("limit", String.valueOf(count)) + .addQueryParameter("offset", "0") + .addQueryParameter("type", type) + .build(); + Request request = new Request.Builder() + .url(url) + .addHeader("Cookie", mToken) + .addHeader("Accept", "application/json") + .build(); + Response response = mOkhttp.newCall(request).execute(); + int code = response.code(); + + if (code >= 200 && code < 300) { + List resources = new ArrayList<>(); + JsonReader reader = new JsonReader(new InputStreamReader(response.body().byteStream(), "UTF-8")); + + reader.beginObject(); + reader.nextName(); + reader.beginArray(); + + while (reader.hasNext()) { + reader.beginObject(); + while (reader.hasNext()) { + String name = reader.nextName(); + if ("uri".equals(name)) { + resources.add(reader.nextString()); + } else { + reader.skipValue(); + } + } + reader.endObject(); + } + + reader.endArray(); + reader.endObject(); + + return resources; + } else { + throw HttpException.Factory.create(response); + } + } +} From 326dd2c34b045d099577c6ad9a7102dabfeb9763 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 11:27:29 +0200 Subject: [PATCH 267/457] Environmental dependent servers list configuration --- core-integration-tests/.gitignore | 2 +- core-integration-tests/build.gradle | 54 ++++++++++++++----- .../android/sdk/util/IntegrationEnv.java | 6 +-- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/core-integration-tests/.gitignore b/core-integration-tests/.gitignore index fb098b18..c902ad95 100644 --- a/core-integration-tests/.gitignore +++ b/core-integration-tests/.gitignore @@ -1,4 +1,4 @@ /build gradle-local.properties servers-local.json -integration_env.properties +test-env.properties diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 4eff1416..7d336d45 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -43,25 +43,55 @@ dependencies { testCompile 'org.bouncycastle:bcprov-jdk16:1.46' } -task prep() { - def resourceDir = file("${projectDir}/src/test/resources") - def env = 'integration_env.properties' +ext { + buildSystemPath = "${rootDir}/buildsystem/" + envPath = "${projectDir}/build/env" + envFileName = 'integration_env.properties' +} + +task prepIntegrationEnv() { + def buildDir = file(envPath) requiredProperties "servers.file.name", "run.report.count" - outputs.file new File(resourceDir, env) + outputs.file new File(buildDir, envFileName) doFirst { copy { - from file("${rootDir}/buildsystem/") - include env - into resourceDir + from file(buildSystemPath) + include envFileName + into buildDir filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.filterTokens) } } } -task copyConfig(type: Copy) { + +task copyConfig << { + Properties envProperties = new Properties() def resourceDir = file("${projectDir}/src/test/resources") - from file("${projectDir}/servers-local.json") - into resourceDir + def dynamicEnv = new File(envPath, envFileName) + + def copyServerConfigurationList = { + def stream = new FileInputStream(dynamicEnv) + envProperties.load(stream) + + def serverConfigPath = envProperties["servers.config.file"] + copy { + from file(serverConfigPath) + into resourceDir + } + } + def createTestEnvProperties = { + def reportRunCount = envProperties["run.report.count"] + def testEnv = file("${resourceDir}/test-env.properties") + testEnv.createNewFile() + + Properties props = new Properties() + props["run.report.count"] = reportRunCount + def stream = new FileOutputStream(testEnv) + props.store(stream, null) + } + + copyServerConfigurationList() + createTestEnvProperties() } -prep.dependsOn copyConfig -compileJava.dependsOn prep \ No newline at end of file +copyConfig.dependsOn prepIntegrationEnv +compileJava.dependsOn copyConfig \ No newline at end of file diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java index d352f73d..069bac2e 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java @@ -41,7 +41,8 @@ * @since 2.0 */ public final class IntegrationEnv { - private static final String PROPERTIES_FILE = "integration_env.properties"; + private static final String PROPERTIES_FILE = "test-env.properties"; + private static final String SERVERS_CONFIG_FILE = "servers-local.json"; private final Properties config; private final Gson mGson; @@ -61,8 +62,7 @@ public static IntegrationEnv load() { } public List getServers() { - String configFile = config.getProperty("servers.config.file"); - TestResource rawConfig = TestResource.create(configFile); + TestResource rawConfig = TestResource.create(SERVERS_CONFIG_FILE); Reader reader = new InputStreamReader(rawConfig.asStream()); return mGson.fromJson(reader, new TypeToken>(){}.getType()); } From f572745faa44c1429b35adbdd6a08179ed602f74 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 11:48:37 +0200 Subject: [PATCH 268/457] Force agnostic test servers config --- core-integration-tests/.gitignore | 1 + core-integration-tests/build.gradle | 7 +++++-- .../com/jaspersoft/android/sdk/util/IntegrationEnv.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core-integration-tests/.gitignore b/core-integration-tests/.gitignore index c902ad95..faf886a2 100644 --- a/core-integration-tests/.gitignore +++ b/core-integration-tests/.gitignore @@ -1,4 +1,5 @@ /build gradle-local.properties servers-local.json +test-servers.json test-env.properties diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 7d336d45..4fcc513f 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -46,7 +46,9 @@ dependencies { ext { buildSystemPath = "${rootDir}/buildsystem/" envPath = "${projectDir}/build/env" - envFileName = 'integration_env.properties' + envFileName = "integration_env.properties" + testPropertiesName = "test-env.properties" + testServersName = "test-servers.json" } task prepIntegrationEnv() { @@ -76,11 +78,12 @@ task copyConfig << { copy { from file(serverConfigPath) into resourceDir + rename { String fileName -> testServersName } } } def createTestEnvProperties = { def reportRunCount = envProperties["run.report.count"] - def testEnv = file("${resourceDir}/test-env.properties") + def testEnv = file("${resourceDir}/${testPropertiesName}") testEnv.createNewFile() Properties props = new Properties() diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java index 069bac2e..851ba035 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java @@ -42,7 +42,7 @@ */ public final class IntegrationEnv { private static final String PROPERTIES_FILE = "test-env.properties"; - private static final String SERVERS_CONFIG_FILE = "servers-local.json"; + private static final String SERVERS_CONFIG_FILE = "test-servers.json"; private final Properties config; private final Gson mGson; From a894b5d6b1c7e547455080210fc4d28f7844d52a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 12:03:54 +0200 Subject: [PATCH 269/457] Add default test environment configuration --- buildsystem/servers-default.json | 12 ++++++++++++ core-integration-tests/build.gradle | 27 ++++++++++++++++++++++++--- gradle.properties | 26 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 buildsystem/servers-default.json create mode 100644 gradle.properties diff --git a/buildsystem/servers-default.json b/buildsystem/servers-default.json new file mode 100644 index 00000000..43b5a1e6 --- /dev/null +++ b/buildsystem/servers-default.json @@ -0,0 +1,12 @@ +[ + { + "url": "http://mobiledemo2.jaspersoft.com/jasperserver-pro", + "auth_config": [ + { + "type": "spring", + "username": "phoneuser", + "password": "phoneuser" + } + ] + } +] \ No newline at end of file diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index 4fcc513f..a48c5ab2 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -72,11 +72,28 @@ task copyConfig << { def copyServerConfigurationList = { def stream = new FileInputStream(dynamicEnv) - envProperties.load(stream) + try { + envProperties.load(stream) + } finally { + stream.close() + } def serverConfigPath = envProperties["servers.config.file"] + def isConfigResidesInProject = rootProject.file(serverConfigPath).exists() + def fileToCopy + if (isConfigResidesInProject) { + fileToCopy = rootProject.file(serverConfigPath) + } + def isFileResidesOnSystem = file(serverConfigPath).exists() + if (isFileResidesOnSystem) { + fileToCopy = file(serverConfigPath) + } + if (fileToCopy == null) { + throw new GradleException("Failed to localate servers list configuration on file system. Path: ${serverConfigPath}") + } + copy { - from file(serverConfigPath) + from fileToCopy into resourceDir rename { String fileName -> testServersName } } @@ -89,7 +106,11 @@ task copyConfig << { Properties props = new Properties() props["run.report.count"] = reportRunCount def stream = new FileOutputStream(testEnv) - props.store(stream, null) + try { + props.store(stream, null) + } finally { + stream.close() + } } copyServerConfigurationList() diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..678681b3 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,26 @@ +# +# Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. +# http://community.jaspersoft.com/project/mobile-sdk-android +# +# Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, +# the following license terms apply: +# +# This program is part of TIBCO Jaspersoft Mobile SDK for Android. +# +# TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with TIBCO Jaspersoft Mobile SDK for Android. If not, see +# . +# + +servers.file.name=buildsystem/servers-default.json +run.report.count=1 From 00e27560c278d441d40083a4ca7a9a7ef97b7eac Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 12:22:32 +0200 Subject: [PATCH 270/457] Make test properties key addition implicit --- core-integration-tests/build.gradle | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core-integration-tests/build.gradle b/core-integration-tests/build.gradle index a48c5ab2..896c1df4 100644 --- a/core-integration-tests/build.gradle +++ b/core-integration-tests/build.gradle @@ -66,21 +66,27 @@ task prepIntegrationEnv() { } task copyConfig << { - Properties envProperties = new Properties() def resourceDir = file("${projectDir}/src/test/resources") - def dynamicEnv = new File(envPath, envFileName) - def copyServerConfigurationList = { - def stream = new FileInputStream(dynamicEnv) + def loadProperties = { source -> + Properties properties = new Properties() + def stream = new FileInputStream(source) try { - envProperties.load(stream) + properties.load(stream) } finally { stream.close() } - + return properties + } + def loadEnvProperties = { + return loadProperties(new File(envPath, envFileName)) + } + def copyServerConfigurationList = { + def envProperties = loadEnvProperties() def serverConfigPath = envProperties["servers.config.file"] - def isConfigResidesInProject = rootProject.file(serverConfigPath).exists() + def fileToCopy + def isConfigResidesInProject = rootProject.file(serverConfigPath).exists() if (isConfigResidesInProject) { fileToCopy = rootProject.file(serverConfigPath) } @@ -99,12 +105,13 @@ task copyConfig << { } } def createTestEnvProperties = { - def reportRunCount = envProperties["run.report.count"] + def envProperties = loadEnvProperties() def testEnv = file("${resourceDir}/${testPropertiesName}") testEnv.createNewFile() Properties props = new Properties() - props["run.report.count"] = reportRunCount + props += envProperties + props.remove("servers.config.file") def stream = new FileOutputStream(testEnv) try { props.store(stream, null) From fe05e910a92c8cb241d4cdb49042255d5e29a220 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 12:39:04 +0200 Subject: [PATCH 271/457] Separating test kit from integration tests namespace --- .../android/sdk/testkit}/dto/AuthConfig.java | 8 +----- .../android/sdk/testkit}/dto/Server.java | 2 +- .../exception/AuthenticationException.java | 2 +- .../exception/ClientErrorException.java | 2 +- .../sdk/testkit}/exception/HttpException.java | 2 +- .../exception/ServerErrorException.java | 2 +- .../testkit}/resource/ResourceRepository.java | 7 ++--- .../sdk/testkit}/token/Authorizer.java | 6 ++-- .../sdk/testkit/token/Credentials.java} | 18 ++++-------- .../sdk/testkit/token/CredentialsMapper.java} | 28 ++++++------------- .../sdk/testkit}/token/TokenFactory.java | 8 +++--- .../sdk/{util => env}/DummyTokenProvider.java | 2 +- .../sdk/{util => env}/IntegrationEnv.java | 4 +-- .../JrsEnvironmentRule.java} | 17 +++++------ .../sdk/{util => env}/JrsMetadata.java | 2 +- .../android/sdk/{util => env}/TestLogger.java | 2 +- .../sdk/{util => env}/TestResource.java | 2 +- .../network/AuthenticationRestApiTest.java | 4 +-- .../sdk/network/InputControlRestApiTest.java | 7 ++--- .../network/ReportExecutionRestApiTest.java | 7 ++--- .../sdk/network/ReportExportRestApiTest.java | 8 ++---- .../sdk/network/ReportOptionRestApiTest.java | 7 ++--- .../sdk/network/RepositoryRestApiTest.java | 4 +-- .../android/sdk/network/ServerRestTest.java | 4 +-- 24 files changed, 61 insertions(+), 94 deletions(-) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/dto/AuthConfig.java (91%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/dto/Server.java (96%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/exception/AuthenticationException.java (96%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/exception/ClientErrorException.java (95%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/exception/HttpException.java (98%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/exception/ServerErrorException.java (95%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/resource/ResourceRepository.java (94%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/token/Authorizer.java (90%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java => main/java/com/jaspersoft/android/sdk/testkit/token/Credentials.java} (79%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java => main/java/com/jaspersoft/android/sdk/testkit/token/CredentialsMapper.java} (55%) rename core-integration-tests/src/{test/java/com/jaspersoft/android/sdk/util/rest => main/java/com/jaspersoft/android/sdk/testkit}/token/TokenFactory.java (92%) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/{util => env}/DummyTokenProvider.java (98%) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/{util => env}/IntegrationEnv.java (96%) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/{util/jrsEnvironmentRule.java => env/JrsEnvironmentRule.java} (86%) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/{util => env}/JrsMetadata.java (99%) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/{util => env}/TestLogger.java (97%) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/{util => env}/TestResource.java (98%) diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/AuthConfig.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/AuthConfig.java similarity index 91% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/AuthConfig.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/AuthConfig.java index 2a010796..94cd390a 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/AuthConfig.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/AuthConfig.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.dto; +package com.jaspersoft.android.sdk.testkit.dto; import com.google.gson.annotations.Expose; @@ -31,8 +31,6 @@ * @since 2.3 */ public final class AuthConfig { - @Expose - private String type; @Expose private String username; @Expose @@ -48,10 +46,6 @@ public String getPassword() { return password; } - public String getType() { - return type; - } - public String getUsername() { return username; } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/Server.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/Server.java similarity index 96% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/Server.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/Server.java index 75cb7956..3ec4d63a 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/dto/Server.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/Server.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.dto; +package com.jaspersoft.android.sdk.testkit.dto; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/AuthenticationException.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/AuthenticationException.java similarity index 96% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/AuthenticationException.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/AuthenticationException.java index 66794854..0c1e8531 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/AuthenticationException.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/AuthenticationException.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.exception; +package com.jaspersoft.android.sdk.testkit.exception; /** * @author Tom Koptel diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ClientErrorException.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/ClientErrorException.java similarity index 95% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ClientErrorException.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/ClientErrorException.java index 6d6eef42..d42b80ac 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ClientErrorException.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/ClientErrorException.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.exception; +package com.jaspersoft.android.sdk.testkit.exception; /** * @author Tom Koptel diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/HttpException.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/HttpException.java similarity index 98% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/HttpException.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/HttpException.java index 2b7b8d7b..7c468cdc 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/HttpException.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/HttpException.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.exception; +package com.jaspersoft.android.sdk.testkit.exception; import com.squareup.okhttp.Response; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ServerErrorException.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/ServerErrorException.java similarity index 95% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ServerErrorException.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/ServerErrorException.java index bde8f35b..b074edd0 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/exception/ServerErrorException.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/exception/ServerErrorException.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.exception; +package com.jaspersoft.android.sdk.testkit.exception; /** * @author Tom Koptel diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/resource/ResourceRepository.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java similarity index 94% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/resource/ResourceRepository.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java index a78dc6ce..5d4bca4e 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/resource/ResourceRepository.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java @@ -22,11 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.resource; +package com.jaspersoft.android.sdk.testkit.resource; -import com.google.gson.Gson; import com.google.gson.stream.JsonReader; -import com.jaspersoft.android.sdk.util.rest.exception.HttpException; +import com.jaspersoft.android.sdk.testkit.exception.HttpException; import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; @@ -45,11 +44,9 @@ public final class ResourceRepository { private final String mBaseUrl; private final String mToken; private final OkHttpClient mOkhttp; - private final Gson mGson; ResourceRepository(String token, String baseUrl) { mOkhttp = new OkHttpClient(); - mGson = new Gson(); mToken = token; mBaseUrl = baseUrl; } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Authorizer.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/Authorizer.java similarity index 90% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Authorizer.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/Authorizer.java index 4dd748f6..601e5855 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Authorizer.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/Authorizer.java @@ -22,9 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.token; +package com.jaspersoft.android.sdk.testkit.token; -import com.jaspersoft.android.sdk.util.rest.exception.HttpException; +import com.jaspersoft.android.sdk.testkit.exception.HttpException; import java.io.IOException; @@ -47,6 +47,6 @@ public static Authorizer create(String baseUrl) { } public String authorize(Credentials credentials) throws IOException, HttpException { - return credentials.delegateSelf(tokeFactory); + return tokeFactory.create(credentials); } } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/Credentials.java similarity index 79% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/Credentials.java index 1268a727..3bc9b901 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/SpringCredentials.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/Credentials.java @@ -22,31 +22,23 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.token; - -import com.jaspersoft.android.sdk.util.rest.exception.HttpException; - -import java.io.IOException; +package com.jaspersoft.android.sdk.testkit.token; /** * @author Tom Koptel * @since 2.3 */ -public final class SpringCredentials extends Credentials { +public final class Credentials { private final String username; private final String password; private final String organization; - public SpringCredentials(String username, String password, String organization) { + private Credentials(String username, String password, String organization) { this.username = username; this.password = password; this.organization = organization; } - protected String delegateSelf(TokenFactory factory) throws IOException, HttpException { - return factory.create(this); - } - public String getOrganization() { return organization; } @@ -86,8 +78,8 @@ public Builder setOrganization(String organization) { return this; } - public SpringCredentials create() { - return new SpringCredentials(mUsername, mPassword, mOrganization); + public Credentials create() { + return new Credentials(mUsername, mPassword, mOrganization); } } } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/CredentialsMapper.java similarity index 55% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/CredentialsMapper.java index 5418c7d9..a1fa4362 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/Credentials.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/CredentialsMapper.java @@ -22,30 +22,20 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.token; +package com.jaspersoft.android.sdk.testkit.token; -import com.jaspersoft.android.sdk.util.rest.dto.AuthConfig; -import com.jaspersoft.android.sdk.util.rest.exception.HttpException; - -import java.io.IOException; +import com.jaspersoft.android.sdk.testkit.dto.AuthConfig; /** * @author Tom Koptel * @since 2.3 */ -public abstract class Credentials { - protected abstract String delegateSelf(TokenFactory factory) throws IOException, HttpException; - - public static class Factory { - public static Credentials create(AuthConfig config) { - if ("spring".equals(config.getType())) { - return SpringCredentials.builder() - .setUsername(config.getUsername()) - .setPassword(config.getPassword()) - .setOrganization(config.getOrganization()) - .create(); - } - throw new UnsupportedOperationException("Test could not create credential of type: " + config.getType()); - } +public final class CredentialsMapper { + public static Credentials transform(AuthConfig config) { + return Credentials.builder() + .setUsername(config.getUsername()) + .setPassword(config.getPassword()) + .setOrganization(config.getOrganization()) + .create(); } } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/TokenFactory.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/TokenFactory.java similarity index 92% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/TokenFactory.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/TokenFactory.java index aaacecf5..3138f0b9 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/rest/token/TokenFactory.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/token/TokenFactory.java @@ -22,10 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.util.rest.token; +package com.jaspersoft.android.sdk.testkit.token; -import com.jaspersoft.android.sdk.util.rest.exception.AuthenticationException; -import com.jaspersoft.android.sdk.util.rest.exception.HttpException; +import com.jaspersoft.android.sdk.testkit.exception.AuthenticationException; +import com.jaspersoft.android.sdk.testkit.exception.HttpException; import com.squareup.okhttp.FormEncodingBuilder; import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.OkHttpClient; @@ -50,7 +50,7 @@ public TokenFactory(String baseUrl) { mOkhttp.setFollowRedirects(false); } - public String create(SpringCredentials credentials) throws IOException, HttpException { + public String create(Credentials credentials) throws IOException, HttpException { FormEncodingBuilder formBody = new FormEncodingBuilder() .add("j_password", credentials.getPassword()) .add("j_username", credentials.getUsername()); diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/DummyTokenProvider.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/DummyTokenProvider.java similarity index 98% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/DummyTokenProvider.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/DummyTokenProvider.java index ac2aee66..3fdc40ec 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/DummyTokenProvider.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/DummyTokenProvider.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util; +package com.jaspersoft.android.sdk.env; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/IntegrationEnv.java similarity index 96% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/IntegrationEnv.java index 851ba035..1435064c 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/IntegrationEnv.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/IntegrationEnv.java @@ -22,13 +22,13 @@ * . */ -package com.jaspersoft.android.sdk.util; +package com.jaspersoft.android.sdk.env; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import com.jaspersoft.android.sdk.util.rest.dto.Server; +import com.jaspersoft.android.sdk.testkit.dto.Server; import java.io.IOException; import java.io.InputStreamReader; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java similarity index 86% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java index 584e74dd..20d910e0 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/jrsEnvironmentRule.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java @@ -22,14 +22,15 @@ * . */ -package com.jaspersoft.android.sdk.util; +package com.jaspersoft.android.sdk.env; -import com.jaspersoft.android.sdk.util.rest.dto.AuthConfig; -import com.jaspersoft.android.sdk.util.rest.dto.Server; -import com.jaspersoft.android.sdk.util.rest.exception.HttpException; -import com.jaspersoft.android.sdk.util.rest.resource.ResourceRepository; -import com.jaspersoft.android.sdk.util.rest.token.Authorizer; -import com.jaspersoft.android.sdk.util.rest.token.Credentials; +import com.jaspersoft.android.sdk.testkit.dto.AuthConfig; +import com.jaspersoft.android.sdk.testkit.dto.Server; +import com.jaspersoft.android.sdk.testkit.exception.HttpException; +import com.jaspersoft.android.sdk.testkit.resource.ResourceRepository; +import com.jaspersoft.android.sdk.testkit.token.Authorizer; +import com.jaspersoft.android.sdk.testkit.token.Credentials; +import com.jaspersoft.android.sdk.testkit.token.CredentialsMapper; import org.junit.rules.ExternalResource; @@ -61,7 +62,7 @@ public Object[] listAuthorizedServers() { for (Server server : servers) { for (AuthConfig config : server.getAuthConfigs()) { - Credentials credentials = Credentials.Factory.create(config); + Credentials credentials = CredentialsMapper.transform(config); try { String token = Authorizer.create(server.getUrl()).authorize(credentials); result.add(new Object[]{token, server.getUrl()}); diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/JrsMetadata.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsMetadata.java similarity index 99% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/JrsMetadata.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsMetadata.java index 43268b47..10eeef36 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/JrsMetadata.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsMetadata.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util; +package com.jaspersoft.android.sdk.env; import java.net.MalformedURLException; import java.net.URL; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestLogger.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/TestLogger.java similarity index 97% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestLogger.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/TestLogger.java index 0ce41a0c..0589e21a 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestLogger.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/TestLogger.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util; +package com.jaspersoft.android.sdk.env; import com.jaspersoft.android.sdk.network.RestApiLog; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestResource.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/TestResource.java similarity index 98% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestResource.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/TestResource.java index 410568f6..458a95cd 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/util/TestResource.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/TestResource.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.util; +package com.jaspersoft.android.sdk.env; import java.io.BufferedReader; import java.io.File; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index ef8c04c9..4c98f23e 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -24,10 +24,8 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; -import com.jaspersoft.android.sdk.util.TestLogger; +import com.jaspersoft.android.sdk.env.TestLogger; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Ignore; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index b2c7abf3..0ca23240 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -24,12 +24,11 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.util.DummyTokenProvider; -import com.jaspersoft.android.sdk.util.JrsMetadata; -import com.jaspersoft.android.sdk.util.TestLogger; +import com.jaspersoft.android.sdk.env.DummyTokenProvider; +import com.jaspersoft.android.sdk.env.JrsMetadata; +import com.jaspersoft.android.sdk.env.TestLogger; import org.junit.Before; import org.junit.Test; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index aa95ab0d..9db94f9a 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -24,14 +24,13 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.util.DummyTokenProvider; -import com.jaspersoft.android.sdk.util.JrsMetadata; -import com.jaspersoft.android.sdk.util.TestLogger; +import com.jaspersoft.android.sdk.env.DummyTokenProvider; +import com.jaspersoft.android.sdk.env.JrsMetadata; +import com.jaspersoft.android.sdk.env.TestLogger; import org.jetbrains.annotations.NotNull; import org.junit.Before; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index f99dc7b4..29ce3cb8 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -24,17 +24,15 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.util.DummyTokenProvider; -import com.jaspersoft.android.sdk.util.JrsMetadata; -import com.jaspersoft.android.sdk.util.TestLogger; +import com.jaspersoft.android.sdk.env.DummyTokenProvider; +import com.jaspersoft.android.sdk.env.JrsMetadata; +import com.jaspersoft.android.sdk.env.TestLogger; import org.jetbrains.annotations.NotNull; import org.junit.Before; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 2a4a3ffb..60040c8d 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -24,11 +24,10 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.util.DummyTokenProvider; -import com.jaspersoft.android.sdk.util.JrsMetadata; -import com.jaspersoft.android.sdk.util.TestLogger; +import com.jaspersoft.android.sdk.env.DummyTokenProvider; +import com.jaspersoft.android.sdk.env.JrsMetadata; +import com.jaspersoft.android.sdk.env.TestLogger; import org.junit.Before; import org.junit.Test; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index d345c140..55b549e2 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -27,8 +27,8 @@ import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.util.JrsEnvironmentRule; -import com.jaspersoft.android.sdk.util.TestLogger; +import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; +import com.jaspersoft.android.sdk.env.TestLogger; import org.junit.ClassRule; import org.junit.Test; diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java index 0340cd18..6dbf28c1 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java @@ -26,8 +26,8 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import com.jaspersoft.android.sdk.util.JrsEnvironmentRule; -import com.jaspersoft.android.sdk.util.TestLogger; +import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; +import com.jaspersoft.android.sdk.env.TestLogger; import org.junit.ClassRule; import org.junit.Test; From 1967471fb27ba3d7ea680e0ef155284f42df3531 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 13:53:03 +0200 Subject: [PATCH 272/457] Adapt report options test to new integration system --- buildsystem/servers-default.json | 1 - .../sdk/testkit/resource/AbstractService.java | 73 +++++++++++ .../testkit/resource/ResourceParameter.java | 114 ++++++++++++++++++ .../testkit/resource/ResourceRepository.java | 78 +++++------- .../resource/ResourceServiceFactory.java | 73 +++++++++++ .../android/sdk/env/JrsEnvironmentRule.java | 11 +- .../IntegrationReportOptionRestApiTest.java | 89 ++++++++++++++ .../sdk/network/ReportOptionRestApiTest.java | 89 -------------- 8 files changed, 388 insertions(+), 140 deletions(-) create mode 100644 core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/AbstractService.java create mode 100644 core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceParameter.java create mode 100644 core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceServiceFactory.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java delete mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java diff --git a/buildsystem/servers-default.json b/buildsystem/servers-default.json index 43b5a1e6..2340bf5f 100644 --- a/buildsystem/servers-default.json +++ b/buildsystem/servers-default.json @@ -3,7 +3,6 @@ "url": "http://mobiledemo2.jaspersoft.com/jasperserver-pro", "auth_config": [ { - "type": "spring", "username": "phoneuser", "password": "phoneuser" } diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/AbstractService.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/AbstractService.java new file mode 100644 index 00000000..277f19c7 --- /dev/null +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/AbstractService.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.testkit.resource; + +import com.jaspersoft.android.sdk.testkit.exception.HttpException; +import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public abstract class AbstractService { + private final String mToken; + private final String mBaseUrl; + private final OkHttpClient mClient; + + + protected AbstractService(String token, String baseUrl) { + if (!baseUrl.endsWith("/")) { + baseUrl += "/"; + } + + mClient = new OkHttpClient(); + mToken = token; + mBaseUrl = baseUrl; + } + + protected Response performRequest() throws IOException, HttpException { + Request request = new Request.Builder() + .url(provideUrl(mBaseUrl)) + .addHeader("Cookie", mToken) + .addHeader("Accept", "application/json") + .build(); + Response response = mClient.newCall(request).execute(); + + int code = response.code(); + + if (code >= 200 && code < 300) { + return response; + } else { + throw HttpException.Factory.create(response); + } + } + + protected abstract HttpUrl provideUrl(String baseUrl); +} diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceParameter.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceParameter.java new file mode 100644 index 00000000..bc59b730 --- /dev/null +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceParameter.java @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.testkit.resource; + +import com.google.gson.stream.JsonReader; +import com.jaspersoft.android.sdk.testkit.exception.HttpException; +import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.Response; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ResourceParameter extends AbstractService { + + private final String mResourceUri; + + public ResourceParameter(String token, String baseUrl, String resourceUri) { + super(token, baseUrl); + mResourceUri = resourceUri; + } + + @Override + protected HttpUrl provideUrl(String baseUrl) { + String path = String.format("rest_v2/reports%s/inputControls/values", mResourceUri); + return HttpUrl.parse(baseUrl + path).newBuilder() + .addQueryParameter("freshData", "true") + .build(); + } + + public Map> listParams() throws IOException, HttpException { + Response response = performRequest(); + Map> params = new HashMap<>(); + mapResponse(response, params); + return params; + } + + private void mapResponse(Response response, Map> params) throws IOException { + JsonReader reader = new JsonReader(new InputStreamReader(response.body().byteStream(), "UTF-8")); + reader.beginObject(); + reader.nextName(); + reader.beginArray(); + while (reader.hasNext()) { + populateParams(params, reader); + } + reader.endArray(); + reader.endObject(); + } + + private void populateParams(Map> params, JsonReader reader) throws IOException { + reader.beginObject(); + while (reader.hasNext()) { + Set values = new HashSet<>(); + String id = "null"; + + String name = reader.nextName(); + if ("options".equals(name)) { + readValues(reader, values); + } else if ("id".equals(name)) { + id = reader.nextString(); + } else { + reader.skipValue(); + } + params.put(id, values); + } + reader.endObject(); + } + + private void readValues(JsonReader reader, Set values) throws IOException { + reader.beginArray(); + while (reader.hasNext()) { + reader.beginObject(); + while (reader.hasNext()) { + String name = reader.nextName(); + if ("value".equals(name)) { + values.add(reader.nextString()); + } else { + reader.skipValue(); + } + } + reader.endObject(); + } + reader.endArray(); + } +} diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java index 5d4bca4e..b60fc70e 100644 --- a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java @@ -27,8 +27,6 @@ import com.google.gson.stream.JsonReader; import com.jaspersoft.android.sdk.testkit.exception.HttpException; import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; import java.io.IOException; @@ -40,63 +38,51 @@ * @author Tom Koptel * @since 2.3 */ -public final class ResourceRepository { - private final String mBaseUrl; - private final String mToken; - private final OkHttpClient mOkhttp; +public final class ResourceRepository extends AbstractService { + private final int mCount; + private final String mType; - ResourceRepository(String token, String baseUrl) { - mOkhttp = new OkHttpClient(); - mToken = token; - mBaseUrl = baseUrl; + ResourceRepository(String token, String baseUrl, int count, String type) { + super(token, baseUrl); + mCount = count; + mType = type; } - public static ResourceRepository create(String token, String baseUrl) { - return new ResourceRepository(token, baseUrl); - } - - public List listResources(String type, int count) throws IOException, HttpException { - HttpUrl url = HttpUrl.parse(mBaseUrl + "/rest_v2/resources").newBuilder() + @Override + protected HttpUrl provideUrl(String baseUrl) { + return HttpUrl.parse(baseUrl + "rest_v2/resources").newBuilder() .addQueryParameter("forceFullPage", "true") - .addQueryParameter("limit", String.valueOf(count)) + .addQueryParameter("limit", String.valueOf(mCount)) .addQueryParameter("offset", "0") - .addQueryParameter("type", type) - .build(); - Request request = new Request.Builder() - .url(url) - .addHeader("Cookie", mToken) - .addHeader("Accept", "application/json") + .addQueryParameter("type", mType) .build(); - Response response = mOkhttp.newCall(request).execute(); - int code = response.code(); + } - if (code >= 200 && code < 300) { - List resources = new ArrayList<>(); - JsonReader reader = new JsonReader(new InputStreamReader(response.body().byteStream(), "UTF-8")); + public List listResources() throws IOException, HttpException { + Response response = performRequest(); + List resources = new ArrayList<>(); + JsonReader reader = new JsonReader(new InputStreamReader(response.body().byteStream(), "UTF-8")); - reader.beginObject(); - reader.nextName(); - reader.beginArray(); + reader.beginObject(); + reader.nextName(); + reader.beginArray(); + while (reader.hasNext()) { + reader.beginObject(); while (reader.hasNext()) { - reader.beginObject(); - while (reader.hasNext()) { - String name = reader.nextName(); - if ("uri".equals(name)) { - resources.add(reader.nextString()); - } else { - reader.skipValue(); - } + String name = reader.nextName(); + if ("uri".equals(name)) { + resources.add(reader.nextString()); + } else { + reader.skipValue(); } - reader.endObject(); } - - reader.endArray(); reader.endObject(); - - return resources; - } else { - throw HttpException.Factory.create(response); } + + reader.endArray(); + reader.endObject(); + + return resources; } } diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceServiceFactory.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceServiceFactory.java new file mode 100644 index 00000000..62431c79 --- /dev/null +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceServiceFactory.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.testkit.resource; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ResourceServiceFactory { + private final String mToken; + private final String mBaseUrl; + + ResourceServiceFactory(String token, String baseUrl) { + mToken = token; + mBaseUrl = baseUrl; + } + + public static Builder builder() { + return new Builder(); + } + + public ResourceRepository resourceRepository(int count, String type) { + return new ResourceRepository(mToken, mBaseUrl, count, type); + } + + public ResourceParameter resourceParameter(String resourceUri) { + return new ResourceParameter(mToken, mBaseUrl, resourceUri); + } + + public static class Builder { + private String mToken; + private String mBaseUrl; + + private Builder() { + } + + public Builder token(String token) { + mToken = token; + return this; + } + + public Builder baseUrl(String baseUrl) { + mBaseUrl = baseUrl; + return this; + } + + public ResourceServiceFactory create() { + return new ResourceServiceFactory(mToken, mBaseUrl); + } + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java index 20d910e0..d2c38f39 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.testkit.dto.AuthConfig; import com.jaspersoft.android.sdk.testkit.dto.Server; import com.jaspersoft.android.sdk.testkit.exception.HttpException; -import com.jaspersoft.android.sdk.testkit.resource.ResourceRepository; +import com.jaspersoft.android.sdk.testkit.resource.ResourceServiceFactory; import com.jaspersoft.android.sdk.testkit.token.Authorizer; import com.jaspersoft.android.sdk.testkit.token.Credentials; import com.jaspersoft.android.sdk.testkit.token.CredentialsMapper; @@ -82,9 +82,12 @@ public Object[] listReports() { try { String token = String.valueOf(pair[0]); String url = String.valueOf(pair[1]); - List reports = ResourceRepository - .create(token, url) - .listResources("reportUnit", getLazyEnv().reportExecNumber()); + ResourceServiceFactory service = ResourceServiceFactory.builder() + .baseUrl(url).token(token).create(); + + List reports = service + .resourceRepository(getLazyEnv().reportExecNumber(), "reportUnit") + .listResources(); for (String report : reports) { result.add(new Object[] {token, url, report}); } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java new file mode 100644 index 00000000..6ba02d82 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; +import com.jaspersoft.android.sdk.env.TestLogger; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import com.jaspersoft.android.sdk.testkit.resource.ResourceServiceFactory; + +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Map; +import java.util.Set; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class IntegrationReportOptionRestApiTest { + + @ClassRule + public static JrsEnvironmentRule sEnv = new JrsEnvironmentRule(); + + @Test + @Parameters(method = "reports") + public void shouldRequestReportOptionsList(String token, String baseUrl, String reportUri) throws Exception { + Set response = createApi(baseUrl).requestReportOptionsList(token, reportUri); + assertThat("Failed load report options data", response != null); + } + + @Test + @Parameters(method = "reports") + public void apiSupportsCrudForReportOption(String token, String baseUrl, String reportUri) throws Exception { + Map> params = ResourceServiceFactory.builder() + .baseUrl(baseUrl).token(token) + .create() + .resourceParameter(reportUri) + .listParams(); + if (params != null && !params.isEmpty()) { + ReportOption response = createApi(baseUrl).createReportOption(token, reportUri, "label", params, true); + assertThat(response.getLabel(), is("label")); + + createApi(baseUrl).updateReportOption(token, reportUri, response.getId(), params); + createApi(baseUrl).deleteReportOption(token, reportUri, response.getId()); + } + } + + private Object[] reports() { + return sEnv.listReports(); + } + + private ReportOptionRestApi createApi(String baseUrl) { + return new ReportOptionRestApi.Builder() + .logger(TestLogger.get(this)) + .baseUrl(baseUrl) + .build(); + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java deleted file mode 100644 index 60040c8d..00000000 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.env.DummyTokenProvider; -import com.jaspersoft.android.sdk.env.JrsMetadata; -import com.jaspersoft.android.sdk.env.TestLogger; - -import org.junit.Before; -import org.junit.Test; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ReportOptionRestApiTest { - - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); - private ReportOptionRestApi apiUnderTest; - - private static final String REPORT_URI = "/public/Samples/Reports/1._Geographic_Results_by_Segment_Report"; - public static final Map> CONTROL_PARAMETERS = new HashMap<>(); - - static { - Set values = new HashSet<>(); - values.add("19"); - CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); - } - - @Before - public void setup() { - if (apiUnderTest == null) { - apiUnderTest = new ReportOptionRestApi.Builder() - .logger(TestLogger.get(this)) - .baseUrl(mMetadata.getServerUrl()) - .build(); - } - } - - @Test - public void shouldRequestReportOptionsList() { - Set response = apiUnderTest.requestReportOptionsList(mAuthenticator.token(), REPORT_URI); - assertThat(response, is(not(nullValue()))); - } - - @Test - public void apiSupportsCrudForReportOption() { - ReportOption response = apiUnderTest.createReportOption(mAuthenticator.token(), REPORT_URI, "label", CONTROL_PARAMETERS, true); - assertThat(response.getLabel(), is("label")); - - apiUnderTest.updateReportOption(mAuthenticator.token(), REPORT_URI, response.getId(), CONTROL_PARAMETERS); - - apiUnderTest.deleteReportOption(mAuthenticator.token(), REPORT_URI, response.getId()); - } -} From 43d61d87d692a746058fb71ac883333c0a35877c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 13:54:12 +0200 Subject: [PATCH 273/457] Refactoring name of Repository test --- ...ryRestApiTest.java => IntegrationRepositoryRestApiTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/{RepositoryRestApiTest.java => IntegrationRepositoryRestApiTest.java} (98%) diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationRepositoryRestApiTest.java similarity index 98% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationRepositoryRestApiTest.java index 55b549e2..2f8a659f 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationRepositoryRestApiTest.java @@ -44,7 +44,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class RepositoryRestApiTest { +public class IntegrationRepositoryRestApiTest { @ClassRule public static JrsEnvironmentRule sEnv = new JrsEnvironmentRule(); From 258e744ae0d47541831d274f851c073a777bd648 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 13:55:55 +0200 Subject: [PATCH 274/457] Refactoring name of Server test --- .../{ServerRestTest.java => IntegrationServerRestApiTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/{ServerRestTest.java => IntegrationServerRestApiTest.java} (99%) diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationServerRestApiTest.java similarity index 99% rename from core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java rename to core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationServerRestApiTest.java index 6dbf28c1..de49f751 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ServerRestTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationServerRestApiTest.java @@ -43,7 +43,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class ServerRestTest { +public class IntegrationServerRestApiTest { @ClassRule public static JrsEnvironmentRule sEnv = new JrsEnvironmentRule(); From 5a936968dbdb1f4c11d42ebcb1ea8adf3f13b353 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 13 Nov 2015 15:14:36 +0200 Subject: [PATCH 275/457] Adapt report execution test to new integration system --- .../{resource => }/AbstractService.java | 6 +- .../android/sdk/testkit/CallAdapter.java | 49 ++++ .../android/sdk/testkit/ReportExec.java | 101 ++++++++ .../{resource => }/ResourceParameter.java | 2 +- .../{resource => }/ResourceRepository.java | 2 +- ...erviceFactory.java => ServiceFactory.java} | 17 +- .../sdk/testkit/dto/ReportExecConfig.java | 75 ++++++ .../android/sdk/env/JrsEnvironmentRule.java | 4 +- ...IntegrationReportExecutionRestApiTest.java | 221 ++++++++++++++++++ .../IntegrationReportOptionRestApiTest.java | 4 +- .../network/ReportExecutionRestApiTest.java | 156 ------------- 11 files changed, 465 insertions(+), 172 deletions(-) rename core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/{resource => }/AbstractService.java (94%) create mode 100644 core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/CallAdapter.java create mode 100644 core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ReportExec.java rename core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/{resource => }/ResourceParameter.java (98%) rename core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/{resource => }/ResourceRepository.java (98%) rename core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/{resource/ResourceServiceFactory.java => ServiceFactory.java} (83%) create mode 100644 core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/ReportExecConfig.java create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java delete mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/AbstractService.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/AbstractService.java similarity index 94% rename from core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/AbstractService.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/AbstractService.java index 277f19c7..aa064c0e 100644 --- a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/AbstractService.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/AbstractService.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.testkit.resource; +package com.jaspersoft.android.sdk.testkit; import com.jaspersoft.android.sdk.testkit.exception.HttpException; import com.squareup.okhttp.HttpUrl; @@ -43,10 +43,6 @@ public abstract class AbstractService { protected AbstractService(String token, String baseUrl) { - if (!baseUrl.endsWith("/")) { - baseUrl += "/"; - } - mClient = new OkHttpClient(); mToken = token; mBaseUrl = baseUrl; diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/CallAdapter.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/CallAdapter.java new file mode 100644 index 00000000..84174f55 --- /dev/null +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/CallAdapter.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.testkit; + +import com.jaspersoft.android.sdk.testkit.exception.HttpException; +import com.squareup.okhttp.Call; +import com.squareup.okhttp.Response; + +import java.io.IOException; + + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class CallAdapter { + public static Response adapt(Call call) throws IOException, HttpException { + Response response = call.execute(); + int code = response.code(); + + if (code >= 200 && code < 300) { + return response; + } else { + throw HttpException.Factory.create(response); + } + } +} diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ReportExec.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ReportExec.java new file mode 100644 index 00000000..65425277 --- /dev/null +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ReportExec.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.testkit; + +import com.google.gson.Gson; +import com.google.gson.stream.JsonReader; +import com.jaspersoft.android.sdk.testkit.dto.ReportExecConfig; +import com.jaspersoft.android.sdk.testkit.exception.HttpException; +import com.squareup.okhttp.HttpUrl; +import com.squareup.okhttp.MediaType; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.RequestBody; +import com.squareup.okhttp.Response; + +import java.io.IOException; +import java.io.InputStreamReader; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ReportExec { + private final String mToken; + private final String mBaseUrl; + private final OkHttpClient mOkhttp; + + ReportExec(String token, String baseUrl) { + mToken = token; + mBaseUrl = baseUrl; + mOkhttp = new OkHttpClient(); + } + + public String start(ReportExecConfig config) throws IOException, HttpException { + HttpUrl httpUrl = HttpUrl.parse(mBaseUrl + "rest_v2/reportExecutions"); + MediaType applicationJson = MediaType.parse("application/json; charset=utf-8"); + + Gson gson = new Gson(); + RequestBody requestBody = RequestBody.create(applicationJson, gson.toJson(config)); + Request request = new Request.Builder() + .url(httpUrl) + .addHeader("Cookie", mToken) + .addHeader("Accept", "application/json") + .post(requestBody) + .build(); + + Response response = CallAdapter.adapt(mOkhttp.newCall(request)); + + JsonReader reader = new JsonReader(new InputStreamReader(response.body().byteStream(), "UTF-8")); + reader.beginObject(); + while (reader.hasNext()) { + String name = reader.nextName(); + if ("requestId".equals(name)) { + return reader.nextString(); + } else { + reader.skipValue(); + } + } + reader.endObject(); + + throw new RuntimeException("Failed to receive 'requestId'"); + } + + public boolean cancel(String executionId) throws IOException, HttpException { + String path = String.format("rest_v2/reportExecutions/%s/status", executionId); + HttpUrl httpUrl = HttpUrl.parse(mBaseUrl + path); + MediaType applicationJson = MediaType.parse("application/json; charset=utf-8"); + RequestBody requestBody = RequestBody.create(applicationJson, "{\"value\": \"cancelled\"}"); + Request request = new Request.Builder() + .url(httpUrl) + .addHeader("Cookie", mToken) + .addHeader("Accept", "application/json") + .put(requestBody) + .build(); + + Response response = CallAdapter.adapt(mOkhttp.newCall(request)); + return response.code() != 204; + } +} diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceParameter.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ResourceParameter.java similarity index 98% rename from core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceParameter.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ResourceParameter.java index bc59b730..7ce59aaa 100644 --- a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceParameter.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ResourceParameter.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.testkit.resource; +package com.jaspersoft.android.sdk.testkit; import com.google.gson.stream.JsonReader; import com.jaspersoft.android.sdk.testkit.exception.HttpException; diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ResourceRepository.java similarity index 98% rename from core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ResourceRepository.java index b60fc70e..99e6cc8c 100644 --- a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceRepository.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ResourceRepository.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.testkit.resource; +package com.jaspersoft.android.sdk.testkit; import com.google.gson.stream.JsonReader; import com.jaspersoft.android.sdk.testkit.exception.HttpException; diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceServiceFactory.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ServiceFactory.java similarity index 83% rename from core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceServiceFactory.java rename to core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ServiceFactory.java index 62431c79..8fff173b 100644 --- a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/resource/ResourceServiceFactory.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/ServiceFactory.java @@ -22,17 +22,17 @@ * . */ -package com.jaspersoft.android.sdk.testkit.resource; +package com.jaspersoft.android.sdk.testkit; /** * @author Tom Koptel * @since 2.3 */ -public final class ResourceServiceFactory { +public final class ServiceFactory { private final String mToken; private final String mBaseUrl; - ResourceServiceFactory(String token, String baseUrl) { + ServiceFactory(String token, String baseUrl) { mToken = token; mBaseUrl = baseUrl; } @@ -49,6 +49,10 @@ public ResourceParameter resourceParameter(String resourceUri) { return new ResourceParameter(mToken, mBaseUrl, resourceUri); } + public ReportExec reporExec() { + return new ReportExec(mToken, mBaseUrl); + } + public static class Builder { private String mToken; private String mBaseUrl; @@ -62,12 +66,15 @@ public Builder token(String token) { } public Builder baseUrl(String baseUrl) { + if (!baseUrl.endsWith("/")) { + baseUrl += "/"; + } mBaseUrl = baseUrl; return this; } - public ResourceServiceFactory create() { - return new ResourceServiceFactory(mToken, mBaseUrl); + public ServiceFactory create() { + return new ServiceFactory(mToken, mBaseUrl); } } } diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/ReportExecConfig.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/ReportExecConfig.java new file mode 100644 index 00000000..76380026 --- /dev/null +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/dto/ReportExecConfig.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.testkit.dto; + +import com.google.gson.annotations.Expose; + +import java.util.Map; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ReportExecConfig { + @Expose + private final Map> parameters; + @Expose + private final String reportUnitUri; + + ReportExecConfig(Map> parameters, String reportUnitUri) { + this.parameters = parameters; + this.reportUnitUri = reportUnitUri; + } + + public String getUri() { + return reportUnitUri; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private Map> mParameters; + private String mReportUnitUri; + + private Builder() {} + + public Builder params(Map> parameters) { + mParameters = parameters; + return this; + } + + public Builder uri(String reportUnitUri) { + mReportUnitUri = reportUnitUri; + return this; + } + + public ReportExecConfig create() { + return new ReportExecConfig(mParameters, mReportUnitUri); + } + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java index d2c38f39..751b8da4 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.testkit.dto.AuthConfig; import com.jaspersoft.android.sdk.testkit.dto.Server; import com.jaspersoft.android.sdk.testkit.exception.HttpException; -import com.jaspersoft.android.sdk.testkit.resource.ResourceServiceFactory; +import com.jaspersoft.android.sdk.testkit.ServiceFactory; import com.jaspersoft.android.sdk.testkit.token.Authorizer; import com.jaspersoft.android.sdk.testkit.token.Credentials; import com.jaspersoft.android.sdk.testkit.token.CredentialsMapper; @@ -82,7 +82,7 @@ public Object[] listReports() { try { String token = String.valueOf(pair[0]); String url = String.valueOf(pair[1]); - ResourceServiceFactory service = ResourceServiceFactory.builder() + ServiceFactory service = ServiceFactory.builder() .baseUrl(url).token(token).create(); List reports = service diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java new file mode 100644 index 00000000..ce0167cb --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; +import com.jaspersoft.android.sdk.env.TestLogger; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.testkit.ServiceFactory; +import com.jaspersoft.android.sdk.testkit.dto.ReportExecConfig; +import com.jaspersoft.android.sdk.testkit.exception.HttpException; + +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(JUnitParamsRunner.class) +public class IntegrationReportExecutionRestApiTest { + + @ClassRule + public static JrsEnvironmentRule sEnv = new JrsEnvironmentRule(); + + private Object[] reports() { + return sEnv.listReports(); + } + + @Test + @Parameters(method = "reports") + public void shouldStartReportExecution(String token, String baseUrl, String reportUri) throws Exception { + ServiceFactory serviceFactory = ServiceFactory.builder() + .baseUrl(baseUrl).token(token) + .create(); + Map> params = + serviceFactory.resourceParameter(reportUri).listParams(); + + ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(reportUri); + if (!params.isEmpty()) { + executionRequestOptions.withParameters(params); + } + + ReportExecutionDescriptor response = createApi(baseUrl).runReportExecution(token, executionRequestOptions); + assertThat("Failed to start report execution", response != null); + + serviceFactory.reporExec().cancel(response.getExecutionId()); + } + + @Test + @Parameters(method = "reports") + public void shouldCancelReportExecution(final String token, final String baseUrl, String reportUri) throws Exception { + startExecution(token, baseUrl, reportUri).perform(new Action() { + @Override + public void call(Session session) { + createApi(baseUrl).cancelReportExecution(token, session.getExecId()); + } + }); + } + + @Test + @Parameters(method = "reports") + public void shouldReturnReportExecutionDetails(final String token, final String baseUrl, String reportUri) throws Exception { + startExecution(token, baseUrl, reportUri).perform(new Action() { + @Override + public void call(Session session) { + ReportExecutionDescriptor response = createApi(baseUrl).requestReportExecutionDetails(token, session.getExecId()); + assertThat("Failed to start received execution details", response != null); + } + }); + } + + @Test + @Parameters(method = "reports") + public void shouldCheckReportExecutionStatus(final String token, final String baseUrl, String reportUri) throws Exception { + startExecution(token, baseUrl, reportUri).perform(new Action() { + @Override + public void call(Session session) { + ExecutionStatus response = createApi(baseUrl).requestReportExecutionStatus(token, session.getExecId()); + assertThat("Failed to received execution status", response != null); + } + }); + } + + @Test + @Parameters(method = "reports") + public void searchForExecutionShouldReturnResult(final String token, final String baseUrl, final String reportUri) throws Exception { + startExecution(token, baseUrl, reportUri).perform(new Action() { + @Override + public void call(Session session) { + Map params = new HashMap<>(); + params.put("reportURI", reportUri); + ReportExecutionSearchResponse response = createApi(baseUrl).searchReportExecution(token, params); + assertThat("Failed to search execution items", !response.getItems().isEmpty()); + } + }); + } + + + @Test + @Parameters(method = "reports") + public void updateOfParametersForExecutionShouldReturnResult(final String token, final String baseUrl, String reportUri) throws Exception { + startExecution(token, baseUrl, reportUri).perform(new Action() { + @Override + public void call(Session session) { + List>> list = new ArrayList<>(); + list.add(session.getParams()); + + boolean success = createApi(baseUrl).updateReportExecution(token, session.getExecId(), list); + assertThat(success, is(true)); + } + }); + } + + + //============================================================================================== + + public static Session startExecution(String token, String baseUrl, String reportUri) throws IOException, HttpException { + return new SessionManager(token, baseUrl, reportUri).start(); + } + + private ReportExecutionRestApi createApi(String baseUrl) { + return new ReportExecutionRestApi.Builder() + .baseUrl(baseUrl) + .logger(TestLogger.get(this)) + .build(); + } + + public static class SessionManager { + private final String token; + private final String baseUrl; + private final String reportUri; + + private SessionManager(String token, String baseUrl, String reportUri) { + this.token = token; + this.baseUrl = baseUrl; + this.reportUri = reportUri; + } + + public Session start() throws IOException, HttpException { + ServiceFactory serviceFactory = ServiceFactory.builder() + .baseUrl(baseUrl).token(token) + .create(); + Map> params = + serviceFactory.resourceParameter(reportUri).listParams(); + ReportExecConfig.Builder configBuilder = ReportExecConfig.builder().uri(reportUri); + if (!params.isEmpty()) { + configBuilder.params(params); + } + String execId = serviceFactory.reporExec().start(configBuilder.create()); + return new Session(serviceFactory, params, execId); + } + } + + private static class Session { + private final ServiceFactory serviceFactory; + private final Map> params; + private final String execId; + + private Session(ServiceFactory serviceFactory, Map> params, String execId) { + this.serviceFactory = serviceFactory; + this.execId = execId; + this.params = params; + } + + public String getExecId() { + return execId; + } + + public Map> getParams() { + return params; + } + + public void perform(Action callback) throws IOException, HttpException { + callback.call(this); + serviceFactory.reporExec().cancel(execId); + } + } + + private interface Action { + void call(Session session); + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java index 6ba02d82..59e616d7 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; import com.jaspersoft.android.sdk.env.TestLogger; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.testkit.resource.ResourceServiceFactory; +import com.jaspersoft.android.sdk.testkit.ServiceFactory; import org.junit.ClassRule; import org.junit.Test; @@ -62,7 +62,7 @@ public void shouldRequestReportOptionsList(String token, String baseUrl, String @Test @Parameters(method = "reports") public void apiSupportsCrudForReportOption(String token, String baseUrl, String reportUri) throws Exception { - Map> params = ResourceServiceFactory.builder() + Map> params = ServiceFactory.builder() .baseUrl(baseUrl).token(token) .create() .resourceParameter(reportUri) diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java deleted file mode 100644 index 9db94f9a..00000000 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.env.DummyTokenProvider; -import com.jaspersoft.android.sdk.env.JrsMetadata; -import com.jaspersoft.android.sdk.env.TestLogger; - -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNot.not; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ReportExecutionRestApiTest { - - private final String REPORT_URI = "/public/Samples/Reports/ProfitDetailReport"; - - ReportExecutionRestApi apiUnderTest; - - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); - - @Before - public void setup() { - if (apiUnderTest == null) { - apiUnderTest = new ReportExecutionRestApi.Builder() - .baseUrl(mMetadata.getServerUrl()) - .logger(TestLogger.get(this)) - .build(); - } - } - - @Test - public void shouldStartReportExecution() { - ReportExecutionDescriptor response = startExecution(); - assertThat(response, is(notNullValue())); - assertThat(response.getStatus(), is(notNullValue())); - } - - /** - * TODO: TEST IS FLAKY provide workaround - */ - @Ignore - public void shouldCancelReportExecution() throws InterruptedException { - ReportExecutionDescriptor response = startExecution(); - boolean cancelled = apiUnderTest.cancelReportExecution(mAuthenticator.token(), response.getExecutionId()); - assertThat(cancelled, is(true)); - } - - @Test - public void shouldReturnReportExecutionDetails() throws IOException { - ReportExecutionDescriptor executionResponse = startExecution(); - - String executionId = executionResponse.getExecutionId(); - ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(mAuthenticator.token(), executionResponse.getExecutionId()); - assertThat(response.getExecutionId(), is(executionId)); - } - - @Test - public void shouldCheckReportExecutionStatus() throws IOException { - ReportExecutionDescriptor executionResponse = startExecution(); - - ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(mAuthenticator.token(), executionResponse.getExecutionId()); - assertThat(response.getStatus(), is(notNullValue())); - } - - /** - * TODO: API is broken requires investigation before release - */ - @Ignore - public void searchForExecutionShouldReturnResult() throws IOException { - ReportExecutionDescriptor executionResponse = startExecution(); - - Map params = new HashMap<>(); - params.put("reportURI", executionResponse.getReportURI()); - - ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(mAuthenticator.token(), params); - assertThat(response.getItems(), is(not(empty()))); - } - - @Test - public void updateOfParametersForExecutionShouldReturnResult() { - List>> list = new ArrayList<>(); - - Map> reportParameter = new HashMap<>(); - reportParameter.put("ProductFamily", new HashSet(Collections.singletonList("Drink"))); - list.add(reportParameter); - - ReportExecutionDescriptor executionResponse = startExecution(); - boolean success = apiUnderTest.updateReportExecution(mAuthenticator.token(), executionResponse.getExecutionId(), list); - assertThat(success, is(true)); - } - - /** - * Helper methods - */ - @NotNull - private ReportExecutionDescriptor startExecution() { - return startExecution(REPORT_URI); - } - - @NotNull - private ReportExecutionDescriptor startExecution(String uri) { - ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); - Map> params = new HashMap<>(); - params.put("ProductFamily", new HashSet(Collections.singletonList("Food"))); - executionRequestOptions.withParameters(params); - - return apiUnderTest.runReportExecution(mAuthenticator.token(), executionRequestOptions); - } -} From 2a5bebd1175db15b28a16f430e1c9b6a61a69c10 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 18 Nov 2015 13:38:34 +0200 Subject: [PATCH 276/457] Force IOException, HttpException and JSException all over codebase --- .../sdk/network/AuthenticationRestApi.java | 5 +- .../network/AuthenticationRestApiImpl.java | 52 ++++++++--------- .../android/sdk/network/CallWrapper.java | 32 ++++------- .../{RestError.java => HttpException.java} | 37 +++--------- .../sdk/network/InputControlRestApi.java | 7 ++- .../sdk/network/InputControlRestApiImpl.java | 7 ++- .../sdk/network/ReportExecutionRestApi.java | 17 ++++-- .../network/ReportExecutionRestApiImpl.java | 18 ++++-- .../sdk/network/ReportExportRestApi.java | 10 ++-- .../sdk/network/ReportExportRestApiImpl.java | 10 ++-- .../sdk/network/ReportOptionRestApi.java | 10 ++-- .../sdk/network/ReportOptionRestApiImpl.java | 9 +-- .../sdk/network/RepositoryRestApi.java | 10 +++- .../sdk/network/RepositoryRestApiImpl.java | 10 +++- .../android/sdk/network/ServerRestApi.java | 22 +++---- .../sdk/network/ServerRestApiImpl.java | 22 +++---- .../android/sdk/service/auth/AuthPolicy.java | 7 ++- .../android/sdk/service/auth/Credentials.java | 4 +- .../sdk/service/auth/JrsAuthenticator.java | 3 +- .../sdk/service/auth/SpringAuthService.java | 4 +- .../sdk/service/auth/SpringCredentials.java | 14 ++++- .../sdk/service/exception/JSException.java} | 37 +++++++----- .../service/report/ExecutionException.java | 13 ++--- .../sdk/service/report/ExportFactory.java | 2 +- .../sdk/service/report/ReportAttachment.java | 3 +- .../sdk/service/report/ReportExecution.java | 21 ++++--- .../report/ReportExecutionUseCase.java | 36 +++++++++--- .../sdk/service/report/ReportExport.java | 3 +- .../service/report/ReportExportUseCase.java | 57 ++++++++++++++----- .../sdk/service/report/ReportService.java | 9 ++- .../exception/ReportExportException.java | 2 +- .../report/exception/ReportRunException.java | 2 +- .../repository/EmeraldMR2SearchStrategy.java | 9 +-- .../repository/EmeraldMR3SearchStrategy.java | 9 +-- .../service/repository/SearchStrategy.java | 3 +- .../sdk/service/repository/SearchTask.java | 3 +- .../service/repository/SearchTaskImpl.java | 3 +- .../sdk/service/repository/SearchUseCase.java | 27 ++++++--- .../sdk/service/server/ServerInfoService.java | 39 ++++++++++--- .../network/AuthenticationRestApiTest.java | 18 +++--- .../sdk/network/InputControlRestApiTest.java | 24 ++++---- .../network/ReportExecutionRestApiTest.java | 37 ++++++------ .../sdk/network/ReportExportRestApiTest.java | 40 +++++++------ .../sdk/network/ReportOptionRestApiTest.java | 40 +++++++------ .../sdk/network/RepositoryRestApiTest.java | 32 +++++------ .../sdk/network/ServerRestApiTest.java | 6 +- .../service/auth/JrsAuthenticatorTest.java | 2 +- .../service/auth/SpringAuthServiceTest.java | 6 +- .../service/data/server/FeatureSetTest.java | 33 ----------- .../service/data/server/ServerInfoTest.java | 33 ----------- .../report/ExecutionExceptionTest.java | 27 +++++---- .../service/report/ReportExecutionTest.java | 16 +++--- .../sdk/service/report/ReportServiceTest.java | 16 +++--- .../service/report/RunExportCriteriaTest.java | 49 ---------------- .../EmeraldMR2SearchStrategyTest.java | 4 +- .../EmeraldMR3SearchStrategyTest.java | 12 ++-- .../repository/SearchTaskImplTest.java | 6 +- .../service/repository/SearchUseCaseTest.java | 2 +- .../service/server/ServerInfoServiceTest.java | 2 +- .../api/AuthenticationRestApiTest.java | 4 +- .../api/InputControlRestApiTest.java | 8 +-- .../api/ReportExecutionRestApiTest.java | 17 +++--- .../api/ReportExportRestApiTest.java | 12 ++-- .../api/ReportOptionRestApiTest.java | 4 +- .../api/RepositoryRestApiTest.java | 6 +- .../api/utils/DummyTokenProvider.java | 4 +- 66 files changed, 518 insertions(+), 530 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/network/{RestError.java => HttpException.java} (61%) rename core/src/{test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java => main/java/com/jaspersoft/android/sdk/service/exception/JSException.java} (55%) delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index a8be8279..e6723fbc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.Map; /** @@ -42,10 +43,10 @@ public interface AuthenticationRestApi { String authenticate(@NotNull String username, @NotNull String password, @Nullable String organization, - @Nullable Map params); + @Nullable Map params) throws HttpException, IOException; @NotNull - EncryptionKey requestEncryptionMetadata(); + EncryptionKey requestEncryptionMetadata() throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java index f0134885..2d1c02f9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java @@ -66,44 +66,40 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { public String authenticate(@NotNull final String username, @NotNull final String password, final String organization, - final Map params) { + final Map params) throws HttpException, IOException { Request request = createAuthRequest(username, password, organization, params); Call call = mClient.newCall(request); - try { - com.squareup.okhttp.Response response = call.execute(); - int statusCode = response.code(); - if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request + com.squareup.okhttp.Response response = call.execute(); + int statusCode = response.code(); + if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request + return CookieExtractor.extract(response); + } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request + String location = response.headers().get("Location"); + if (location == null) { + throw new IllegalStateException("Location HEADER is missing please contact JRS admin"); + } + HttpUrl url = HttpUrl.parse(location); + String errorQueryParameter = url.queryParameter("error"); + if (errorQueryParameter == null) { return CookieExtractor.extract(response); - } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request - String location = response.headers().get("Location"); - if (location == null) { - throw new IllegalStateException("Location HEADER is missing please contact JRS admin"); - } - HttpUrl url = HttpUrl.parse(location); - String errorQueryParameter = url.queryParameter("error"); - if (errorQueryParameter == null) { - return CookieExtractor.extract(response); - } else { - com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() - .protocol(response.protocol()) - .request(response.request()) - .headers(response.headers()) - .body(response.body()) - .code(401) - .build(); - throw RestError.httpError(response401); - } } else { - throw RestError.httpError(response); + com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() + .protocol(response.protocol()) + .request(response.request()) + .headers(response.headers()) + .body(response.body()) + .code(401) + .build(); + throw HttpException.httpError(response401); } - } catch (IOException ex) { - throw RestError.networkError(ex); + } else { + throw HttpException.httpError(response); } } @NotNull @Override - public EncryptionKey requestEncryptionMetadata() { + public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); String anonymousToken = CookieExtractor.extract(response.raw()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java b/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java index 29e63efd..28116816 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java @@ -44,29 +44,21 @@ public static CallWrapper wrap(Call originalCall) { return new CallWrapper<>(originalCall); } - public Body body() { - try { - Response response = mDelegateCall.execute(); - if (response.isSuccess()) { - return response.body(); - } else { - throw RestError.httpError(response); - } - } catch (IOException ex) { - throw RestError.networkError(ex); + public Body body() throws HttpException, IOException { + Response response = mDelegateCall.execute(); + if (response.isSuccess()) { + return response.body(); + } else { + throw HttpException.httpError(response); } } - public Response response() { - try { - Response response = mDelegateCall.execute(); - if (response.isSuccess()) { - return response; - } else { - throw RestError.httpError(response); - } - } catch (IOException ex) { - throw RestError.networkError(ex); + public Response response() throws HttpException, IOException { + Response response = mDelegateCall.execute(); + if (response.isSuccess()) { + return response; + } else { + throw HttpException.httpError(response); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java similarity index 61% rename from core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java index e1b2e143..7a8d1862 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RestError.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java @@ -36,33 +36,26 @@ * @author Tom Koptel * @since 2.0 */ -public final class RestError extends RuntimeException { - static RestError networkError(IOException exception) { - return new RestError(exception.getMessage(), null, Kind.NETWORK, +public class HttpException extends Exception { + static HttpException networkError(IOException exception) { + return new HttpException(exception.getMessage(), null, exception); } - static RestError httpError(Response response) { + static HttpException httpError(Response response) { return httpError(response.raw()); } - static RestError httpError(com.squareup.okhttp.Response response) { + static HttpException httpError(com.squareup.okhttp.Response response) { String message = response.code() + " " + response.message(); - return new RestError(message, response, Kind.HTTP, null); - } - - static RestError unexpectedError(Throwable exception) { - return new RestError(exception.getMessage(), null, Kind.UNEXPECTED, - exception); + return new HttpException(message, response, null); } private final com.squareup.okhttp.Response response; - private final Kind kind; - RestError(String message,com.squareup.okhttp.Response response,Kind kind, Throwable exception) { + HttpException(String message, com.squareup.okhttp.Response response, Throwable exception) { super(message, exception); this.response = response; - this.kind = kind; } // HTTP status code. @@ -83,20 +76,4 @@ public String urlString() { return response.request().urlString(); } - public Kind kind() { - return kind; - } - - /** Identifies the event kind which triggered a {@link RestError}. */ - public enum Kind { - /** An {@link IOException} occurred while communicating to the server. */ - NETWORK, - /** A non-200 HTTP status code was received from the server. */ - HTTP, - /** - * An internal error occurred while attempting to execute a request. It is best practice to - * re-throw this exception so your application crashes. - */ - UNEXPECTED - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index 13180211..df389bc6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.NotNull; +import java.io.IOException; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -52,12 +53,12 @@ public interface InputControlRestApi { @NotNull Collection requestInputControls(@NotNull String token, @NotNull String reportUri, - boolean excludeState); + boolean excludeState) throws HttpException, IOException; @NotNull Collection requestInputControlsInitialStates(@NotNull String token, @NotNull String reportUri, - boolean freshData); + boolean freshData) throws HttpException, IOException; /** * Provides values for specified controls. This API helpful to @@ -73,7 +74,7 @@ Collection requestInputControlsInitialStates(@NotNull String Collection requestInputControlsStates(@NotNull String token, @NotNull String reportUri, @NotNull Map> controlsValues, - boolean freshData); + boolean freshData) throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java index 5a33bb8e..a5fbce6b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java @@ -33,6 +33,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -62,7 +63,7 @@ final class InputControlRestApiImpl implements InputControlRestApi { @Override public Collection requestInputControls(@Nullable String token, @Nullable String reportUri, - boolean excludeState) { + boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -76,7 +77,7 @@ public Collection requestInputControls(@Nullable String token, @Override public Collection requestInputControlsInitialStates(@Nullable String token, @Nullable String reportUri, - boolean freshData) { + boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -90,7 +91,7 @@ public Collection requestInputControlsInitialStates(@Nullable public Collection requestInputControlsStates(@Nullable String token, @Nullable String reportUri, @Nullable Map> controlsValues, - boolean freshData) { + boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); Utils.checkNotNull(token, "Request token should not be null"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index e4e9d885..709b6f53 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull; +import java.io.IOException; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -42,23 +43,27 @@ public interface ReportExecutionRestApi { @NotNull - ReportExecutionDescriptor runReportExecution(@NotNull String token, @NotNull ReportExecutionRequestOptions executionOptions); + ReportExecutionDescriptor runReportExecution(@NotNull String token, + @NotNull ReportExecutionRequestOptions executionOptions) throws HttpException, IOException; @NotNull - ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String token, @NotNull String executionId); + ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String token, + @NotNull String executionId) throws HttpException, IOException; @NotNull - ExecutionStatus requestReportExecutionStatus(@NotNull String token, @NotNull String executionId); + ExecutionStatus requestReportExecutionStatus(@NotNull String token, + @NotNull String executionId) throws HttpException, IOException; - boolean cancelReportExecution(@NotNull String token, @NotNull String executionId); + boolean cancelReportExecution(@NotNull String token, + @NotNull String executionId) throws HttpException, IOException; boolean updateReportExecution(@NotNull String token, @NotNull String executionId, - @NotNull Collection>> params); + @NotNull Collection>> params) throws HttpException, IOException; // TODO: API is broken requires investigation before release @NotNull - ReportExecutionSearchResponse searchReportExecution(@NotNull String token, Map params); + ReportExecutionSearchResponse searchReportExecution(@NotNull String token, Map params) throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java index 3ecccc1a..932dd564 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java @@ -32,6 +32,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -62,7 +63,8 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NotNull @Override - public ReportExecutionDescriptor runReportExecution(@Nullable String token, @Nullable ReportExecutionRequestOptions executionOptions) { + public ReportExecutionDescriptor runReportExecution(@Nullable String token, + @Nullable ReportExecutionRequestOptions executionOptions) throws IOException, HttpException { Utils.checkNotNull(executionOptions, "Execution options should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -72,7 +74,8 @@ public ReportExecutionDescriptor runReportExecution(@Nullable String token, @Nul @NotNull @Override - public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String token, @Nullable String executionId) { + public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String token, + @Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -82,7 +85,8 @@ public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String @NotNull @Override - public ExecutionStatus requestReportExecutionStatus(@Nullable String token, @Nullable String executionId) { + public ExecutionStatus requestReportExecutionStatus(@Nullable String token, + @Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -91,7 +95,8 @@ public ExecutionStatus requestReportExecutionStatus(@Nullable String token, @Nul } @Override - public boolean cancelReportExecution(@Nullable String token, @Nullable String executionId) { + public boolean cancelReportExecution(@Nullable String token, + @Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -104,7 +109,7 @@ public boolean cancelReportExecution(@Nullable String token, @Nullable String ex @Override public boolean updateReportExecution(@Nullable String token, @Nullable String executionId, - @Nullable Collection>> params) { + @Nullable Collection>> params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); @@ -118,7 +123,8 @@ public boolean updateReportExecution(@Nullable String token, @NotNull @Override - public ReportExecutionSearchResponse searchReportExecution(@Nullable String token, @Nullable Map params) { + public ReportExecutionSearchResponse searchReportExecution(@Nullable String token, + @Nullable Map params) throws IOException, HttpException { Utils.checkNotNull(params, "Search params should not be null"); Utils.checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); Utils.checkNotNull(token, "Request token should not be null"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java index 9f2402c6..9d0c9ed8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java @@ -33,6 +33,8 @@ import org.jetbrains.annotations.NotNull; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 @@ -42,23 +44,23 @@ public interface ReportExportRestApi { @NotNull ExportExecutionDescriptor runExportExecution(@NotNull String token, @NotNull String executionId, - @NotNull ExecutionRequestOptions executionOptions); + @NotNull ExecutionRequestOptions executionOptions) throws HttpException, IOException; @NotNull ExecutionStatus checkExportExecutionStatus(@NotNull String token, @NotNull String executionId, - @NotNull String exportId); + @NotNull String exportId) throws HttpException, IOException; @NotNull ExportOutputResource requestExportOutput(@NotNull String token, @NotNull String executionId, - @NotNull String exportId); + @NotNull String exportId) throws HttpException, IOException; @NotNull OutputResource requestExportAttachment(@NotNull String token, @NotNull String executionId, @NotNull String exportId, - @NotNull String attachmentId); + @NotNull String attachmentId) throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index 573b2885..80c15dc3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -34,6 +34,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; + import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; @@ -59,7 +61,7 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @Override public ExportExecutionDescriptor runExportExecution(@Nullable String token, @Nullable String executionId, - @Nullable ExecutionRequestOptions executionOptions) { + @Nullable ExecutionRequestOptions executionOptions) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(executionOptions, "Execution options should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -72,7 +74,7 @@ public ExportExecutionDescriptor runExportExecution(@Nullable String token, @Override public ExecutionStatus checkExportExecutionStatus(@Nullable String token, @Nullable String executionId, - @Nullable String exportId) { + @Nullable String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -85,7 +87,7 @@ public ExecutionStatus checkExportExecutionStatus(@Nullable String token, @Override public ExportOutputResource requestExportOutput(@Nullable String token, @Nullable String executionId, - @Nullable String exportId) { + @Nullable String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -106,7 +108,7 @@ public ExportOutputResource requestExportOutput(@Nullable String token, public OutputResource requestExportAttachment(@Nullable String token, @Nullable String executionId, @Nullable String exportId, - @Nullable String attachmentId) { + @Nullable String attachmentId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); Utils.checkNotNull(attachmentId, "Attachment id should not be null"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java index 44faf10d..26b35cc1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java @@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull; +import java.io.IOException; import java.util.Map; import java.util.Set; @@ -38,22 +39,23 @@ public interface ReportOptionRestApi { @NotNull - Set requestReportOptionsList(@NotNull String reportUnitUri, @NotNull String token); + Set requestReportOptionsList(@NotNull String reportUnitUri, + @NotNull String token) throws HttpException, IOException; @NotNull ReportOption createReportOption(@NotNull String token, @NotNull String reportUnitUri, @NotNull String optionLabel, @NotNull Map> controlsValues, - boolean overwrite); + boolean overwrite) throws HttpException, IOException; void updateReportOption(@NotNull String token, @NotNull String reportUnitUri, @NotNull String optionId, - @NotNull Map> controlsValues); + @NotNull Map> controlsValues) throws HttpException, IOException; void deleteReportOption(@NotNull String token, @NotNull String reportUnitUri, - @NotNull String optionId); + @NotNull String optionId) throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java index 5a21724f..409a1934 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java @@ -32,6 +32,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -62,7 +63,7 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { @NotNull @Override public Set requestReportOptionsList(@Nullable String token, - @Nullable String reportUnitUri) { + @Nullable String reportUnitUri) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -86,7 +87,7 @@ public ReportOption createReportOption(@Nullable String token, @Nullable String reportUnitUri, @Nullable String optionLabel, @Nullable Map> controlsValues, - boolean overwrite) { + boolean overwrite) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionLabel, "Option label should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); @@ -100,7 +101,7 @@ public ReportOption createReportOption(@Nullable String token, public void updateReportOption(@Nullable String token, @Nullable String reportUnitUri, @Nullable String optionId, - @Nullable Map> controlsValues) { + @Nullable Map> controlsValues) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); @@ -113,7 +114,7 @@ public void updateReportOption(@Nullable String token, @Override public void deleteReportOption(@Nullable String token, @Nullable String reportUnitUri, - @Nullable String optionId) { + @Nullable String optionId) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(token, "Request token should not be null"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java index 21e9f8df..e4415ced 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java @@ -32,6 +32,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.Map; /** @@ -40,13 +41,16 @@ */ public interface RepositoryRestApi { @NotNull - ResourceSearchResult searchResources(@NotNull String token, @Nullable Map searchParams); + ResourceSearchResult searchResources(@NotNull String token, + @Nullable Map searchParams) throws HttpException, IOException; @NotNull - ReportLookup requestReportResource(@NotNull String token, @NotNull String resourceUri); + ReportLookup requestReportResource(@NotNull String token, + @NotNull String resourceUri) throws HttpException, IOException; @NotNull - FolderLookup requestFolderResource(@NotNull String token, @NotNull String resourceUri); + FolderLookup requestFolderResource(@NotNull String token, + @NotNull String resourceUri) throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java index f304a05e..a5f47e37 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java @@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -57,7 +58,8 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NotNull @Override - public ResourceSearchResult searchResources(@Nullable String token, @Nullable Map searchParams) { + public ResourceSearchResult searchResources(@Nullable String token, + @Nullable Map searchParams) throws IOException, HttpException { Utils.checkNotNull(token, "Request token should not be null"); Iterable types = null; @@ -105,7 +107,8 @@ public ResourceSearchResult searchResources(@Nullable String token, @Nullable Ma @NotNull @Override - public ReportLookup requestReportResource(@Nullable String token, @Nullable String resourceUri) { + public ReportLookup requestReportResource(@Nullable String token, + @Nullable String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Report uri should not be null"); Utils.checkNotNull(token, "Request token should not be null"); @@ -115,7 +118,8 @@ public ReportLookup requestReportResource(@Nullable String token, @Nullable Stri @NotNull @Override - public FolderLookup requestFolderResource(@Nullable String token, @Nullable String resourceUri) { + public FolderLookup requestFolderResource(@Nullable String token, + @Nullable String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Folder uri should not be null"); Utils.checkNotNull(token, "Request token should not be null"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java index ceddaf03..5a37bd51 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java @@ -28,6 +28,8 @@ import org.jetbrains.annotations.NotNull; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 @@ -35,34 +37,34 @@ public interface ServerRestApi { @NotNull - ServerInfoData requestServerInfo(); + ServerInfoData requestServerInfo() throws HttpException, IOException; @NotNull - String requestBuild(); + String requestBuild() throws HttpException, IOException; @NotNull - String requestDateFormatPattern(); + String requestDateFormatPattern() throws HttpException, IOException; @NotNull - String requestDateTimeFormatPattern(); + String requestDateTimeFormatPattern() throws HttpException, IOException; @NotNull - String requestEdition(); + String requestEdition() throws HttpException, IOException; @NotNull - String requestEditionName(); + String requestEditionName() throws HttpException, IOException; @NotNull - String requestVersion(); + String requestVersion() throws HttpException, IOException; @NotNull - String requestFeatures(); + String requestFeatures() throws HttpException, IOException; @NotNull - String requestLicenseType(); + String requestLicenseType() throws HttpException, IOException; @NotNull - String requestExpiration(); + String requestExpiration() throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java index b834a9d3..1d46bb7b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java @@ -28,6 +28,8 @@ import org.jetbrains.annotations.NotNull; +import java.io.IOException; + import retrofit.Call; import retrofit.Retrofit; import retrofit.http.GET; @@ -47,62 +49,62 @@ public ServerRestApiImpl(Retrofit retrofit) { @NotNull @Override - public ServerInfoData requestServerInfo() { + public ServerInfoData requestServerInfo() throws IOException, HttpException { Call call = mApi.requestServerInfo(); return CallWrapper.wrap(call).body(); } @NotNull @Override - public String requestEdition() { + public String requestEdition() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestEdition()).body(); } @NotNull @Override - public String requestVersion() { + public String requestVersion() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestVersion()).body(); } @NotNull @Override - public String requestBuild() { + public String requestBuild() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestBuild()).body(); } @NotNull @Override - public String requestFeatures() { + public String requestFeatures() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestFeatures()).body(); } @NotNull @Override - public String requestEditionName() { + public String requestEditionName() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestEditionName()).body(); } @NotNull @Override - public String requestLicenseType() { + public String requestLicenseType() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestLicenseType()).body(); } @NotNull @Override - public String requestExpiration() { + public String requestExpiration() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestExpiration()).body(); } @NotNull @Override - public String requestDateFormatPattern() { + public String requestDateFormatPattern() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestDateFormatPattern()).body(); } @NotNull @Override - public String requestDateTimeFormatPattern() { + public String requestDateTimeFormatPattern() throws IOException, HttpException { return CallWrapper.wrap(mApi.requestDateTimeFormatPattern()).body(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java index 239ccbec..ceebd9cd 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java @@ -1,15 +1,18 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.HttpException; import org.jetbrains.annotations.NotNull; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 */ interface AuthPolicy { - String applyCredentials(SpringCredentials credentials); + String applyCredentials(SpringCredentials credentials) throws IOException, HttpException; class Default implements AuthPolicy { private final SpringAuthService mSpringService; @@ -31,7 +34,7 @@ public static Default create(@NotNull String baseUrl) { } @Override - public String applyCredentials(SpringCredentials credentials) { + public String applyCredentials(SpringCredentials credentials) throws IOException, HttpException { return mSpringService.authenticate(credentials); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java index 4510f0e3..325bb7b8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java @@ -1,9 +1,11 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.service.exception.JSException; + /** * @author Tom Koptel * @since 2.0 */ public abstract class Credentials { - protected abstract String applyPolicy(AuthPolicy authPolicy); + protected abstract String applyPolicy(AuthPolicy authPolicy) throws JSException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java index 99f5d370..92108d70 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java @@ -1,6 +1,7 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -34,7 +35,7 @@ public static JrsAuthenticator create(@NotNull AuthenticationRestApi restApi) { } @NotNull - public String authenticate(@NotNull Credentials credentials) { + public String authenticate(@NotNull Credentials credentials) throws JSException { checkNotNull(credentials, "Credentials should not be null"); return credentials.applyPolicy(mAuthPolicy); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index b0195b32..3ddc5e04 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -25,12 +25,14 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import java.io.IOException; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -69,7 +71,7 @@ public static SpringAuthService create(@NotNull AuthenticationRestApi restApi) { } @NotNull - public String authenticate(SpringCredentials credentials) { + public String authenticate(SpringCredentials credentials) throws IOException, HttpException { String password = credentials.getPassword(); EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index fb2277ae..38f4b059 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -1,9 +1,13 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.JSException; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; +import java.io.IOException; import java.util.Locale; import java.util.TimeZone; @@ -64,8 +68,14 @@ public Locale getLocale() { } @Override - protected String applyPolicy(AuthPolicy policy) { - return policy.applyCredentials(this); + protected String applyPolicy(AuthPolicy policy) throws JSException { + try { + return policy.applyCredentials(this); + } catch (IOException e) { + throw JSException.wrap(e); + } catch (HttpException e) { + throw JSException.wrap(e); + } } @Override diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/JSException.java similarity index 55% rename from core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/exception/JSException.java index 74e1a1fc..51ebe698 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunReportCriteriaTest.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/JSException.java @@ -22,28 +22,37 @@ * . */ -package com.jaspersoft.android.sdk.service.report; +package com.jaspersoft.android.sdk.service.exception; -import org.junit.Before; -import org.junit.Test; +import com.jaspersoft.android.sdk.network.HttpException; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; +import java.io.IOException; /** * @author Tom Koptel - * @since 2.0 + * @since 2.3 */ -public class RunReportCriteriaTest { - private ExecutionCriteria objectUnderTest; +public class JSException extends Exception { + public static final int EXPORT_EXECUTION_CANCELLED = 1; + public static final int EXPORT_EXECUTION_FAILED = 2; + public static final int REPORT_EXECUTION_CANCELLED = 2; + public static final int REPORT_EXECUTION_FAILED = 3; - @Before - public void setUp() throws Exception { - objectUnderTest = RunReportCriteria.builder().create(); + public static JSException wrap(IOException e) { + throw new UnsupportedOperationException("Not implemented"); } - @Test - public void interactiveShouldBeTrueByDefault() { - assertThat(objectUnderTest.isInteractive(), is(true)); + public static JSException wrap(HttpException e) { + throw new UnsupportedOperationException("Not implemented"); } + + public static JSException create(String message, Throwable cause, int exportExecutionCancelled) { + return null; + } + + public int code() { + throw new UnsupportedOperationException("Not implemented"); + } + + } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java index 29d51896..b2459c2d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java @@ -24,14 +24,13 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; -import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; +import com.jaspersoft.android.sdk.service.exception.JSException; /** * @author Tom Koptel * @since 2.0 */ -final class ExecutionException extends RuntimeException { +final class ExecutionException extends Exception { private final Kind mKind; private ExecutionException(Kind kind, String message) { @@ -72,16 +71,16 @@ public boolean isCancelled() { return Kind.EXPORT_CANCELLED == mKind || Kind.REPORT_CANCELLED == mKind; } - public RuntimeException adaptToClientException() { + public JSException adaptToClientException() { switch (mKind) { case REPORT_FAILED: case REPORT_CANCELLED: - return new ReportRunException(getMessage(), getCause()); + return JSException.create(getMessage(), getCause(), JSException.REPORT_EXECUTION_CANCELLED); case EXPORT_FAILED: case EXPORT_CANCELLED: - return new ReportExportException(getMessage(), getCause()); + return JSException.create(getMessage(), getCause(), JSException.EXPORT_EXECUTION_CANCELLED); } - return new UnsupportedOperationException("Unexpected type of kind: " + mKind); + throw new UnsupportedOperationException("Unexpected type of kind: " + mKind); } private enum Kind { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index 1360e748..ffa7133f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -54,7 +54,7 @@ final class ExportFactory { @NotNull public ReportExport create(ReportExecutionDescriptor executionDetails, - ExportExecutionDescriptor exportExecutionDetails) { + ExportExecutionDescriptor exportExecutionDetails) throws ExecutionException { String exportId = exportExecutionDetails.getExportId(); ExportDescriptor export = findExportDescriptor(executionDetails, exportId); if (export == null) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index 9db85a47..2603f7cc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; @@ -50,7 +51,7 @@ public final class ReportAttachment { } @NotNull - public ResourceOutput download() { + public ResourceOutput download() throws JSException { return mExportUseCase.requestExportAttachmentOutput( mExecutionId, mExportId, mFileName); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index b04fcd52..48e5fed9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -63,16 +64,18 @@ public final class ReportExecution { } @NotNull - public ReportMetadata waitForReportCompletion() { + public ReportMetadata waitForReportCompletion() throws JSException { try { return performAwaitFoReport(); } catch (ExecutionException ex) { throw ex.adaptToClientException(); + } catch (JSException e) { + throw e; } } @NotNull - public ReportExport export(RunExportCriteria criteria) { + public ReportExport export(RunExportCriteria criteria) throws JSException { try { return performExport(criteria); } catch (ExecutionException ex) { @@ -88,11 +91,13 @@ public ReportExport export(RunExportCriteria criteria) { } } throw ex.adaptToClientException(); + } catch (JSException e) { + throw e; } } @NotNull - private ReportMetadata performAwaitFoReport() { + private ReportMetadata performAwaitFoReport() throws JSException, ExecutionException { ReportExecutionDescriptor details = requestExecutionDetails(); ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); return new ReportMetadata(mReportUri, @@ -100,14 +105,14 @@ private ReportMetadata performAwaitFoReport() { } @NotNull - private ReportExport performExport(RunExportCriteria criteria) { + private ReportExport performExport(RunExportCriteria criteria) throws JSException, ExecutionException { ExportExecutionDescriptor exportDetails = runExport(criteria); waitForExportReadyStatus(exportDetails); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); return mExportFactory.create(currentDetails, exportDetails); } - private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) { + private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws JSException, ExecutionException{ final String exportId = exportDetails.getExportId(); Status status = Status.wrap(exportDetails.getStatus()); @@ -129,7 +134,7 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) { } @NotNull - private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) { + private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) throws JSException, ExecutionException{ Status status = Status.wrap(details.getStatus()); ReportExecutionDescriptor resultDetails = details; @@ -152,12 +157,12 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD } @NotNull - private ExportExecutionDescriptor runExport(RunExportCriteria criteria) { + private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws JSException { return mExportUseCase.runExport(mExecutionId, criteria); } @NotNull - private ReportExecutionDescriptor requestExecutionDetails() { + private ReportExecutionDescriptor requestExecutionDetails() throws JSException { return mExecutionUseCase.requestExecutionDetails(mExecutionId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index c5b39e1f..e105c077 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -24,14 +24,18 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 @@ -50,19 +54,37 @@ final class ReportExecutionUseCase { } @NotNull - public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) { + public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) throws JSException { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); - return mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); + try { + return mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } @NotNull - public Status requestStatus(String executionId) { - ExecutionStatus executionStatus = mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); - return Status.wrap(executionStatus.getStatus()); + public Status requestStatus(String executionId) throws JSException { + try { + ExecutionStatus executionStatus = mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); + return Status.wrap(executionStatus.getStatus()); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } @NotNull - public ReportExecutionDescriptor requestExecutionDetails(String executionId) { - return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), executionId); + public ReportExecutionDescriptor requestExecutionDetails(String executionId) throws JSException { + try { + return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), executionId); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index e614a332..9bd70e00 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; @@ -56,7 +57,7 @@ public Collection getAttachments() { } @NotNull - public ReportOutput download() { + public ReportOutput download() throws JSException { return mExportUseCase.requestExportOutput(mExecutionId, mExportId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 5741d321..25d58554 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -33,9 +34,12 @@ import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 @@ -53,29 +57,54 @@ final class ReportExportUseCase { } @NotNull - public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) { + public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) throws JSException { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); - return mExportApi.runExportExecution(mTokenProvider.provideToken(), executionId, options); + try { + return mExportApi.runExportExecution(mTokenProvider.provideToken(), executionId, options); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } @NotNull - public Status checkExportExecutionStatus(String executionId, String exportId) { - ExecutionStatus exportStatus = mExportApi - .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); - return Status.wrap(exportStatus.getStatus()); + public Status checkExportExecutionStatus(String executionId, String exportId) throws JSException { + try { + ExecutionStatus exportStatus = mExportApi + .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); + return Status.wrap(exportStatus.getStatus()); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } @NotNull - public ReportOutput requestExportOutput(String executionId, String exportId) { - ExportOutputResource result = mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); - return OutputDataMapper.transform(result); + public ReportOutput requestExportOutput(String executionId, String exportId) throws JSException { + try { + ExportOutputResource result = mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); + return OutputDataMapper.transform(result); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } @NotNull - public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, String fileName) { - OutputResource result = mExportApi.requestExportAttachment( - mTokenProvider.provideToken(), - executionId, exportId, fileName); - return OutputDataMapper.transform(result); + public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, String fileName) throws JSException { + OutputResource result = null; + try { + result = mExportApi.requestExportAttachment( + mTokenProvider.provideToken(), + executionId, exportId, fileName); + return OutputDataMapper.transform(result); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index ad4aef47..4b81bf05 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.exception.JSException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; @@ -76,16 +77,18 @@ public static ReportService create(TokenProvider tokenProvider, InfoProvider inf reportExportUseCase); } - public ReportExecution run(String reportUri, RunReportCriteria criteria) { + public ReportExecution run(String reportUri, RunReportCriteria criteria) throws JSException { try { return performRun(reportUri, criteria); } catch (ExecutionException ex) { throw ex.adaptToClientException(); + } catch (JSException ex) { + throw ex; } } @NotNull - private ReportExecution performRun(String reportUri, RunReportCriteria criteria) { + private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws JSException, ExecutionException { ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); waitForReportExecutionStart(reportUri, details); @@ -98,7 +101,7 @@ private ReportExecution performRun(String reportUri, RunReportCriteria criteria) details.getReportURI()); } - private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) { + private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) throws ExecutionException, JSException { String executionId = details.getExecutionId(); Status status = Status.wrap(details.getStatus()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java index 3b521434..30ca7c46 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportExportException extends RuntimeException { +public final class ReportExportException extends Exception { public ReportExportException(String detailMessage, Throwable throwable) { super(detailMessage, throwable); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java index 84d00d8c..3e305cac 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportRunException extends RuntimeException { +public final class ReportRunException extends Exception { public ReportRunException(String detailMessage, Throwable throwable) { super(detailMessage, throwable); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 05848a78..e7ce8e0e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; @@ -59,7 +60,7 @@ public EmeraldMR2SearchStrategy(InternalCriteria criteria, } @Override - public Collection searchNext() { + public Collection searchNext() throws JSException { int limit = mInitialCriteria.getLimit(); int offset = mInitialCriteria.getOffset(); @@ -75,7 +76,7 @@ public boolean hasNext() { return !mEndReached; } - private void calculateDisposition(int offset) { + private void calculateDisposition(int offset) throws JSException { boolean serverDispositionUndefined = offset >= mServerDisposition; if (serverDispositionUndefined) { internalSearch(offset); @@ -83,7 +84,7 @@ private void calculateDisposition(int offset) { } @NotNull - private Collection internalSearch(int limit) { + private Collection internalSearch(int limit) throws JSException { int count = 0; while (mBuffer.size() < limit && hasNext()) { SearchResult response = performSearch(limit); @@ -111,7 +112,7 @@ private Collection internalSearch(int limit) { } @NotNull - private SearchResult performSearch(int limit) { + private SearchResult performSearch(int limit) throws JSException { InternalCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) .limit(limit) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 0ad7a7c3..6eea0f2d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; @@ -58,7 +59,7 @@ public EmeraldMR3SearchStrategy(InternalCriteria criteria, SearchUseCase searchU } @Override - public Collection searchNext() { + public Collection searchNext() throws JSException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } @@ -75,7 +76,7 @@ public boolean hasNext() { } @NotNull - private Collection performLookup() { + private Collection performLookup() throws JSException { InternalCriteria newSearchCriteria = createNextCriteria(); SearchResult result = performApiCall(newSearchCriteria); updateInternalOffset(result); @@ -83,11 +84,11 @@ private Collection performLookup() { } @NotNull - private SearchResult performApiCall(InternalCriteria newSearchCriteria) { + private SearchResult performApiCall(InternalCriteria newSearchCriteria) throws JSException { return mSearchUseCase.performSearch(newSearchCriteria); } - private void defineInternalOffset() { + private void defineInternalOffset() throws JSException { if (mUserOffset == 0) { mInternalOffset = mUserOffset; } else { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index b76e9558..5553ccf4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.service.exception.JSException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -37,7 +38,7 @@ * @since 2.0 */ interface SearchStrategy { - Collection searchNext(); + Collection searchNext() throws JSException; boolean hasNext(); class Factory { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index dc61a0b2..56923c52 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.NotNull; @@ -36,6 +37,6 @@ */ public interface SearchTask { @NotNull - Collection nextLookup(); + Collection nextLookup() throws JSException; boolean hasNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index cabdd958..12e42ec9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.service.exception.JSException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -59,7 +60,7 @@ final class SearchTaskImpl implements SearchTask { @NotNull @Override - public Collection nextLookup() { + public Collection nextLookup() throws JSException { return defineSearchStrategy().searchNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index f48666be..1450c86e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -24,8 +24,10 @@ package com.jaspersoft.android.sdk.service.repository; +import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; +import com.jaspersoft.android.sdk.service.exception.JSException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -33,6 +35,7 @@ import org.jetbrains.annotations.NotNull; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Collection; @@ -56,16 +59,24 @@ public SearchUseCase( } @NotNull - public SearchResult performSearch(@NotNull InternalCriteria criteria) { - ResourceSearchResult response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); - SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); + public SearchResult performSearch(@NotNull InternalCriteria criteria) throws JSException { + ResourceSearchResult response = null; + try { + response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); - SearchResult searchResult = new SearchResult(); - searchResult.setNextOffset(response.getNextOffset()); + SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); - Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); - searchResult.setResources(resources); + SearchResult searchResult = new SearchResult(); + searchResult.setNextOffset(response.getNextOffset()); - return searchResult; + Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); + searchResult.setResources(resources); + + return searchResult; + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 27b9bed4..6f2371b5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -24,13 +24,16 @@ package com.jaspersoft.android.sdk.service.server; +import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.jetbrains.annotations.TestOnly; +import java.io.IOException; import java.text.SimpleDateFormat; /** @@ -55,18 +58,36 @@ public static ServerInfoService create(String baseUrl) { return new ServerInfoService(restApi, ServerInfoTransformer.get()); } - public ServerInfo requestServerInfo() { - ServerInfoData response = mRestApi.requestServerInfo(); - return mTransformer.transform(response); + public ServerInfo requestServerInfo() throws JSException { + try { + ServerInfoData response = mRestApi.requestServerInfo(); + return mTransformer.transform(response); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } - public ServerVersion requestServerVersion() { - String version = mRestApi.requestVersion(); - return ServerVersion.defaultParser().parse(version); + public ServerVersion requestServerVersion() throws JSException { + try { + String version = mRestApi.requestVersion(); + return ServerVersion.defaultParser().parse(version); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } - public SimpleDateFormat requestServerDateTimeFormat() { - String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); - return new SimpleDateFormat(dateTimeFormat); + public SimpleDateFormat requestServerDateTimeFormat() throws JSException { + try { + String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); + return new SimpleDateFormat(dateTimeFormat); + } catch (HttpException e) { + throw JSException.wrap(e); + } catch (IOException e) { + throw JSException.wrap(e); + } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index b353d174..017d829f 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -70,7 +68,7 @@ public void setup() { } @Test - public void shouldReturnResponseForSuccessRedirect() { + public void shouldReturnResponseForSuccessRedirect() throws Exception { MockResponse mockResponse = MockResponseFactory.create302() .addHeader("Set-Cookie", "cookie1") .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); @@ -81,8 +79,8 @@ public void shouldReturnResponseForSuccessRedirect() { } @Test - public void shouldRiseErrorForErrorRedirect() { - mExpectedException.expect(RestError.class); + public void shouldRiseErrorForErrorRedirect() throws Exception { + mExpectedException.expect(HttpException.class); MockResponse mockResponse = MockResponseFactory.create302() .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_ERROR) @@ -93,8 +91,8 @@ public void shouldRiseErrorForErrorRedirect() { } @Test - public void shouldRiseErrorForHttpException() { - mExpectedException.expect(RestError.class); + public void shouldRiseErrorForHttpException() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -102,7 +100,7 @@ public void shouldRiseErrorForHttpException() { } @Test - public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() { + public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() throws Exception { mExpectedException.expect(IllegalStateException.class); mExpectedException.expectMessage("Location HEADER is missing please contact JRS admin"); @@ -112,7 +110,7 @@ public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() { } @Test - public void shouldReturnEncryptionKeyIfApiAvailable() { + public void shouldReturnEncryptionKeyIfApiAvailable() throws Exception { MockResponse anonymousCookie = MockResponseFactory.create200() .setBody("6.1") .addHeader("Set-Cookie", "cookie1"); @@ -126,7 +124,7 @@ public void shouldReturnEncryptionKeyIfApiAvailable() { } @Test - public void shouldReturnEmptyEncryptionKeyIfApiNotAvailable() { + public void shouldReturnEmptyEncryptionKeyIfApiNotAvailable() throws Exception { MockResponse anonymousCookie = MockResponseFactory.create200() .setBody("6.1") .addHeader("Set-Cookie", "cookie1"); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index ca764395..3f34409e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.InputControlRestApi; -import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.test.MockResponseFactory; @@ -86,57 +84,57 @@ public void setup() { } @Test - public void requestInputControlsShouldNotAllowNullReportUri() { + public void requestInputControlsShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); restApiUnderTest.requestInputControls("cookie", null, false); } @Test - public void requestInputControlsInitialStatesShouldNotAllowNullToken() { + public void requestInputControlsInitialStatesShouldNotAllowNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); restApiUnderTest.requestInputControlsInitialStates(null, "/uri", false); } @Test - public void requestInputControlsStatesShouldNotAllowNullReportUri() { + public void requestInputControlsStatesShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); restApiUnderTest.requestInputControlsStates("cookie", null, Collections.EMPTY_MAP, true); } @Test - public void requestInputControlsStatesShouldNotAllowNullControlParams() { + public void requestInputControlsStatesShouldNotAllowNullControlParams() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); restApiUnderTest.requestInputControlsStates("cookie", "any_id", null, true); } @Test - public void requestInputControlsStatesShouldNotAllowNullToken() { + public void requestInputControlsStatesShouldNotAllowNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); restApiUnderTest.requestInputControlsStates(null, "any_id", Collections.EMPTY_MAP, true); } @Test - public void requestInputControlsShouldThrowRestErrorFor500() { - mExpectedException.expect(RestError.class); + public void requestInputControlsShouldThrowRestErrorFor500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); restApiUnderTest.requestInputControls("cookie", "any_id", true); } @Test - public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() { - mExpectedException.expect(RestError.class); + public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); restApiUnderTest.requestInputControlsInitialStates("cookie", "any_id", true); } @Test - public void requestInputControlsStatesShouldThrowRestErrorFor500() { - mExpectedException.expect(RestError.class); + public void requestInputControlsStatesShouldThrowRestErrorFor500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); restApiUnderTest.requestInputControlsStates("cookie", "any_id", Collections.EMPTY_MAP, true); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index c5339434..7691b5de 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; @@ -43,7 +41,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -100,8 +97,8 @@ public void setup() { } @Test - public void shouldThroughRestErrorOnSearchRequestIfHttpError() { - mExpectedException.expect(RestError.class); + public void shouldThroughRestErrorOnSearchRequestIfHttpError() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -109,7 +106,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() { } @Test - public void bodyParameterShouldNotBeNullForRunReportExecution() { + public void bodyParameterShouldNotBeNullForRunReportExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); @@ -117,7 +114,7 @@ public void bodyParameterShouldNotBeNullForRunReportExecution() { } @Test - public void tokenShouldNotBeNullForRunReportExecution() { + public void tokenShouldNotBeNullForRunReportExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -126,7 +123,7 @@ public void tokenShouldNotBeNullForRunReportExecution() { } @Test - public void executionIdShouldNotBeNullForRequestExecutionDetails() { + public void executionIdShouldNotBeNullForRequestExecutionDetails() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); @@ -134,7 +131,7 @@ public void executionIdShouldNotBeNullForRequestExecutionDetails() { } @Test - public void tokenShouldNotBeNullForRequestExecutionDetails() { + public void tokenShouldNotBeNullForRequestExecutionDetails() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -142,7 +139,7 @@ public void tokenShouldNotBeNullForRequestExecutionDetails() { } @Test - public void executionIdShouldNotBeNullForRequestExecutionStatus() { + public void executionIdShouldNotBeNullForRequestExecutionStatus() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); @@ -150,7 +147,7 @@ public void executionIdShouldNotBeNullForRequestExecutionStatus() { } @Test - public void tokenShouldNotBeNullForRequestExecutionStatus() { + public void tokenShouldNotBeNullForRequestExecutionStatus() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -158,7 +155,7 @@ public void tokenShouldNotBeNullForRequestExecutionStatus() { } @Test - public void executionIdShouldNotBeNullForCancelRequestExecution() { + public void executionIdShouldNotBeNullForCancelRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); @@ -166,7 +163,7 @@ public void executionIdShouldNotBeNullForCancelRequestExecution() { } @Test - public void tokenShouldNotBeNullForCancelRequestExecution() { + public void tokenShouldNotBeNullForCancelRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -174,7 +171,7 @@ public void tokenShouldNotBeNullForCancelRequestExecution() { } @Test - public void bodyParameterShouldNotBeNullForExecutionUpdate() { + public void bodyParameterShouldNotBeNullForExecutionUpdate() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution params should not be null"); @@ -182,7 +179,7 @@ public void bodyParameterShouldNotBeNullForExecutionUpdate() { } @Test - public void bodyParameterShouldNotBeEmptyForExecutionUpdate() { + public void bodyParameterShouldNotBeEmptyForExecutionUpdate() throws Exception { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Execution params should not be empty"); @@ -261,7 +258,7 @@ public void shouldUpdateReportExecution() throws Exception { } @Test - public void responseShouldNotBeCancelledIfResponseIs204() { + public void responseShouldNotBeCancelledIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); boolean cancelled = restApiUnderTest.cancelReportExecution("cookie", "any_id"); @@ -270,7 +267,7 @@ public void responseShouldNotBeCancelledIfResponseIs204() { } @Test - public void responseShouldBeCancelledIfResponseIs200() { + public void responseShouldBeCancelledIfResponseIs200() throws Exception { MockResponse response = MockResponseFactory.create200().setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); @@ -280,7 +277,7 @@ public void responseShouldBeCancelledIfResponseIs200() { } @Test - public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws IOException { + public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution("cookie", SEARCH_PARAMS); @@ -288,7 +285,7 @@ public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws IOExcep } @Test - public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOException { + public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); @@ -298,7 +295,7 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws IOEx } @Test - public void executionUpdateRequestShouldBeSuccessIfResponseIs204() { + public void executionUpdateRequestShouldBeSuccessIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); boolean response = restApiUnderTest.updateReportExecution("cookie", "any_id", PARAMS); assertThat(response, is(true)); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index 24f98e26..ebc61355 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; @@ -73,7 +71,7 @@ public void setup() { } @Test - public void executionIdShouldNotBeNullForRunRequestExecution() { + public void executionIdShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); @@ -81,7 +79,7 @@ public void executionIdShouldNotBeNullForRunRequestExecution() { } @Test - public void bodyShouldNotBeNullForRunRequestExecution() { + public void bodyShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); @@ -89,7 +87,7 @@ public void bodyShouldNotBeNullForRunRequestExecution() { } @Test - public void tokenShouldNotBeNullForRunRequestExecution() { + public void tokenShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -97,7 +95,7 @@ public void tokenShouldNotBeNullForRunRequestExecution() { } @Test - public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() { + public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); @@ -105,7 +103,7 @@ public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() { } @Test - public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() { + public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); @@ -113,7 +111,7 @@ public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() { } @Test - public void tokenShouldNotBeNullForCheckRequestExecutionStatus() { + public void tokenShouldNotBeNullForCheckRequestExecutionStatus() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -121,7 +119,7 @@ public void tokenShouldNotBeNullForCheckRequestExecutionStatus() { } @Test - public void executionIdParameterShouldNotBeNullForAttachmentRequest() { + public void executionIdParameterShouldNotBeNullForAttachmentRequest() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); @@ -129,7 +127,7 @@ public void executionIdParameterShouldNotBeNullForAttachmentRequest() { } @Test - public void exportIdParameterShouldNotBeNullForAttachmentRequest() { + public void exportIdParameterShouldNotBeNullForAttachmentRequest() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); @@ -137,7 +135,7 @@ public void exportIdParameterShouldNotBeNullForAttachmentRequest() { } @Test - public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { + public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Attachment id should not be null"); @@ -145,7 +143,7 @@ public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() { } @Test - public void tokenIdParameterShouldNotBeNullForAttachmentRequest() { + public void tokenIdParameterShouldNotBeNullForAttachmentRequest() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -153,7 +151,7 @@ public void tokenIdParameterShouldNotBeNullForAttachmentRequest() { } @Test - public void requestForOutputShouldParsePagesFromHeader() { + public void requestForOutputShouldParsePagesFromHeader() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody("") .addHeader("report-pages", "1-10"); @@ -235,8 +233,8 @@ public void shouldCheckExportExecutionStatus() throws Exception { } @Test - public void runExportExecutionShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); + public void runExportExecutionShouldThrowRestErrorOn500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -244,8 +242,8 @@ public void runExportExecutionShouldThrowRestErrorOn500() { } @Test - public void checkExportExecutionStatusShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); + public void checkExportExecutionStatusShouldThrowRestErrorOn500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -253,8 +251,8 @@ public void checkExportExecutionStatusShouldThrowRestErrorOn500() { } @Test - public void requestExportOutputShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); + public void requestExportOutputShouldThrowRestErrorOn500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -262,8 +260,8 @@ public void requestExportOutputShouldThrowRestErrorOn500() { } @Test - public void requestExportAttachmentShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); + public void requestExportAttachmentShouldThrowRestErrorOn500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index f62b7fce..1040117e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.ReportOptionRestApi; -import com.jaspersoft.android.sdk.network.RestError; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -77,91 +75,91 @@ public void setup() { } @Test - public void requestReportOptionsListShouldNotAllowNullReportUnitUri() { + public void requestReportOptionsListShouldNotAllowNullReportUnitUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); restApiUnderTest.requestReportOptionsList("cookie", null); } @Test - public void requestReportOptionsListShouldNotAllowNullToken() { + public void requestReportOptionsListShouldNotAllowNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); restApiUnderTest.requestReportOptionsList(null, "/my/uri"); } @Test - public void createReportOptionShouldNotAllowNullReportUri() { + public void createReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); restApiUnderTest.createReportOption("cookie", null, "label", Collections.EMPTY_MAP, false); } @Test - public void createReportOptionShouldNotAllowNullToken() { + public void createReportOptionShouldNotAllowNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); restApiUnderTest.createReportOption(null, "/my/uri", "label", Collections.EMPTY_MAP, false); } @Test - public void createReportOptionShouldNotAllowNullOptionLabel() { + public void createReportOptionShouldNotAllowNullOptionLabel() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option label should not be null"); restApiUnderTest.createReportOption("cookie", "any_id", null, Collections.EMPTY_MAP, false); } @Test - public void createReportOptionShouldNotAllowNullControlsValues() { + public void createReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); restApiUnderTest.createReportOption("cookie", "any_id", "label", null, false); } @Test - public void updateReportOptionShouldNotAllowNullReportUri() { + public void updateReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); restApiUnderTest.updateReportOption("cookie", null, "option_id", Collections.EMPTY_MAP); } @Test - public void updateReportOptionShouldNotAllowNullOptionId() { + public void updateReportOptionShouldNotAllowNullOptionId() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); restApiUnderTest.updateReportOption("cookie", "any_id", null, Collections.EMPTY_MAP); } @Test - public void updateReportOptionShouldNotAllowNullControlsValues() { + public void updateReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); restApiUnderTest.updateReportOption("cookie", "any_id", "option_id", null); } @Test - public void updateReportOptionShouldNotAllowNullToken() { + public void updateReportOptionShouldNotAllowNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); restApiUnderTest.updateReportOption(null, "any_id", "option_id", Collections.EMPTY_MAP); } @Test - public void deleteReportOptionShouldNotAllowNullReportUri() { + public void deleteReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); restApiUnderTest.deleteReportOption("cookie", null, "option_id"); } @Test - public void deleteReportOptionShouldNotAllowNullOptionId() { + public void deleteReportOptionShouldNotAllowNullOptionId() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); restApiUnderTest.deleteReportOption("cookie", "any_id", null); } @Test - public void deleteReportOptionShouldNotAllowNullToken() { + public void deleteReportOptionShouldNotAllowNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); restApiUnderTest.deleteReportOption(null, "any_id", "option_id"); @@ -227,8 +225,8 @@ public void apiShouldDeleteReportOption() throws Exception { } @Test - public void requestReportOptionsListShouldThrow500Error() { - mExpectedException.expect(RestError.class); + public void requestReportOptionsListShouldThrow500Error() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -236,8 +234,8 @@ public void requestReportOptionsListShouldThrow500Error() { } @Test - public void updateReportOptionShouldThrowRestErrorFor500() { - mExpectedException.expect(RestError.class); + public void updateReportOptionShouldThrowRestErrorFor500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -245,8 +243,8 @@ public void updateReportOptionShouldThrowRestErrorFor500() { } @Test - public void deleteReportOptionShouldThrowRestErrorFor500() { - mExpectedException.expect(RestError.class); + public void deleteReportOptionShouldThrowRestErrorFor500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index ece36534..d4300ee5 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -75,7 +75,7 @@ public void setup() { } @Test - public void shouldReturnEmptyResponseForNoContentResponse() { + public void shouldReturnEmptyResponseForNoContentResponse() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); @@ -83,7 +83,7 @@ public void shouldReturnEmptyResponseForNoContentResponse() { } @Test - public void requestForSearchShouldParseHeaderResultCount() { + public void requestForSearchShouldParseHeaderResultCount() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Result-Count", "100"); @@ -94,7 +94,7 @@ public void requestForSearchShouldParseHeaderResultCount() { } @Test - public void requestForSearchShouldParseHeaderTotalCount() { + public void requestForSearchShouldParseHeaderTotalCount() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Total-Count", "1000"); @@ -105,7 +105,7 @@ public void requestForSearchShouldParseHeaderTotalCount() { } @Test - public void requestForSearchShouldParseHeaderStartIndex() { + public void requestForSearchShouldParseHeaderStartIndex() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Start-Index", "5"); @@ -116,7 +116,7 @@ public void requestForSearchShouldParseHeaderStartIndex() { } @Test - public void requestForSearchShouldParseHeaderNextOffset() { + public void requestForSearchShouldParseHeaderNextOffset() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody(searchResponse.asString()) .addHeader("Next-Offset", "10"); @@ -127,7 +127,7 @@ public void requestForSearchShouldParseHeaderNextOffset() { } @Test - public void searchResourcesShouldNotAcceptNullToken() { + public void searchResourcesShouldNotAcceptNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -135,7 +135,7 @@ public void searchResourcesShouldNotAcceptNullToken() { } @Test - public void requestForReportResourceShouldNotAcceptNullUri() { + public void requestForReportResourceShouldNotAcceptNullUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); @@ -143,7 +143,7 @@ public void requestForReportResourceShouldNotAcceptNullUri() { } @Test - public void requestForReportResourceShouldNotAcceptNullToken() { + public void requestForReportResourceShouldNotAcceptNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -151,7 +151,7 @@ public void requestForReportResourceShouldNotAcceptNullToken() { } @Test - public void requestForFolderResourceShouldNotAcceptNullUri() { + public void requestForFolderResourceShouldNotAcceptNullUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Folder uri should not be null"); @@ -159,7 +159,7 @@ public void requestForFolderResourceShouldNotAcceptNullUri() { } @Test - public void requestForFolderResourceShouldNotAcceptNullToken() { + public void requestForFolderResourceShouldNotAcceptNullToken() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Request token should not be null"); @@ -167,8 +167,8 @@ public void requestForFolderResourceShouldNotAcceptNullToken() { } @Test - public void searchResourcesShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); + public void searchResourcesShouldThrowRestErrorOn500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -176,8 +176,8 @@ public void searchResourcesShouldThrowRestErrorOn500() { } @Test - public void requestReportResourceShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); + public void requestReportResourceShouldThrowRestErrorOn500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); @@ -185,8 +185,8 @@ public void requestReportResourceShouldThrowRestErrorOn500() { } @Test - public void requestFolderResourceShouldThrowRestErrorOn500() { - mExpectedException.expect(RestError.class); + public void requestFolderResourceShouldThrowRestErrorOn500() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java index f772c006..1f41f6af 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.RestError; -import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -58,8 +56,8 @@ public void setup() { } @Test - public void shouldThroughRestErrorForHttpError() { - mExpectedException.expect(RestError.class); + public void shouldThroughRestErrorForHttpError() throws Exception { + mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java index ca5fbb95..c14e940c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java @@ -61,7 +61,7 @@ public void factoryMethodShouldNotAcceptNullApi() { } @Test - public void authenticateShouldNotAcceptNullCredentials() { + public void authenticateShouldNotAcceptNullCredentials() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Credentials should not be null"); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index 61ff05cd..ea6a4fb3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -79,7 +79,7 @@ public class SpringAuthServiceTest { } @Before - public void setup() { + public void setup() throws Exception { MockitoAnnotations.initMocks(this); objectUnderTest = new SpringAuthService( mAlgorithm, @@ -100,7 +100,7 @@ public void setup() { } @Test - public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { + public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() throws Exception { when(mKey.isAvailable()).thenReturn(true); when(mKey.getExponent()).thenReturn("e"); when(mKey.getModulus()).thenReturn("m"); @@ -114,7 +114,7 @@ public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() { } @Test - public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() { + public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() throws Exception { when(mKey.isAvailable()).thenReturn(false); objectUnderTest.authenticate(credentials); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java deleted file mode 100644 index e8029df2..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/FeatureSetTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.server; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class FeatureSetTest { - -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java deleted file mode 100644 index f78833d1..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerInfoTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.server; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ServerInfoTest { - -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java index 11d76ec5..cbe8519b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java @@ -24,8 +24,7 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; -import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; +import com.jaspersoft.android.sdk.service.exception.JSException; import org.junit.Test; @@ -90,32 +89,32 @@ public void testIsCancelled() throws Exception { @Test public void testReportCancelledAdaptsToClientEx() throws Exception { ExecutionException ex = ExecutionException.reportCancelled("/"); - RuntimeException runtimeException = ex.adaptToClientException(); - assertThat(runtimeException.getMessage(), is(notNullValue())); - assertThat(runtimeException, is(instanceOf(ReportRunException.class))); + JSException clientException = ex.adaptToClientException(); + assertThat(clientException.getMessage(), is(notNullValue())); + assertThat(clientException.code(), is(JSException.REPORT_EXECUTION_CANCELLED)); } @Test public void testReportFailedAdaptsToClientEx() throws Exception { ExecutionException ex = ExecutionException.reportFailed("/"); - RuntimeException runtimeException = ex.adaptToClientException(); - assertThat(runtimeException.getMessage(), is(notNullValue())); - assertThat(runtimeException, is(instanceOf(ReportRunException.class))); + JSException clientException = ex.adaptToClientException(); + assertThat(clientException.getMessage(), is(notNullValue())); + assertThat(clientException.code(), is(JSException.REPORT_EXECUTION_FAILED)); } @Test public void testExportCancelledAdaptsToClientEx() throws Exception { ExecutionException ex = ExecutionException.exportCancelled("/"); - RuntimeException runtimeException = ex.adaptToClientException(); - assertThat(runtimeException.getMessage(), is(notNullValue())); - assertThat(runtimeException, is(instanceOf(ReportExportException.class))); + JSException clientException = ex.adaptToClientException(); + assertThat(clientException.getMessage(), is(notNullValue())); + assertThat(clientException.code(), is(JSException.EXPORT_EXECUTION_CANCELLED)); } @Test public void testExportFailedAdaptsToClientEx() throws Exception { ExecutionException ex = ExecutionException.exportFailed("/"); - RuntimeException runtimeException = ex.adaptToClientException(); - assertThat(runtimeException.getMessage(), is(notNullValue())); - assertThat(runtimeException, is(instanceOf(ReportExportException.class))); + JSException clientException = ex.adaptToClientException(); + assertThat(clientException.getMessage(), is(notNullValue())); + assertThat(clientException.code(), is(JSException.EXPORT_EXECUTION_FAILED)); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 2cc9b650..de49f2c3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -140,7 +140,7 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { } @Test - public void testRunShouldThrowFailedIfStatusFailed() { + public void testRunShouldThrowFailedIfStatusFailed() throws Exception { mException.expect(ReportExportException.class); mException.expectMessage("Export for report '/report/uri' failed on server side"); @@ -162,7 +162,7 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { } @Test - public void testRunShouldThrowCancelledIfStatusCancelled() { + public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { mException.expect(ReportExportException.class); mException.expectMessage("Export for report '/report/uri' was cancelled"); @@ -184,7 +184,7 @@ public void testRunReportPendingCase() throws Exception { } @Test - public void ensureThatExportCancelledEventWillBeResolved() { + public void ensureThatExportCancelledEventWillBeResolved() throws Exception { mockRunExportExecution("cancelled", "ready"); mockReportExecutionDetails("ready"); @@ -217,7 +217,7 @@ public void testAwaitCompleteReportShouldLoopCalls() throws Exception { } @Test - public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() { + public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() throws Exception { mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); @@ -227,7 +227,7 @@ public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() { } @Test - public void testAwaitCompleteReportThrowFailedIfStatusFailed() { + public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception { mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); @@ -236,20 +236,20 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() { objectUnderTest.waitForReportCompletion(); } - private void mockCheckExportExecStatus(String... statusChain) { + private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); when(mExecutionStatusResponse.getStatus()).then(StatusChain.of(statusChain)); when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(mExecutionStatusResponse); } - private void mockRunExportExecution(String... statusChain) { + private void mockRunExportExecution(String... statusChain) throws Exception { ensureChain(statusChain); when(mExportExecDetails.getExportId()).thenReturn("export_id"); when(mExportExecDetails.getStatus()).then(StatusChain.of(statusChain)); when(mExportRestApi.runExportExecution(anyString(), anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); } - private void mockReportExecutionDetails(String... statusChain) { + private void mockReportExecutionDetails(String... statusChain) throws Exception { ensureChain(statusChain); Set exports = Collections.singleton(mExportExecution); when(mExportExecution.getStatus()).thenReturn("execution"); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 58b99fc5..f678c4a1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -100,7 +100,7 @@ public void setUp() throws Exception { } @Test - public void testRunShouldCreateActiveSession() { + public void testRunShouldCreateActiveSession() throws Exception { mockRunReportExecution("execution"); mockRunReportExecution("ready"); @@ -112,7 +112,7 @@ public void testRunShouldCreateActiveSession() { } @Test - public void testRunThrowsFailedStatusImmediately() { + public void testRunThrowsFailedStatusImmediately() throws Exception { mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); @@ -122,7 +122,7 @@ public void testRunThrowsFailedStatusImmediately() { } @Test - public void testRunShouldThrowFailedIfStatusFailed() { + public void testRunShouldThrowFailedIfStatusFailed() throws Exception { mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' failed on server side"); @@ -133,7 +133,7 @@ public void testRunShouldThrowFailedIfStatusFailed() { } @Test - public void testRunThrowsCancelledStatusImmediately() { + public void testRunThrowsCancelledStatusImmediately() throws Exception { mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); @@ -143,7 +143,7 @@ public void testRunThrowsCancelledStatusImmediately() { } @Test - public void testRunShouldThrowCancelledIfStatusCancelled() { + public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { mException.expect(ReportRunException.class); mException.expectMessage("Report execution '/report/uri' was cancelled"); @@ -154,7 +154,7 @@ public void testRunShouldThrowCancelledIfStatusCancelled() { } @Test - public void testRunShouldLoopUntilStatusExecution() { + public void testRunShouldLoopUntilStatusExecution() throws Exception { mockRunReportExecution("queued"); mockReportExecutionStatus("queued", "execution"); @@ -162,12 +162,12 @@ public void testRunShouldLoopUntilStatusExecution() { verify(executionApi, times(2)).requestReportExecutionStatus(anyString(), eq("exec_id")); } - private void mockReportExecutionStatus(String... statusChain) { + private void mockReportExecutionStatus(String... statusChain) throws Exception { when(statusDetails.getStatus()).then(StatusChain.of(statusChain)); when(executionApi.requestReportExecutionStatus(anyString(), anyString())).thenReturn(statusDetails); } - private void mockRunReportExecution(String execution) { + private void mockRunReportExecution(String execution) throws Exception { when(initDetails.getStatus()).thenReturn(execution); when(initDetails.getExecutionId()).thenReturn("exec_id"); when(executionApi.runReportExecution(anyString(), any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java deleted file mode 100644 index 3562d4af..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RunExportCriteriaTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class RunExportCriteriaTest { - private ExecutionCriteria objectUnderTest; - - @Before - public void setUp() throws Exception { - objectUnderTest = RunExportCriteria.builder().create(); - } - - @Test - public void interactiveShouldBeTrueByDefault() { - assertThat(objectUnderTest.isInteractive(), is(true)); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java index 4c7515f4..304f5f0c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java @@ -73,7 +73,7 @@ public class EmeraldMR2SearchStrategyTest { public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); @Before - public void setupMocks() { + public void setupMocks() throws Exception { MockitoAnnotations.initMocks(this); when(mSearchUseCase.performSearch(Matchers.any(InternalCriteria.class))).thenReturn(mResponse); @@ -146,7 +146,7 @@ public void forCustomOffsetShouldCalculateServerDisposition() throws Exception { } @Test - public void shouldReturnEmptyCollectionForZeroLimit() { + public void shouldReturnEmptyCollectionForZeroLimit() throws Exception { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(userCriteria, mSearchUseCase); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java index 4dbcb123..4ffb6f58 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java @@ -64,7 +64,7 @@ public class EmeraldMR3SearchStrategyTest { SearchResult mResponse; @Before - public void setupMocks() { + public void setupMocks() throws Exception { MockitoAnnotations.initMocks(this); when(mSearchUseCase.performSearch(any(InternalCriteria.class))).thenReturn(mResponse); @@ -74,7 +74,7 @@ public void setupMocks() { } @Test - public void shouldMakeImmediateCallOnApiForUserOffsetZero() { + public void shouldMakeImmediateCallOnApiForUserOffsetZero() throws Exception { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); @@ -88,7 +88,7 @@ public void shouldMakeImmediateCallOnApiForUserOffsetZero() { } @Test - public void makesAdditionalCallOnApiIfUserOffsetNotZero() { + public void makesAdditionalCallOnApiIfUserOffsetNotZero() throws Exception { InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); @@ -102,7 +102,7 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() { } @Test - public void secondSearchLookupShouldUseNextOffset() { + public void secondSearchLookupShouldUseNextOffset() throws Exception { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); @@ -124,7 +124,7 @@ public void secondSearchLookupShouldUseNextOffset() { } @Test - public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { + public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() throws Exception { EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(NO_CRITERIA, mSearchUseCase); when(mResponse.getNextOffset()).thenReturn(133); @@ -142,7 +142,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() { } @Test - public void shouldReturnEmptyCollectionForZeroLimit() { + public void shouldReturnEmptyCollectionForZeroLimit() throws Exception { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); SearchStrategy strategy = new EmeraldMR3SearchStrategy(userCriteria, mSearchUseCase); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index d4a619fc..988c3821 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -64,7 +64,7 @@ public class SearchTaskImplTest { private SearchTaskImpl objectUnderTest; @Before - public void setup() { + public void setup() throws Exception { MockitoAnnotations.initMocks(this); objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApi, mTokenProvider, mInfoProvider); @@ -84,7 +84,7 @@ public void setup() { } @Test - public void nextLookupShouldDefineSearchStrategy() { + public void nextLookupShouldDefineSearchStrategy() throws Exception { objectUnderTest.nextLookup(); PowerMockito.verifyStatic(times(1)); @@ -94,7 +94,7 @@ public void nextLookupShouldDefineSearchStrategy() { } @Test - public void secondLookupShouldUseCachedStrategy() { + public void secondLookupShouldUseCachedStrategy() throws Exception { objectUnderTest.nextLookup(); objectUnderTest.nextLookup(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index ab9604b9..8bcf7101 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -89,7 +89,7 @@ public void setup() { } @Test - public void shouldProvideAndAdaptSearchResult() { + public void shouldProvideAndAdaptSearchResult() throws Exception { when(mResult.getNextOffset()).thenReturn(100); when(mRepositoryRestApi.searchResources(anyString(), any(Map.class))).thenReturn(mResult); when(mInfoProvider.provideDateTimeFormat()).thenReturn(DATE_TIME_FORMAT); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java index 23990ab6..99645a6d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java @@ -63,7 +63,7 @@ public void setup() { } @Test - public void requestInfoShouldProvideServerInfoDataObject() { + public void requestInfoShouldProvideServerInfoDataObject() throws Exception { when(mockApi.requestServerInfo()).thenReturn(mockResponse); serviceUnderTest.requestServerInfo(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 3bc324a7..06a5145e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -33,8 +33,6 @@ import org.junit.Ignore; import org.junit.Test; -import java.io.IOException; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -62,7 +60,7 @@ public void shouldEncryptWithPassword() throws Exception { } @Test - public void shouldReturnResponseForSpringRequest() throws IOException { + public void shouldReturnResponseForSpringRequest() throws Exception { AuthenticationRestApi authApi = new AuthenticationRestApi.Builder() .baseUrl(mobileDemo2) .logger(TestLogger.get(this)) diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 6648f2a2..54e9f741 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -74,7 +74,7 @@ public void setup() { } @Test - public void shouldProvideInputControlsList() { + public void shouldProvideInputControlsList() throws Exception { Collection controls = mRestApi.requestInputControls(mAuthenticator.token(), REPORT_URI, false); assertThat(controls, is(not(empty()))); @@ -86,7 +86,7 @@ public void shouldProvideInputControlsList() { * TODO: Implement annotation to mark specific API tests. */ @Test - public void shouldProvideInputControlsListIfStateExcluded() { + public void shouldProvideInputControlsListIfStateExcluded() throws Exception { Collection controls = mRestApi.requestInputControls(mAuthenticator.token(), REPORT_URI, true); assertThat(controls, is(not(empty()))); @@ -95,13 +95,13 @@ public void shouldProvideInputControlsListIfStateExcluded() { } @Test - public void shouldProvideFreshInitialInputControlsValues() { + public void shouldProvideFreshInitialInputControlsValues() throws Exception { Collection states = mRestApi.requestInputControlsInitialStates(mAuthenticator.token(), REPORT_URI, true); assertThat(states, is(not(empty()))); } @Test - public void shouldProvideFreshStatesForInputControls() { + public void shouldProvideFreshStatesForInputControls() throws Exception { Collection states = mRestApi.requestInputControlsStates(mAuthenticator.token(), REPORT_URI, CONTROL_PARAMETERS, true); assertThat(states, is(not(empty()))); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index a7b70a8b..0ed4c99e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -38,7 +38,6 @@ import org.junit.Ignore; import org.junit.Test; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -77,7 +76,7 @@ public void setup() { } @Test - public void shouldStartReportExecution() { + public void shouldStartReportExecution() throws Exception { ReportExecutionDescriptor response = startExecution(); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(notNullValue())); @@ -87,14 +86,14 @@ public void shouldStartReportExecution() { * TODO: TEST IS FLAKY provide workaround */ @Ignore - public void shouldCancelReportExecution() throws InterruptedException { + public void shouldCancelReportExecution() throws Exception { ReportExecutionDescriptor response = startExecution(); boolean cancelled = apiUnderTest.cancelReportExecution(mAuthenticator.token(), response.getExecutionId()); assertThat(cancelled, is(true)); } @Test - public void shouldReturnReportExecutionDetails() throws IOException { + public void shouldReturnReportExecutionDetails() throws Exception { ReportExecutionDescriptor executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); @@ -103,7 +102,7 @@ public void shouldReturnReportExecutionDetails() throws IOException { } @Test - public void shouldCheckReportExecutionStatus() throws IOException { + public void shouldCheckReportExecutionStatus() throws Exception { ReportExecutionDescriptor executionResponse = startExecution(); ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(mAuthenticator.token(), executionResponse.getExecutionId()); @@ -114,7 +113,7 @@ public void shouldCheckReportExecutionStatus() throws IOException { * TODO: API is broken requires investigation before release */ @Ignore - public void searchForExecutionShouldReturnResult() throws IOException { + public void searchForExecutionShouldReturnResult() throws Exception { ReportExecutionDescriptor executionResponse = startExecution(); Map params = new HashMap<>(); @@ -125,7 +124,7 @@ public void searchForExecutionShouldReturnResult() throws IOException { } @Test - public void updateOfParametersForExecutionShouldReturnResult() { + public void updateOfParametersForExecutionShouldReturnResult() throws Exception { List>> list = new ArrayList<>(); Map> reportParameter = new HashMap<>(); @@ -141,12 +140,12 @@ public void updateOfParametersForExecutionShouldReturnResult() { * Helper methods */ @NotNull - private ReportExecutionDescriptor startExecution() { + private ReportExecutionDescriptor startExecution() throws Exception { return startExecution(REPORT_URI); } @NotNull - private ReportExecutionDescriptor startExecution(String uri) { + private ReportExecutionDescriptor startExecution(String uri) throws Exception { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); Map> params = new HashMap<>(); params.put("ProductFamily", new HashSet(Collections.singletonList("Food"))); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 426f3ff8..0158f0c4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -40,8 +40,6 @@ import org.junit.Before; import org.junit.Test; -import java.io.IOException; - import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; @@ -77,14 +75,14 @@ public void setup() { } @Test - public void runExportRequestShouldReturnResult() { + public void runExportRequestShouldReturnResult() throws Exception { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); assertThat(execDetails.getExportId(), is(notNullValue())); } @Test - public void checkExportRequestStatusShouldReturnResult() throws IOException { + public void checkExportRequestStatusShouldReturnResult() throws Exception { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(mAuthenticator.token(), exec.getExecutionId(), execDetails.getExportId()); @@ -92,7 +90,7 @@ public void checkExportRequestStatusShouldReturnResult() throws IOException { } @Test - public void requestExportOutputShouldReturnResult() { + public void requestExportOutputShouldReturnResult() throws Exception { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); ExportOutputResource output = apiUnderTest.requestExportOutput(mAuthenticator.token(), exec.getExecutionId(), execDetails.getExportId()); @@ -106,7 +104,7 @@ public void requestExportOutputShouldReturnResult() { * Helper methods */ @NotNull - private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor exec) { + private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor exec) throws Exception { ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") .withOutputFormat("PDF"); @@ -114,7 +112,7 @@ private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor } @NotNull - private ReportExecutionDescriptor startExecution() { + private ReportExecutionDescriptor startExecution() throws Exception { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); return mExecApi.runReportExecution(mAuthenticator.token(), executionRequestOptions); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 8c6fbb71..f9630376 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -73,13 +73,13 @@ public void setup() { } @Test - public void shouldRequestReportOptionsList() { + public void shouldRequestReportOptionsList() throws Exception { Set response = apiUnderTest.requestReportOptionsList(mAuthenticator.token(), REPORT_URI); assertThat(response, is(not(nullValue()))); } @Test - public void apiSupportsCrudForReportOption() { + public void apiSupportsCrudForReportOption() throws Exception { ReportOption response = apiUnderTest.createReportOption(mAuthenticator.token(), REPORT_URI, "label", CONTROL_PARAMETERS, true); assertThat(response.getLabel(), is("label")); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index bb7579d0..25191fe7 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -62,21 +62,21 @@ public void setup() { } @Test - public void shouldRequestListOfResources() { + public void shouldRequestListOfResources() throws Exception { ResourceSearchResult resourceSearchResult = api.searchResources(mAuthenticator.token(), null); assertThat(resourceSearchResult, is(notNullValue())); assertThat(resourceSearchResult.getResources(), is(not(empty()))); } @Test - public void shouldRequestReport() { + public void shouldRequestReport() throws Exception { ReportLookup report = api.requestReportResource(mAuthenticator.token(), "/public/Samples/Reports/AllAccounts"); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @Test - public void shouldRequestRootFolder() { + public void shouldRequestRootFolder() throws Exception { FolderLookup folder = api.requestFolderResource(mAuthenticator.token(), "/"); assertThat(folder, is(notNullValue())); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index 9af2fbc3..9872884a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -46,7 +46,7 @@ public static DummyTokenProvider create(JrsMetadata metadata) { } @NotNull - public String provideToken() { + public String provideToken() throws Exception { if (mToken == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() .baseUrl(mJrsMetadata.getServerUrl()) @@ -57,7 +57,7 @@ public String provideToken() { return mToken; } - public String token() { + public String token() throws Exception { return provideToken(); } } From 6670aafbb2e8825da98f01e81401ca2049f92a7f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 18 Nov 2015 23:19:47 +0200 Subject: [PATCH 277/457] Implement StatusException for service module --- .../android/sdk/network/HttpException.java | 22 ++- .../android/sdk/service/auth/Credentials.java | 4 +- .../sdk/service/auth/JrsAuthenticator.java | 4 +- .../sdk/service/auth/SpringCredentials.java | 11 +- .../sdk/service/exception/JSException.java | 58 -------- .../StatusCodes.java} | 24 +++- .../StatusException.java} | 17 ++- .../internal/StatusExceptionMapper.java | 86 +++++++++++ .../service/report/ExecutionException.java | 134 ------------------ .../sdk/service/report/ExportFactory.java | 10 +- .../sdk/service/report/ReportAttachment.java | 4 +- .../sdk/service/report/ReportExecution.java | 68 +++++---- .../report/ReportExecutionUseCase.java | 24 ++-- .../sdk/service/report/ReportExport.java | 4 +- .../service/report/ReportExportUseCase.java | 31 ++-- .../sdk/service/report/ReportService.java | 32 +++-- .../repository/EmeraldMR2SearchStrategy.java | 10 +- .../repository/EmeraldMR3SearchStrategy.java | 10 +- .../service/repository/SearchStrategy.java | 4 +- .../sdk/service/repository/SearchTask.java | 4 +- .../service/repository/SearchTaskImpl.java | 4 +- .../sdk/service/repository/SearchUseCase.java | 9 +- .../sdk/service/server/ServerInfoService.java | 21 +-- .../internal/StatusExceptionMapperTest.java | 69 +++++++++ .../report/ExecutionExceptionTest.java | 120 ---------------- .../service/report/ReportExecutionTest.java | 73 ++++++---- .../sdk/service/report/ReportServiceTest.java | 45 +++--- 27 files changed, 403 insertions(+), 499 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/exception/JSException.java rename core/src/main/java/com/jaspersoft/android/sdk/service/{report/exception/ReportRunException.java => exception/StatusCodes.java} (60%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{report/exception/ReportExportException.java => exception/StatusException.java} (77%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java index 7a8d1862..abbbad4c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java @@ -25,7 +25,14 @@ package com.jaspersoft.android.sdk.network; +import com.google.gson.Gson; +import com.google.gson.JsonParseException; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; + import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import retrofit.Response; @@ -37,10 +44,6 @@ * @since 2.0 */ public class HttpException extends Exception { - static HttpException networkError(IOException exception) { - return new HttpException(exception.getMessage(), null, - exception); - } static HttpException httpError(Response response) { return httpError(response.raw()); @@ -68,8 +71,15 @@ public String message() { return response.message(); } - public String errorBody() { - return Utils.bodyToString(response.body()); + public ErrorDescriptor getDescriptor() throws IOException { + Gson gson = GsonFactory.create(); + InputStream stream = response.body().byteStream(); + InputStreamReader reader = new InputStreamReader(stream); + try { + return gson.fromJson(reader, ErrorDescriptor.class); + } catch (JsonParseException ex) { + return null; + } } public String urlString() { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java index 325bb7b8..4191b896 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java @@ -1,11 +1,11 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; /** * @author Tom Koptel * @since 2.0 */ public abstract class Credentials { - protected abstract String applyPolicy(AuthPolicy authPolicy) throws JSException; + protected abstract String applyPolicy(AuthPolicy authPolicy) throws StatusException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java index 92108d70..88870039 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java @@ -1,7 +1,7 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -35,7 +35,7 @@ public static JrsAuthenticator create(@NotNull AuthenticationRestApi restApi) { } @NotNull - public String authenticate(@NotNull Credentials credentials) throws JSException { + public String authenticate(@NotNull Credentials credentials) throws StatusException { checkNotNull(credentials, "Credentials should not be null"); return credentials.applyPolicy(mAuthPolicy); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index 38f4b059..2069c685 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -1,7 +1,8 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,13 +69,13 @@ public Locale getLocale() { } @Override - protected String applyPolicy(AuthPolicy policy) throws JSException { + protected String applyPolicy(AuthPolicy policy) throws StatusException { try { return policy.applyCredentials(this); - } catch (IOException e) { - throw JSException.wrap(e); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); + } catch (IOException e) { + throw StatusExceptionMapper.transform(e); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/JSException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/JSException.java deleted file mode 100644 index 51ebe698..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/JSException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.exception; - -import com.jaspersoft.android.sdk.network.HttpException; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.3 - */ -public class JSException extends Exception { - public static final int EXPORT_EXECUTION_CANCELLED = 1; - public static final int EXPORT_EXECUTION_FAILED = 2; - public static final int REPORT_EXECUTION_CANCELLED = 2; - public static final int REPORT_EXECUTION_FAILED = 3; - - public static JSException wrap(IOException e) { - throw new UnsupportedOperationException("Not implemented"); - } - - public static JSException wrap(HttpException e) { - throw new UnsupportedOperationException("Not implemented"); - } - - public static JSException create(String message, Throwable cause, int exportExecutionCancelled) { - return null; - } - - public int code() { - throw new UnsupportedOperationException("Not implemented"); - } - - -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java similarity index 60% rename from core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java index 3e305cac..1c8cc150 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportRunException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java @@ -22,14 +22,26 @@ * . */ -package com.jaspersoft.android.sdk.service.report.exception; +package com.jaspersoft.android.sdk.service.exception; /** * @author Tom Koptel - * @since 2.0 + * @since 2.3 */ -public final class ReportRunException extends Exception { - public ReportRunException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); - } +public final class StatusCodes { + public static final int ERROR = 1; + public static final int NETWORK_ERROR = 2; + public static final int CLIENT_ERROR = 3; + public static final int INTERNAL_ERROR = 4; + public static final int PERMISSION_ERROR = 5; + public static final int AUTHORIZATION_ERROR = 6; + + // EXPORT + public static final int EXPORT_PAGE_OUT_OF_RANGE = 100; + public static final int EXPORT_EXECUTION_CANCELLED = 101; + public static final int EXPORT_EXECUTION_FAILED = 102; + + // REPORT + public static final int REPORT_EXECUTION_CANCELLED = 201; + public static final int REPORT_EXECUTION_FAILED = 202; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java similarity index 77% rename from core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java index 30ca7c46..646cdda7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/exception/ReportExportException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java @@ -22,14 +22,21 @@ * . */ -package com.jaspersoft.android.sdk.service.report.exception; +package com.jaspersoft.android.sdk.service.exception; /** * @author Tom Koptel - * @since 2.0 + * @since 2.3 */ -public final class ReportExportException extends Exception { - public ReportExportException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); +public class StatusException extends Exception { + private final int mCode; + + public StatusException(String message, Throwable cause, int code) { + super(message, cause); + mCode = code; + } + + public int code() { + return mCode; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java new file mode 100644 index 00000000..f620ab6d --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.StatusException; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class StatusExceptionMapper { + @NotNull + public static StatusException transform(IOException e) { + return new StatusException("Failed to perform network request. Check network!", e, StatusCodes.NETWORK_ERROR); + } + + @NotNull + public static StatusException transform(HttpException e) { + try { + ErrorDescriptor descriptor = e.getDescriptor(); + if (e.getDescriptor() == null) { + return mapHttpCodesToState(e); + } else { + return mapDescriptorToState(e, descriptor); + } + } catch (IOException ioEx) { + return transform(ioEx); + } + } + + @NotNull + private static StatusException mapHttpCodesToState(HttpException e) { + switch (e.code()) { + case 500: + return new StatusException("Server encountered unexpected error", e, StatusCodes.INTERNAL_ERROR); + case 404: + return new StatusException("Service exist but requested entity not found", e, StatusCodes.CLIENT_ERROR); + case 400: + return new StatusException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); + case 403: + return new StatusException("User has no access to resource", e, StatusCodes.PERMISSION_ERROR); + case 401: + return new StatusException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); + default: + return new StatusException("The operation failed with no more detailed information", e, StatusCodes.ERROR); + } + } + + @NotNull + private static StatusException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { + if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { + return new StatusException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); + } else { + return mapHttpCodesToState(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java deleted file mode 100644 index b2459c2d..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionException.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.service.exception.JSException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ExecutionException extends Exception { - private final Kind mKind; - - private ExecutionException(Kind kind, String message) { - super(message); - mKind = kind; - } - - private ExecutionException(Kind kind, String message, Throwable throwable) { - super(message, throwable); - mKind = kind; - } - - public static ExecutionException reportFailed(String reportUri) { - return Kind.REPORT_FAILED.exception(reportUri); - } - - public static ExecutionException reportFailed(String reportUri, Throwable throwable) { - return Kind.REPORT_FAILED.exception(reportUri, throwable); - } - - public static ExecutionException reportCancelled(String reportUri) { - return Kind.REPORT_CANCELLED.exception(reportUri); - } - - public static ExecutionException exportFailed(String reportUri) { - return Kind.EXPORT_FAILED.exception(reportUri); - } - - public static ExecutionException exportFailed(String reportUri, Throwable throwable) { - return Kind.EXPORT_FAILED.exception(reportUri, throwable); - } - - public static ExecutionException exportCancelled(String reportUri) { - return Kind.EXPORT_CANCELLED.exception(reportUri); - } - - public boolean isCancelled() { - return Kind.EXPORT_CANCELLED == mKind || Kind.REPORT_CANCELLED == mKind; - } - - public JSException adaptToClientException() { - switch (mKind) { - case REPORT_FAILED: - case REPORT_CANCELLED: - return JSException.create(getMessage(), getCause(), JSException.REPORT_EXECUTION_CANCELLED); - case EXPORT_FAILED: - case EXPORT_CANCELLED: - return JSException.create(getMessage(), getCause(), JSException.EXPORT_EXECUTION_CANCELLED); - } - throw new UnsupportedOperationException("Unexpected type of kind: " + mKind); - } - - private enum Kind { - REPORT_FAILED { - @Override - public ExecutionException exception(String reportUri) { - String message = String.format("Report execution '%s' failed on server side", reportUri); - return new ExecutionException(this, message); - } - @Override - public ExecutionException exception(String reportUri, Throwable throwable) { - String message = String.format("Report execution '%s' failed. Reason: %s", reportUri, throwable.getMessage()); - return new ExecutionException(this, message, throwable); - } - }, - REPORT_CANCELLED { - @Override - public ExecutionException exception(String reportUri) { - String message = String.format("Report execution '%s' was cancelled", reportUri); - return new ExecutionException(this, message); - } - }, - EXPORT_FAILED { - @Override - public ExecutionException exception(String reportUri) { - String message = String.format("Export for report '%s' failed on server side", reportUri); - return new ExecutionException(this, message); - } - @Override - public ExecutionException exception(String reportUri, Throwable throwable) { - String message = String.format("Export for report '%s' failed. Reason: %s", reportUri, throwable.getMessage()); - return new ExecutionException(this, message, throwable); - } - }, - EXPORT_CANCELLED { - @Override - public ExecutionException exception(String reportUri) { - String message = String.format("Export for report '%s' was cancelled", reportUri); - return new ExecutionException(this, message); - } - }; - - public ExecutionException exception(String message) { - throw new UnsupportedOperationException(); - } - - public ExecutionException exception(String message, Throwable throwable) { - throw new UnsupportedOperationException(); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index ffa7133f..57069957 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -28,6 +28,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,21 +46,19 @@ final class ExportFactory { private final ReportExportUseCase mExportUseCase; private final String mExecutionId; - private final String mReportUri; - ExportFactory(ReportExportUseCase exportUseCase, String executionId, String reportUri) { + ExportFactory(ReportExportUseCase exportUseCase, String executionId) { mExportUseCase = exportUseCase; mExecutionId = executionId; - mReportUri = reportUri; } @NotNull public ReportExport create(ReportExecutionDescriptor executionDetails, - ExportExecutionDescriptor exportExecutionDetails) throws ExecutionException { + ExportExecutionDescriptor exportExecutionDetails) throws StatusException { String exportId = exportExecutionDetails.getExportId(); ExportDescriptor export = findExportDescriptor(executionDetails, exportId); if (export == null) { - throw ExecutionException.exportFailed(mReportUri); + throw new StatusException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); } Collection attachments = adaptAttachments(export); return new ReportExport(mExecutionId, exportId, attachments, mExportUseCase); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index 2603f7cc..02b581ac 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; @@ -51,7 +51,7 @@ public final class ReportAttachment { } @NotNull - public ResourceOutput download() throws JSException { + public ResourceOutput download() throws StatusException { return mExportUseCase.requestExportAttachmentOutput( mExecutionId, mExportId, mFileName); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 48e5fed9..e83a764d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -25,10 +25,12 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -60,44 +62,34 @@ public final class ReportExecution { mExecutionId = executionId; mReportUri = reportUri; - mExportFactory = new ExportFactory(exportUseCase, mExecutionId, mReportUri); + mExportFactory = new ExportFactory(exportUseCase, mExecutionId); } @NotNull - public ReportMetadata waitForReportCompletion() throws JSException { - try { - return performAwaitFoReport(); - } catch (ExecutionException ex) { - throw ex.adaptToClientException(); - } catch (JSException e) { - throw e; - } + public ReportMetadata waitForReportCompletion() throws StatusException { + return performAwaitFoReport(); } @NotNull - public ReportExport export(RunExportCriteria criteria) throws JSException { + public ReportExport export(RunExportCriteria criteria) throws StatusException { try { return performExport(criteria); - } catch (ExecutionException ex) { - if (ex.isCancelled()) { + } catch (StatusException ex) { + boolean isCancelled = (ex.code() == StatusCodes.EXPORT_EXECUTION_CANCELLED || + ex.code() == StatusCodes.REPORT_EXECUTION_CANCELLED); + if (isCancelled) { /** * Cancelled by technical reason. User applied Jive(for e.g. have applied new filter). * Cancelled when report execution finished. This event flags that we need rerun export. */ - try { - return performExport(criteria); - } catch (ExecutionException nestedEx) { - throw nestedEx.adaptToClientException(); - } + return performExport(criteria); } - throw ex.adaptToClientException(); - } catch (JSException e) { - throw e; + throw ex; } } @NotNull - private ReportMetadata performAwaitFoReport() throws JSException, ExecutionException { + private ReportMetadata performAwaitFoReport() throws StatusException { ReportExecutionDescriptor details = requestExecutionDetails(); ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); return new ReportMetadata(mReportUri, @@ -105,28 +97,31 @@ private ReportMetadata performAwaitFoReport() throws JSException, ExecutionExcep } @NotNull - private ReportExport performExport(RunExportCriteria criteria) throws JSException, ExecutionException { + private ReportExport performExport(RunExportCriteria criteria) throws StatusException { ExportExecutionDescriptor exportDetails = runExport(criteria); waitForExportReadyStatus(exportDetails); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); return mExportFactory.create(currentDetails, exportDetails); } - private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws JSException, ExecutionException{ + private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws StatusException { final String exportId = exportDetails.getExportId(); Status status = Status.wrap(exportDetails.getStatus()); + ErrorDescriptor descriptor = exportDetails.getErrorDescriptor(); while (!status.isReady()) { if (status.isCancelled()) { - throw ExecutionException.exportCancelled(mReportUri); + throw new StatusException( + String.format("Export for report '%s' execution cancelled", mReportUri), null, + StatusCodes.EXPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw ExecutionException.exportFailed(mReportUri); + throw new StatusException(descriptor.getMessage(), null, StatusCodes.EXPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw ExecutionException.exportFailed(mReportUri, ex); + throw new StatusException("Unexpected error", ex, StatusCodes.ERROR); } status = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); @@ -134,35 +129,38 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) t } @NotNull - private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) throws JSException, ExecutionException{ + private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) throws StatusException { Status status = Status.wrap(details.getStatus()); - + ErrorDescriptor descriptor = details.getErrorDescriptor(); ReportExecutionDescriptor resultDetails = details; while (!status.isReady()) { if (status.isCancelled()) { - throw ExecutionException.reportCancelled(mReportUri); + throw new StatusException( + String.format("Report '%s' execution cancelled", mReportUri), null, + StatusCodes.REPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw ExecutionException.reportFailed(mReportUri); + throw new StatusException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw ExecutionException.reportFailed(mReportUri, ex); + throw new StatusException("Unexpected error", ex, StatusCodes.ERROR); } - resultDetails = requestExecutionDetails(); status = Status.wrap(details.getStatus()); + descriptor = details.getErrorDescriptor(); + resultDetails = requestExecutionDetails(); } return resultDetails; } @NotNull - private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws JSException { + private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws StatusException { return mExportUseCase.runExport(mExecutionId, criteria); } @NotNull - private ReportExecutionDescriptor requestExecutionDetails() throws JSException { + private ReportExecutionDescriptor requestExecutionDetails() throws StatusException { return mExecutionUseCase.requestExecutionDetails(mExecutionId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index e105c077..4f768ff8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -30,7 +30,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; import org.jetbrains.annotations.NotNull; @@ -54,37 +55,36 @@ final class ReportExecutionUseCase { } @NotNull - public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) throws JSException { + public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) throws StatusException { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); try { return mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } @NotNull - public Status requestStatus(String executionId) throws JSException { + public ExecutionStatus requestStatus(String executionId) throws StatusException { try { - ExecutionStatus executionStatus = mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); - return Status.wrap(executionStatus.getStatus()); + return mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } @NotNull - public ReportExecutionDescriptor requestExecutionDetails(String executionId) throws JSException { + public ReportExecutionDescriptor requestExecutionDetails(String executionId) throws StatusException { try { return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), executionId); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 9bd70e00..df0101ae 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; @@ -57,7 +57,7 @@ public Collection getAttachments() { } @NotNull - public ReportOutput download() throws JSException { + public ReportOutput download() throws StatusException { return mExportUseCase.requestExportOutput(mExecutionId, mExportId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 25d58554..90af935a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -34,7 +34,8 @@ import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; import org.jetbrains.annotations.NotNull; @@ -57,54 +58,54 @@ final class ReportExportUseCase { } @NotNull - public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) throws JSException { + public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) throws StatusException { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); try { return mExportApi.runExportExecution(mTokenProvider.provideToken(), executionId, options); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } @NotNull - public Status checkExportExecutionStatus(String executionId, String exportId) throws JSException { + public Status checkExportExecutionStatus(String executionId, String exportId) throws StatusException { try { ExecutionStatus exportStatus = mExportApi .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); return Status.wrap(exportStatus.getStatus()); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } @NotNull - public ReportOutput requestExportOutput(String executionId, String exportId) throws JSException { + public ReportOutput requestExportOutput(String executionId, String exportId) throws StatusException { try { ExportOutputResource result = mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); return OutputDataMapper.transform(result); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } @NotNull - public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, String fileName) throws JSException { - OutputResource result = null; + public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, + String fileName) throws StatusException { try { - result = mExportApi.requestExportAttachment( + OutputResource result = mExportApi.requestExportAttachment( mTokenProvider.provideToken(), executionId, exportId, fileName); return OutputDataMapper.transform(result); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 4b81bf05..6b142446 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -26,8 +26,11 @@ import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.StatusException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; @@ -77,18 +80,12 @@ public static ReportService create(TokenProvider tokenProvider, InfoProvider inf reportExportUseCase); } - public ReportExecution run(String reportUri, RunReportCriteria criteria) throws JSException { - try { - return performRun(reportUri, criteria); - } catch (ExecutionException ex) { - throw ex.adaptToClientException(); - } catch (JSException ex) { - throw ex; - } + public ReportExecution run(String reportUri, RunReportCriteria criteria) throws StatusException { + return performRun(reportUri, criteria); } @NotNull - private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws JSException, ExecutionException { + private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws StatusException { ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); waitForReportExecutionStart(reportUri, details); @@ -101,23 +98,28 @@ private ReportExecution performRun(String reportUri, RunReportCriteria criteria) details.getReportURI()); } - private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) throws ExecutionException, JSException { + private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) throws StatusException { String executionId = details.getExecutionId(); Status status = Status.wrap(details.getStatus()); + ErrorDescriptor descriptor = details.getErrorDescriptor(); while (!status.isReady() && !status.isExecution()) { if (status.isCancelled()) { - throw ExecutionException.reportCancelled(reportUri); + throw new StatusException( + String.format("Report '%s' execution cancelled", reportUri), null, + StatusCodes.REPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw ExecutionException.reportFailed(reportUri); + throw new StatusException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw ExecutionException.reportFailed(reportUri, ex); + throw new StatusException("Unexpected error", ex, StatusCodes.ERROR); } - status = mExecutionUseCase.requestStatus(executionId); + ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); + status = Status.wrap(statusDetails.getStatus()); + descriptor = statusDetails.getErrorDescriptor(); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index e7ce8e0e..6fce8568 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; @@ -60,7 +60,7 @@ public EmeraldMR2SearchStrategy(InternalCriteria criteria, } @Override - public Collection searchNext() throws JSException { + public Collection searchNext() throws StatusException { int limit = mInitialCriteria.getLimit(); int offset = mInitialCriteria.getOffset(); @@ -76,7 +76,7 @@ public boolean hasNext() { return !mEndReached; } - private void calculateDisposition(int offset) throws JSException { + private void calculateDisposition(int offset) throws StatusException { boolean serverDispositionUndefined = offset >= mServerDisposition; if (serverDispositionUndefined) { internalSearch(offset); @@ -84,7 +84,7 @@ private void calculateDisposition(int offset) throws JSException { } @NotNull - private Collection internalSearch(int limit) throws JSException { + private Collection internalSearch(int limit) throws StatusException { int count = 0; while (mBuffer.size() < limit && hasNext()) { SearchResult response = performSearch(limit); @@ -112,7 +112,7 @@ private Collection internalSearch(int limit) throws JSException { } @NotNull - private SearchResult performSearch(int limit) throws JSException { + private SearchResult performSearch(int limit) throws StatusException { InternalCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) .limit(limit) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 6eea0f2d..83b0c9f2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; @@ -59,7 +59,7 @@ public EmeraldMR3SearchStrategy(InternalCriteria criteria, SearchUseCase searchU } @Override - public Collection searchNext() throws JSException { + public Collection searchNext() throws StatusException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } @@ -76,7 +76,7 @@ public boolean hasNext() { } @NotNull - private Collection performLookup() throws JSException { + private Collection performLookup() throws StatusException { InternalCriteria newSearchCriteria = createNextCriteria(); SearchResult result = performApiCall(newSearchCriteria); updateInternalOffset(result); @@ -84,11 +84,11 @@ private Collection performLookup() throws JSException { } @NotNull - private SearchResult performApiCall(InternalCriteria newSearchCriteria) throws JSException { + private SearchResult performApiCall(InternalCriteria newSearchCriteria) throws StatusException { return mSearchUseCase.performSearch(newSearchCriteria); } - private void defineInternalOffset() throws JSException { + private void defineInternalOffset() throws StatusException { if (mUserOffset == 0) { mInternalOffset = mUserOffset; } else { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 5553ccf4..ef8d9a59 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -38,7 +38,7 @@ * @since 2.0 */ interface SearchStrategy { - Collection searchNext() throws JSException; + Collection searchNext() throws StatusException; boolean hasNext(); class Factory { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 56923c52..ef607ca5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.jetbrains.annotations.NotNull; @@ -37,6 +37,6 @@ */ public interface SearchTask { @NotNull - Collection nextLookup() throws JSException; + Collection nextLookup() throws StatusException; boolean hasNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 12e42ec9..ce74ca64 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -60,7 +60,7 @@ final class SearchTaskImpl implements SearchTask { @NotNull @Override - public Collection nextLookup() throws JSException { + public Collection nextLookup() throws StatusException { return defineSearchStrategy().searchNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 1450c86e..6f828d3f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -27,7 +27,8 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -59,7 +60,7 @@ public SearchUseCase( } @NotNull - public SearchResult performSearch(@NotNull InternalCriteria criteria) throws JSException { + public SearchResult performSearch(@NotNull InternalCriteria criteria) throws StatusException { ResourceSearchResult response = null; try { response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); @@ -74,9 +75,9 @@ public SearchResult performSearch(@NotNull InternalCriteria criteria) throws JSE return searchResult; } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 6f2371b5..f14d673a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -29,7 +29,8 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.exception.JSException; +import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; import org.jetbrains.annotations.TestOnly; @@ -58,36 +59,36 @@ public static ServerInfoService create(String baseUrl) { return new ServerInfoService(restApi, ServerInfoTransformer.get()); } - public ServerInfo requestServerInfo() throws JSException { + public ServerInfo requestServerInfo() throws StatusException { try { ServerInfoData response = mRestApi.requestServerInfo(); return mTransformer.transform(response); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } - public ServerVersion requestServerVersion() throws JSException { + public ServerVersion requestServerVersion() throws StatusException { try { String version = mRestApi.requestVersion(); return ServerVersion.defaultParser().parse(version); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } - public SimpleDateFormat requestServerDateTimeFormat() throws JSException { + public SimpleDateFormat requestServerDateTimeFormat() throws StatusException { try { String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); return new SimpleDateFormat(dateTimeFormat); } catch (HttpException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } catch (IOException e) { - throw JSException.wrap(e); + throw StatusExceptionMapper.transform(e); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java new file mode 100644 index 00000000..1394bdab --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.StatusException; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.io.IOException; +import java.net.SocketTimeoutException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsInstanceOf.instanceOf; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public class StatusExceptionMapperTest { + @Mock + HttpException mHttpException; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testTransformIOException() throws Exception { + IOException ioException = new IOException("Socket timed out", new SocketTimeoutException()); + StatusException statusException = StatusExceptionMapper.transform(ioException); + assertThat(statusException.code(), is(StatusCodes.NETWORK_ERROR)); + assertThat(statusException.getMessage(), is("Socket timed out")); + assertThat(statusException.getCause(), is(instanceOf(SocketTimeoutException.class))); + } + + @Test + public void testTransformHttpException() throws Exception { + // TODO implement cases + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java deleted file mode 100644 index cbe8519b..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionExceptionTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.service.exception.JSException; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ExecutionExceptionTest { - - @Test - public void testReportFailed() throws Exception { - ExecutionException ex = ExecutionException.reportFailed("/my/uri"); - assertThat(ex.getMessage(), is("Report execution '/my/uri' failed on server side")); - } - - @Test - public void testReportFailedWithThrowable() throws Exception { - ExecutionException ex = ExecutionException.reportFailed("/my/uri", new InterruptedException("interrupted")); - assertThat(ex.getMessage(), is("Report execution '/my/uri' failed. Reason: interrupted")); - assertThat(ex.getCause(), is(instanceOf(InterruptedException.class))); - } - - @Test - public void testReportCancelled() throws Exception { - ExecutionException ex = ExecutionException.reportCancelled("/my/uri"); - assertThat(ex.getMessage(), is("Report execution '/my/uri' was cancelled")); - } - - @Test - public void testExportFailed() throws Exception { - ExecutionException ex = ExecutionException.exportFailed("/my/uri"); - assertThat(ex.getMessage(), is("Export for report '/my/uri' failed on server side")); - } - - @Test - public void testExportFailedWithThrowable() throws Exception { - ExecutionException ex = ExecutionException.exportFailed("/my/uri", new InterruptedException("interrupted")); - assertThat(ex.getMessage(), is("Export for report '/my/uri' failed. Reason: interrupted")); - } - - @Test - public void testExportCancelled() throws Exception { - ExecutionException ex = ExecutionException.exportCancelled("/my/uri"); - assertThat(ex.getMessage(), is("Export for report '/my/uri' was cancelled")); - - } - - @Test - public void testIsCancelled() throws Exception { - ExecutionException exportEx = ExecutionException.exportCancelled("/my/uri"); - assertThat(exportEx.isCancelled(), is(true)); - - ExecutionException reportEx = ExecutionException.reportCancelled("/my/uri"); - assertThat(reportEx.isCancelled(), is(true)); - } - - @Test - public void testReportCancelledAdaptsToClientEx() throws Exception { - ExecutionException ex = ExecutionException.reportCancelled("/"); - JSException clientException = ex.adaptToClientException(); - assertThat(clientException.getMessage(), is(notNullValue())); - assertThat(clientException.code(), is(JSException.REPORT_EXECUTION_CANCELLED)); - } - - @Test - public void testReportFailedAdaptsToClientEx() throws Exception { - ExecutionException ex = ExecutionException.reportFailed("/"); - JSException clientException = ex.adaptToClientException(); - assertThat(clientException.getMessage(), is(notNullValue())); - assertThat(clientException.code(), is(JSException.REPORT_EXECUTION_FAILED)); - } - - @Test - public void testExportCancelledAdaptsToClientEx() throws Exception { - ExecutionException ex = ExecutionException.exportCancelled("/"); - JSException clientException = ex.adaptToClientException(); - assertThat(clientException.getMessage(), is(notNullValue())); - assertThat(clientException.code(), is(JSException.EXPORT_EXECUTION_CANCELLED)); - } - - @Test - public void testExportFailedAdaptsToClientEx() throws Exception { - ExecutionException ex = ExecutionException.exportFailed("/"); - JSException clientException = ex.adaptToClientException(); - assertThat(clientException.getMessage(), is(notNullValue())); - assertThat(clientException.code(), is(JSException.EXPORT_EXECUTION_FAILED)); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index de49f2c3..16d09e27 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; @@ -33,8 +34,8 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; -import com.jaspersoft.android.sdk.service.report.exception.ReportExportException; -import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.junit.Before; import org.junit.Rule; @@ -52,6 +53,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -71,6 +73,7 @@ ExportExecutionDescriptor.class, ExportDescriptor.class, ExecutionStatus.class, + ErrorDescriptor.class, ExecutionOptionsDataMapper.class}) public class ReportExecutionTest { @@ -84,6 +87,8 @@ public class ReportExecutionTest { ExportDescriptor mExportExecution; @Mock ExecutionStatus mExecutionStatusResponse; + @Mock + ErrorDescriptor mDescriptor; @Mock ReportExportRestApi mExportRestApi; @@ -130,46 +135,53 @@ public void testRequestExportIdealCase() throws Exception { @Test public void testRunThrowsFailedStatusImmediately() throws Exception { - mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/report/uri' failed on server side"); - // export run request mockRunExportExecution("failed"); - objectUnderTest.export(exportCriteria); + try { + objectUnderTest.export(exportCriteria); + fail("Should throw Status exception"); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); + } } @Test public void testRunShouldThrowFailedIfStatusFailed() throws Exception { - mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/report/uri' failed on server side"); - mockRunExportExecution("queued"); - mockCheckExportExecStatus("failed"); - objectUnderTest.export(exportCriteria); + try { + objectUnderTest.export(exportCriteria); + fail("Should throw Status exception"); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); + } } @Test public void testRunThrowsCancelledStatusImmediately() throws Exception { - mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/report/uri' was cancelled"); - // export run request mockRunExportExecution("cancelled"); - objectUnderTest.export(exportCriteria); + try { + objectUnderTest.export(exportCriteria); + fail("Should throw Status exception"); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_CANCELLED)); + } } @Test public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { - mException.expect(ReportExportException.class); - mException.expectMessage("Export for report '/report/uri' was cancelled"); - mockRunExportExecution("queued"); mockCheckExportExecStatus("cancelled"); - objectUnderTest.export(exportCriteria); + try { + objectUnderTest.export(exportCriteria); + fail("Should throw Status exception"); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_CANCELLED)); + } } @Test @@ -218,27 +230,30 @@ public void testAwaitCompleteReportShouldLoopCalls() throws Exception { @Test public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() throws Exception { - mException.expect(ReportRunException.class); - mException.expectMessage("Report execution '/report/uri' was cancelled"); - mockReportExecutionDetails("execution", "cancelled"); - objectUnderTest.waitForReportCompletion(); + try { + objectUnderTest.waitForReportCompletion(); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); + } } @Test public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception { - mException.expect(ReportRunException.class); - mException.expectMessage("Report execution '/report/uri' failed on server side"); - mockReportExecutionDetails("execution", "failed"); - objectUnderTest.waitForReportCompletion(); - } + try { + objectUnderTest.waitForReportCompletion(); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); + } + } private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); when(mExecutionStatusResponse.getStatus()).then(StatusChain.of(statusChain)); + when(mExecutionStatusResponse.getErrorDescriptor()).thenReturn(mDescriptor); when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(mExecutionStatusResponse); } @@ -246,6 +261,7 @@ private void mockRunExportExecution(String... statusChain) throws Exception { ensureChain(statusChain); when(mExportExecDetails.getExportId()).thenReturn("export_id"); when(mExportExecDetails.getStatus()).then(StatusChain.of(statusChain)); + when(mExportExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(mExportRestApi.runExportExecution(anyString(), anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); } @@ -256,6 +272,7 @@ private void mockReportExecutionDetails(String... statusChain) throws Exception when(mExportExecution.getId()).thenReturn("export_id"); when(mExecDetails.getExports()).thenReturn(exports); when(mExecDetails.getStatus()).then(StatusChain.of(statusChain)); + when(mExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(mExecutionRestApi.requestReportExecutionDetails(anyString(), anyString())).thenReturn(mExecDetails); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index f678c4a1..4aa613ed 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -26,11 +26,13 @@ import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.report.exception.ReportRunException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.StatusException; import org.junit.Before; import org.junit.Rule; @@ -62,6 +64,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({ ExecutionStatus.class, + ErrorDescriptor.class, ReportExecutionDescriptor.class, ExecutionOptionsDataMapper.class}) public class ReportServiceTest { @@ -72,6 +75,8 @@ public class ReportServiceTest { ReportExportRestApi exportApi; @Mock TokenProvider mTokenProvider; + @Mock + ErrorDescriptor mDescriptor; @Mock RunReportCriteria configuration; @@ -113,44 +118,48 @@ public void testRunShouldCreateActiveSession() throws Exception { @Test public void testRunThrowsFailedStatusImmediately() throws Exception { - mException.expect(ReportRunException.class); - mException.expectMessage("Report execution '/report/uri' failed on server side"); - mockRunReportExecution("failed"); - objectUnderTest.run("/report/uri", configuration); + try { + objectUnderTest.run("/report/uri", configuration); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); + } } @Test public void testRunShouldThrowFailedIfStatusFailed() throws Exception { - mException.expect(ReportRunException.class); - mException.expectMessage("Report execution '/report/uri' failed on server side"); - mockRunReportExecution("queued"); mockReportExecutionStatus("failed"); - objectUnderTest.run("/report/uri", configuration); + try { + objectUnderTest.run("/report/uri", configuration); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); + } } @Test public void testRunThrowsCancelledStatusImmediately() throws Exception { - mException.expect(ReportRunException.class); - mException.expectMessage("Report execution '/report/uri' was cancelled"); - mockRunReportExecution("cancelled"); - objectUnderTest.run("/report/uri", configuration); + try { + objectUnderTest.run("/report/uri", configuration); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); + } } @Test public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { - mException.expect(ReportRunException.class); - mException.expectMessage("Report execution '/report/uri' was cancelled"); - mockRunReportExecution("queued"); mockReportExecutionStatus("cancelled"); - objectUnderTest.run("/report/uri", configuration); + try { + objectUnderTest.run("/report/uri", configuration); + } catch (StatusException ex) { + assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); + } } @Test @@ -164,11 +173,13 @@ public void testRunShouldLoopUntilStatusExecution() throws Exception { private void mockReportExecutionStatus(String... statusChain) throws Exception { when(statusDetails.getStatus()).then(StatusChain.of(statusChain)); + when(statusDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(executionApi.requestReportExecutionStatus(anyString(), anyString())).thenReturn(statusDetails); } private void mockRunReportExecution(String execution) throws Exception { when(initDetails.getStatus()).thenReturn(execution); + when(initDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(initDetails.getExecutionId()).thenReturn("exec_id"); when(executionApi.runReportExecution(anyString(), any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); } From 7679bcf675acbdfcf4112fb8a3bfc333e070671b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 18 Nov 2015 23:40:09 +0200 Subject: [PATCH 278/457] Implement additional tests for StatusExceptionMapperTest --- .../sdk/service/exception/StatusCodes.java | 4 +- .../service/exception/StatusException.java | 2 +- .../internal/StatusExceptionMapper.java | 4 +- .../internal/StatusExceptionMapperTest.java | 91 ++++++++++++++++++- 4 files changed, 91 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java index 1c8cc150..e3bc2ff6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java @@ -26,14 +26,14 @@ /** * @author Tom Koptel - * @since 2.3 + * @since 2.0 */ public final class StatusCodes { public static final int ERROR = 1; public static final int NETWORK_ERROR = 2; public static final int CLIENT_ERROR = 3; public static final int INTERNAL_ERROR = 4; - public static final int PERMISSION_ERROR = 5; + public static final int PERMISSION_DENIED_ERROR = 5; public static final int AUTHORIZATION_ERROR = 6; // EXPORT diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java index 646cdda7..3699f074 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java @@ -26,7 +26,7 @@ /** * @author Tom Koptel - * @since 2.3 + * @since 2.0 */ public class StatusException extends Exception { private final int mCode; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java index f620ab6d..2acb0c70 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java @@ -35,7 +35,7 @@ /** * @author Tom Koptel - * @since 2.3 + * @since 2.0 */ public final class StatusExceptionMapper { @NotNull @@ -67,7 +67,7 @@ private static StatusException mapHttpCodesToState(HttpException e) { case 400: return new StatusException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); case 403: - return new StatusException("User has no access to resource", e, StatusCodes.PERMISSION_ERROR); + return new StatusException("User has no access to resource", e, StatusCodes.PERMISSION_DENIED_ERROR); case 401: return new StatusException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); default: diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java index 1394bdab..bd5567db 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java @@ -25,13 +25,17 @@ package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.StatusException; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.io.IOException; import java.net.SocketTimeoutException; @@ -39,14 +43,19 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsInstanceOf.instanceOf; +import static org.powermock.api.mockito.PowerMockito.when; /** * @author Tom Koptel - * @since 2.3 + * @since 2.0 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ErrorDescriptor.class}) public class StatusExceptionMapperTest { @Mock HttpException mHttpException; + @Mock + ErrorDescriptor mDescriptor; @Before public void setUp() throws Exception { @@ -58,12 +67,84 @@ public void testTransformIOException() throws Exception { IOException ioException = new IOException("Socket timed out", new SocketTimeoutException()); StatusException statusException = StatusExceptionMapper.transform(ioException); assertThat(statusException.code(), is(StatusCodes.NETWORK_ERROR)); - assertThat(statusException.getMessage(), is("Socket timed out")); - assertThat(statusException.getCause(), is(instanceOf(SocketTimeoutException.class))); + assertThat(statusException.getMessage(), is("Failed to perform network request. Check network!")); + assertThat(statusException.getCause(), is(instanceOf(IOException.class))); + } + + @Test + public void testTransform500HttpException() throws Exception { + when(mHttpException.code()).thenReturn(500); + when(mHttpException.getDescriptor()).thenReturn(null); + + StatusException statusException = StatusExceptionMapper.transform(mHttpException); + assertThat(statusException.code(), is(StatusCodes.INTERNAL_ERROR)); + assertThat(statusException.getMessage(), is("Server encountered unexpected error")); + assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + } + + @Test + public void testTransform404HttpException() throws Exception { + when(mHttpException.code()).thenReturn(404); + when(mHttpException.getDescriptor()).thenReturn(null); + + StatusException statusException = StatusExceptionMapper.transform(mHttpException); + assertThat(statusException.code(), is(StatusCodes.CLIENT_ERROR)); + assertThat(statusException.getMessage(), is("Service exist but requested entity not found")); + assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); } @Test - public void testTransformHttpException() throws Exception { - // TODO implement cases + public void testTransform400HttpException() throws Exception { + when(mHttpException.code()).thenReturn(400); + when(mHttpException.getDescriptor()).thenReturn(null); + + StatusException statusException = StatusExceptionMapper.transform(mHttpException); + assertThat(statusException.code(), is(StatusCodes.CLIENT_ERROR)); + assertThat(statusException.getMessage(), is("Some parameters in request not valid")); + assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + } + + @Test + public void testTransform403HttpException() throws Exception { + when(mHttpException.code()).thenReturn(403); + when(mHttpException.getDescriptor()).thenReturn(null); + + StatusException statusException = StatusExceptionMapper.transform(mHttpException); + assertThat(statusException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); + assertThat(statusException.getMessage(), is("User has no access to resource")); + assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + } + + @Test + public void testTransform401HttpException() throws Exception { + when(mHttpException.code()).thenReturn(401); + when(mHttpException.getDescriptor()).thenReturn(null); + + StatusException statusException = StatusExceptionMapper.transform(mHttpException); + assertThat(statusException.code(), is(StatusCodes.AUTHORIZATION_ERROR)); + assertThat(statusException.getMessage(), is("User is not authorized")); + assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + } + + @Test + public void testTransformWithDescriptorWithMissingKey() throws IOException { + when(mDescriptor.getErrorCode()).thenReturn("missing.key"); + when(mHttpException.code()).thenReturn(403); + when(mHttpException.getDescriptor()).thenReturn(mDescriptor); + + StatusException statusException = StatusExceptionMapper.transform(mHttpException); + assertThat(statusException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); + assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + } + + @Test + public void testTransformWillHandleIOExceptionForDescriptorMapping() throws IOException { + when(mDescriptor.getErrorCode()).thenReturn("missing.key"); + when(mHttpException.code()).thenReturn(403); + when(mHttpException.getDescriptor()).thenThrow(new IOException("Failed IO")); + + StatusException statusException = StatusExceptionMapper.transform(mHttpException); + assertThat(statusException.code(), is(StatusCodes.NETWORK_ERROR)); + assertThat(statusException.getCause(), is(instanceOf(IOException.class))); } } \ No newline at end of file From f60e534b175812bc0a2eb1f5c9ac86bd0aa2f237 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 19 Nov 2015 11:50:56 +0200 Subject: [PATCH 279/457] Rename StatusException -> ServiceException --- .../android/sdk/service/auth/Credentials.java | 4 +- .../sdk/service/auth/JrsAuthenticator.java | 4 +- .../sdk/service/auth/SpringCredentials.java | 10 +-- ...usException.java => ServiceException.java} | 4 +- ...apper.java => ServiceExceptionMapper.java} | 30 ++++----- .../sdk/service/report/ExportFactory.java | 6 +- .../sdk/service/report/ReportAttachment.java | 4 +- .../sdk/service/report/ReportExecution.java | 32 +++++----- .../report/ReportExecutionUseCase.java | 22 +++---- .../sdk/service/report/ReportExport.java | 4 +- .../service/report/ReportExportUseCase.java | 28 ++++---- .../sdk/service/report/ReportService.java | 14 ++-- .../repository/EmeraldMR2SearchStrategy.java | 10 +-- .../repository/EmeraldMR3SearchStrategy.java | 10 +-- .../service/repository/SearchStrategy.java | 4 +- .../sdk/service/repository/SearchTask.java | 4 +- .../service/repository/SearchTaskImpl.java | 4 +- .../sdk/service/repository/SearchUseCase.java | 10 +-- .../sdk/service/server/ServerInfoService.java | 22 +++---- ...t.java => ServiceExceptionMapperTest.java} | 64 +++++++++---------- .../service/report/ReportExecutionTest.java | 14 ++-- .../sdk/service/report/ReportServiceTest.java | 10 +-- 22 files changed, 157 insertions(+), 157 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/service/exception/{StatusException.java => ServiceException.java} (91%) rename core/src/main/java/com/jaspersoft/android/sdk/service/internal/{StatusExceptionMapper.java => ServiceExceptionMapper.java} (61%) rename core/src/test/java/com/jaspersoft/android/sdk/service/internal/{StatusExceptionMapperTest.java => ServiceExceptionMapperTest.java} (59%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java index 4191b896..8436dca0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java @@ -1,11 +1,11 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; /** * @author Tom Koptel * @since 2.0 */ public abstract class Credentials { - protected abstract String applyPolicy(AuthPolicy authPolicy) throws StatusException; + protected abstract String applyPolicy(AuthPolicy authPolicy) throws ServiceException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java index 88870039..2ab6bdc9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java @@ -1,7 +1,7 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -35,7 +35,7 @@ public static JrsAuthenticator create(@NotNull AuthenticationRestApi restApi) { } @NotNull - public String authenticate(@NotNull Credentials credentials) throws StatusException { + public String authenticate(@NotNull Credentials credentials) throws ServiceException { checkNotNull(credentials, "Credentials should not be null"); return credentials.applyPolicy(mAuthPolicy); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index 2069c685..e56841d0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -1,8 +1,8 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.exception.StatusException; -import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -69,13 +69,13 @@ public Locale getLocale() { } @Override - protected String applyPolicy(AuthPolicy policy) throws StatusException { + protected String applyPolicy(AuthPolicy policy) throws ServiceException { try { return policy.applyCredentials(this); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/ServiceException.java similarity index 91% rename from core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/exception/ServiceException.java index 3699f074..261a400f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/ServiceException.java @@ -28,10 +28,10 @@ * @author Tom Koptel * @since 2.0 */ -public class StatusException extends Exception { +public class ServiceException extends Exception { private final int mCode; - public StatusException(String message, Throwable cause, int code) { + public ServiceException(String message, Throwable cause, int code) { super(message, cause); mCode = code; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java similarity index 61% rename from core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java index 2acb0c70..0a272226 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -37,14 +37,14 @@ * @author Tom Koptel * @since 2.0 */ -public final class StatusExceptionMapper { +public final class ServiceExceptionMapper { @NotNull - public static StatusException transform(IOException e) { - return new StatusException("Failed to perform network request. Check network!", e, StatusCodes.NETWORK_ERROR); + public static ServiceException transform(IOException e) { + return new ServiceException("Failed to perform network request. Check network!", e, StatusCodes.NETWORK_ERROR); } @NotNull - public static StatusException transform(HttpException e) { + public static ServiceException transform(HttpException e) { try { ErrorDescriptor descriptor = e.getDescriptor(); if (e.getDescriptor() == null) { @@ -58,27 +58,27 @@ public static StatusException transform(HttpException e) { } @NotNull - private static StatusException mapHttpCodesToState(HttpException e) { + private static ServiceException mapHttpCodesToState(HttpException e) { switch (e.code()) { case 500: - return new StatusException("Server encountered unexpected error", e, StatusCodes.INTERNAL_ERROR); + return new ServiceException("Server encountered unexpected error", e, StatusCodes.INTERNAL_ERROR); case 404: - return new StatusException("Service exist but requested entity not found", e, StatusCodes.CLIENT_ERROR); - case 400: - return new StatusException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); + return new ServiceException("Service exist but requested entity not found", e, StatusCodes.CLIENT_ERROR); case 403: - return new StatusException("User has no access to resource", e, StatusCodes.PERMISSION_DENIED_ERROR); + return new ServiceException("User has no access to resource", e, StatusCodes.PERMISSION_DENIED_ERROR); case 401: - return new StatusException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); + return new ServiceException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); + case 400: + return new ServiceException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); default: - return new StatusException("The operation failed with no more detailed information", e, StatusCodes.ERROR); + return new ServiceException("The operation failed with no more detailed information", e, StatusCodes.ERROR); } } @NotNull - private static StatusException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { + private static ServiceException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { - return new StatusException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); + return new ServiceException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); } else { return mapHttpCodesToState(e); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index 57069957..ec0db383 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -29,7 +29,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,11 +54,11 @@ final class ExportFactory { @NotNull public ReportExport create(ReportExecutionDescriptor executionDetails, - ExportExecutionDescriptor exportExecutionDetails) throws StatusException { + ExportExecutionDescriptor exportExecutionDetails) throws ServiceException { String exportId = exportExecutionDetails.getExportId(); ExportDescriptor export = findExportDescriptor(executionDetails, exportId); if (export == null) { - throw new StatusException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); + throw new ServiceException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); } Collection attachments = adaptAttachments(export); return new ReportExport(mExecutionId, exportId, attachments, mExportUseCase); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index 02b581ac..e444c181 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -51,7 +51,7 @@ public final class ReportAttachment { } @NotNull - public ResourceOutput download() throws StatusException { + public ResourceOutput download() throws ServiceException { return mExportUseCase.requestExportAttachmentOutput( mExecutionId, mExportId, mFileName); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index e83a764d..4d99bc97 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -30,7 +30,7 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -66,15 +66,15 @@ public final class ReportExecution { } @NotNull - public ReportMetadata waitForReportCompletion() throws StatusException { + public ReportMetadata waitForReportCompletion() throws ServiceException { return performAwaitFoReport(); } @NotNull - public ReportExport export(RunExportCriteria criteria) throws StatusException { + public ReportExport export(RunExportCriteria criteria) throws ServiceException { try { return performExport(criteria); - } catch (StatusException ex) { + } catch (ServiceException ex) { boolean isCancelled = (ex.code() == StatusCodes.EXPORT_EXECUTION_CANCELLED || ex.code() == StatusCodes.REPORT_EXECUTION_CANCELLED); if (isCancelled) { @@ -89,7 +89,7 @@ public ReportExport export(RunExportCriteria criteria) throws StatusException { } @NotNull - private ReportMetadata performAwaitFoReport() throws StatusException { + private ReportMetadata performAwaitFoReport() throws ServiceException { ReportExecutionDescriptor details = requestExecutionDetails(); ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); return new ReportMetadata(mReportUri, @@ -97,31 +97,31 @@ private ReportMetadata performAwaitFoReport() throws StatusException { } @NotNull - private ReportExport performExport(RunExportCriteria criteria) throws StatusException { + private ReportExport performExport(RunExportCriteria criteria) throws ServiceException { ExportExecutionDescriptor exportDetails = runExport(criteria); waitForExportReadyStatus(exportDetails); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); return mExportFactory.create(currentDetails, exportDetails); } - private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws StatusException { + private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws ServiceException { final String exportId = exportDetails.getExportId(); Status status = Status.wrap(exportDetails.getStatus()); ErrorDescriptor descriptor = exportDetails.getErrorDescriptor(); while (!status.isReady()) { if (status.isCancelled()) { - throw new StatusException( + throw new ServiceException( String.format("Export for report '%s' execution cancelled", mReportUri), null, StatusCodes.EXPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw new StatusException(descriptor.getMessage(), null, StatusCodes.EXPORT_EXECUTION_FAILED); + throw new ServiceException(descriptor.getMessage(), null, StatusCodes.EXPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw new StatusException("Unexpected error", ex, StatusCodes.ERROR); + throw new ServiceException("Unexpected error", ex, StatusCodes.ERROR); } status = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); @@ -129,23 +129,23 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) t } @NotNull - private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) throws StatusException { + private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) throws ServiceException { Status status = Status.wrap(details.getStatus()); ErrorDescriptor descriptor = details.getErrorDescriptor(); ReportExecutionDescriptor resultDetails = details; while (!status.isReady()) { if (status.isCancelled()) { - throw new StatusException( + throw new ServiceException( String.format("Report '%s' execution cancelled", mReportUri), null, StatusCodes.REPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw new StatusException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); + throw new ServiceException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw new StatusException("Unexpected error", ex, StatusCodes.ERROR); + throw new ServiceException("Unexpected error", ex, StatusCodes.ERROR); } status = Status.wrap(details.getStatus()); descriptor = details.getErrorDescriptor(); @@ -155,12 +155,12 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD } @NotNull - private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws StatusException { + private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws ServiceException { return mExportUseCase.runExport(mExecutionId, criteria); } @NotNull - private ReportExecutionDescriptor requestExecutionDetails() throws StatusException { + private ReportExecutionDescriptor requestExecutionDetails() throws ServiceException { return mExecutionUseCase.requestExecutionDetails(mExecutionId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 4f768ff8..badf1e62 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -30,8 +30,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.exception.StatusException; -import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.NotNull; @@ -55,36 +55,36 @@ final class ReportExecutionUseCase { } @NotNull - public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) throws StatusException { + public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) throws ServiceException { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); try { return mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } @NotNull - public ExecutionStatus requestStatus(String executionId) throws StatusException { + public ExecutionStatus requestStatus(String executionId) throws ServiceException { try { return mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } @NotNull - public ReportExecutionDescriptor requestExecutionDetails(String executionId) throws StatusException { + public ReportExecutionDescriptor requestExecutionDetails(String executionId) throws ServiceException { try { return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), executionId); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index df0101ae..d9c29d65 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -57,7 +57,7 @@ public Collection getAttachments() { } @NotNull - public ReportOutput download() throws StatusException { + public ReportOutput download() throws ServiceException { return mExportUseCase.requestExportOutput(mExecutionId, mExportId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 90af935a..218a8f19 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -34,8 +34,8 @@ import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.StatusException; -import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.NotNull; @@ -58,54 +58,54 @@ final class ReportExportUseCase { } @NotNull - public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) throws StatusException { + public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) throws ServiceException { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); try { return mExportApi.runExportExecution(mTokenProvider.provideToken(), executionId, options); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } @NotNull - public Status checkExportExecutionStatus(String executionId, String exportId) throws StatusException { + public Status checkExportExecutionStatus(String executionId, String exportId) throws ServiceException { try { ExecutionStatus exportStatus = mExportApi .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); return Status.wrap(exportStatus.getStatus()); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } @NotNull - public ReportOutput requestExportOutput(String executionId, String exportId) throws StatusException { + public ReportOutput requestExportOutput(String executionId, String exportId) throws ServiceException { try { ExportOutputResource result = mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); return OutputDataMapper.transform(result); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } @NotNull public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, - String fileName) throws StatusException { + String fileName) throws ServiceException { try { OutputResource result = mExportApi.requestExportAttachment( mTokenProvider.provideToken(), executionId, exportId, fileName); return OutputDataMapper.transform(result); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 6b142446..3f59d91c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -30,7 +30,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; @@ -80,12 +80,12 @@ public static ReportService create(TokenProvider tokenProvider, InfoProvider inf reportExportUseCase); } - public ReportExecution run(String reportUri, RunReportCriteria criteria) throws StatusException { + public ReportExecution run(String reportUri, RunReportCriteria criteria) throws ServiceException { return performRun(reportUri, criteria); } @NotNull - private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws StatusException { + private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws ServiceException { ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); waitForReportExecutionStart(reportUri, details); @@ -98,24 +98,24 @@ private ReportExecution performRun(String reportUri, RunReportCriteria criteria) details.getReportURI()); } - private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) throws StatusException { + private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) throws ServiceException { String executionId = details.getExecutionId(); Status status = Status.wrap(details.getStatus()); ErrorDescriptor descriptor = details.getErrorDescriptor(); while (!status.isReady() && !status.isExecution()) { if (status.isCancelled()) { - throw new StatusException( + throw new ServiceException( String.format("Report '%s' execution cancelled", reportUri), null, StatusCodes.REPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw new StatusException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); + throw new ServiceException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw new StatusException("Unexpected error", ex, StatusCodes.ERROR); + throw new ServiceException("Unexpected error", ex, StatusCodes.ERROR); } ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); status = Status.wrap(statusDetails.getStatus()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java index 6fce8568..5f0f8092 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -60,7 +60,7 @@ public EmeraldMR2SearchStrategy(InternalCriteria criteria, } @Override - public Collection searchNext() throws StatusException { + public Collection searchNext() throws ServiceException { int limit = mInitialCriteria.getLimit(); int offset = mInitialCriteria.getOffset(); @@ -76,7 +76,7 @@ public boolean hasNext() { return !mEndReached; } - private void calculateDisposition(int offset) throws StatusException { + private void calculateDisposition(int offset) throws ServiceException { boolean serverDispositionUndefined = offset >= mServerDisposition; if (serverDispositionUndefined) { internalSearch(offset); @@ -84,7 +84,7 @@ private void calculateDisposition(int offset) throws StatusException { } @NotNull - private Collection internalSearch(int limit) throws StatusException { + private Collection internalSearch(int limit) throws ServiceException { int count = 0; while (mBuffer.size() < limit && hasNext()) { SearchResult response = performSearch(limit); @@ -112,7 +112,7 @@ private Collection internalSearch(int limit) throws StatusException { } @NotNull - private SearchResult performSearch(int limit) throws StatusException { + private SearchResult performSearch(int limit) throws ServiceException { InternalCriteria nextCriteria = mInitialCriteria.newBuilder() .offset(mServerDisposition) .limit(limit) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java index 83b0c9f2..a4d7a9a3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -59,7 +59,7 @@ public EmeraldMR3SearchStrategy(InternalCriteria criteria, SearchUseCase searchU } @Override - public Collection searchNext() throws StatusException { + public Collection searchNext() throws ServiceException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } @@ -76,7 +76,7 @@ public boolean hasNext() { } @NotNull - private Collection performLookup() throws StatusException { + private Collection performLookup() throws ServiceException { InternalCriteria newSearchCriteria = createNextCriteria(); SearchResult result = performApiCall(newSearchCriteria); updateInternalOffset(result); @@ -84,11 +84,11 @@ private Collection performLookup() throws StatusException { } @NotNull - private SearchResult performApiCall(InternalCriteria newSearchCriteria) throws StatusException { + private SearchResult performApiCall(InternalCriteria newSearchCriteria) throws ServiceException { return mSearchUseCase.performSearch(newSearchCriteria); } - private void defineInternalOffset() throws StatusException { + private void defineInternalOffset() throws ServiceException { if (mUserOffset == 0) { mInternalOffset = mUserOffset; } else { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index ef8d9a59..16086007 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -38,7 +38,7 @@ * @since 2.0 */ interface SearchStrategy { - Collection searchNext() throws StatusException; + Collection searchNext() throws ServiceException; boolean hasNext(); class Factory { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index ef607ca5..09e16814 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -37,6 +37,6 @@ */ public interface SearchTask { @NotNull - Collection nextLookup() throws StatusException; + Collection nextLookup() throws ServiceException; boolean hasNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index ce74ca64..f58c1394 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -60,7 +60,7 @@ final class SearchTaskImpl implements SearchTask { @NotNull @Override - public Collection nextLookup() throws StatusException { + public Collection nextLookup() throws ServiceException { return defineSearchStrategy().searchNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 6f828d3f..b8e39fc4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -27,8 +27,8 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.exception.StatusException; -import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; @@ -60,7 +60,7 @@ public SearchUseCase( } @NotNull - public SearchResult performSearch(@NotNull InternalCriteria criteria) throws StatusException { + public SearchResult performSearch(@NotNull InternalCriteria criteria) throws ServiceException { ResourceSearchResult response = null; try { response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); @@ -75,9 +75,9 @@ public SearchResult performSearch(@NotNull InternalCriteria criteria) throws Sta return searchResult; } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index f14d673a..3a11d363 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -29,8 +29,8 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.exception.StatusException; -import com.jaspersoft.android.sdk.service.internal.StatusExceptionMapper; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.TestOnly; @@ -59,36 +59,36 @@ public static ServerInfoService create(String baseUrl) { return new ServerInfoService(restApi, ServerInfoTransformer.get()); } - public ServerInfo requestServerInfo() throws StatusException { + public ServerInfo requestServerInfo() throws ServiceException { try { ServerInfoData response = mRestApi.requestServerInfo(); return mTransformer.transform(response); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } - public ServerVersion requestServerVersion() throws StatusException { + public ServerVersion requestServerVersion() throws ServiceException { try { String version = mRestApi.requestVersion(); return ServerVersion.defaultParser().parse(version); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } - public SimpleDateFormat requestServerDateTimeFormat() throws StatusException { + public SimpleDateFormat requestServerDateTimeFormat() throws ServiceException { try { String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); return new SimpleDateFormat(dateTimeFormat); } catch (HttpException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } catch (IOException e) { - throw StatusExceptionMapper.transform(e); + throw ServiceExceptionMapper.transform(e); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java similarity index 59% rename from core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java index bd5567db..18129442 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/StatusExceptionMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.junit.Before; import org.junit.Test; @@ -51,7 +51,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({ErrorDescriptor.class}) -public class StatusExceptionMapperTest { +public class ServiceExceptionMapperTest { @Mock HttpException mHttpException; @Mock @@ -65,10 +65,10 @@ public void setUp() throws Exception { @Test public void testTransformIOException() throws Exception { IOException ioException = new IOException("Socket timed out", new SocketTimeoutException()); - StatusException statusException = StatusExceptionMapper.transform(ioException); - assertThat(statusException.code(), is(StatusCodes.NETWORK_ERROR)); - assertThat(statusException.getMessage(), is("Failed to perform network request. Check network!")); - assertThat(statusException.getCause(), is(instanceOf(IOException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(ioException); + assertThat(serviceException.code(), is(StatusCodes.NETWORK_ERROR)); + assertThat(serviceException.getMessage(), is("Failed to perform network request. Check network!")); + assertThat(serviceException.getCause(), is(instanceOf(IOException.class))); } @Test @@ -76,10 +76,10 @@ public void testTransform500HttpException() throws Exception { when(mHttpException.code()).thenReturn(500); when(mHttpException.getDescriptor()).thenReturn(null); - StatusException statusException = StatusExceptionMapper.transform(mHttpException); - assertThat(statusException.code(), is(StatusCodes.INTERNAL_ERROR)); - assertThat(statusException.getMessage(), is("Server encountered unexpected error")); - assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + assertThat(serviceException.code(), is(StatusCodes.INTERNAL_ERROR)); + assertThat(serviceException.getMessage(), is("Server encountered unexpected error")); + assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @Test @@ -87,10 +87,10 @@ public void testTransform404HttpException() throws Exception { when(mHttpException.code()).thenReturn(404); when(mHttpException.getDescriptor()).thenReturn(null); - StatusException statusException = StatusExceptionMapper.transform(mHttpException); - assertThat(statusException.code(), is(StatusCodes.CLIENT_ERROR)); - assertThat(statusException.getMessage(), is("Service exist but requested entity not found")); - assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + assertThat(serviceException.code(), is(StatusCodes.CLIENT_ERROR)); + assertThat(serviceException.getMessage(), is("Service exist but requested entity not found")); + assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @Test @@ -98,10 +98,10 @@ public void testTransform400HttpException() throws Exception { when(mHttpException.code()).thenReturn(400); when(mHttpException.getDescriptor()).thenReturn(null); - StatusException statusException = StatusExceptionMapper.transform(mHttpException); - assertThat(statusException.code(), is(StatusCodes.CLIENT_ERROR)); - assertThat(statusException.getMessage(), is("Some parameters in request not valid")); - assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + assertThat(serviceException.code(), is(StatusCodes.CLIENT_ERROR)); + assertThat(serviceException.getMessage(), is("Some parameters in request not valid")); + assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @Test @@ -109,10 +109,10 @@ public void testTransform403HttpException() throws Exception { when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenReturn(null); - StatusException statusException = StatusExceptionMapper.transform(mHttpException); - assertThat(statusException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); - assertThat(statusException.getMessage(), is("User has no access to resource")); - assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + assertThat(serviceException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); + assertThat(serviceException.getMessage(), is("User has no access to resource")); + assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @Test @@ -120,10 +120,10 @@ public void testTransform401HttpException() throws Exception { when(mHttpException.code()).thenReturn(401); when(mHttpException.getDescriptor()).thenReturn(null); - StatusException statusException = StatusExceptionMapper.transform(mHttpException); - assertThat(statusException.code(), is(StatusCodes.AUTHORIZATION_ERROR)); - assertThat(statusException.getMessage(), is("User is not authorized")); - assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + assertThat(serviceException.code(), is(StatusCodes.AUTHORIZATION_ERROR)); + assertThat(serviceException.getMessage(), is("User is not authorized")); + assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @Test @@ -132,9 +132,9 @@ public void testTransformWithDescriptorWithMissingKey() throws IOException { when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenReturn(mDescriptor); - StatusException statusException = StatusExceptionMapper.transform(mHttpException); - assertThat(statusException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); - assertThat(statusException.getCause(), is(instanceOf(HttpException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + assertThat(serviceException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); + assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @Test @@ -143,8 +143,8 @@ public void testTransformWillHandleIOExceptionForDescriptorMapping() throws IOEx when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenThrow(new IOException("Failed IO")); - StatusException statusException = StatusExceptionMapper.transform(mHttpException); - assertThat(statusException.code(), is(StatusCodes.NETWORK_ERROR)); - assertThat(statusException.getCause(), is(instanceOf(IOException.class))); + ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + assertThat(serviceException.code(), is(StatusCodes.NETWORK_ERROR)); + assertThat(serviceException.getCause(), is(instanceOf(IOException.class))); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 16d09e27..590e088d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -35,7 +35,7 @@ import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.junit.Before; import org.junit.Rule; @@ -141,7 +141,7 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { try { objectUnderTest.export(exportCriteria); fail("Should throw Status exception"); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); } } @@ -153,7 +153,7 @@ public void testRunShouldThrowFailedIfStatusFailed() throws Exception { try { objectUnderTest.export(exportCriteria); fail("Should throw Status exception"); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); } } @@ -166,7 +166,7 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { try { objectUnderTest.export(exportCriteria); fail("Should throw Status exception"); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_CANCELLED)); } } @@ -179,7 +179,7 @@ public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { try { objectUnderTest.export(exportCriteria); fail("Should throw Status exception"); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_CANCELLED)); } } @@ -234,7 +234,7 @@ public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() throws Exce try { objectUnderTest.waitForReportCompletion(); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); } } @@ -245,7 +245,7 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception try { objectUnderTest.waitForReportCompletion(); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 4aa613ed..3d48769b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -32,7 +32,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.exception.StatusException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.junit.Before; import org.junit.Rule; @@ -122,7 +122,7 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { try { objectUnderTest.run("/report/uri", configuration); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); } } @@ -134,7 +134,7 @@ public void testRunShouldThrowFailedIfStatusFailed() throws Exception { try { objectUnderTest.run("/report/uri", configuration); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); } } @@ -145,7 +145,7 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { try { objectUnderTest.run("/report/uri", configuration); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); } } @@ -157,7 +157,7 @@ public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { try { objectUnderTest.run("/report/uri", configuration); - } catch (StatusException ex) { + } catch (ServiceException ex) { assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); } } From 9e13d00eccd2d7ea1cf424d866fd33b5fe71c3e5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 19 Nov 2015 11:51:35 +0200 Subject: [PATCH 280/457] Remove redundant check from spring authorization --- .../android/sdk/network/AuthenticationRestApiImpl.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java index 2d1c02f9..e3674cbf 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java @@ -75,9 +75,6 @@ public String authenticate(@NotNull final String username, return CookieExtractor.extract(response); } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request String location = response.headers().get("Location"); - if (location == null) { - throw new IllegalStateException("Location HEADER is missing please contact JRS admin"); - } HttpUrl url = HttpUrl.parse(location); String errorQueryParameter = url.queryParameter("error"); if (errorQueryParameter == null) { From 177b99a95e40a8f067b1ee2f1566217c613f5289 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 19 Nov 2015 11:54:21 +0200 Subject: [PATCH 281/457] Rename StausCodes.ERROR -> StatusCodes.UNDEFINED_ERROR --- .../jaspersoft/android/sdk/service/exception/StatusCodes.java | 2 +- .../android/sdk/service/internal/ServiceExceptionMapper.java | 2 +- .../android/sdk/service/report/ReportExecution.java | 4 ++-- .../jaspersoft/android/sdk/service/report/ReportService.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java index e3bc2ff6..66515339 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java @@ -29,7 +29,7 @@ * @since 2.0 */ public final class StatusCodes { - public static final int ERROR = 1; + public static final int UNDEFINED_ERROR = 1; public static final int NETWORK_ERROR = 2; public static final int CLIENT_ERROR = 3; public static final int INTERNAL_ERROR = 4; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java index 0a272226..c609180b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java @@ -71,7 +71,7 @@ private static ServiceException mapHttpCodesToState(HttpException e) { case 400: return new ServiceException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); default: - return new ServiceException("The operation failed with no more detailed information", e, StatusCodes.ERROR); + return new ServiceException("The operation failed with no more detailed information", e, StatusCodes.UNDEFINED_ERROR); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 4d99bc97..257faf56 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -121,7 +121,7 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) t try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.ERROR); + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } status = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); @@ -145,7 +145,7 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.ERROR); + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } status = Status.wrap(details.getStatus()); descriptor = details.getErrorDescriptor(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 3f59d91c..2f76629d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -115,7 +115,7 @@ private void waitForReportExecutionStart(String reportUri, ReportExecutionDescri try { Thread.sleep(mDelay); } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.ERROR); + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); status = Status.wrap(statusDetails.getStatus()); From 5d5f2f8531ac0a5c68c02c2b2271df8c42c10976 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 19 Nov 2015 11:54:48 +0200 Subject: [PATCH 282/457] Force private constructor for StatusCodes --- .../jaspersoft/android/sdk/service/exception/StatusCodes.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java index 66515339..67c35670 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java @@ -44,4 +44,6 @@ public final class StatusCodes { // REPORT public static final int REPORT_EXECUTION_CANCELLED = 201; public static final int REPORT_EXECUTION_FAILED = 202; + + private StatusCodes() {} } From b0278f8af9851130865e5e739c5c30d56d185711 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 19 Nov 2015 11:56:03 +0200 Subject: [PATCH 283/457] Drop unnecessary check for Location header in tests --- .../android/sdk/network/AuthenticationRestApiTest.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index 017d829f..6794a2d9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -99,16 +99,6 @@ public void shouldRiseErrorForHttpException() throws Exception { mRestApi.authenticate("joeuser", "joeuser", "null", null); } - @Test - public void shouldRiseIllegalExceptionIfLocationHeaderIsMissing() throws Exception { - mExpectedException.expect(IllegalStateException.class); - mExpectedException.expectMessage("Location HEADER is missing please contact JRS admin"); - - mWebMockRule.enqueue(MockResponseFactory.create302().addHeader("Set-Cookie", "cookie1")); - - mRestApi.authenticate("joeuser", "joeuser", "null", null); - } - @Test public void shouldReturnEncryptionKeyIfApiAvailable() throws Exception { MockResponse anonymousCookie = MockResponseFactory.create200() From d01c90b9cf94ed7091c58c4480390013562945c4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 25 Nov 2015 11:30:15 +0200 Subject: [PATCH 284/457] Update server versioning approach --- .../data/server/DefaultVersionParser.java | 8 ++- .../sdk/service/data/server/FeatureSet.java | 70 ------------------- .../sdk/service/data/server/ServerInfo.java | 26 +++---- .../service/data/server/ServerVersion.java | 41 +++++------ .../service/repository/SearchStrategy.java | 6 +- .../sdk/service/server/ServerInfoService.java | 2 +- .../service/server/ServerInfoTransformer.java | 33 +++++++-- .../data/server/ServerVersionTest.java | 40 +++++------ .../repository/SearchStrategyTest.java | 4 +- .../server/ServerInfoTransformerTest.java | 5 +- 10 files changed, 95 insertions(+), 140 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java index cda48556..5ab00e9d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java @@ -24,16 +24,18 @@ package com.jaspersoft.android.sdk.service.data.server; +import org.jetbrains.annotations.NotNull; + import java.math.BigDecimal; /** * @author Tom Koptel * @since 2.0 */ -enum DefaultVersionParser implements ServerVersion.Parser { +enum DefaultVersionParser { INSTANCE; - @Override + @NotNull public ServerVersion parse(String rawVersion) { double value = convertToDouble(rawVersion); ServerVersion serverVersion = findReleaseByCode(value); @@ -43,7 +45,7 @@ public ServerVersion parse(String rawVersion) { private ServerVersion findReleaseByCode(final double versionCode) { for (ServerVersion release : ServerVersion.values()) { - if (Double.compare(release.getVersionCode(), versionCode) == 0) { + if (Double.compare(release.code(), versionCode) == 0) { return release; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java deleted file mode 100644 index bd68f110..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/FeatureSet.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.server; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class FeatureSet { - private final String mRawData; - - FeatureSet(String rawData) { - mRawData = rawData; - } - - public Set asSet() { - String[] split = mRawData.split(" "); - return new HashSet<>(Arrays.asList(split)); - } - - public String asString() { - return mRawData; - } - - public static FeatureSet parse(String rawString) { - return new FeatureSet(rawString); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - FeatureSet that = (FeatureSet) o; - - return !(mRawData != null ? !mRawData.equals(that.mRawData) : that.mRawData != null); - - } - - @Override - public int hashCode() { - return mRawData != null ? mRawData.hashCode() : 0; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index 5d123e74..62eb819b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.data.server; import java.text.SimpleDateFormat; +import java.util.Set; /** * @author Tom Koptel @@ -38,7 +39,7 @@ public class ServerInfo { private String licenseType; private String build; private String editionName; - private FeatureSet features; + private Set features; public String getBuild() { return build; @@ -52,24 +53,24 @@ public SimpleDateFormat getDateFormatPattern() { return dateFormatPattern; } - public void setDateFormatPattern(String dateFormatPattern) { - this.dateFormatPattern = new SimpleDateFormat(dateFormatPattern); + public void setDateFormatPattern(SimpleDateFormat dateFormatPattern) { + this.dateFormatPattern = dateFormatPattern; } public SimpleDateFormat getDatetimeFormatPattern() { return datetimeFormatPattern; } - public void setDatetimeFormatPattern(String datetimeFormatPattern) { - this.datetimeFormatPattern = new SimpleDateFormat(datetimeFormatPattern); + public void setDatetimeFormatPattern(SimpleDateFormat datetimeFormatPattern) { + this.datetimeFormatPattern = datetimeFormatPattern; } public ServerEdition getEdition() { return edition; } - public void setEdition(String edition) { - this.edition = ServerEdition.valueOf(edition); + public void setEdition(ServerEdition edition) { + this.edition = edition; } public String getEditionName() { @@ -80,12 +81,12 @@ public void setEditionName(String editionName) { this.editionName = editionName; } - public FeatureSet getFeatures() { + public Set getFeatures() { return features; } - public void setFeatures(String features) { - this.features = FeatureSet.parse(features); + public void setFeatures(Set features) { + this.features = features; } public String getLicenseType() { @@ -100,8 +101,7 @@ public ServerVersion getVersion() { return version; } - public void setVersion(String version) { - ServerVersion.Parser parser = ServerVersion.defaultParser(); - this.version = parser.parse(version); + public void setVersion(ServerVersion version) { + this.version = version; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java index 649dd682..195f841e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -25,20 +25,23 @@ package com.jaspersoft.android.sdk.service.data.server; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 */ public enum ServerVersion { UNKNOWN(0d), - EMERALD(5.0d), - EMERALD_MR1(5.2d), - EMERALD_MR2(5.5d), - EMERALD_MR3(5.6d), - EMERALD_MR4(5.61d), - AMBER(6.0d), - AMBER_MR1(6.01d), - AMBER_MR2(6.1d); + v5(5.0d), + v5_2(5.2d), + v5_5(5.5d), + v5_6(5.6d), + v5_61(5.61d), + v6(6.0d), + v6_0_1(6.01d), + v6_1(6.1d), + v6_1_1(6.11d); private double mVersionCode; private String mRawValue; @@ -47,14 +50,6 @@ public enum ServerVersion { this.mVersionCode = versionCode; } - public String getRawValue() { - return mRawValue; - } - - public double getVersionCode() { - return mVersionCode; - } - void setVersionCode(double versionCode) { mVersionCode = versionCode; } @@ -63,11 +58,17 @@ void setRawValue(String rawValue) { mRawValue = rawValue; } - public static Parser defaultParser() { - return DefaultVersionParser.INSTANCE; + public double code() { + return mVersionCode; + } + + @NotNull + public String rawCode() { + return mRawValue; } - public interface Parser { - ServerVersion parse(String rawVersion); + @NotNull + public static ServerVersion parse(String versionName) { + return DefaultVersionParser.INSTANCE.parse(versionName); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 16086007..3b733ef7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -50,13 +50,13 @@ public static SearchStrategy get(InternalCriteria criteria, ResourceMapper resourceMapper = new ResourceMapper(); SearchUseCase searchUseCase = new SearchUseCase(resourceMapper, repositoryRestApi, tokenProvider, infoProvider); - if (version.getVersionCode() <= ServerVersion.EMERALD_MR2.getVersionCode()) { + if (version.code() <= ServerVersion.v5_5.code()) { return new EmeraldMR2SearchStrategy(criteria, searchUseCase); } - if (version.getVersionCode() >= ServerVersion.EMERALD_MR3.getVersionCode()) { + if (version.code() >= ServerVersion.v5_6.code()) { return new EmeraldMR3SearchStrategy(criteria, searchUseCase); } - throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + version.getRawValue()); + throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + version.rawCode()); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 3a11d363..7d071871 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -73,7 +73,7 @@ public ServerInfo requestServerInfo() throws ServiceException { public ServerVersion requestServerVersion() throws ServiceException { try { String version = mRestApi.requestVersion(); - return ServerVersion.defaultParser().parse(version); + return ServerVersion.parse(version); } catch (HttpException e) { throw ServiceExceptionMapper.transform(e); } catch (IOException e) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java index 0e43463b..742547ff 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -25,7 +25,14 @@ package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; + +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * @author Tom Koptel @@ -48,12 +55,28 @@ public static ServerInfoTransformer get() { public ServerInfo transform(ServerInfoData response) { ServerInfo serverInfo = new ServerInfo(); serverInfo.setBuild(response.getBuild()); - serverInfo.setDateFormatPattern(response.getDateFormatPattern()); - serverInfo.setDatetimeFormatPattern(response.getDatetimeFormatPattern()); - serverInfo.setVersion(response.getVersion()); - serverInfo.setEdition(response.getEdition()); + + SimpleDateFormat dateDateFormat = new SimpleDateFormat(response.getDateFormatPattern()); + serverInfo.setDateFormatPattern(dateDateFormat); + + SimpleDateFormat dateTimeFormat = new SimpleDateFormat(response.getDatetimeFormatPattern()); + serverInfo.setDatetimeFormatPattern(dateTimeFormat); + + ServerVersion release = ServerVersion.parse(response.getVersion()); + serverInfo.setVersion(release); + + ServerEdition edition = ServerEdition.valueOf(response.getEdition()); + serverInfo.setEdition(edition); serverInfo.setEditionName(response.getEditionName()); - serverInfo.setFeatures(response.getFeatures()); + + Set features = parseFeatureSet(response.getFeatures()); + serverInfo.setFeatures(features); + return serverInfo; } + + private Set parseFeatureSet(String features) { + String[] split = features.split(" "); + return new HashSet(Arrays.asList(split)); + } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java index a38a4ac0..d203585a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java @@ -41,35 +41,35 @@ public class ServerVersionTest { @Test @Parameters({ - "5.0.0, EMERALD", - "5.2.0, EMERALD_MR1", - "5.5.0, EMERALD_MR2", - "5.6.0, EMERALD_MR3", - "5.6.1, EMERALD_MR4", - "6.0, AMBER", - "6.0.1, AMBER_MR1", - "6.1, AMBER_MR2", + "5.0.0, v5", + "5.2.0, v5_2", + "5.5.0, v5_5", + "5.6.0, v5_6", + "5.6.1, v5_61", + "6.0, v6", + "6.0.1, v6_0_1", + "6.1, v6_1", }) public void shouldParseSemanticVersioning(String versionCode, String enumName) { ServerVersion expectedRelease = ServerVersion.valueOf(enumName); - ServerVersion resultRelease = ServerVersion.defaultParser().parse(versionCode); + ServerVersion resultRelease = ServerVersion.parse(versionCode); assertThat(resultRelease, is(expectedRelease)); } @Test @Parameters({ - "5.0, EMERALD", - "5.2, EMERALD_MR1", - "5.5, EMERALD_MR2", - "5.6, EMERALD_MR3", - "5.6.1, EMERALD_MR4", - "6.0, AMBER", - "6.0.1, AMBER_MR1", - "6.1, AMBER_MR2", + "5.0, v5", + "5.2, v5_2", + "5.5, v5_5", + "5.6, v5_6", + "5.6.1, v5_61", + "6.0, v6", + "6.0.1, v6_0_1", + "6.1, v6_1", }) public void shouldParseCode(String versionCode, String enumName) { ServerVersion expectedRelease = ServerVersion.valueOf(enumName); - ServerVersion resultRelease = ServerVersion.defaultParser().parse(versionCode); + ServerVersion resultRelease = ServerVersion.parse(versionCode); assertThat(resultRelease, is(expectedRelease)); } @@ -79,7 +79,7 @@ public void shouldParseCode(String versionCode, String enumName) { "5.6.0-BETA", }) public void shouldParseNonSemanticVersioning(String nonSemanticVersion) { - ServerVersion resultRelease = ServerVersion.defaultParser().parse(nonSemanticVersion); - assertThat(resultRelease, is(ServerVersion.EMERALD_MR3)); + ServerVersion resultRelease = ServerVersion.parse(nonSemanticVersion); + assertThat(resultRelease, is(ServerVersion.v5_6)); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index 12ccee23..099655f6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -68,7 +68,7 @@ public void before() { "5.5", }) public void factoryCreatesEmeraldMR2Strategy(String version) { - ServerVersion serverVersion = ServerVersion.defaultParser().parse(version); + ServerVersion serverVersion = ServerVersion.parse(version); when(mInfoProvider.provideVersion()).thenReturn(serverVersion); SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); @@ -81,7 +81,7 @@ public void factoryCreatesEmeraldMR2Strategy(String version) { "6.0.1", }) public void factoryCreatesEmeraldMR3Strategy(String version) { - ServerVersion serverVersion = ServerVersion.defaultParser().parse(version); + ServerVersion serverVersion = ServerVersion.parse(version); when(mInfoProvider.provideVersion()).thenReturn(serverVersion); SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index 04550e53..da5f779b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.server.ServerInfoTransformer; import org.junit.Before; import org.junit.Test; @@ -90,7 +89,7 @@ public void shouldTransformDateTimeFormatProperty() { @Test public void shouldTransformServerVersionProperty() { ServerInfo info = transformerUnderTest.transform(mServerInfoData); - assertThat(info.getVersion(), is(ServerVersion.AMBER_MR2)); + assertThat(info.getVersion(), is(ServerVersion.v6_1)); } @Test @@ -108,7 +107,7 @@ public void shouldTransformServerEditionNameProperty() { @Test public void shouldTransformFeaturesProperty() { ServerInfo info = transformerUnderTest.transform(mServerInfoData); - assertThat(info.getFeatures().asSet(), contains("Fusion")); + assertThat(info.getFeatures(), contains("Fusion")); } } From 96b9205b9ba33f2a374e86661ba86a04157f0a66 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 25 Nov 2015 12:17:42 +0200 Subject: [PATCH 285/457] Fix server version 5_61 -> 5_6_1 --- .../android/sdk/service/data/server/ServerVersion.java | 2 +- .../android/sdk/service/data/server/ServerVersionTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java index 195f841e..de87e12c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -37,7 +37,7 @@ public enum ServerVersion { v5_2(5.2d), v5_5(5.5d), v5_6(5.6d), - v5_61(5.61d), + v5_6_1(5.61d), v6(6.0d), v6_0_1(6.01d), v6_1(6.1d), diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java index d203585a..c94fdb80 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java @@ -45,7 +45,7 @@ public class ServerVersionTest { "5.2.0, v5_2", "5.5.0, v5_5", "5.6.0, v5_6", - "5.6.1, v5_61", + "5.6.1, v5_6_1", "6.0, v6", "6.0.1, v6_0_1", "6.1, v6_1", @@ -62,7 +62,7 @@ public void shouldParseSemanticVersioning(String versionCode, String enumName) { "5.2, v5_2", "5.5, v5_5", "5.6, v5_6", - "5.6.1, v5_61", + "5.6.1, v5_6_1", "6.0, v6", "6.0.1, v6_0_1", "6.1, v6_1", From 311a93580d377168fbcfbbcbfa590ea3fce204c1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 25 Nov 2015 12:57:20 +0200 Subject: [PATCH 286/457] Drop ServerVersion enum --- .../sdk/service/data/server/ServerInfo.java | 6 +- .../service/data/server/ServerVersion.java | 74 ---------------- .../service/repository/SearchStrategy.java | 10 +-- .../sdk/service/server/InfoProvider.java | 3 +- .../sdk/service/server/ServerInfoService.java | 5 +- .../service/server/ServerInfoTransformer.java | 5 +- .../VersionParser.java} | 26 +----- .../data/server/ServerVersionTest.java | 85 ------------------- .../repository/SearchStrategyTest.java | 11 +-- .../server/ServerInfoTransformerTest.java | 3 +- .../VersionParserTest.java} | 8 +- 11 files changed, 24 insertions(+), 212 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java rename core/src/main/java/com/jaspersoft/android/sdk/service/{data/server/DefaultVersionParser.java => server/VersionParser.java} (72%) delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java rename core/src/test/java/com/jaspersoft/android/sdk/service/{data/server/DefaultVersionParserTest.java => server/VersionParserTest.java} (89%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index 62eb819b..7deb0bce 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -34,7 +34,7 @@ public class ServerInfo { private SimpleDateFormat dateFormatPattern; private SimpleDateFormat datetimeFormatPattern; - private ServerVersion version; + private double version; private ServerEdition edition; private String licenseType; private String build; @@ -97,11 +97,11 @@ public void setLicenseType(String licenseType) { this.licenseType = licenseType; } - public ServerVersion getVersion() { + public double getVersion() { return version; } - public void setVersion(ServerVersion version) { + public void setVersion(double version) { this.version = version; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java deleted file mode 100644 index de87e12c..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.server; - - -import org.jetbrains.annotations.NotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public enum ServerVersion { - UNKNOWN(0d), - v5(5.0d), - v5_2(5.2d), - v5_5(5.5d), - v5_6(5.6d), - v5_6_1(5.61d), - v6(6.0d), - v6_0_1(6.01d), - v6_1(6.1d), - v6_1_1(6.11d); - - private double mVersionCode; - private String mRawValue; - - ServerVersion(double versionCode) { - this.mVersionCode = versionCode; - } - - void setVersionCode(double versionCode) { - mVersionCode = versionCode; - } - - void setRawValue(String rawValue) { - mRawValue = rawValue; - } - - public double code() { - return mVersionCode; - } - - @NotNull - public String rawCode() { - return mRawValue; - } - - @NotNull - public static ServerVersion parse(String versionName) { - return DefaultVersionParser.INSTANCE.parse(versionName); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 3b733ef7..710a2725 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -29,7 +29,6 @@ import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.util.Collection; @@ -46,18 +45,17 @@ public static SearchStrategy get(InternalCriteria criteria, RepositoryRestApi repositoryRestApi, InfoProvider infoProvider, TokenProvider tokenProvider) { - ServerVersion version = infoProvider.provideVersion(); + double version = infoProvider.provideVersion(); ResourceMapper resourceMapper = new ResourceMapper(); SearchUseCase searchUseCase = new SearchUseCase(resourceMapper, repositoryRestApi, tokenProvider, infoProvider); - if (version.code() <= ServerVersion.v5_5.code()) { + if (version <= 5.5d) { return new EmeraldMR2SearchStrategy(criteria, searchUseCase); } - if (version.code() >= ServerVersion.v5_6.code()) { + if (version >= 5.6d) { return new EmeraldMR3SearchStrategy(criteria, searchUseCase); } - throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + version.rawCode()); + throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + version); } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java index a8e34024..a15149f9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.jetbrains.annotations.NotNull; @@ -43,7 +42,7 @@ public interface InfoProvider { @NotNull ServerInfo provideInfo(); @NotNull - ServerVersion provideVersion(); + double provideVersion(); @NotNull SimpleDateFormat provideDateTimeFormat(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 7d071871..e2e5f162 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; @@ -70,10 +69,10 @@ public ServerInfo requestServerInfo() throws ServiceException { } } - public ServerVersion requestServerVersion() throws ServiceException { + public double requestServerVersion() throws ServiceException { try { String version = mRestApi.requestVersion(); - return ServerVersion.parse(version); + return VersionParser.INSTANCE.toDouble(version); } catch (HttpException e) { throw ServiceExceptionMapper.transform(e); } catch (IOException e) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java index 742547ff..aa55010e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -27,7 +27,6 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -62,8 +61,8 @@ public ServerInfo transform(ServerInfoData response) { SimpleDateFormat dateTimeFormat = new SimpleDateFormat(response.getDatetimeFormatPattern()); serverInfo.setDatetimeFormatPattern(dateTimeFormat); - ServerVersion release = ServerVersion.parse(response.getVersion()); - serverInfo.setVersion(release); + double version = VersionParser.INSTANCE.toDouble(response.getVersion()); + serverInfo.setVersion(version); ServerEdition edition = ServerEdition.valueOf(response.getEdition()); serverInfo.setEdition(edition); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java similarity index 72% rename from core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java index 5ab00e9d..a6fa8fc6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParser.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java @@ -22,9 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.data.server; - -import org.jetbrains.annotations.NotNull; +package com.jaspersoft.android.sdk.service.server; import java.math.BigDecimal; @@ -32,28 +30,10 @@ * @author Tom Koptel * @since 2.0 */ -enum DefaultVersionParser { +enum VersionParser { INSTANCE; - @NotNull - public ServerVersion parse(String rawVersion) { - double value = convertToDouble(rawVersion); - ServerVersion serverVersion = findReleaseByCode(value); - serverVersion.setRawValue(rawVersion); - return serverVersion; - } - - private ServerVersion findReleaseByCode(final double versionCode) { - for (ServerVersion release : ServerVersion.values()) { - if (Double.compare(release.code(), versionCode) == 0) { - return release; - } - } - ServerVersion.UNKNOWN.setVersionCode(versionCode); - return ServerVersion.UNKNOWN; - } - - double convertToDouble(String version) { + public double toDouble(String version) { double versionCode = 0d; // update version code if (version != null) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java deleted file mode 100644 index c94fdb80..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.server; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(JUnitParamsRunner.class) -public class ServerVersionTest { - @Test - @Parameters({ - "5.0.0, v5", - "5.2.0, v5_2", - "5.5.0, v5_5", - "5.6.0, v5_6", - "5.6.1, v5_6_1", - "6.0, v6", - "6.0.1, v6_0_1", - "6.1, v6_1", - }) - public void shouldParseSemanticVersioning(String versionCode, String enumName) { - ServerVersion expectedRelease = ServerVersion.valueOf(enumName); - ServerVersion resultRelease = ServerVersion.parse(versionCode); - assertThat(resultRelease, is(expectedRelease)); - } - - @Test - @Parameters({ - "5.0, v5", - "5.2, v5_2", - "5.5, v5_5", - "5.6, v5_6", - "5.6.1, v5_6_1", - "6.0, v6", - "6.0.1, v6_0_1", - "6.1, v6_1", - }) - public void shouldParseCode(String versionCode, String enumName) { - ServerVersion expectedRelease = ServerVersion.valueOf(enumName); - ServerVersion resultRelease = ServerVersion.parse(versionCode); - assertThat(resultRelease, is(expectedRelease)); - } - - @Test - @Parameters({ - "5.6.0 Preview", - "5.6.0-BETA", - }) - public void shouldParseNonSemanticVersioning(String nonSemanticVersion) { - ServerVersion resultRelease = ServerVersion.parse(nonSemanticVersion); - assertThat(resultRelease, is(ServerVersion.v5_6)); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index 099655f6..e77fe01e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -27,7 +27,6 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.server.InfoProvider; import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; @@ -65,11 +64,10 @@ public void before() { @Test @Parameters({ "5.0", - "5.5", + "5.5" }) public void factoryCreatesEmeraldMR2Strategy(String version) { - ServerVersion serverVersion = ServerVersion.parse(version); - when(mInfoProvider.provideVersion()).thenReturn(serverVersion); + when(mInfoProvider.provideVersion()).thenReturn(Double.valueOf(version)); SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); @@ -78,11 +76,10 @@ public void factoryCreatesEmeraldMR2Strategy(String version) { @Test @Parameters({ "6.0", - "6.0.1", + "6.1" }) public void factoryCreatesEmeraldMR3Strategy(String version) { - ServerVersion serverVersion = ServerVersion.parse(version); - when(mInfoProvider.provideVersion()).thenReturn(serverVersion); + when(mInfoProvider.provideVersion()).thenReturn(Double.valueOf(version)); SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index da5f779b..1df3b53e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -27,7 +27,6 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; @@ -89,7 +88,7 @@ public void shouldTransformDateTimeFormatProperty() { @Test public void shouldTransformServerVersionProperty() { ServerInfo info = transformerUnderTest.transform(mServerInfoData); - assertThat(info.getVersion(), is(ServerVersion.v6_1)); + assertThat(info.getVersion(), is(6.1d)); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java similarity index 89% rename from core/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java index 8d6c7aec..56f1dc9d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/DefaultVersionParserTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.data.server; +package com.jaspersoft.android.sdk.service.server; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,7 +38,7 @@ * @since 2.0 */ @RunWith(JUnitParamsRunner.class) -public class DefaultVersionParserTest { +public class VersionParserTest { @Test @Parameters({ "5.0.0, 5", @@ -54,7 +54,7 @@ public class DefaultVersionParserTest { }) public void shouldParseSemanticVersioning(String versionCode, String expected) { double expectedCode = Double.valueOf(expected); - double resultCode = DefaultVersionParser.INSTANCE.convertToDouble(versionCode); + double resultCode = VersionParser.INSTANCE.toDouble(versionCode); assertThat(resultCode, is(expectedCode)); } @@ -69,7 +69,7 @@ public void shouldParseSemanticVersioning(String versionCode, String expected) { }) public void shouldParseLongSemanticVersioning(String versionCode, String expected) { double expectedCode = Double.valueOf(expected); - double resultCode = DefaultVersionParser.INSTANCE.convertToDouble(versionCode); + double resultCode = VersionParser.INSTANCE.toDouble(versionCode); assertThat(resultCode, is(expectedCode)); } } \ No newline at end of file From 504bc741ee78a492e79020498492462a23890d90 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 25 Nov 2015 14:05:31 +0200 Subject: [PATCH 287/457] Add configuration for read/connect timeouts --- .../android/sdk/network/ClientBuilder.java | 16 ++++++++++++++++ .../android/sdk/network/GenericBuilder.java | 14 +++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java index bc418b27..85bedae5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java @@ -26,6 +26,8 @@ import com.squareup.okhttp.OkHttpClient; +import java.util.concurrent.TimeUnit; + /** * @author Tom Koptel * @since 2.0 @@ -33,6 +35,8 @@ final class ClientBuilder { private final OkHttpClient mOkHttpClient; private RestApiLog mLog = RestApiLog.NONE; + private long connectTimeout = 10000; + private long readTimeout = 10000; public ClientBuilder() { mOkHttpClient = new OkHttpClient(); @@ -43,7 +47,19 @@ public ClientBuilder setLog(RestApiLog logger) { return this; } + public ClientBuilder connectionTimeOut(long timeout) { + connectTimeout = timeout; + return this; + } + + public ClientBuilder readTimeout(long timeout) { + readTimeout = timeout; + return this; + } + public OkHttpClient build() { + mOkHttpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS); + mOkHttpClient.setConnectTimeout(connectTimeout, TimeUnit.MILLISECONDS); mOkHttpClient.interceptors().add(new LoggingInterceptor(mLog)); return mOkHttpClient; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java index 2a93fd0a..03be93b6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java @@ -42,7 +42,7 @@ public GenericBuilder() { @SuppressWarnings("unchecked") public TargetBuilder baseUrl(String baseUrl) { adapterBuilder.baseUrl(baseUrl); - return (TargetBuilder) this; + return (TargetBuilder) this; } @SuppressWarnings("unchecked") @@ -51,6 +51,18 @@ public TargetBuilder logger(RestApiLog log) { return (TargetBuilder) this; } + @SuppressWarnings("unchecked") + public TargetBuilder connectionTimeOut(long timeout) { + clientBuilder.connectionTimeOut(timeout); + return (TargetBuilder) this; + } + + @SuppressWarnings("unchecked") + public TargetBuilder readTimeout(long timeout) { + clientBuilder.readTimeout(timeout); + return (TargetBuilder) this; + } + void ensureDefaults() { clientBuilder.ensureDefaults(); adapterBuilder.ensureDefaults(); From 07e931cac594ba05aae2a23c4794cdc957671b06 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 25 Nov 2015 14:14:32 +0200 Subject: [PATCH 288/457] Update public API for network timeouts --- .../jaspersoft/android/sdk/network/ClientBuilder.java | 8 ++++---- .../jaspersoft/android/sdk/network/GenericBuilder.java | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java index 85bedae5..9c4629ef 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java @@ -47,13 +47,13 @@ public ClientBuilder setLog(RestApiLog logger) { return this; } - public ClientBuilder connectionTimeOut(long timeout) { - connectTimeout = timeout; + public ClientBuilder connectionTimeOut(long timeout, TimeUnit unit) { + connectTimeout = unit.toMillis(timeout); return this; } - public ClientBuilder readTimeout(long timeout) { - readTimeout = timeout; + public ClientBuilder readTimeout(long timeout, TimeUnit unit) { + readTimeout = unit.toMillis(timeout); return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java index 03be93b6..db03c293 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java @@ -26,6 +26,8 @@ import retrofit.Retrofit; +import java.util.concurrent.TimeUnit; + /** * @author Tom Koptel * @since 2.0 @@ -52,14 +54,14 @@ public TargetBuilder logger(RestApiLog log) { } @SuppressWarnings("unchecked") - public TargetBuilder connectionTimeOut(long timeout) { - clientBuilder.connectionTimeOut(timeout); + public TargetBuilder connectionTimeOut(long timeout, TimeUnit unit) { + clientBuilder.connectionTimeOut(timeout, unit); return (TargetBuilder) this; } @SuppressWarnings("unchecked") - public TargetBuilder readTimeout(long timeout) { - clientBuilder.readTimeout(timeout); + public TargetBuilder readTimeout(long timeout, TimeUnit unit) { + clientBuilder.readTimeout(timeout, unit); return (TargetBuilder) this; } From 548e256822270d959affffdc1ef17ec8a0f9c241 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 25 Nov 2015 15:39:35 +0200 Subject: [PATCH 289/457] Add factory ServerInfoService#create(ServerRestApi) --- .../android/sdk/service/server/ServerInfoService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index e2e5f162..a65f4de5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -58,6 +58,10 @@ public static ServerInfoService create(String baseUrl) { return new ServerInfoService(restApi, ServerInfoTransformer.get()); } + public static ServerInfoService create(ServerRestApi restApi) { + return new ServerInfoService(restApi, ServerInfoTransformer.get()); + } + public ServerInfo requestServerInfo() throws ServiceException { try { ServerInfoData response = mRestApi.requestServerInfo(); From c54a312c678c44e05ef7ff16850041a919d34601 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 25 Nov 2015 16:10:43 +0200 Subject: [PATCH 290/457] Add basic implementation of rest client --- .../android/sdk/service/RestClient.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java new file mode 100644 index 00000000..27633826 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class RestClient { + private final String mServerUrl; + private final int mReadTimeOut; + private final int mConnectionTimeOut; + + RestClient(String serverUrl, int readTimeOut, int connectionTimeOut) { + mServerUrl = serverUrl; + mReadTimeOut = readTimeOut; + mConnectionTimeOut = connectionTimeOut; + } + + public static class Builder { + private String mServerUrl; + private int mConnectionReadTimeOut; + private int mConnectionTimeOut; + + private Builder() { + } + + public Builder serverUrl(String serverUrl) { + mServerUrl = serverUrl; + return this; + } + + public Builder connectionReadTimeOut(int connectionReadTimeOut) { + mConnectionReadTimeOut = connectionReadTimeOut; + return this; + } + + public Builder connectionTimeOut(int connectionTimeOut) { + mConnectionTimeOut = connectionTimeOut; + return this; + } + + public RestClient create() { + return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut); + } + } +} From 01f825ca47a8fce216de5429eebbe5b09e65cf5c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 11:31:52 +0200 Subject: [PATCH 291/457] Initial session abstraction --- .../android/sdk/service/AnonymousSession.java | 75 +++++++++++++++ .../android/sdk/service/RestClient.java | 64 ++++++++++--- .../android/sdk/service/Session.java | 92 +++++++++++++++++++ .../sdk/service/auth/TokenProvider.java | 2 +- .../sdk/service/report/ReportService.java | 12 +-- .../sdk/service/server/InfoProvider.java | 8 +- .../android/sdk/service/RestClientTest.java | 51 ++++++++++ 7 files changed, 278 insertions(+), 26 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/Session.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java new file mode 100644 index 00000000..972ae614 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java @@ -0,0 +1,75 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.ServerRestApi; +import com.jaspersoft.android.sdk.service.auth.JrsAuthenticator; +import com.jaspersoft.android.sdk.service.server.ServerInfoService; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.TimeUnit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class AnonymousSession { + protected final RestClient mClient; + + private JrsAuthenticator mAuthenticator; + private ServerInfoService mInfoService; + + protected AnonymousSession(RestClient client) { + mClient = client; + } + + @NotNull + public final JrsAuthenticator authApi() { + if (mAuthenticator == null) { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() + .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) + .baseUrl(mClient.getServerUrl()) + .build(); + + mAuthenticator = JrsAuthenticator.create(restApi); + } + return mAuthenticator; + } + + @NotNull + public final ServerInfoService infoApi() { + if (mInfoService == null) { + ServerRestApi restApi = new ServerRestApi.Builder() + .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) + .baseUrl(mClient.getServerUrl()) + .build(); + mInfoService = ServerInfoService.create(restApi); + } + return mInfoService; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index 27633826..73bdac15 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -24,41 +24,79 @@ package com.jaspersoft.android.sdk.service; +import com.jaspersoft.android.sdk.service.auth.Credentials; + +import java.util.concurrent.TimeUnit; + /** * @author Tom Koptel * @since 2.0 */ public final class RestClient { private final String mServerUrl; - private final int mReadTimeOut; - private final int mConnectionTimeOut; + private final long mReadTimeOut; + private final long mConnectionTimeOut; + + private AnonymousSession mAnonymousSession; - RestClient(String serverUrl, int readTimeOut, int connectionTimeOut) { + RestClient(String serverUrl, long readTimeOut, long connectionTimeOut) { mServerUrl = serverUrl; mReadTimeOut = readTimeOut; mConnectionTimeOut = connectionTimeOut; } - public static class Builder { - private String mServerUrl; - private int mConnectionReadTimeOut; - private int mConnectionTimeOut; + public Session authenticate(Credentials credentials) { + return new Session(this, credentials); + } + + public AnonymousSession getAnonymousSession() { + if (mAnonymousSession == null) { + mAnonymousSession = new AnonymousSession(this); + } + return mAnonymousSession; + } + + public String getServerUrl() { + return mServerUrl; + } + + public long getReadTimeOut() { + return mReadTimeOut; + } + + public long getConnectionTimeOut() { + return mConnectionTimeOut; + } + public static Builder builder() { + return new Builder(); + } + + public static class Builder { private Builder() { } - public Builder serverUrl(String serverUrl) { + public ConditionalBuilder serverUrl(String serverUrl) { + return new ConditionalBuilder(serverUrl); + } + } + + public static class ConditionalBuilder { + private final String mServerUrl; + private long mConnectionReadTimeOut = TimeUnit.SECONDS.toMillis(10); + private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10);; + + private ConditionalBuilder(String serverUrl) { mServerUrl = serverUrl; - return this; } - public Builder connectionReadTimeOut(int connectionReadTimeOut) { - mConnectionReadTimeOut = connectionReadTimeOut; + public ConditionalBuilder readTimeOut(int timeOut, TimeUnit unit) { + mConnectionReadTimeOut = unit.toMillis(timeOut); return this; } - public Builder connectionTimeOut(int connectionTimeOut) { - mConnectionTimeOut = connectionTimeOut; + public ConditionalBuilder connectionTimeOut(int timeOut, TimeUnit unit) { + mConnectionTimeOut = unit.toMillis(timeOut); return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java new file mode 100644 index 00000000..ee32a7e9 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -0,0 +1,92 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportService; +import com.jaspersoft.android.sdk.service.server.InfoProvider; +import org.jetbrains.annotations.NotNull; + +import java.text.SimpleDateFormat; +import java.util.concurrent.TimeUnit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class Session extends AnonymousSession implements TokenProvider, InfoProvider { + private final Credentials mCredentials; + + private ReportService mReportService; + + public Session(RestClient client, Credentials credentials) { + super(client); + mCredentials = credentials; + } + + @NotNull + public ReportService reportApi() { + if (mReportService == null) { + ReportExecutionRestApi executionApi = new ReportExecutionRestApi.Builder() + .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) + .baseUrl(mClient.getServerUrl()) + .build(); + ReportExportRestApi exportApi = new ReportExportRestApi.Builder() + .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) + .baseUrl(mClient.getServerUrl()) + .build(); + mReportService = ReportService.create(executionApi, exportApi, this, this); + } + return mReportService; + } + + @NotNull + @Override + public String getBaseUrl() { + return mClient.getServerUrl(); + } + + @Override + public String provideToken() throws ServiceException { + return authApi().authenticate(mCredentials); + } + + @Override + public double provideVersion() throws ServiceException { + return infoApi().requestServerVersion(); + } + + @NotNull + @Override + public SimpleDateFormat provideDateTimeFormat() throws ServiceException { + return infoApi().requestServerDateTimeFormat(); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java index 3d3285b5..5e51af2e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java @@ -29,5 +29,5 @@ * @since 2.0 */ public interface TokenProvider { - String provideToken(); + String provideToken() throws Exception; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 2f76629d..7f48bda7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -59,14 +59,12 @@ public final class ReportService { mExportUseCase = exportUseCase; } - public static ReportService create(TokenProvider tokenProvider, InfoProvider infoProvider) { + public static ReportService create( + ReportExecutionRestApi executionApi, + ReportExportRestApi exportApi, + TokenProvider tokenProvider, + InfoProvider infoProvider) { String baseUrl = infoProvider.getBaseUrl(); - ReportExecutionRestApi executionApi = new ReportExecutionRestApi.Builder() - .baseUrl(baseUrl) - .build(); - ReportExportRestApi exportApi = new ReportExportRestApi.Builder() - .baseUrl(baseUrl) - .build(); ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(baseUrl); ReportExecutionUseCase reportExecutionUseCase = diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java index a15149f9..9a424a97 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import java.text.SimpleDateFormat; @@ -39,10 +40,7 @@ public interface InfoProvider { @NotNull String getBaseUrl(); + double provideVersion() throws ServiceException; @NotNull - ServerInfo provideInfo(); - @NotNull - double provideVersion(); - @NotNull - SimpleDateFormat provideDateTimeFormat(); + SimpleDateFormat provideDateTimeFormat() throws ServiceException; } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java new file mode 100644 index 00000000..9653dad2 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.auth.SpringCredentials; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +public class RestClientTest { + + @Test + public void testIntegration() { + RestClient client = RestClient.builder() + .serverUrl("http://localhost") + .connectionTimeOut(5, TimeUnit.DAYS) + .readTimeOut(5, TimeUnit.DAYS) + .create(); + Credentials credentials = SpringCredentials.builder().build(); + + Session session = client.authenticate(credentials); + session.reportApi(); + + AnonymousSession anonymousSession = client.getAnonymousSession(); + anonymousSession.authApi(); + anonymousSession.infoApi(); + } +} \ No newline at end of file From ef404146be25fc0bf6274614ef08f571f474e4d0 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 12:53:40 +0200 Subject: [PATCH 292/457] Initial CallExecutor implementation --- .../android/sdk/service/internal/Call.java | 37 ++++ .../sdk/service/internal/CallExecutor.java | 81 +++++++++ .../sdk/service/internal/TokenCache.java | 37 ++++ .../sdk/service/internal/TokenFactory.java | 38 ++++ .../service/internal/CallExecutorTest.java | 163 ++++++++++++++++++ 5 files changed, 356 insertions(+) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCache.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java new file mode 100644 index 00000000..0b471336 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface Call { + public T perform(String token) throws IOException, HttpException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java new file mode 100644 index 00000000..1ca08071 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java @@ -0,0 +1,81 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.exception.ServiceException; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class CallExecutor { + private final TokenCache mTokenCache; + private final TokenFactory mTokenFactory; + private final Credentials mCredentials; + + public CallExecutor(Credentials credentials, TokenCache tokenCache, TokenFactory tokenFactory) { + mTokenCache = tokenCache; + mTokenFactory = tokenFactory; + mCredentials = credentials; + } + + // TODO: Discuss ServiceException reconsider approach on basis of Status result object +/* + public T execute(Call call) { + } +*/ + public T execute(Call call) throws ServiceException { + String token = mTokenCache.get(mCredentials); + try { + if (token == null) { + token = mTokenFactory.create(mCredentials); + mTokenCache.put(mCredentials, token); + } + return call.perform(token); + } catch (IOException e) { + throw ServiceExceptionMapper.transform(e); + } catch (HttpException e) { + if (e.code() == 401) { + mTokenCache.evict(mCredentials); + + try { + token = mTokenFactory.create(mCredentials); + mTokenCache.put(mCredentials, token); + return call.perform(token); + } catch (IOException e1) { + throw ServiceExceptionMapper.transform(e1); + } catch (HttpException e1) { + throw ServiceExceptionMapper.transform(e1); + } + } else { + throw ServiceExceptionMapper.transform(e); + } + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCache.java new file mode 100644 index 00000000..cbcf660c --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCache.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.service.auth.Credentials; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface TokenCache { + String get(Credentials credentials); + void put(Credentials credentials, String token); + void evict(Credentials credentials); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java new file mode 100644 index 00000000..746c86f2 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.auth.Credentials; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface TokenFactory { + String create(Credentials credentials) throws IOException, HttpException; +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java new file mode 100644 index 00000000..624e4544 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java @@ -0,0 +1,163 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; + +public class CallExecutorTest { + + @Mock + TokenCache mCache; + @Mock + TokenFactory mFactory; + @Mock + Credentials mCredentials; + @Mock + Call mCall; + + @Mock + HttpException _401Exception; + + private CallExecutor resolver; + private Object mResponse = new Object(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + when(_401Exception.code()).thenReturn(401); + when(mCall.perform(anyString())).thenReturn(mResponse); + resolver = new CallExecutor(mCredentials, mCache, mFactory); + } + + @Test + public void testExecuteWithValidCache() throws Exception { + when(mCache.get(any(Credentials.class))).thenReturn("token"); + + assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); + + verify(mCache).get(mCredentials); + verify(mCall).perform("token"); + verifyNoMoreInteractions(mCache); + verifyZeroInteractions(mFactory); + } + + @Test + public void testExecuteWithEmptyCache() throws Exception { + when(mCache.get(any(Credentials.class))).thenReturn(null); + when(mFactory.create(any(Credentials.class))).thenReturn("token"); + + assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); + + verify(mCache).get(mCredentials); + verify(mFactory).create(mCredentials); + verify(mCache).put(mCredentials, "token"); + verify(mCall).perform("token"); + } + + @Test + public void testExecuteWithInvalidCache() throws Exception { + when(mCache.get(any(Credentials.class))).thenReturn("invalid token"); + + when(_401Exception.code()).thenReturn(401); + when(mCall.perform(anyString())).thenAnswer(_401ResponseAtFirstInvokation()); + + when(mFactory.create(any(Credentials.class))).thenReturn("token"); + + assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); + + verify(mCache).get(mCredentials); + verify(mCall).perform("invalid token"); + verify(mCache).evict(mCredentials); + verify(mFactory).create(mCredentials); + verify(mCache).put(mCredentials, "token"); + verify(mCall).perform("token"); + } + + @Test + public void testExecuteWithInvalidCredentials() throws Exception { + when(mCache.get(any(Credentials.class))).thenReturn("invalid token"); + when(mCall.perform(anyString())).thenThrow(_401Exception); + when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); + + try { + resolver.execute(mCall); + } catch (ServiceException exception) { + assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); + } + + verify(mCache).get(mCredentials); + verify(mCall).perform("invalid token"); + verify(mCache).evict(mCredentials); + verify(mFactory).create(mCredentials); + } + + @Test + public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { + when(mCache.get(any(Credentials.class))).thenReturn(null); + when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); + + try { + resolver.execute(mCall); + } catch (ServiceException exception) { + assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); + } + + verify(mCache).get(mCredentials); + verify(mCache).evict(mCredentials); + + verify(mFactory, times(2)).create(mCredentials); + verifyNoMoreInteractions(mCache); + verifyNoMoreInteractions(mFactory); + verifyZeroInteractions(mCall); + } + + private Answer _401ResponseAtFirstInvokation() { + return new Answer() { + int invocationCount = 0; + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + if (invocationCount == 0) { + invocationCount++; + throw _401Exception; + } + return mResponse; + } + }; + } +} \ No newline at end of file From e4dc4edcdf830058bdfb10bc16ebb17162dac25e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 13:25:43 +0200 Subject: [PATCH 293/457] Hide TokenFactory implementation --- .../sdk/service/internal/TokenFactory.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java index 746c86f2..a6a5d7f7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java @@ -25,7 +25,10 @@ package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.auth.JrsAuthenticator; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import java.io.IOException; @@ -33,6 +36,26 @@ * @author Tom Koptel * @since 2.0 */ -public interface TokenFactory { - String create(Credentials credentials) throws IOException, HttpException; +class TokenFactory { + private final RestClient mRestClient; + + private TokenFactory(RestClient restClient) { + mRestClient = restClient; + } + + public String create(Credentials credentials) throws IOException, HttpException { + JrsAuthenticator auth = mRestClient.getAnonymousSession().authApi(); + try { + return auth.authenticate(credentials); + } catch (ServiceException e) { + Throwable throwable = e.getCause(); + if (throwable instanceof IOException) { + throw (IOException) throwable; + } + if (throwable instanceof HttpException) { + throw (HttpException) throwable; + } + throw new RuntimeException("Boom", throwable); + } + } } From 338d1f4de38b6d730094b5f5b8eb42688a066545 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 14:29:11 +0200 Subject: [PATCH 294/457] Integrating call executor for report service --- .../android/sdk/service/RestClient.java | 19 +++- .../android/sdk/service/Session.java | 15 +-- .../sdk/service/internal/CallExecutor.java | 10 +- .../sdk/service/internal/TokenFactory.java | 2 +- .../report/ReportExecutionUseCase.java | 61 ++++++------ .../service/report/ReportExportUseCase.java | 92 +++++++++---------- .../sdk/service/report/ReportService.java | 32 ++++--- .../{internal => token}/TokenCache.java | 2 +- .../android/sdk/service/RestClientTest.java | 8 +- .../service/internal/CallExecutorTest.java | 1 + .../service/report/ReportAttachmentTest.java | 8 +- .../service/report/ReportExecutionTest.java | 24 ++--- .../sdk/service/report/ReportExportTest.java | 7 +- .../sdk/service/report/ReportServiceTest.java | 15 ++- 14 files changed, 149 insertions(+), 147 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/service/{internal => token}/TokenCache.java (96%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index 73bdac15..2c4c98e7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.token.TokenCache; import java.util.concurrent.TimeUnit; @@ -36,16 +37,18 @@ public final class RestClient { private final String mServerUrl; private final long mReadTimeOut; private final long mConnectionTimeOut; + private final TokenCache mTokenCache; private AnonymousSession mAnonymousSession; - RestClient(String serverUrl, long readTimeOut, long connectionTimeOut) { + RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, TokenCache tokenCache) { mServerUrl = serverUrl; mReadTimeOut = readTimeOut; mConnectionTimeOut = connectionTimeOut; + mTokenCache = tokenCache; } - public Session authenticate(Credentials credentials) { + public Session newSession(Credentials credentials) { return new Session(this, credentials); } @@ -56,6 +59,10 @@ public AnonymousSession getAnonymousSession() { return mAnonymousSession; } + public TokenCache getTokenCache() { + return mTokenCache; + } + public String getServerUrl() { return mServerUrl; } @@ -85,6 +92,7 @@ public static class ConditionalBuilder { private final String mServerUrl; private long mConnectionReadTimeOut = TimeUnit.SECONDS.toMillis(10); private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10);; + private TokenCache mTokenCache; private ConditionalBuilder(String serverUrl) { mServerUrl = serverUrl; @@ -100,8 +108,13 @@ public ConditionalBuilder connectionTimeOut(int timeOut, TimeUnit unit) { return this; } + public ConditionalBuilder cache(TokenCache cache) { + mTokenCache = cache; + return this; + } + public RestClient create() { - return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut); + return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mTokenCache); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index ee32a7e9..0991d3d6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -34,7 +32,6 @@ import org.jetbrains.annotations.NotNull; import java.text.SimpleDateFormat; -import java.util.concurrent.TimeUnit; /** * @author Tom Koptel @@ -53,17 +50,7 @@ public Session(RestClient client, Credentials credentials) { @NotNull public ReportService reportApi() { if (mReportService == null) { - ReportExecutionRestApi executionApi = new ReportExecutionRestApi.Builder() - .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) - .baseUrl(mClient.getServerUrl()) - .build(); - ReportExportRestApi exportApi = new ReportExportRestApi.Builder() - .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) - .baseUrl(mClient.getServerUrl()) - .build(); - mReportService = ReportService.create(executionApi, exportApi, this, this); + mReportService = ReportService.create(mClient, mCredentials); } return mReportService; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java index 1ca08071..229159f9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java @@ -25,8 +25,11 @@ package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.token.TokenCache; +import org.jetbrains.annotations.TestOnly; import java.io.IOException; @@ -39,12 +42,17 @@ public class CallExecutor { private final TokenFactory mTokenFactory; private final Credentials mCredentials; - public CallExecutor(Credentials credentials, TokenCache tokenCache, TokenFactory tokenFactory) { + @TestOnly + CallExecutor(Credentials credentials, TokenCache tokenCache, TokenFactory tokenFactory) { mTokenCache = tokenCache; mTokenFactory = tokenFactory; mCredentials = credentials; } + public static CallExecutor create(RestClient client, Credentials credentials) { + return new CallExecutor(credentials, client.getTokenCache(), new TokenFactory(client)); + } + // TODO: Discuss ServiceException reconsider approach on basis of Status result object /* public T execute(Call call) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java index a6a5d7f7..1444bc18 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java @@ -39,7 +39,7 @@ class TokenFactory { private final RestClient mRestClient; - private TokenFactory(RestClient restClient) { + TokenFactory(RestClient restClient) { mRestClient = restClient; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index badf1e62..e7f926a3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -29,10 +29,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; - +import com.jaspersoft.android.sdk.service.internal.Call; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -43,48 +42,48 @@ */ final class ReportExecutionUseCase { private final ReportExecutionRestApi mExecutionApi; - private final TokenProvider mTokenProvider; + private final CallExecutor mCallExecutor; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; ReportExecutionUseCase(ReportExecutionRestApi executionApi, - TokenProvider tokenProvider, + CallExecutor callExecutor, ExecutionOptionsDataMapper executionOptionsMapper) { mExecutionApi = executionApi; - mTokenProvider = tokenProvider; + mCallExecutor = callExecutor; mExecutionOptionsMapper = executionOptionsMapper; } @NotNull - public ReportExecutionDescriptor runReportExecution(String reportUri, RunReportCriteria criteria) throws ServiceException { - ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); - try { - return mExecutionApi.runReportExecution(mTokenProvider.provideToken(), options); - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + public ReportExecutionDescriptor runReportExecution(final String reportUri, final RunReportCriteria criteria) throws ServiceException { + Call call = new Call() { + @Override + public ReportExecutionDescriptor perform(String token) throws IOException, HttpException { + ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); + return mExecutionApi.runReportExecution(token, options); + } + }; + return mCallExecutor.execute(call); } @NotNull - public ExecutionStatus requestStatus(String executionId) throws ServiceException { - try { - return mExecutionApi.requestReportExecutionStatus(mTokenProvider.provideToken(), executionId); - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + public ExecutionStatus requestStatus(final String executionId) throws ServiceException { + Call call = new Call() { + @Override + public ExecutionStatus perform(String token) throws IOException, HttpException { + return mExecutionApi.requestReportExecutionStatus(token, executionId); + } + }; + return mCallExecutor.execute(call); } @NotNull - public ReportExecutionDescriptor requestExecutionDetails(String executionId) throws ServiceException { - try { - return mExecutionApi.requestReportExecutionDetails(mTokenProvider.provideToken(), executionId); - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + public ReportExecutionDescriptor requestExecutionDetails(final String executionId) throws ServiceException { + Call call = new Call() { + @Override + public ReportExecutionDescriptor perform(String token) throws IOException, HttpException { + return mExecutionApi.requestReportExecutionDetails(token, executionId); + } + }; + return mCallExecutor.execute(call); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 218a8f19..cf58fefe 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -31,12 +31,11 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; - +import com.jaspersoft.android.sdk.service.internal.Call; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -47,65 +46,64 @@ */ final class ReportExportUseCase { private final ReportExportRestApi mExportApi; - private final TokenProvider mTokenProvider; + private final CallExecutor mCallExecutor; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; - ReportExportUseCase(ReportExportRestApi exportApi, TokenProvider tokenProvider, - ExecutionOptionsDataMapper executionOptionsMapper) { + ReportExportUseCase(ReportExportRestApi exportApi, + CallExecutor callExecutor, ExecutionOptionsDataMapper executionOptionsMapper) { mExportApi = exportApi; - mTokenProvider = tokenProvider; + mCallExecutor = callExecutor; mExecutionOptionsMapper = executionOptionsMapper; } @NotNull - public ExportExecutionDescriptor runExport(String executionId, RunExportCriteria criteria) throws ServiceException { - ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); - try { - return mExportApi.runExportExecution(mTokenProvider.provideToken(), executionId, options); - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + public ExportExecutionDescriptor runExport(final String executionId, final RunExportCriteria criteria) throws ServiceException { + Call call = new Call() { + @Override + public ExportExecutionDescriptor perform(String token) throws IOException, HttpException { + ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); + return mExportApi.runExportExecution(token, executionId, options); + } + }; + return mCallExecutor.execute(call); } @NotNull - public Status checkExportExecutionStatus(String executionId, String exportId) throws ServiceException { - try { - ExecutionStatus exportStatus = mExportApi - .checkExportExecutionStatus(mTokenProvider.provideToken(), executionId, exportId); - return Status.wrap(exportStatus.getStatus()); - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + public Status checkExportExecutionStatus(final String executionId, final String exportId) throws ServiceException { + Call call = new Call() { + @Override + public Status perform(String token) throws IOException, HttpException { + ExecutionStatus exportStatus = mExportApi + .checkExportExecutionStatus(token, executionId, exportId); + return Status.wrap(exportStatus.getStatus()); + } + }; + return mCallExecutor.execute(call); } @NotNull - public ReportOutput requestExportOutput(String executionId, String exportId) throws ServiceException { - try { - ExportOutputResource result = mExportApi.requestExportOutput(mTokenProvider.provideToken(), executionId, exportId); - return OutputDataMapper.transform(result); - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + public ReportOutput requestExportOutput(final String executionId, final String exportId) throws ServiceException { + Call call = new Call() { + @Override + public ReportOutput perform(String token) throws IOException, HttpException { + ExportOutputResource result = mExportApi.requestExportOutput(token, executionId, exportId); + return OutputDataMapper.transform(result); + } + }; + return mCallExecutor.execute(call); } @NotNull - public ResourceOutput requestExportAttachmentOutput(String executionId, String exportId, - String fileName) throws ServiceException { - try { - OutputResource result = mExportApi.requestExportAttachment( - mTokenProvider.provideToken(), - executionId, exportId, fileName); - return OutputDataMapper.transform(result); - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + public ResourceOutput requestExportAttachmentOutput(final String executionId, final String exportId, + final String fileName) throws ServiceException { + Call call = new Call() { + @Override + public ResourceOutput perform(String token) throws IOException, HttpException { + OutputResource result = mExportApi.requestExportAttachment( + token, executionId, exportId, fileName); + return OutputDataMapper.transform(result); + } + }; + return mCallExecutor.execute(call); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 7f48bda7..a2a7ff74 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -29,11 +29,11 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.RestClient; +import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; - +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -59,18 +59,24 @@ public final class ReportService { mExportUseCase = exportUseCase; } - public static ReportService create( - ReportExecutionRestApi executionApi, - ReportExportRestApi exportApi, - TokenProvider tokenProvider, - InfoProvider infoProvider) { - String baseUrl = infoProvider.getBaseUrl(); - ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(baseUrl); + public static ReportService create(RestClient client, Credentials credentials) { + ReportExecutionRestApi executionApi = new ReportExecutionRestApi.Builder() + .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) + .baseUrl(client.getServerUrl()) + .build(); + ReportExportRestApi exportApi = new ReportExportRestApi.Builder() + .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) + .baseUrl(client.getServerUrl()) + .build(); + CallExecutor callExecutor = CallExecutor.create(client, credentials); + ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getServerUrl()); ReportExecutionUseCase reportExecutionUseCase = - new ReportExecutionUseCase(executionApi, tokenProvider, executionOptionsMapper); + new ReportExecutionUseCase(executionApi, callExecutor, executionOptionsMapper); ReportExportUseCase reportExportUseCase = - new ReportExportUseCase(exportApi, tokenProvider, executionOptionsMapper); + new ReportExportUseCase(exportApi, callExecutor, executionOptionsMapper); return new ReportService( TimeUnit.SECONDS.toMillis(1), diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java index cbcf660c..aaac94bd 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.internal; +package com.jaspersoft.android.sdk.service.token; import com.jaspersoft.android.sdk.service.auth.Credentials; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java index 9653dad2..a51977c9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java @@ -39,9 +39,13 @@ public void testIntegration() { .connectionTimeOut(5, TimeUnit.DAYS) .readTimeOut(5, TimeUnit.DAYS) .create(); - Credentials credentials = SpringCredentials.builder().build(); + Credentials credentials = SpringCredentials.builder() + .username("any") + .password("any") + .organization("any") + .build(); - Session session = client.authenticate(credentials); + Session session = client.newSession(credentials); session.reportApi(); AnonymousSession anonymousSession = client.getAnonymousSession(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java index 624e4544..5187f3d6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.token.TokenCache; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 2dcf21a7..e2843895 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -26,9 +26,8 @@ import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; - +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -56,7 +55,7 @@ public class ReportAttachmentTest { @Mock ReportExportRestApi mExportRestApi; @Mock - TokenProvider mTokenProvider; + CallExecutor mCallExecutor; @Mock OutputResource input; @@ -65,10 +64,9 @@ public class ReportAttachmentTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn("cookie"); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mCallExecutor, executionOptionsDataMapper); objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", exportUseCase); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 590e088d..3583dbd7 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -26,17 +26,12 @@ import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.*; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -57,9 +52,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.*; import static org.powermock.api.mockito.PowerMockito.when; /** @@ -94,12 +87,12 @@ public class ReportExecutionTest { ReportExportRestApi mExportRestApi; @Mock ReportExecutionRestApi mExecutionRestApi; + @Mock - TokenProvider mTokenProvider; + CallExecutor mCallExecutor; private ReportExecution objectUnderTest; - @Rule public ExpectedException mException = ExpectedException.none(); @@ -107,13 +100,12 @@ public class ReportExecutionTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - when(mTokenProvider.provideToken()).thenReturn("cookie"); when(mExecDetails.getExecutionId()).thenReturn("execution_id"); when(mExecDetails.getReportURI()).thenReturn("/report/uri"); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/report/uri"); - ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(mExecutionRestApi, mTokenProvider, executionOptionsDataMapper); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); + ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(mExecutionRestApi, mCallExecutor, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mCallExecutor, executionOptionsDataMapper); objectUnderTest = new ReportExecution( TimeUnit.SECONDS.toMillis(0), reportExecutionUseCase, diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 6adefa88..01b198dd 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -25,8 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; - +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -47,7 +46,7 @@ public class ReportExportTest { @Mock ReportExportRestApi mExportRestApi; @Mock - TokenProvider mTokenProvider; + CallExecutor mCallExecutor; private ReportExport objectUnderTest; @@ -56,7 +55,7 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mTokenProvider, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mCallExecutor, executionOptionsDataMapper); objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), exportUseCase); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 3d48769b..a45dc8c6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -30,10 +30,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -52,9 +51,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.*; import static org.powermock.api.mockito.PowerMockito.when; /** @@ -74,7 +71,7 @@ public class ReportServiceTest { @Mock ReportExportRestApi exportApi; @Mock - TokenProvider mTokenProvider; + CallExecutor mCallExecutor; @Mock ErrorDescriptor mDescriptor; @@ -95,8 +92,8 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, mTokenProvider, executionOptionsDataMapper); - ReportExportUseCase exportUseCase = new ReportExportUseCase(exportApi, mTokenProvider, executionOptionsDataMapper); + ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, mCallExecutor, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(exportApi, mCallExecutor, executionOptionsDataMapper); objectUnderTest = new ReportService( TimeUnit.MILLISECONDS.toMillis(0), From f3b32983527b52d73356016679fb6cf6e6093c51 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 15:07:24 +0200 Subject: [PATCH 295/457] Introducing call executor abstraction --- .../sdk/service/{internal => }/Call.java | 2 +- .../android/sdk/service/CallExecutor.java | 35 ++++++++++++ ...allExecutor.java => CallExecutorImpl.java} | 13 +++-- .../android/sdk/service/RestClient.java | 1 - .../sdk/service/{token => }/TokenCache.java | 2 +- .../service/{internal => }/TokenFactory.java | 3 +- .../report/ReportExecutionUseCase.java | 4 +- .../service/report/ReportExportUseCase.java | 4 +- .../sdk/service/report/ReportService.java | 5 +- ...torTest.java => CallExecutorImplTest.java} | 9 ++-- .../android/sdk/service/FakeCallExecutor.java | 54 +++++++++++++++++++ .../service/report/ReportAttachmentTest.java | 6 +-- .../service/report/ReportExecutionTest.java | 10 ++-- .../sdk/service/report/ReportExportTest.java | 9 ++-- .../sdk/service/report/ReportServiceTest.java | 9 ++-- 15 files changed, 122 insertions(+), 44 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/service/{internal => }/Call.java (96%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutor.java rename core/src/main/java/com/jaspersoft/android/sdk/service/{internal/CallExecutor.java => CallExecutorImpl.java} (85%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{token => }/TokenCache.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{internal => }/TokenFactory.java (95%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{internal/CallExecutorTest.java => CallExecutorImplTest.java} (95%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Call.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/Call.java index 0b471336..e69fdeb1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Call.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.internal; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.HttpException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutor.java new file mode 100644 index 00000000..c3a5dbde --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutor.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.exception.ServiceException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface CallExecutor { + T execute(Call call) throws ServiceException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java similarity index 85% rename from core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java index 229159f9..98464f6b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java @@ -22,13 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.service.internal; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.token.TokenCache; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.TestOnly; import java.io.IOException; @@ -37,20 +36,20 @@ * @author Tom Koptel * @since 2.0 */ -public class CallExecutor { +public final class CallExecutorImpl implements CallExecutor { private final TokenCache mTokenCache; private final TokenFactory mTokenFactory; private final Credentials mCredentials; @TestOnly - CallExecutor(Credentials credentials, TokenCache tokenCache, TokenFactory tokenFactory) { + CallExecutorImpl(Credentials credentials, TokenCache tokenCache, TokenFactory tokenFactory) { mTokenCache = tokenCache; mTokenFactory = tokenFactory; mCredentials = credentials; } - public static CallExecutor create(RestClient client, Credentials credentials) { - return new CallExecutor(credentials, client.getTokenCache(), new TokenFactory(client)); + public static CallExecutorImpl create(RestClient client, Credentials credentials) { + return new CallExecutorImpl(credentials, client.getTokenCache(), new TokenFactory(client)); } // TODO: Discuss ServiceException reconsider approach on basis of Status result object diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index 2c4c98e7..e0c09e07 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.token.TokenCache; import java.util.concurrent.TimeUnit; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java index aaac94bd..0fb2fe05 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.token; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java similarity index 95% rename from core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java index 1444bc18..12847026 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java @@ -22,10 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.service.internal; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.auth.JrsAuthenticator; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index e7f926a3..0d5197e5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -29,9 +29,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.Call; +import com.jaspersoft.android.sdk.service.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Call; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.jetbrains.annotations.NotNull; import java.io.IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index cf58fefe..ab46fa0e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -31,11 +31,11 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.Call; +import com.jaspersoft.android.sdk.service.CallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Call; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.jetbrains.annotations.NotNull; import java.io.IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index a2a7ff74..f1540859 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -29,11 +29,12 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.CallExecutor; +import com.jaspersoft.android.sdk.service.CallExecutorImpl; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -70,7 +71,7 @@ public static ReportService create(RestClient client, Credentials credentials) { .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .baseUrl(client.getServerUrl()) .build(); - CallExecutor callExecutor = CallExecutor.create(client, credentials); + CallExecutor callExecutor = CallExecutorImpl.create(client, credentials); ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getServerUrl()); ReportExecutionUseCase reportExecutionUseCase = diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java similarity index 95% rename from core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java index 5187f3d6..0af46bfd 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/CallExecutorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java @@ -22,13 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.service.internal; +package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.token.TokenCache; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -41,7 +40,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; -public class CallExecutorTest { +public class CallExecutorImplTest { @Mock TokenCache mCache; @@ -55,7 +54,7 @@ public class CallExecutorTest { @Mock HttpException _401Exception; - private CallExecutor resolver; + private CallExecutorImpl resolver; private Object mResponse = new Object(); @Before @@ -63,7 +62,7 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenReturn(mResponse); - resolver = new CallExecutor(mCredentials, mCache, mFactory); + resolver = new CallExecutorImpl(mCredentials, mCache, mFactory); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java new file mode 100644 index 00000000..663b6fe8 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class FakeCallExecutor implements CallExecutor { + private final String mToken; + + public FakeCallExecutor(String token) { + mToken = token; + } + + @Override + public T execute(Call call) throws ServiceException { + try { + return call.perform(mToken); + } catch (IOException e) { + throw ServiceExceptionMapper.transform(e); + } catch (HttpException e) { + throw ServiceExceptionMapper.transform(e); + } + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index e2843895..5fa96eec 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -26,8 +26,8 @@ import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -55,8 +55,6 @@ public class ReportAttachmentTest { @Mock ReportExportRestApi mExportRestApi; @Mock - CallExecutor mCallExecutor; - @Mock OutputResource input; private ReportAttachment objectUnderTest; @@ -66,7 +64,7 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mCallExecutor, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, new FakeCallExecutor("cookie"), executionOptionsDataMapper); objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", exportUseCase); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 3583dbd7..0f93f9b7 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -28,10 +28,10 @@ import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.*; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -88,9 +88,6 @@ public class ReportExecutionTest { @Mock ReportExecutionRestApi mExecutionRestApi; - @Mock - CallExecutor mCallExecutor; - private ReportExecution objectUnderTest; @Rule @@ -104,8 +101,9 @@ public void setUp() throws Exception { when(mExecDetails.getReportURI()).thenReturn("/report/uri"); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/report/uri"); - ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(mExecutionRestApi, mCallExecutor, executionOptionsDataMapper); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mCallExecutor, executionOptionsDataMapper); + FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); + ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(mExecutionRestApi, callExecutor, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, callExecutor, executionOptionsDataMapper); objectUnderTest = new ReportExecution( TimeUnit.SECONDS.toMillis(0), reportExecutionUseCase, diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 01b198dd..406eb65c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -33,7 +33,6 @@ import java.util.Collections; -import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -45,8 +44,6 @@ public class ReportExportTest { @Mock ReportExportRestApi mExportRestApi; - @Mock - CallExecutor mCallExecutor; private ReportExport objectUnderTest; @@ -55,14 +52,14 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, mCallExecutor, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, new FakeCallExecutor("cookie"), executionOptionsDataMapper); objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), exportUseCase); } @Test public void testDownload() throws Exception { objectUnderTest.download(); - verify(mExportRestApi).requestExportOutput(anyString(), eq("report_execution_id"), eq("export_id")); + verify(mExportRestApi).requestExportOutput(eq("cookie"), eq("report_execution_id"), eq("export_id")); verifyNoMoreInteractions(mExportRestApi); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index a45dc8c6..3ab34659 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -30,9 +30,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -71,8 +71,6 @@ public class ReportServiceTest { @Mock ReportExportRestApi exportApi; @Mock - CallExecutor mCallExecutor; - @Mock ErrorDescriptor mDescriptor; @Mock @@ -92,8 +90,9 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, mCallExecutor, executionOptionsDataMapper); - ReportExportUseCase exportUseCase = new ReportExportUseCase(exportApi, mCallExecutor, executionOptionsDataMapper); + FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); + ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, callExecutor, executionOptionsDataMapper); + ReportExportUseCase exportUseCase = new ReportExportUseCase(exportApi, callExecutor, executionOptionsDataMapper); objectUnderTest = new ReportService( TimeUnit.MILLISECONDS.toMillis(0), From 9bcbfd097ac0d0d55589e3889ce5192e87a15aa1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 16:42:31 +0200 Subject: [PATCH 296/457] Add InMemoryTokenCache implementation --- .../android/sdk/service/CallExecutorImpl.java | 8 +-- .../sdk/service/InMemoryTokenCache.java | 48 ++++++++++++++++++ .../android/sdk/service/TokenCache.java | 8 ++- .../sdk/service/CallExecutorImplTest.java | 30 +++++------ .../sdk/service/InMemoryTokenCacheTest.java | 50 +++++++++++++++++++ 5 files changed, 120 insertions(+), 24 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryTokenCache.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java index 98464f6b..51c259ed 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java @@ -58,22 +58,22 @@ public T execute(Call call) { } */ public T execute(Call call) throws ServiceException { - String token = mTokenCache.get(mCredentials); + String token = mTokenCache.get(); try { if (token == null) { token = mTokenFactory.create(mCredentials); - mTokenCache.put(mCredentials, token); + mTokenCache.put(token); } return call.perform(token); } catch (IOException e) { throw ServiceExceptionMapper.transform(e); } catch (HttpException e) { if (e.code() == 401) { - mTokenCache.evict(mCredentials); + mTokenCache.evict(); try { token = mTokenFactory.create(mCredentials); - mTokenCache.put(mCredentials, token); + mTokenCache.put(token); return call.perform(token); } catch (IOException e1) { throw ServiceExceptionMapper.transform(e1); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryTokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryTokenCache.java new file mode 100644 index 00000000..276484ee --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryTokenCache.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class InMemoryTokenCache implements TokenCache { + private String mCache; + + @Override + public String get() { + return mCache; + } + + @Override + public void put(String token) { + mCache = token; + } + + @Override + public void evict() { + mCache = null; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java index 0fb2fe05..6b50990f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java @@ -24,14 +24,12 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.service.auth.Credentials; - /** * @author Tom Koptel * @since 2.0 */ public interface TokenCache { - String get(Credentials credentials); - void put(Credentials credentials, String token); - void evict(Credentials credentials); + String get(); + void put(String token); + void evict(); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java index 0af46bfd..2b83fe41 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java @@ -67,11 +67,11 @@ public void setUp() throws Exception { @Test public void testExecuteWithValidCache() throws Exception { - when(mCache.get(any(Credentials.class))).thenReturn("token"); + when(mCache.get()).thenReturn("token"); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mCache).get(mCredentials); + verify(mCache).get(); verify(mCall).perform("token"); verifyNoMoreInteractions(mCache); verifyZeroInteractions(mFactory); @@ -79,20 +79,20 @@ public void testExecuteWithValidCache() throws Exception { @Test public void testExecuteWithEmptyCache() throws Exception { - when(mCache.get(any(Credentials.class))).thenReturn(null); + when(mCache.get()).thenReturn(null); when(mFactory.create(any(Credentials.class))).thenReturn("token"); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mCache).get(mCredentials); + verify(mCache).get(); verify(mFactory).create(mCredentials); - verify(mCache).put(mCredentials, "token"); + verify(mCache).put("token"); verify(mCall).perform("token"); } @Test public void testExecuteWithInvalidCache() throws Exception { - when(mCache.get(any(Credentials.class))).thenReturn("invalid token"); + when(mCache.get()).thenReturn("invalid token"); when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenAnswer(_401ResponseAtFirstInvokation()); @@ -101,17 +101,17 @@ public void testExecuteWithInvalidCache() throws Exception { assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mCache).get(mCredentials); + verify(mCache).get(); verify(mCall).perform("invalid token"); - verify(mCache).evict(mCredentials); + verify(mCache).evict(); verify(mFactory).create(mCredentials); - verify(mCache).put(mCredentials, "token"); + verify(mCache).put("token"); verify(mCall).perform("token"); } @Test public void testExecuteWithInvalidCredentials() throws Exception { - when(mCache.get(any(Credentials.class))).thenReturn("invalid token"); + when(mCache.get()).thenReturn("invalid token"); when(mCall.perform(anyString())).thenThrow(_401Exception); when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); @@ -121,15 +121,15 @@ public void testExecuteWithInvalidCredentials() throws Exception { assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); } - verify(mCache).get(mCredentials); + verify(mCache).get(); verify(mCall).perform("invalid token"); - verify(mCache).evict(mCredentials); + verify(mCache).evict(); verify(mFactory).create(mCredentials); } @Test public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { - when(mCache.get(any(Credentials.class))).thenReturn(null); + when(mCache.get()).thenReturn(null); when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); try { @@ -138,8 +138,8 @@ public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); } - verify(mCache).get(mCredentials); - verify(mCache).evict(mCredentials); + verify(mCache).get(); + verify(mCache).evict(); verify(mFactory, times(2)).create(mCredentials); verifyNoMoreInteractions(mCache); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java new file mode 100644 index 00000000..9733939b --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertThat; + +public class InMemoryTokenCacheTest { + + private InMemoryTokenCache cache; + + @Before + public void setUp() throws Exception { + cache = new InMemoryTokenCache(); + } + + @Test + public void testCache() throws Exception { + cache.put("token"); + assertThat(cache.get(), is("token")); + cache.evict(); + assertThat(cache.get(), is(nullValue())); + } +} \ No newline at end of file From e1ada97dc1b0688c974eccff89eeb12d48eb0fb5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 16:59:35 +0200 Subject: [PATCH 297/457] Remove token cache associatin with rest client --- .../android/sdk/service/CallExecutorImpl.java | 8 ++- .../android/sdk/service/RestClient.java | 20 ++------ .../android/sdk/service/Session.java | 49 +++++++++++++++---- .../sdk/service/report/ReportService.java | 6 +-- .../android/sdk/service/RestClientTest.java | 2 +- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java index 51c259ed..c8ccfb31 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java @@ -48,8 +48,12 @@ public final class CallExecutorImpl implements CallExecutor { mCredentials = credentials; } - public static CallExecutorImpl create(RestClient client, Credentials credentials) { - return new CallExecutorImpl(credentials, client.getTokenCache(), new TokenFactory(client)); + public static CallExecutorImpl create(RestClient client, Session session) { + return new CallExecutorImpl( + session.getCredentials(), + session.getTokenCache(), + new TokenFactory(client) + ); } // TODO: Discuss ServiceException reconsider approach on basis of Status result object diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index e0c09e07..d83989be 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -36,19 +36,17 @@ public final class RestClient { private final String mServerUrl; private final long mReadTimeOut; private final long mConnectionTimeOut; - private final TokenCache mTokenCache; private AnonymousSession mAnonymousSession; - RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, TokenCache tokenCache) { + private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut) { mServerUrl = serverUrl; mReadTimeOut = readTimeOut; mConnectionTimeOut = connectionTimeOut; - mTokenCache = tokenCache; } - public Session newSession(Credentials credentials) { - return new Session(this, credentials); + public Session.Builder newSession(Credentials credentials) { + return new Session.Builder(this, credentials); } public AnonymousSession getAnonymousSession() { @@ -58,10 +56,6 @@ public AnonymousSession getAnonymousSession() { return mAnonymousSession; } - public TokenCache getTokenCache() { - return mTokenCache; - } - public String getServerUrl() { return mServerUrl; } @@ -91,7 +85,6 @@ public static class ConditionalBuilder { private final String mServerUrl; private long mConnectionReadTimeOut = TimeUnit.SECONDS.toMillis(10); private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10);; - private TokenCache mTokenCache; private ConditionalBuilder(String serverUrl) { mServerUrl = serverUrl; @@ -107,13 +100,8 @@ public ConditionalBuilder connectionTimeOut(int timeOut, TimeUnit unit) { return this; } - public ConditionalBuilder cache(TokenCache cache) { - mTokenCache = cache; - return this; - } - public RestClient create() { - return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mTokenCache); + return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index 0991d3d6..7eb71857 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -25,11 +25,11 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.report.ReportService; import com.jaspersoft.android.sdk.service.server.InfoProvider; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import java.text.SimpleDateFormat; @@ -37,20 +37,32 @@ * @author Tom Koptel * @since 2.0 */ -public final class Session extends AnonymousSession implements TokenProvider, InfoProvider { +public final class Session extends AnonymousSession implements InfoProvider { + private final Credentials mCredentials; + private final TokenCache mTokenCache; private ReportService mReportService; - public Session(RestClient client, Credentials credentials) { + @TestOnly + Session(RestClient client, Credentials credentials, TokenCache tokenCache) { super(client); mCredentials = credentials; + mTokenCache = tokenCache; + } + + TokenCache getTokenCache() { + return mTokenCache; + } + + public Credentials getCredentials() { + return mCredentials; } @NotNull public ReportService reportApi() { if (mReportService == null) { - mReportService = ReportService.create(mClient, mCredentials); + mReportService = ReportService.create(mClient, this); } return mReportService; } @@ -61,11 +73,6 @@ public String getBaseUrl() { return mClient.getServerUrl(); } - @Override - public String provideToken() throws ServiceException { - return authApi().authenticate(mCredentials); - } - @Override public double provideVersion() throws ServiceException { return infoApi().requestServerVersion(); @@ -76,4 +83,28 @@ public double provideVersion() throws ServiceException { public SimpleDateFormat provideDateTimeFormat() throws ServiceException { return infoApi().requestServerDateTimeFormat(); } + + public static class Builder { + private final RestClient mClient; + private final Credentials mCredentials; + + private TokenCache mTokenCache; + + Builder(RestClient client, Credentials credentials) { + mClient = client; + mCredentials = credentials; + } + + public Builder tokenCache(TokenCache tokenCache) { + mTokenCache = tokenCache; + return this; + } + + public Session create() { + if (mTokenCache == null) { + mTokenCache = new InMemoryTokenCache(); + } + return new Session(mClient, mCredentials, mTokenCache); + } + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index f1540859..6aac5349 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -32,7 +32,7 @@ import com.jaspersoft.android.sdk.service.CallExecutor; import com.jaspersoft.android.sdk.service.CallExecutorImpl; import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import org.jetbrains.annotations.NotNull; @@ -60,7 +60,7 @@ public final class ReportService { mExportUseCase = exportUseCase; } - public static ReportService create(RestClient client, Credentials credentials) { + public static ReportService create(RestClient client, Session session) { ReportExecutionRestApi executionApi = new ReportExecutionRestApi.Builder() .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) @@ -71,7 +71,7 @@ public static ReportService create(RestClient client, Credentials credentials) { .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .baseUrl(client.getServerUrl()) .build(); - CallExecutor callExecutor = CallExecutorImpl.create(client, credentials); + CallExecutor callExecutor = CallExecutorImpl.create(client, session); ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getServerUrl()); ReportExecutionUseCase reportExecutionUseCase = diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java index a51977c9..1313752d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java @@ -45,7 +45,7 @@ public void testIntegration() { .organization("any") .build(); - Session session = client.newSession(credentials); + Session session = client.newSession(credentials).create(); session.reportApi(); AnonymousSession anonymousSession = client.getAnonymousSession(); From f777696a49b434a371c4938a31c79ac04b5c257e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 17:25:15 +0200 Subject: [PATCH 298/457] Info cache abstraction --- .../sdk/service/InMemoryInfoCache.java | 50 ++++++++++++++++++ .../android/sdk/service/InfoCache.java | 37 ++++++++++++++ .../sdk/service/InMemoryInfoCacheTest.java | 51 +++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryInfoCache.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/InfoCache.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryInfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryInfoCache.java new file mode 100644 index 00000000..829a8a51 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryInfoCache.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class InMemoryInfoCache implements InfoCache { + private ServerInfo mInfoCache; + + @Override + public ServerInfo get() { + return mInfoCache; + } + + @Override + public void put(ServerInfo serverInfo) { + mInfoCache = serverInfo; + } + + @Override + public void evict() { + mInfoCache = null; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCache.java new file mode 100644 index 00000000..66a2e8ac --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCache.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface InfoCache { + ServerInfo get(); + void put(ServerInfo serverInfo); + void evict(); +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java new file mode 100644 index 00000000..ca7acfdf --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertThat; + +public class InMemoryInfoCacheTest { + private InfoCache mInfoCache; + + @Before + public void setUp() throws Exception { + mInfoCache = new InMemoryInfoCache(); + } + + @Test + public void testGet() throws Exception { + ServerInfo serverInfo = new ServerInfo(); + mInfoCache.put(serverInfo); + assertThat(mInfoCache.get(), is(serverInfo)); + mInfoCache.evict(); + assertThat(mInfoCache.get(), is(nullValue())); + } +} \ No newline at end of file From 29e26fb81057d95bb8b579d50724647ea19ad8de Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 17:28:55 +0200 Subject: [PATCH 299/457] Associate info cache with session --- .../jaspersoft/android/sdk/service/Session.java | 15 +++++++++++++-- .../android/sdk/service/RestClientTest.java | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index 7eb71857..dcc26ba8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -41,14 +41,16 @@ public final class Session extends AnonymousSession implements InfoProvider { private final Credentials mCredentials; private final TokenCache mTokenCache; + private final InfoCache mInfo; private ReportService mReportService; @TestOnly - Session(RestClient client, Credentials credentials, TokenCache tokenCache) { + Session(RestClient client, Credentials credentials, TokenCache tokenCache, InfoCache infoCache) { super(client); mCredentials = credentials; mTokenCache = tokenCache; + mInfo = infoCache; } TokenCache getTokenCache() { @@ -89,12 +91,18 @@ public static class Builder { private final Credentials mCredentials; private TokenCache mTokenCache; + private InfoCache mInfoCache; Builder(RestClient client, Credentials credentials) { mClient = client; mCredentials = credentials; } + public Builder infoCache(InfoCache infoCache) { + mInfoCache = infoCache; + return this; + } + public Builder tokenCache(TokenCache tokenCache) { mTokenCache = tokenCache; return this; @@ -104,7 +112,10 @@ public Session create() { if (mTokenCache == null) { mTokenCache = new InMemoryTokenCache(); } - return new Session(mClient, mCredentials, mTokenCache); + if (mInfoCache == null) { + mInfoCache = new InMemoryInfoCache(); + } + return new Session(mClient, mCredentials, mTokenCache, mInfoCache); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java index 1313752d..beed48ed 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java @@ -45,7 +45,10 @@ public void testIntegration() { .organization("any") .build(); - Session session = client.newSession(credentials).create(); + Session session = client.newSession(credentials) + .tokenCache(new InMemoryTokenCache()) + .infoCache(new InMemoryInfoCache()) + .create(); session.reportApi(); AnonymousSession anonymousSession = client.getAnonymousSession(); From 0ce0d57a7f5f6215a85327493bf23bdc4eae53c1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 17:57:27 +0200 Subject: [PATCH 300/457] Implementing Info cache manager --- .../android/sdk/service/AnonymousSession.java | 7 +- .../android/sdk/service/InfoCacheManager.java | 36 +++++++++ .../sdk/service/InfoCacheManagerImpl.java | 65 ++++++++++++++++ .../android/sdk/service/Session.java | 17 ++++- .../sdk/service/server/ServerInfoService.java | 14 ++-- .../sdk/service/InfoCacheManagerImplTest.java | 76 +++++++++++++++++++ 6 files changed, 198 insertions(+), 17 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java index 972ae614..c7db6cba 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java @@ -63,12 +63,7 @@ public final JrsAuthenticator authApi() { @NotNull public final ServerInfoService infoApi() { if (mInfoService == null) { - ServerRestApi restApi = new ServerRestApi.Builder() - .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) - .baseUrl(mClient.getServerUrl()) - .build(); - mInfoService = ServerInfoService.create(restApi); + mInfoService = ServerInfoService.create(mClient); } return mInfoService; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java new file mode 100644 index 00000000..c127ddea --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface InfoCacheManager { + ServerInfo getInfo() throws Exception; + void invalidateInfo(); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java new file mode 100644 index 00000000..9aae6a6e --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.server.ServerInfoService; +import org.jetbrains.annotations.TestOnly; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class InfoCacheManagerImpl implements InfoCacheManager { + private final ServerInfoService mInfoService; + private final InfoCache mInfoCache; + + @TestOnly + InfoCacheManagerImpl(ServerInfoService infoService, InfoCache infoCache) { + mInfoService = infoService; + mInfoCache = infoCache; + } + + public static InfoCacheManager create(RestClient client, InfoCache infoCache) { + ServerInfoService serverInfoService = ServerInfoService.create(client); + return new InfoCacheManagerImpl(serverInfoService, infoCache); + } + + @Override + public ServerInfo getInfo() throws ServiceException { + ServerInfo info = mInfoCache.get(); + if (info == null) { + info = mInfoService.requestServerInfo(); + mInfoCache.put(info); + } + return info; + } + + @Override + public void invalidateInfo() { + mInfoCache.evict(); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index dcc26ba8..c693014d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -41,16 +41,16 @@ public final class Session extends AnonymousSession implements InfoProvider { private final Credentials mCredentials; private final TokenCache mTokenCache; - private final InfoCache mInfo; + private final InfoCacheManager mInfoCacheManager; private ReportService mReportService; @TestOnly - Session(RestClient client, Credentials credentials, TokenCache tokenCache, InfoCache infoCache) { + Session(RestClient client, Credentials credentials, TokenCache tokenCache, InfoCacheManager infoCacheManager) { super(client); mCredentials = credentials; mTokenCache = tokenCache; - mInfo = infoCache; + mInfoCacheManager = infoCacheManager; } TokenCache getTokenCache() { @@ -92,6 +92,7 @@ public static class Builder { private TokenCache mTokenCache; private InfoCache mInfoCache; + private InfoCacheManager mInfoCacheManager; Builder(RestClient client, Credentials credentials) { mClient = client; @@ -103,6 +104,11 @@ public Builder infoCache(InfoCache infoCache) { return this; } + public Builder infoCacheManager(InfoCacheManager infoCacheManager) { + mInfoCacheManager = infoCacheManager; + return this; + } + public Builder tokenCache(TokenCache tokenCache) { mTokenCache = tokenCache; return this; @@ -115,7 +121,10 @@ public Session create() { if (mInfoCache == null) { mInfoCache = new InMemoryInfoCache(); } - return new Session(mClient, mCredentials, mTokenCache, mInfoCache); + if (mInfoCacheManager == null) { + mInfoCacheManager = InfoCacheManagerImpl.create(mClient, mInfoCache); + } + return new Session(mClient, mCredentials, mTokenCache, mInfoCacheManager); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index a65f4de5..43e0d47b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; @@ -35,12 +36,13 @@ import java.io.IOException; import java.text.SimpleDateFormat; +import java.util.concurrent.TimeUnit; /** * @author Tom Koptel * @since 2.0 */ -public final class ServerInfoService { +public class ServerInfoService { private final ServerRestApi mRestApi; private final ServerInfoTransformer mTransformer; @@ -50,18 +52,16 @@ public final class ServerInfoService { mTransformer = transformer; } - public static ServerInfoService create(String baseUrl) { + public static ServerInfoService create(RestClient client) { ServerRestApi restApi = new ServerRestApi.Builder() - .baseUrl(baseUrl) + .baseUrl(client.getServerUrl()) + .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(client.getReadTimeOut(), TimeUnit.MICROSECONDS) .build(); return new ServerInfoService(restApi, ServerInfoTransformer.get()); } - public static ServerInfoService create(ServerRestApi restApi) { - return new ServerInfoService(restApi, ServerInfoTransformer.get()); - } - public ServerInfo requestServerInfo() throws ServiceException { try { ServerInfoData response = mRestApi.requestServerInfo(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java new file mode 100644 index 00000000..abcb48eb --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java @@ -0,0 +1,76 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.server.ServerInfoService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + +public class InfoCacheManagerImplTest { + @Mock + ServerInfoService mInfoService; + @Mock + InfoCache mInfoCache; + @Mock + ServerInfo info; + + private InfoCacheManager mManager; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + when(mInfoService.requestServerInfo()).thenReturn(info); + mManager = new InfoCacheManagerImpl(mInfoService, mInfoCache); + } + + @Test + public void testGetInfoWithCache() throws Exception { + when(mInfoCache.get()).thenReturn(info); + mManager.getInfo(); + verify(mInfoCache).get(); + } + + @Test + public void testGetInfoWithoutCache() throws Exception { + when(mInfoCache.get()).thenReturn(null); + mManager.getInfo(); + verify(mInfoCache).get(); + verify(mInfoService).requestServerInfo(); + verify(mInfoCache).put(info); + } + + @Test + public void testInvalidateInfo() throws Exception { + mManager.invalidateInfo(); + verify(mInfoCache).evict(); + } +} \ No newline at end of file From 8618b2f783370055835cc695423a35b44d66f847 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 19:05:08 +0200 Subject: [PATCH 301/457] Integrating call executor, info cache manager with repo API --- .../android/sdk/service/InfoCacheManager.java | 3 +- .../android/sdk/service/Session.java | 31 +++----- .../service/repository/RepositoryService.java | 32 +++++--- .../service/repository/SearchStrategy.java | 14 +--- .../service/repository/SearchTaskImpl.java | 38 +++++++--- .../sdk/service/repository/SearchUseCase.java | 73 +++++++++++-------- .../android/sdk/service/RestClientTest.java | 1 + .../repository/RepositoryServiceTest.java | 8 +- .../repository/SearchStrategyTest.java | 24 ++---- .../repository/SearchTaskImplTest.java | 37 +++++----- .../service/repository/SearchUseCaseTest.java | 31 ++++---- 11 files changed, 151 insertions(+), 141 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java index c127ddea..e697f01c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java @@ -25,12 +25,13 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; /** * @author Tom Koptel * @since 2.0 */ public interface InfoCacheManager { - ServerInfo getInfo() throws Exception; + ServerInfo getInfo() throws ServiceException; void invalidateInfo(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index c693014d..df8da39f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -25,25 +25,23 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.report.ReportService; -import com.jaspersoft.android.sdk.service.server.InfoProvider; +import com.jaspersoft.android.sdk.service.repository.RepositoryService; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; -import java.text.SimpleDateFormat; - /** * @author Tom Koptel * @since 2.0 */ -public final class Session extends AnonymousSession implements InfoProvider { +public final class Session extends AnonymousSession { private final Credentials mCredentials; private final TokenCache mTokenCache; private final InfoCacheManager mInfoCacheManager; private ReportService mReportService; + private RepositoryService mRepositoryService; @TestOnly Session(RestClient client, Credentials credentials, TokenCache tokenCache, InfoCacheManager infoCacheManager) { @@ -57,6 +55,10 @@ TokenCache getTokenCache() { return mTokenCache; } + public InfoCacheManager getInfoCacheManager() { + return mInfoCacheManager; + } + public Credentials getCredentials() { return mCredentials; } @@ -70,20 +72,11 @@ public ReportService reportApi() { } @NotNull - @Override - public String getBaseUrl() { - return mClient.getServerUrl(); - } - - @Override - public double provideVersion() throws ServiceException { - return infoApi().requestServerVersion(); - } - - @NotNull - @Override - public SimpleDateFormat provideDateTimeFormat() throws ServiceException { - return infoApi().requestServerDateTimeFormat(); + public RepositoryService repositoryApi() { + if (mRepositoryService == null) { + mRepositoryService = RepositoryService.create(mClient, this); + } + return mRepositoryService; } public static class Builder { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 7328c3fa..fa2298c2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -25,8 +25,10 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.*; +import org.jetbrains.annotations.TestOnly; + +import java.util.concurrent.TimeUnit; /** * @author Tom Koptel @@ -34,18 +36,28 @@ */ public class RepositoryService { private final RepositoryRestApi mRepositoryRestApi; - private final TokenProvider mTokenProvider; - private final InfoProvider mInfoProvider; + private final CallExecutor mCallExecutor; + private final InfoCacheManager mInfoCacheManager; - public RepositoryService(RepositoryRestApi repositoryRestApi, - TokenProvider tokenProvider, - InfoProvider infoProvider) { + @TestOnly + RepositoryService(RepositoryRestApi repositoryRestApi, CallExecutor callExecutor, InfoCacheManager infoCacheManager) { mRepositoryRestApi = repositoryRestApi; - mTokenProvider = tokenProvider; - mInfoProvider = infoProvider; + mCallExecutor = callExecutor; + mInfoCacheManager = infoCacheManager; + } + + public static RepositoryService create(RestClient client, Session session) { + RepositoryRestApi repositoryRestApi = new RepositoryRestApi.Builder() + .baseUrl(client.getServerUrl()) + .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) + .build(); + CallExecutor callExecutor = CallExecutorImpl.create(client, session); + + return new RepositoryService(repositoryRestApi, callExecutor, session.getInfoCacheManager()); } public SearchTask search(SearchCriteria criteria) { - return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryRestApi, mTokenProvider, mInfoProvider); + return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryRestApi, mCallExecutor, mInfoCacheManager); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java index 710a2725..81bf516f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java @@ -24,11 +24,8 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import java.util.Collection; @@ -41,14 +38,7 @@ interface SearchStrategy { boolean hasNext(); class Factory { - public static SearchStrategy get(InternalCriteria criteria, - RepositoryRestApi repositoryRestApi, - InfoProvider infoProvider, - TokenProvider tokenProvider) { - double version = infoProvider.provideVersion(); - ResourceMapper resourceMapper = new ResourceMapper(); - SearchUseCase searchUseCase = new SearchUseCase(resourceMapper, repositoryRestApi, tokenProvider, infoProvider); - + public static SearchStrategy get(SearchUseCase searchUseCase, InternalCriteria criteria, double version) { if (version <= 5.5d) { return new EmeraldMR2SearchStrategy(criteria, searchUseCase); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index f58c1394..0b59fc36 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -25,13 +25,13 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.CallExecutor; +import com.jaspersoft.android.sdk.service.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; - +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.util.Collection; @@ -42,20 +42,21 @@ final class SearchTaskImpl implements SearchTask { private final InternalCriteria mCriteria; private final RepositoryRestApi mRepositoryRestApi; - private final TokenProvider mTokenProvider; - private final InfoProvider mInfoProvider; + private final CallExecutor mCallExecutor; + private final InfoCacheManager mInfoCacheManager; @Nullable private SearchStrategy strategy; + @TestOnly SearchTaskImpl(InternalCriteria criteria, RepositoryRestApi repositoryRestApi, - TokenProvider tokenProvider, - InfoProvider infoProvider) { + CallExecutor callExecutor, + InfoCacheManager infoCacheManager) { mCriteria = criteria; mRepositoryRestApi = repositoryRestApi; - mTokenProvider = tokenProvider; - mInfoProvider = infoProvider; + mCallExecutor = callExecutor; + mInfoCacheManager = infoCacheManager; } @NotNull @@ -76,9 +77,22 @@ public boolean hasNext() { return true; } - private SearchStrategy defineSearchStrategy() { + private SearchStrategy defineSearchStrategy() throws ServiceException { if (strategy == null) { - strategy = SearchStrategy.Factory.get(mCriteria, mRepositoryRestApi, mInfoProvider, mTokenProvider); + double version = mInfoCacheManager.getInfo().getVersion(); + + ResourceMapper resourceMapper = new ResourceMapper(); + SearchUseCase searchUseCase = new SearchUseCase( + resourceMapper, + mRepositoryRestApi, + mInfoCacheManager, + mCallExecutor + ); + strategy = SearchStrategy.Factory.get( + searchUseCase, + mCriteria, + version + ); } return strategy; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index b8e39fc4..7b33e758 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -27,57 +27,70 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.Call; +import com.jaspersoft.android.sdk.service.CallExecutor; +import com.jaspersoft.android.sdk.service.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; - +import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Collection; +import java.util.Map; /** * @author Tom Koptel * @since 2.0 */ -final class SearchUseCase { - private final RepositoryRestApi mRestApi; - private final TokenProvider mTokenProvider; - private final InfoProvider mInfoProvider; +class SearchUseCase { private final ResourceMapper mDataMapper; + private final RepositoryRestApi mRestApi; + private final InfoCacheManager mInfoCacheManager; + private final CallExecutor mCallExecutor; - public SearchUseCase( - ResourceMapper dataMapper, RepositoryRestApi restApi, - TokenProvider tokenProvider, InfoProvider infoProvider) { - mRestApi = restApi; - mTokenProvider = tokenProvider; - mInfoProvider = infoProvider; + SearchUseCase(ResourceMapper dataMapper, + RepositoryRestApi restApi, + InfoCacheManager infoCacheManager, + CallExecutor callExecutor) { mDataMapper = dataMapper; + mRestApi = restApi; + mInfoCacheManager = infoCacheManager; + mCallExecutor = callExecutor; } @NotNull - public SearchResult performSearch(@NotNull InternalCriteria criteria) throws ServiceException { - ResourceSearchResult response = null; - try { - response = mRestApi.searchResources(mTokenProvider.provideToken(), CriteriaMapper.map(criteria)); + public SearchResult performSearch(@NotNull final InternalCriteria internalCriteria) throws ServiceException { + Call call = new Call() { + @Override + public SearchResult perform(String token) throws IOException, HttpException { + Map criteria = CriteriaMapper.map(internalCriteria); + ResourceSearchResult response = mRestApi.searchResources(token, criteria); - SimpleDateFormat dateTimeFormat = mInfoProvider.provideDateTimeFormat(); + SimpleDateFormat dateTimeFormat = null; + try { + dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); - SearchResult searchResult = new SearchResult(); - searchResult.setNextOffset(response.getNextOffset()); + SearchResult searchResult = new SearchResult(); + searchResult.setNextOffset(response.getNextOffset()); - Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); - searchResult.setResources(resources); + Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); + searchResult.setResources(resources); - return searchResult; - } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); - } + return searchResult; + } catch (ServiceException e) { + Throwable cause = e.getCause(); + if (cause instanceof IOException) { + throw (IOException) cause; + } + if (cause instanceof HttpException) { + throw (HttpException) cause; + } + throw new RuntimeException(cause); + } + } + }; + return mCallExecutor.execute(call); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java index beed48ed..eff20def 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java @@ -50,6 +50,7 @@ public void testIntegration() { .infoCache(new InMemoryInfoCache()) .create(); session.reportApi(); + session.repositoryApi(); AnonymousSession anonymousSession = client.getAnonymousSession(); anonymousSession.authApi(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index ada4a00f..3fdc0930 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -25,9 +25,9 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.server.InfoProvider; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.InfoCacheManager; import com.jaspersoft.android.sdk.service.auth.TokenProvider; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -49,7 +49,7 @@ public class RepositoryServiceTest { @Mock TokenProvider mTokenProvider; @Mock - InfoProvider mInfoProvider; + InfoCacheManager mInfoCacheManager; private RepositoryService objectUnderTest; @@ -59,7 +59,7 @@ public class RepositoryServiceTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new RepositoryService(repoApi, mTokenProvider, mInfoProvider); + objectUnderTest = new RepositoryService(repoApi, new FakeCallExecutor("cookie"), mInfoCacheManager); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java index e77fe01e..b2a57442 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java @@ -24,22 +24,16 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; - +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertThat; -import static org.powermock.api.mockito.PowerMockito.when; /** * @author Tom Koptel @@ -50,11 +44,7 @@ public class SearchStrategyTest { private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock - RepositoryRestApi mRepoApi; - @Mock - TokenProvider mTokenProvider; - @Mock - InfoProvider mInfoProvider; + SearchUseCase mSearchUseCase; @Before public void before() { @@ -67,9 +57,7 @@ public void before() { "5.5" }) public void factoryCreatesEmeraldMR2Strategy(String version) { - when(mInfoProvider.provideVersion()).thenReturn(Double.valueOf(version)); - - SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(mSearchUseCase, CRITERIA, Double.valueOf(version)); assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); } @@ -79,9 +67,7 @@ public void factoryCreatesEmeraldMR2Strategy(String version) { "6.1" }) public void factoryCreatesEmeraldMR3Strategy(String version) { - when(mInfoProvider.provideVersion()).thenReturn(Double.valueOf(version)); - - SearchStrategy searchStrategy = SearchStrategy.Factory.get(CRITERIA, mRepoApi, mInfoProvider, mTokenProvider); + SearchStrategy searchStrategy = SearchStrategy.Factory.get(mSearchUseCase, CRITERIA, Double.valueOf(version)); assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index 988c3821..a042e608 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -25,9 +25,10 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; - +import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.InfoCacheManager; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,11 +38,11 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.Collections; + import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Matchers.anyDouble; +import static org.mockito.Mockito.*; /** * @author Tom Koptel @@ -57,28 +58,28 @@ public class SearchTaskImplTest { @Mock SearchStrategy mSearchStrategy; @Mock - TokenProvider mTokenProvider; + InfoCacheManager mInfoCacheManager; @Mock - InfoProvider mInfoProvider; + ServerInfo mServerInfo; private SearchTaskImpl objectUnderTest; @Before public void setup() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApi, mTokenProvider, mInfoProvider); + objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApi, new FakeCallExecutor("cookie"), mInfoCacheManager); - when(mSearchStrategy.searchNext()).thenReturn(null); + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + when(mSearchStrategy.searchNext()).thenReturn(Collections.emptyList()); PowerMockito.mockStatic(SearchStrategy.Factory.class); PowerMockito.when( SearchStrategy.Factory.get( + any(SearchUseCase.class), any(InternalCriteria.class), - any(RepositoryRestApi.class), - any(InfoProvider.class), - any(TokenProvider.class) + anyDouble() ) ).thenReturn(mSearchStrategy); } @@ -87,10 +88,8 @@ public void setup() throws Exception { public void nextLookupShouldDefineSearchStrategy() throws Exception { objectUnderTest.nextLookup(); - PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq(CRITERIA), eq(mRepoApi), eq(mInfoProvider), eq(mTokenProvider)); - verify(mSearchStrategy).searchNext(); + verify(mInfoCacheManager).getInfo(); } @Test @@ -98,9 +97,7 @@ public void secondLookupShouldUseCachedStrategy() throws Exception { objectUnderTest.nextLookup(); objectUnderTest.nextLookup(); - PowerMockito.verifyStatic(times(1)); - SearchStrategy.Factory.get(eq(CRITERIA), eq(mRepoApi), eq(mInfoProvider), eq(mTokenProvider)); - + verify(mInfoCacheManager).getInfo(); verify(mSearchStrategy, times(2)).searchNext(); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 8bcf7101..840f5aaf 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -27,12 +27,11 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.server.InfoProvider; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; - import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -47,9 +46,7 @@ import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyCollection; -import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.*; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -60,18 +57,16 @@ public class SearchUseCaseTest { public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat(); - @Mock - RepositoryRestApi mRepositoryRestApi; + @Mock ResourceMapper mDataMapper; @Mock - TokenProvider mTokenProvider; + RepositoryRestApi mRepositoryRestApi; @Mock - InfoProvider mInfoProvider; + InfoCacheManager mInfoCacheManager; @Mock ResourceLookup mResourceLookup; - @Mock InternalCriteria mCriteria; @Mock @@ -83,16 +78,24 @@ public class SearchUseCaseTest { private SearchUseCase objectUnderTest; @Before - public void setup() { + public void setup() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchUseCase(mDataMapper, mRepositoryRestApi, mTokenProvider, mInfoProvider); + + when(mServerInfo.getDatetimeFormatPattern()).thenReturn(DATE_TIME_FORMAT); + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + + objectUnderTest = new SearchUseCase( + mDataMapper, + mRepositoryRestApi, + mInfoCacheManager, + new FakeCallExecutor("cookie") + ); } @Test public void shouldProvideAndAdaptSearchResult() throws Exception { when(mResult.getNextOffset()).thenReturn(100); when(mRepositoryRestApi.searchResources(anyString(), any(Map.class))).thenReturn(mResult); - when(mInfoProvider.provideDateTimeFormat()).thenReturn(DATE_TIME_FORMAT); Collection resources = new ArrayList(); when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); From 7542331927d12e59b282d141ce7654a1b8e522fe Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 19:09:13 +0200 Subject: [PATCH 302/457] Remove token/info providers --- .../sdk/service/auth/TokenProvider.java | 33 ------------- .../sdk/service/server/InfoProvider.java | 46 ------------------- .../repository/RepositoryServiceTest.java | 3 -- 3 files changed, 82 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java deleted file mode 100644 index 5e51af2e..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/TokenProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.auth; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface TokenProvider { - String provideToken() throws Exception; -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java deleted file mode 100644 index 9a424a97..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/InfoProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.server; - -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; - -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import org.jetbrains.annotations.NotNull; - -import java.text.SimpleDateFormat; - -/** - * Internal interface to abstract out server info generation strategy - * - * @author Tom Koptel - * @since 2.0 - */ -public interface InfoProvider { - @NotNull - String getBaseUrl(); - double provideVersion() throws ServiceException; - @NotNull - SimpleDateFormat provideDateTimeFormat() throws ServiceException; -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 3fdc0930..236d99f2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -27,7 +27,6 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.InfoCacheManager; -import com.jaspersoft.android.sdk.service.auth.TokenProvider; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -47,8 +46,6 @@ public class RepositoryServiceTest { @Mock RepositoryRestApi repoApi; @Mock - TokenProvider mTokenProvider; - @Mock InfoCacheManager mInfoCacheManager; private RepositoryService objectUnderTest; From 2c2f07b5d798e1dbce34490371cca83bd0e85182 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 19:17:44 +0200 Subject: [PATCH 303/457] Reduce Authentication factory API --- .../android/sdk/service/AnonymousSession.java | 18 ++--- .../android/sdk/service/TokenFactory.java | 4 +- ...icator.java => AuthenticationService.java} | 24 +++---- .../auth/AuthenticationServiceTest.java | 45 ++++++++++++ .../service/auth/JrsAuthenticatorTest.java | 70 ------------------- 5 files changed, 63 insertions(+), 98 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/service/auth/{JrsAuthenticator.java => AuthenticationService.java} (56%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java index c7db6cba..9d2bef0b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java @@ -24,14 +24,10 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.ServerRestApi; -import com.jaspersoft.android.sdk.service.auth.JrsAuthenticator; +import com.jaspersoft.android.sdk.service.auth.AuthenticationService; import com.jaspersoft.android.sdk.service.server.ServerInfoService; import org.jetbrains.annotations.NotNull; -import java.util.concurrent.TimeUnit; - /** * @author Tom Koptel * @since 2.0 @@ -39,7 +35,7 @@ public class AnonymousSession { protected final RestClient mClient; - private JrsAuthenticator mAuthenticator; + private AuthenticationService mAuthenticator; private ServerInfoService mInfoService; protected AnonymousSession(RestClient client) { @@ -47,15 +43,9 @@ protected AnonymousSession(RestClient client) { } @NotNull - public final JrsAuthenticator authApi() { + public final AuthenticationService authApi() { if (mAuthenticator == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() - .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) - .baseUrl(mClient.getServerUrl()) - .build(); - - mAuthenticator = JrsAuthenticator.create(restApi); + mAuthenticator = AuthenticationService.create(mClient); } return mAuthenticator; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java index 12847026..b8c3ed87 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.auth.JrsAuthenticator; +import com.jaspersoft.android.sdk.service.auth.AuthenticationService; import com.jaspersoft.android.sdk.service.exception.ServiceException; import java.io.IOException; @@ -43,7 +43,7 @@ class TokenFactory { } public String create(Credentials credentials) throws IOException, HttpException { - JrsAuthenticator auth = mRestClient.getAnonymousSession().authApi(); + AuthenticationService auth = mRestClient.getAnonymousSession().authApi(); try { return auth.authenticate(credentials); } catch (ServiceException e) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java similarity index 56% rename from core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java index 2ab6bdc9..2dc7a820 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java @@ -1,37 +1,37 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import java.util.concurrent.TimeUnit; + import static com.jaspersoft.android.sdk.service.internal.Preconditions.checkNotNull; /** * @author Tom Koptel * @since 2.0 */ -public final class JrsAuthenticator { +public final class AuthenticationService { private final AuthPolicy mAuthPolicy; @TestOnly - JrsAuthenticator(AuthPolicy authPolicy) { + AuthenticationService(AuthPolicy authPolicy) { mAuthPolicy = authPolicy; } @NotNull - public static JrsAuthenticator create(@NotNull String baseUrl) { - checkNotNull(baseUrl, "Base url should not be null"); - AuthPolicy policyImpl = AuthPolicy.Default.create(baseUrl); - return new JrsAuthenticator(policyImpl); - } - - @NotNull - public static JrsAuthenticator create(@NotNull AuthenticationRestApi restApi) { - checkNotNull(restApi, "Authentication API should not be null"); + public static AuthenticationService create(@NotNull RestClient mClient) { + AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() + .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) + .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) + .baseUrl(mClient.getServerUrl()) + .build(); AuthPolicy policyImpl = AuthPolicy.Default.create(restApi); - return new JrsAuthenticator(policyImpl); + return new AuthenticationService(policyImpl); } @NotNull diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java new file mode 100644 index 00000000..a61b6555 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java @@ -0,0 +1,45 @@ +package com.jaspersoft.android.sdk.service.auth; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +/** + * @author Tom Koptel + */ +public class AuthenticationServiceTest { + + @Mock + AuthPolicy mAuthPolicy; + @Mock + Credentials mCredentials; + + private AuthenticationService authenticatorUnderTest; + + @Rule + public ExpectedException mExpectedException = ExpectedException.none(); + + @Before + public void setupMocks() throws Exception { + MockitoAnnotations.initMocks(this); + when(mCredentials.applyPolicy(any(AuthPolicy.class))).thenReturn("cookie"); + authenticatorUnderTest = new AuthenticationService(mAuthPolicy); + } + + @Test + public void testAuthenticate() throws Exception { + authenticatorUnderTest.authenticate(mCredentials); + + verify(mCredentials).applyPolicy(mAuthPolicy); + verifyNoMoreInteractions(mCredentials); + verifyNoMoreInteractions(mAuthPolicy); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java deleted file mode 100644 index c14e940c..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/JrsAuthenticatorTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.jaspersoft.android.sdk.service.auth; - -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -/** - * @author Tom Koptel - */ -public class JrsAuthenticatorTest { - - @Mock - AuthPolicy mAuthPolicy; - @Mock - Credentials mCredentials; - - private JrsAuthenticator authenticatorUnderTest; - - @Rule - public ExpectedException mExpectedException = ExpectedException.none(); - - @Before - public void setupMocks() { - MockitoAnnotations.initMocks(this); - authenticatorUnderTest = new JrsAuthenticator(mAuthPolicy); - } - - @Test - public void testAuthenticate() throws Exception { - authenticatorUnderTest.authenticate(mCredentials); - - verify(mCredentials).applyPolicy(mAuthPolicy); - verifyNoMoreInteractions(mCredentials); - verifyNoMoreInteractions(mAuthPolicy); - } - - @Test - public void factoryMethodShouldNotAcceptNullBaseUrl() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Base url should not be null"); - - String baseUrl = null; - JrsAuthenticator.create(baseUrl); - } - - @Test - public void factoryMethodShouldNotAcceptNullApi() { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Authentication API should not be null"); - - AuthenticationRestApi restApi = null; - JrsAuthenticator.create(restApi); - } - - @Test - public void authenticateShouldNotAcceptNullCredentials() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Credentials should not be null"); - - authenticatorUnderTest.authenticate(null); - } -} \ No newline at end of file From 48c0bbcc63894ad42a6e3d479e9dbedd78ad2a8c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 19:39:46 +0200 Subject: [PATCH 304/457] Implementing TokenCacheManager and factory --- .../android/sdk/service/CallExecutorImpl.java | 24 ++++--- .../android/sdk/service/Session.java | 21 ++++-- .../sdk/service/TokenCacheManager.java | 39 +++++++++++ .../sdk/service/TokenManagerFactory.java | 65 +++++++++++++++++++ .../sdk/service/CallExecutorImplTest.java | 50 ++++++++------ 5 files changed, 166 insertions(+), 33 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/TokenCacheManager.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java index c8ccfb31..3507d758 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java @@ -37,13 +37,18 @@ * @since 2.0 */ public final class CallExecutorImpl implements CallExecutor { - private final TokenCache mTokenCache; + private final TokenCacheManager.Factory mTokenCacheManagerFactory; + private final InfoCacheManager mInfoCacheManager; private final TokenFactory mTokenFactory; private final Credentials mCredentials; @TestOnly - CallExecutorImpl(Credentials credentials, TokenCache tokenCache, TokenFactory tokenFactory) { - mTokenCache = tokenCache; + CallExecutorImpl(Credentials credentials, + TokenCacheManager.Factory tokenCacheManagerFactory, + InfoCacheManager cacheManager, + TokenFactory tokenFactory) { + mTokenCacheManagerFactory = tokenCacheManagerFactory; + mInfoCacheManager = cacheManager; mTokenFactory = tokenFactory; mCredentials = credentials; } @@ -51,7 +56,8 @@ public final class CallExecutorImpl implements CallExecutor { public static CallExecutorImpl create(RestClient client, Session session) { return new CallExecutorImpl( session.getCredentials(), - session.getTokenCache(), + session.getTokenCacheManagerFactory(), + session.getInfoCacheManager(), new TokenFactory(client) ); } @@ -62,22 +68,24 @@ public T execute(Call call) { } */ public T execute(Call call) throws ServiceException { - String token = mTokenCache.get(); + double versionCode = mInfoCacheManager.getInfo().getVersion(); + TokenCacheManager tokenCacheManager = mTokenCacheManagerFactory.create(versionCode); + String token = tokenCacheManager.getToken(); try { if (token == null) { token = mTokenFactory.create(mCredentials); - mTokenCache.put(token); + tokenCacheManager.persistToken(token); } return call.perform(token); } catch (IOException e) { throw ServiceExceptionMapper.transform(e); } catch (HttpException e) { if (e.code() == 401) { - mTokenCache.evict(); + tokenCacheManager.invalidateToken(); try { token = mTokenFactory.create(mCredentials); - mTokenCache.put(token); + tokenCacheManager.persistToken(token); return call.perform(token); } catch (IOException e1) { throw ServiceExceptionMapper.transform(e1); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index df8da39f..d19b5313 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -37,22 +37,22 @@ public final class Session extends AnonymousSession { private final Credentials mCredentials; - private final TokenCache mTokenCache; private final InfoCacheManager mInfoCacheManager; + private final TokenCacheManager.Factory mTokenCacheManagerFactory; private ReportService mReportService; private RepositoryService mRepositoryService; @TestOnly - Session(RestClient client, Credentials credentials, TokenCache tokenCache, InfoCacheManager infoCacheManager) { + Session(RestClient client, Credentials credentials, TokenCacheManager.Factory tokenCacheManagerFactory, InfoCacheManager infoCacheManager) { super(client); mCredentials = credentials; - mTokenCache = tokenCache; + mTokenCacheManagerFactory = tokenCacheManagerFactory; mInfoCacheManager = infoCacheManager; } - TokenCache getTokenCache() { - return mTokenCache; + TokenCacheManager.Factory getTokenCacheManagerFactory() { + return mTokenCacheManagerFactory; } public InfoCacheManager getInfoCacheManager() { @@ -86,6 +86,7 @@ public static class Builder { private TokenCache mTokenCache; private InfoCache mInfoCache; private InfoCacheManager mInfoCacheManager; + private TokenCacheManager.Factory mTokenCacheManagerFactory; Builder(RestClient client, Credentials credentials) { mClient = client; @@ -102,6 +103,11 @@ public Builder infoCacheManager(InfoCacheManager infoCacheManager) { return this; } + public Builder tokenCacheManagerFactory(TokenCacheManager.Factory tokenCacheManagerFactory) { + mTokenCacheManagerFactory = tokenCacheManagerFactory; + return this; + } + public Builder tokenCache(TokenCache tokenCache) { mTokenCache = tokenCache; return this; @@ -117,7 +123,10 @@ public Session create() { if (mInfoCacheManager == null) { mInfoCacheManager = InfoCacheManagerImpl.create(mClient, mInfoCache); } - return new Session(mClient, mCredentials, mTokenCache, mInfoCacheManager); + if (mTokenCacheManagerFactory == null) { + mTokenCacheManagerFactory = new TokenManagerFactory(mTokenCache); + } + return new Session(mClient, mCredentials, mTokenCacheManagerFactory, mInfoCacheManager); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCacheManager.java new file mode 100644 index 00000000..6db7775b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCacheManager.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface TokenCacheManager { + public String getToken(); + public void persistToken(String token); + public void invalidateToken(); + + interface Factory { + TokenCacheManager create(double versionCode); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java new file mode 100644 index 00000000..87a8d286 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class TokenManagerFactory implements TokenCacheManager.Factory { + private final TokenCache mTokenCache; + + public TokenManagerFactory(TokenCache tokenCache) { + mTokenCache = tokenCache; + } + + @Override + public TokenCacheManager create(double versionCode) { + return new DefaultManager(mTokenCache); + } + + private static class DefaultManager implements TokenCacheManager{ + private final TokenCache mTokenCache; + + private DefaultManager(TokenCache tokenCache) { + mTokenCache = tokenCache; + } + + @Override + public String getToken() { + return mTokenCache.get(); + } + + @Override + public void persistToken(String token) { + mTokenCache.put(token); + } + + @Override + public void invalidateToken() { + mTokenCache.evict(); + } + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java index 2b83fe41..6136165c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import org.junit.Before; @@ -43,7 +44,12 @@ public class CallExecutorImplTest { @Mock - TokenCache mCache; + TokenCacheManager mTokenCacheManager; + @Mock + TokenCacheManager.Factory mTokenCacheManagerFactory; + @Mock + InfoCacheManager mInfoCacheManager; + @Mock TokenFactory mFactory; @Mock @@ -54,6 +60,9 @@ public class CallExecutorImplTest { @Mock HttpException _401Exception; + @Mock + ServerInfo mServerInfo; + private CallExecutorImpl resolver; private Object mResponse = new Object(); @@ -62,37 +71,40 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenReturn(mResponse); - resolver = new CallExecutorImpl(mCredentials, mCache, mFactory); + + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + when(mTokenCacheManagerFactory.create(anyDouble())).thenReturn(mTokenCacheManager); + resolver = new CallExecutorImpl(mCredentials, mTokenCacheManagerFactory, mInfoCacheManager, mFactory); } @Test public void testExecuteWithValidCache() throws Exception { - when(mCache.get()).thenReturn("token"); + when(mTokenCacheManager.getToken()).thenReturn("token"); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mCache).get(); + verify(mTokenCacheManager).getToken(); verify(mCall).perform("token"); - verifyNoMoreInteractions(mCache); + verifyNoMoreInteractions(mTokenCacheManager); verifyZeroInteractions(mFactory); } @Test public void testExecuteWithEmptyCache() throws Exception { - when(mCache.get()).thenReturn(null); + when(mTokenCacheManager.getToken()).thenReturn(null); when(mFactory.create(any(Credentials.class))).thenReturn("token"); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mCache).get(); + verify(mTokenCacheManager).getToken(); verify(mFactory).create(mCredentials); - verify(mCache).put("token"); + verify(mTokenCacheManager).persistToken("token"); verify(mCall).perform("token"); } @Test public void testExecuteWithInvalidCache() throws Exception { - when(mCache.get()).thenReturn("invalid token"); + when(mTokenCacheManager.getToken()).thenReturn("invalid token"); when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenAnswer(_401ResponseAtFirstInvokation()); @@ -101,17 +113,17 @@ public void testExecuteWithInvalidCache() throws Exception { assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mCache).get(); + verify(mTokenCacheManager).getToken(); verify(mCall).perform("invalid token"); - verify(mCache).evict(); + verify(mTokenCacheManager).invalidateToken(); verify(mFactory).create(mCredentials); - verify(mCache).put("token"); + verify(mTokenCacheManager).persistToken("token"); verify(mCall).perform("token"); } @Test public void testExecuteWithInvalidCredentials() throws Exception { - when(mCache.get()).thenReturn("invalid token"); + when(mTokenCacheManager.getToken()).thenReturn("invalid token"); when(mCall.perform(anyString())).thenThrow(_401Exception); when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); @@ -121,15 +133,15 @@ public void testExecuteWithInvalidCredentials() throws Exception { assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); } - verify(mCache).get(); + verify(mTokenCacheManager).getToken(); verify(mCall).perform("invalid token"); - verify(mCache).evict(); + verify(mTokenCacheManager).invalidateToken(); verify(mFactory).create(mCredentials); } @Test public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { - when(mCache.get()).thenReturn(null); + when(mTokenCacheManager.getToken()).thenReturn(null); when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); try { @@ -138,11 +150,11 @@ public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); } - verify(mCache).get(); - verify(mCache).evict(); + verify(mTokenCacheManager).getToken(); + verify(mTokenCacheManager).invalidateToken(); verify(mFactory, times(2)).create(mCredentials); - verifyNoMoreInteractions(mCache); + verifyNoMoreInteractions(mTokenCacheManager); verifyNoMoreInteractions(mFactory); verifyZeroInteractions(mCall); } From 1b34ca159ac6d428b3353948bea402d62f2cab8c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 19:44:13 +0200 Subject: [PATCH 305/457] Group components by packages --- .../sdk/service/InfoCacheManagerImpl.java | 2 ++ .../android/sdk/service/Session.java | 8 ++++++- .../sdk/service/TokenManagerFactory.java | 3 +++ .../android/sdk/service/{ => call}/Call.java | 2 +- .../sdk/service/{ => call}/CallExecutor.java | 2 +- .../service/{ => info}/InMemoryInfoCache.java | 4 ++-- .../sdk/service/{ => info}/InfoCache.java | 2 +- .../service/{ => info}/InfoCacheManager.java | 2 +- .../DefaultCallExecutor.java} | 23 +++++++++++-------- .../service/{ => internal}/TokenFactory.java | 3 ++- .../report/ReportExecutionUseCase.java | 4 ++-- .../service/report/ReportExportUseCase.java | 4 ++-- .../sdk/service/report/ReportService.java | 6 ++--- .../service/repository/RepositoryService.java | 5 +++- .../service/repository/SearchTaskImpl.java | 4 ++-- .../sdk/service/repository/SearchUseCase.java | 6 ++--- .../{ => token}/InMemoryTokenCache.java | 4 +++- .../sdk/service/{ => token}/TokenCache.java | 2 +- .../{ => token}/TokenCacheManager.java | 2 +- ...Test.java => DefaultCallExecutorTest.java} | 11 ++++++--- .../android/sdk/service/FakeCallExecutor.java | 2 ++ .../sdk/service/InMemoryInfoCacheTest.java | 2 ++ .../sdk/service/InMemoryTokenCacheTest.java | 1 + .../sdk/service/InfoCacheManagerImplTest.java | 2 ++ .../android/sdk/service/RestClientTest.java | 2 ++ .../repository/RepositoryServiceTest.java | 2 +- .../repository/SearchTaskImplTest.java | 2 +- .../service/repository/SearchUseCaseTest.java | 2 +- 28 files changed, 75 insertions(+), 39 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => call}/Call.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => call}/CallExecutor.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => info}/InMemoryInfoCache.java (92%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => info}/InfoCache.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => info}/InfoCacheManager.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{CallExecutorImpl.java => internal/DefaultCallExecutor.java} (80%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => internal}/TokenFactory.java (95%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => token}/InMemoryTokenCache.java (92%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => token}/TokenCache.java (95%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => token}/TokenCacheManager.java (96%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{CallExecutorImplTest.java => DefaultCallExecutorTest.java} (92%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java index 9aae6a6e..235f54cd 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java @@ -26,6 +26,8 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.info.InfoCache; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.server.ServerInfoService; import org.jetbrains.annotations.TestOnly; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index d19b5313..7cb15da2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -25,8 +25,14 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; +import com.jaspersoft.android.sdk.service.info.InfoCache; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.report.ReportService; import com.jaspersoft.android.sdk.service.repository.RepositoryService; +import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; +import com.jaspersoft.android.sdk.service.token.TokenCache; +import com.jaspersoft.android.sdk.service.token.TokenCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -51,7 +57,7 @@ public final class Session extends AnonymousSession { mInfoCacheManager = infoCacheManager; } - TokenCacheManager.Factory getTokenCacheManagerFactory() { + public TokenCacheManager.Factory getTokenCacheManagerFactory() { return mTokenCacheManagerFactory; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java index 87a8d286..0f868193 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java @@ -24,6 +24,9 @@ package com.jaspersoft.android.sdk.service; +import com.jaspersoft.android.sdk.service.token.TokenCache; +import com.jaspersoft.android.sdk.service.token.TokenCacheManager; + /** * @author Tom Koptel * @since 2.0 diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Call.java b/core/src/main/java/com/jaspersoft/android/sdk/service/call/Call.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/Call.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/call/Call.java index e69fdeb1..c1b53350 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Call.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/call/Call.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.call; import com.jaspersoft.android.sdk.network.HttpException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/call/CallExecutor.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutor.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/call/CallExecutor.java index c3a5dbde..4a4040d1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/call/CallExecutor.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.call; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryInfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java similarity index 92% rename from core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryInfoCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java index 829a8a51..6f8395ce 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryInfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -30,7 +30,7 @@ * @author Tom Koptel * @since 2.0 */ -public class InMemoryInfoCache implements InfoCache { +public final class InMemoryInfoCache implements InfoCache { private ServerInfo mInfoCache; @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/InfoCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java index 66a2e8ac..c2d7fdca 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCacheManager.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCacheManager.java index e697f01c..3efecf60 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCacheManager.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java similarity index 80% rename from core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java index 3507d758..34250f9d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/CallExecutorImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java @@ -22,12 +22,17 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.RestClient; +import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.call.Call; +import com.jaspersoft.android.sdk.service.call.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; +import com.jaspersoft.android.sdk.service.token.TokenCacheManager; import org.jetbrains.annotations.TestOnly; import java.io.IOException; @@ -36,25 +41,25 @@ * @author Tom Koptel * @since 2.0 */ -public final class CallExecutorImpl implements CallExecutor { +public class DefaultCallExecutor implements CallExecutor { private final TokenCacheManager.Factory mTokenCacheManagerFactory; private final InfoCacheManager mInfoCacheManager; private final TokenFactory mTokenFactory; private final Credentials mCredentials; @TestOnly - CallExecutorImpl(Credentials credentials, - TokenCacheManager.Factory tokenCacheManagerFactory, - InfoCacheManager cacheManager, - TokenFactory tokenFactory) { + DefaultCallExecutor(Credentials credentials, + TokenCacheManager.Factory tokenCacheManagerFactory, + InfoCacheManager cacheManager, + TokenFactory tokenFactory) { mTokenCacheManagerFactory = tokenCacheManagerFactory; mInfoCacheManager = cacheManager; mTokenFactory = tokenFactory; mCredentials = credentials; } - public static CallExecutorImpl create(RestClient client, Session session) { - return new CallExecutorImpl( + public static DefaultCallExecutor create(RestClient client, Session session) { + return new DefaultCallExecutor( session.getCredentials(), session.getTokenCacheManagerFactory(), session.getInfoCacheManager(), diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java similarity index 95% rename from core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java index b8c3ed87..2123bf3b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java @@ -22,9 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.auth.AuthenticationService; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 0d5197e5..fff79b14 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -29,8 +29,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.Call; -import com.jaspersoft.android.sdk.service.CallExecutor; +import com.jaspersoft.android.sdk.service.call.Call; +import com.jaspersoft.android.sdk.service.call.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index ab46fa0e..55c68d2b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -31,8 +31,8 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.Call; -import com.jaspersoft.android.sdk.service.CallExecutor; +import com.jaspersoft.android.sdk.service.call.Call; +import com.jaspersoft.android.sdk.service.call.CallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 6aac5349..21f619a2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -29,8 +29,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.CallExecutor; -import com.jaspersoft.android.sdk.service.CallExecutorImpl; +import com.jaspersoft.android.sdk.service.call.CallExecutor; +import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -71,7 +71,7 @@ public static ReportService create(RestClient client, Session session) { .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .baseUrl(client.getServerUrl()) .build(); - CallExecutor callExecutor = CallExecutorImpl.create(client, session); + CallExecutor callExecutor = DefaultCallExecutor.create(client, session); ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getServerUrl()); ReportExecutionUseCase reportExecutionUseCase = diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index fa2298c2..daec89d9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -26,6 +26,9 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.*; +import com.jaspersoft.android.sdk.service.call.CallExecutor; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; import org.jetbrains.annotations.TestOnly; import java.util.concurrent.TimeUnit; @@ -52,7 +55,7 @@ public static RepositoryService create(RestClient client, Session session) { .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .build(); - CallExecutor callExecutor = CallExecutorImpl.create(client, session); + CallExecutor callExecutor = DefaultCallExecutor.create(client, session); return new RepositoryService(repositoryRestApi, callExecutor, session.getInfoCacheManager()); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 0b59fc36..1cd01dfd 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -25,8 +25,8 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.CallExecutor; -import com.jaspersoft.android.sdk.service.InfoCacheManager; +import com.jaspersoft.android.sdk.service.call.CallExecutor; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 7b33e758..a1de4726 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -27,9 +27,9 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.Call; -import com.jaspersoft.android.sdk.service.CallExecutor; -import com.jaspersoft.android.sdk.service.InfoCacheManager; +import com.jaspersoft.android.sdk.service.call.Call; +import com.jaspersoft.android.sdk.service.call.CallExecutor; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryTokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java similarity index 92% rename from core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryTokenCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java index 276484ee..72870eda 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InMemoryTokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java @@ -22,7 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.token; + +import com.jaspersoft.android.sdk.service.token.TokenCache; /** * @author Tom Koptel diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java similarity index 95% rename from core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java index 6b50990f..14edb198 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.token; /** * @author Tom Koptel diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCacheManager.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/TokenCacheManager.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCacheManager.java index 6db7775b..efc61f62 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCacheManager.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.token; /** * @author Tom Koptel diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/DefaultCallExecutorTest.java similarity index 92% rename from core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/DefaultCallExecutorTest.java index 6136165c..85dbea89 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/CallExecutorImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/DefaultCallExecutorTest.java @@ -26,9 +26,14 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.call.Call; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; +import com.jaspersoft.android.sdk.service.internal.TokenFactory; +import com.jaspersoft.android.sdk.service.token.TokenCacheManager; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -41,7 +46,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; -public class CallExecutorImplTest { +public class DefaultCallExecutorTest { @Mock TokenCacheManager mTokenCacheManager; @@ -63,7 +68,7 @@ public class CallExecutorImplTest { @Mock ServerInfo mServerInfo; - private CallExecutorImpl resolver; + private DefaultCallExecutor resolver; private Object mResponse = new Object(); @Before @@ -74,7 +79,7 @@ public void setUp() throws Exception { when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); when(mTokenCacheManagerFactory.create(anyDouble())).thenReturn(mTokenCacheManager); - resolver = new CallExecutorImpl(mCredentials, mTokenCacheManagerFactory, mInfoCacheManager, mFactory); + resolver = new DefaultCallExecutor(mCredentials, mTokenCacheManagerFactory, mInfoCacheManager, mFactory); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java index 663b6fe8..585fe1cf 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.call.Call; +import com.jaspersoft.android.sdk.service.call.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java index ca7acfdf..9afad336 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; +import com.jaspersoft.android.sdk.service.info.InfoCache; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java index 9733939b..b071185e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service; +import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java index abcb48eb..45ff589d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.info.InfoCache; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.server.ServerInfoService; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java index eff20def..7ef1c978 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java @@ -26,6 +26,8 @@ import com.jaspersoft.android.sdk.service.auth.Credentials; import com.jaspersoft.android.sdk.service.auth.SpringCredentials; +import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; +import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; import org.junit.Test; import java.util.concurrent.TimeUnit; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 236d99f2..5e35ece6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.InfoCacheManager; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index a042e608..18062e5a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -26,7 +26,7 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.InfoCacheManager; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 840f5aaf..de1f8792 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -28,7 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.InfoCacheManager; +import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; From 0c552a3bde3bb998cb8c90b3d9dc2d2e111eedd2 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 30 Nov 2015 19:49:24 +0200 Subject: [PATCH 306/457] Wrap url/token into server bundle --- .../android/sdk/env/JrsEnvironmentRule.java | 9 +++--- .../android/sdk/env/ServerBundle.java | 28 +++++++++++++++++++ ...IntegrationReportExecutionRestApiTest.java | 25 +++++++++++++---- .../IntegrationReportOptionRestApiTest.java | 9 ++++-- .../IntegrationRepositoryRestApiTest.java | 17 +++++------ 5 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerBundle.java diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java index 751b8da4..b9fbd1f2 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/JrsEnvironmentRule.java @@ -65,7 +65,7 @@ public Object[] listAuthorizedServers() { Credentials credentials = CredentialsMapper.transform(config); try { String token = Authorizer.create(server.getUrl()).authorize(credentials); - result.add(new Object[]{token, server.getUrl()}); + result.add(new Object[]{new ServerBundle(token, server.getUrl())}); } catch (IOException | HttpException e) { System.out.println(e); } @@ -80,8 +80,9 @@ public Object[] listReports() { for (Object o : listAuthorizedServers()) { Object[] pair = (Object[]) o; try { - String token = String.valueOf(pair[0]); - String url = String.valueOf(pair[1]); + ServerBundle bundle = (ServerBundle) pair[0]; + String token = bundle.getToken(); + String url = bundle.getUrl(); ServiceFactory service = ServiceFactory.builder() .baseUrl(url).token(token).create(); @@ -89,7 +90,7 @@ public Object[] listReports() { .resourceRepository(getLazyEnv().reportExecNumber(), "reportUnit") .listResources(); for (String report : reports) { - result.add(new Object[] {token, url, report}); + result.add(new Object[] {bundle, report}); } } catch (IOException | HttpException e) { System.out.println(e); diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerBundle.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerBundle.java new file mode 100644 index 00000000..5a0d9304 --- /dev/null +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerBundle.java @@ -0,0 +1,28 @@ +package com.jaspersoft.android.sdk.env; + +/** + * @author Tom Koptel + * @since 2.3 + */ +public final class ServerBundle { + private final String token; + private final String url; + + public ServerBundle(String token, String url) { + this.token = token; + this.url = url; + } + + public String getToken() { + return token; + } + + public String getUrl() { + return url; + } + + @Override + public String toString() { + return url; + } +} diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java index ce0167cb..249599fe 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportExecutionRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; +import com.jaspersoft.android.sdk.env.ServerBundle; import com.jaspersoft.android.sdk.env.TestLogger; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; @@ -67,7 +68,9 @@ private Object[] reports() { @Test @Parameters(method = "reports") - public void shouldStartReportExecution(String token, String baseUrl, String reportUri) throws Exception { + public void shouldStartReportExecution(ServerBundle bundle, String reportUri) throws Exception { + String baseUrl = bundle.getUrl(); + String token = bundle.getToken(); ServiceFactory serviceFactory = ServiceFactory.builder() .baseUrl(baseUrl).token(token) .create(); @@ -87,7 +90,9 @@ public void shouldStartReportExecution(String token, String baseUrl, String repo @Test @Parameters(method = "reports") - public void shouldCancelReportExecution(final String token, final String baseUrl, String reportUri) throws Exception { + public void shouldCancelReportExecution(ServerBundle bundle, String reportUri) throws Exception { + String baseUrl = bundle.getUrl(); + String token = bundle.getToken(); startExecution(token, baseUrl, reportUri).perform(new Action() { @Override public void call(Session session) { @@ -98,7 +103,9 @@ public void call(Session session) { @Test @Parameters(method = "reports") - public void shouldReturnReportExecutionDetails(final String token, final String baseUrl, String reportUri) throws Exception { + public void shouldReturnReportExecutionDetails(ServerBundle bundle, String reportUri) throws Exception { + String baseUrl = bundle.getUrl(); + String token = bundle.getToken(); startExecution(token, baseUrl, reportUri).perform(new Action() { @Override public void call(Session session) { @@ -110,7 +117,9 @@ public void call(Session session) { @Test @Parameters(method = "reports") - public void shouldCheckReportExecutionStatus(final String token, final String baseUrl, String reportUri) throws Exception { + public void shouldCheckReportExecutionStatus(ServerBundle bundle, String reportUri) throws Exception { + String baseUrl = bundle.getUrl(); + String token = bundle.getToken(); startExecution(token, baseUrl, reportUri).perform(new Action() { @Override public void call(Session session) { @@ -122,7 +131,9 @@ public void call(Session session) { @Test @Parameters(method = "reports") - public void searchForExecutionShouldReturnResult(final String token, final String baseUrl, final String reportUri) throws Exception { + public void searchForExecutionShouldReturnResult(ServerBundle bundle, final String reportUri) throws Exception { + String baseUrl = bundle.getUrl(); + String token = bundle.getToken(); startExecution(token, baseUrl, reportUri).perform(new Action() { @Override public void call(Session session) { @@ -137,7 +148,9 @@ public void call(Session session) { @Test @Parameters(method = "reports") - public void updateOfParametersForExecutionShouldReturnResult(final String token, final String baseUrl, String reportUri) throws Exception { + public void updateOfParametersForExecutionShouldReturnResult(ServerBundle bundle, String reportUri) throws Exception { + String baseUrl = bundle.getUrl(); + String token = bundle.getToken(); startExecution(token, baseUrl, reportUri).perform(new Action() { @Override public void call(Session session) { diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java index 59e616d7..b337dbee 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationReportOptionRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; +import com.jaspersoft.android.sdk.env.ServerBundle; import com.jaspersoft.android.sdk.env.TestLogger; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.testkit.ServiceFactory; @@ -54,14 +55,16 @@ public class IntegrationReportOptionRestApiTest { @Test @Parameters(method = "reports") - public void shouldRequestReportOptionsList(String token, String baseUrl, String reportUri) throws Exception { - Set response = createApi(baseUrl).requestReportOptionsList(token, reportUri); + public void shouldRequestReportOptionsList(ServerBundle bundle, String reportUri) throws Exception { + Set response = createApi(bundle.getUrl()).requestReportOptionsList(bundle.getToken(), reportUri); assertThat("Failed load report options data", response != null); } @Test @Parameters(method = "reports") - public void apiSupportsCrudForReportOption(String token, String baseUrl, String reportUri) throws Exception { + public void apiSupportsCrudForReportOption(ServerBundle bundle, String reportUri) throws Exception { + String baseUrl = bundle.getUrl(); + String token = bundle.getToken(); Map> params = ServiceFactory.builder() .baseUrl(baseUrl).token(token) .create() diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationRepositoryRestApiTest.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationRepositoryRestApiTest.java index 2f8a659f..c0a80926 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationRepositoryRestApiTest.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/network/IntegrationRepositoryRestApiTest.java @@ -24,11 +24,12 @@ package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; +import com.jaspersoft.android.sdk.env.ServerBundle; +import com.jaspersoft.android.sdk.env.TestLogger; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.env.JrsEnvironmentRule; -import com.jaspersoft.android.sdk.env.TestLogger; import org.junit.ClassRule; import org.junit.Test; @@ -51,22 +52,22 @@ public class IntegrationRepositoryRestApiTest { @Test @Parameters(method = "reports") - public void shouldRequestReport(String token, String baseUrl, String reportUri) { - ReportLookup report = createApi(baseUrl).requestReportResource(token, reportUri); + public void shouldRequestReport(ServerBundle bundle, String reportUri) { + ReportLookup report = createApi(bundle.getUrl()).requestReportResource(bundle.getToken(), reportUri); assertThat("Failed load report data", report != null); } @Test @Parameters(method = "servers") - public void shouldRequestListOfResources(String token, String baseUrl) { - ResourceSearchResult response = createApi(baseUrl).searchResources(token, null); + public void shouldRequestListOfResources(ServerBundle bundle) { + ResourceSearchResult response = createApi(bundle.getUrl()).searchResources(bundle.getToken(), null); assertThat("Failed to perform search lookup", response != null); } @Test @Parameters(method = "servers") - public void shouldRequestRootFolder(String token, String baseUrl) { - FolderLookup folder = createApi(baseUrl).requestFolderResource(token, "/"); + public void shouldRequestRootFolder(ServerBundle bundle) { + FolderLookup folder = createApi(bundle.getUrl()).requestFolderResource(bundle.getToken(), "/"); assertThat("Failed to root folder response", folder != null); } From a36abb28ef127b6a983d1576e00d3abc53e896e1 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Dec 2015 15:25:23 +0200 Subject: [PATCH 307/457] Remove Server Edition --- .../service/data/server/ServerEdition.java | 33 ------------------- .../sdk/service/data/server/ServerInfo.java | 8 ++--- .../service/server/ServerInfoTransformer.java | 4 +-- .../server/ServerInfoTransformerTest.java | 4 +-- 4 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java deleted file mode 100644 index 5fc78c80..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerEdition.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.server; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public enum ServerEdition { - PRO, CE -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index 7deb0bce..c9cfebe1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -35,7 +35,7 @@ public class ServerInfo { private SimpleDateFormat dateFormatPattern; private SimpleDateFormat datetimeFormatPattern; private double version; - private ServerEdition edition; + private String edition; private String licenseType; private String build; private String editionName; @@ -65,11 +65,11 @@ public void setDatetimeFormatPattern(SimpleDateFormat datetimeFormatPattern) { this.datetimeFormatPattern = datetimeFormatPattern; } - public ServerEdition getEdition() { - return edition; + public boolean isPro() { + return "PRO".equals(edition); } - public void setEdition(ServerEdition edition) { + public void setEdition(String edition) { this.edition = edition; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java index aa55010e..368f8daf 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import java.text.SimpleDateFormat; @@ -64,8 +63,7 @@ public ServerInfo transform(ServerInfoData response) { double version = VersionParser.INSTANCE.toDouble(response.getVersion()); serverInfo.setVersion(version); - ServerEdition edition = ServerEdition.valueOf(response.getEdition()); - serverInfo.setEdition(edition); + serverInfo.setEdition(response.getEdition()); serverInfo.setEditionName(response.getEditionName()); Set features = parseFeatureSet(response.getFeatures()); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index 1df3b53e..afa2a042 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -25,9 +25,7 @@ package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import com.jaspersoft.android.sdk.service.data.server.ServerEdition; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -94,7 +92,7 @@ public void shouldTransformServerVersionProperty() { @Test public void shouldTransformServerEditionProperty() { ServerInfo info = transformerUnderTest.transform(mServerInfoData); - assertThat(info.getEdition(), is(ServerEdition.PRO)); + assertThat(info.isPro(), is(true)); } @Test From 7cd1a2994a2c3bb46171073598a2635fd7975bed Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Dec 2015 15:41:14 +0200 Subject: [PATCH 308/457] Fix ServerInfoTransformerTest license type issue --- .../service/server/ServerInfoTransformer.java | 1 + .../server/ServerInfoTransformerTest.java | 35 ++----------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java index 368f8daf..4a526531 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -68,6 +68,7 @@ public ServerInfo transform(ServerInfoData response) { Set features = parseFeatureSet(response.getFeatures()); serverInfo.setFeatures(features); + serverInfo.setLicenseType(response.getLicenseType()); return serverInfo; } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index afa2a042..cb8fe38c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -63,48 +63,19 @@ public void setup() { when(mServerInfoData.getEdition()).thenReturn("PRO"); when(mServerInfoData.getEditionName()).thenReturn("Enterprise for AWS"); when(mServerInfoData.getFeatures()).thenReturn("Fusion"); + when(mServerInfoData.getLicenseType()).thenReturn("Type"); } @Test - public void shouldTransformBuildProperty() { + public void shouldTransform() { ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getBuild(), is("20150527_1447")); - } - - @Test - public void shouldTransformDateFormatProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getDateFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd"))); - } - - @Test - public void shouldTransformDateTimeFormatProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getDatetimeFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"))); - } - - @Test - public void shouldTransformServerVersionProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getVersion(), is(6.1d)); - } - - @Test - public void shouldTransformServerEditionProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.isPro(), is(true)); - } - - @Test - public void shouldTransformServerEditionNameProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getEditionName(), is("Enterprise for AWS")); - } - - @Test - public void shouldTransformFeaturesProperty() { - ServerInfo info = transformerUnderTest.transform(mServerInfoData); assertThat(info.getFeatures(), contains("Fusion")); + assertThat(info.getLicenseType(), is("Type")); } - } From 60a4f18afbfdf673e3c3e8a96d9056c4d7ffafe7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Dec 2015 15:43:13 +0200 Subject: [PATCH 309/457] Add Server version codes mapping --- .../data/server/ServerVersionCodes.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java new file mode 100644 index 00000000..f75d43c1 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.server; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ServerVersionCodes { + public static double v5_5 = 5.5d; + public static double v5_6_1 = 5.61d; + public static double v6 = 6.0d; + public static double v6_0_1 = 6.01d; + public static double v6_1 = 6.1d; + public static double v6_11 = 6.11d; + public static double v6_2 = 6.2d; + + private ServerVersionCodes() {} +} From c735ccadd3daf01f42733caed4c7a6a8f6ab6c4d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Dec 2015 15:54:16 +0200 Subject: [PATCH 310/457] Expose edition as PRO --- .../android/sdk/service/data/server/ServerInfo.java | 4 ++-- .../android/sdk/service/server/ServerInfoTransformerTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index c9cfebe1..63c4556f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -65,8 +65,8 @@ public void setDatetimeFormatPattern(SimpleDateFormat datetimeFormatPattern) { this.datetimeFormatPattern = datetimeFormatPattern; } - public boolean isPro() { - return "PRO".equals(edition); + public String getEdition() { + return edition; } public void setEdition(String edition) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index cb8fe38c..942b2ff3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -73,7 +73,7 @@ public void shouldTransform() { assertThat(info.getDateFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd"))); assertThat(info.getDatetimeFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"))); assertThat(info.getVersion(), is(6.1d)); - assertThat(info.isPro(), is(true)); + assertThat(info.getEdition(), is("PRO")); assertThat(info.getEditionName(), is("Enterprise for AWS")); assertThat(info.getFeatures(), contains("Fusion")); assertThat(info.getLicenseType(), is("Type")); From a8299000381126b9cc702dc17f3b7189ccdd0238 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Dec 2015 15:55:46 +0200 Subject: [PATCH 311/457] Add version v5_6 --- .../android/sdk/service/data/server/ServerVersionCodes.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java index f75d43c1..efd6fc0f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java @@ -30,6 +30,7 @@ */ public final class ServerVersionCodes { public static double v5_5 = 5.5d; + public static double v5_6 = 5.6d; public static double v5_6_1 = 5.61d; public static double v6 = 6.0d; public static double v6_0_1 = 6.01d; From 1ee2cf92a46d098ab1a3d6b9824b403101efafb3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Dec 2015 16:12:24 +0200 Subject: [PATCH 312/457] Revert missing factory for ServerInfoService --- .../android/sdk/service/server/ServerInfoService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index e2e5f162..a65f4de5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -58,6 +58,10 @@ public static ServerInfoService create(String baseUrl) { return new ServerInfoService(restApi, ServerInfoTransformer.get()); } + public static ServerInfoService create(ServerRestApi restApi) { + return new ServerInfoService(restApi, ServerInfoTransformer.get()); + } + public ServerInfo requestServerInfo() throws ServiceException { try { ServerInfoData response = mRestApi.requestServerInfo(); From b192c37d9052800c9ba8b2e60ec3b8da29eee6b2 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 1 Dec 2015 16:28:41 +0200 Subject: [PATCH 313/457] Exposing VersionParser --- .../sdk/service/server/ServerInfoService.java | 2 +- .../service/server/ServerInfoTransformer.java | 2 +- .../sdk/service/server/VersionParser.java | 50 +++++++++++-------- .../sdk/service/server/VersionParserTest.java | 15 +++++- 4 files changed, 45 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index a65f4de5..a4c9b739 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -76,7 +76,7 @@ public ServerInfo requestServerInfo() throws ServiceException { public double requestServerVersion() throws ServiceException { try { String version = mRestApi.requestVersion(); - return VersionParser.INSTANCE.toDouble(version); + return VersionParser.toDouble(version); } catch (HttpException e) { throw ServiceExceptionMapper.transform(e); } catch (IOException e) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java index 4a526531..4e01db31 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -60,7 +60,7 @@ public ServerInfo transform(ServerInfoData response) { SimpleDateFormat dateTimeFormat = new SimpleDateFormat(response.getDatetimeFormatPattern()); serverInfo.setDatetimeFormatPattern(dateTimeFormat); - double version = VersionParser.INSTANCE.toDouble(response.getVersion()); + double version = VersionParser.toDouble(response.getVersion()); serverInfo.setVersion(version); serverInfo.setEdition(response.getEdition()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java index a6fa8fc6..adf00649 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java @@ -30,30 +30,40 @@ * @author Tom Koptel * @since 2.0 */ -enum VersionParser { - INSTANCE; +public class VersionParser { - public double toDouble(String version) { - double versionCode = 0d; - // update version code + private VersionParser() { + } + + public static double toDouble(String version) { if (version != null) { - String[] subs = version.split("\\."); - - BigDecimal decimalSubVersion, decimalFactor, decimalResult; - BigDecimal decimalVersion = new BigDecimal("0"); - for (int i = 0; i < subs.length; i++) { - try { - decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); - } catch (NumberFormatException ex) { - decimalSubVersion = new BigDecimal("0"); - } - - decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); - decimalResult = decimalSubVersion.multiply(decimalFactor); - decimalVersion = decimalVersion.add(decimalResult); + try { + return Double.parseDouble(version); + } catch (NumberFormatException ex) { + return parseSchema(version); + } + } + return 0d; + } + + private static double parseSchema(String version) { + double versionCode; + String[] subs = version.split("\\."); + + BigDecimal decimalSubVersion, decimalFactor, decimalResult; + BigDecimal decimalVersion = new BigDecimal("0"); + for (int i = 0; i < subs.length; i++) { + try { + decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); + } catch (NumberFormatException ex) { + decimalSubVersion = new BigDecimal("0"); } - versionCode = decimalVersion.doubleValue(); + + decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); + decimalResult = decimalSubVersion.multiply(decimalFactor); + decimalVersion = decimalVersion.add(decimalResult); } + versionCode = decimalVersion.doubleValue(); return versionCode; } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java index 56f1dc9d..cb980f0e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java @@ -54,7 +54,18 @@ public class VersionParserTest { }) public void shouldParseSemanticVersioning(String versionCode, String expected) { double expectedCode = Double.valueOf(expected); - double resultCode = VersionParser.INSTANCE.toDouble(versionCode); + double resultCode = VersionParser.toDouble(versionCode); + assertThat(resultCode, is(expectedCode)); + } + + @Test + @Parameters({ + "5.61, 5.61", + "6.01, 6.01" + }) + public void shouldParseValidDouble(String versionCode, String expected) { + double expectedCode = Double.valueOf(expected); + double resultCode = VersionParser.toDouble(versionCode); assertThat(resultCode, is(expectedCode)); } @@ -69,7 +80,7 @@ public void shouldParseSemanticVersioning(String versionCode, String expected) { }) public void shouldParseLongSemanticVersioning(String versionCode, String expected) { double expectedCode = Double.valueOf(expected); - double resultCode = VersionParser.INSTANCE.toDouble(versionCode); + double resultCode = VersionParser.toDouble(versionCode); assertThat(resultCode, is(expectedCode)); } } \ No newline at end of file From 3ca5496fe1e0542996b10d267ded9e2fb1016144 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Dec 2015 14:03:50 +0200 Subject: [PATCH 314/457] Implementing ServerVersion abstraction --- .../service/data/server/ServerVersion.java | 103 +++++++++++++++ .../service/data/server/VersionParser.java | 69 ++++++++++ .../data/server/ServerVersionTest.java | 125 ++++++++++++++++++ 3 files changed, 297 insertions(+) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java new file mode 100644 index 00000000..2c9b56c8 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -0,0 +1,103 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.server; + +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ServerVersion implements Comparable { + private final String versionName; + private final double versionCode; + + public static ServerVersion v5_5 = new ServerVersion("5.5", 5.5d); + public static ServerVersion v5_6 = new ServerVersion("5.6", 5.6d); + public static ServerVersion v5_6_1 = new ServerVersion("5.6.1", 5.61d); + public static ServerVersion v6 = new ServerVersion("6.0", 6d); + public static ServerVersion v6_0_1 = new ServerVersion("6.0.1", 6.01d); + public static ServerVersion v6_1 = new ServerVersion("6.1", 6.1d); + public static ServerVersion v6_1_1 = new ServerVersion("6.1.1", 6.11d); + public static ServerVersion v6_2 = new ServerVersion("6.2", 6.2d); + + ServerVersion(String versionName, double versionCode) { + this.versionName = versionName; + this.versionCode = versionCode; + } + + @NotNull + public static ServerVersion valueOf(@NotNull String version) { + double code = VersionParser.toDouble(version); + if (code == 0) { + throw new IllegalArgumentException(String.format("Version '%s' not defined", version)); + } + return new ServerVersion(version, code); + } + + public boolean greaterThan(ServerVersion other) { + return this.compareTo(other) == 1; + } + + public boolean greaterThanOrEquals(ServerVersion other) { + return greaterThan(other) || equals(other); + } + + public boolean lessThan(ServerVersion other) { + return this.compareTo(other) == -1; + } + + public boolean lessThanOrEquals(ServerVersion other) { + return lessThan(other) || equals(other); + } + + @Override + public int compareTo(ServerVersion other) { + return Double.compare(versionCode, other.versionCode); + } + + @Override + public String toString() { + return versionName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ServerVersion that = (ServerVersion) o; + + if (Double.compare(that.versionCode, versionCode) != 0) return false; + + return true; + } + + @Override + public int hashCode() { + long temp = Double.doubleToLongBits(versionCode); + return (int) (temp ^ (temp >>> 32)); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java new file mode 100644 index 00000000..4256a976 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.server; + +import java.math.BigDecimal; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class VersionParser { + + private VersionParser() { + } + + public static double toDouble(String version) { + if (version != null) { + try { + return Double.parseDouble(version); + } catch (NumberFormatException ex) { + return parseSchema(version); + } + } + return 0d; + } + + private static double parseSchema(String version) { + double versionCode; + String[] subs = version.split("\\."); + + BigDecimal decimalSubVersion, decimalFactor, decimalResult; + BigDecimal decimalVersion = new BigDecimal("0"); + for (int i = 0; i < subs.length; i++) { + try { + decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); + } catch (NumberFormatException ex) { + decimalSubVersion = new BigDecimal("0"); + } + + decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); + decimalResult = decimalSubVersion.multiply(decimalFactor); + decimalVersion = decimalVersion.add(decimalResult); + } + versionCode = decimalVersion.doubleValue(); + return versionCode; + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java new file mode 100644 index 00000000..55bf9d51 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java @@ -0,0 +1,125 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.server; + +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +@RunWith(JUnitParamsRunner.class) +public class ServerVersionTest { + + @Test + @Parameters({ + "v5_6, v5_5", + "v5_6_1, v5_6", + "v6, v5_6_1", + "v6_0_1, v6", + "v6_1, v6", + "v6_1_1, v6_1", + "v6_2, v6_1_1" + }) + public void testGreaterThan(String greater, String lesser) throws Exception { + ServerVersion v1 = (ServerVersion) ServerVersion.class.getField(greater).get(null); + ServerVersion v2 = (ServerVersion) ServerVersion.class.getField(lesser).get(null); + assertThat(String.format("%s should be greater than %s", greater, lesser), v1.greaterThan(v2)); + } + + @Test + @Parameters({ + "v5_6, v5_5", + "v5_6_1, v5_6", + "v6, v5_6_1", + "v6_0_1, v6", + "v6_1, v6", + "v6_1_1, v6_1", + "v6_2, v6_1_1" + }) + public void testGreaterThanOrEquals(String greater, String lesser) throws Exception { + ServerVersion v1 = (ServerVersion) ServerVersion.class.getField(greater).get(null); + ServerVersion v2 = (ServerVersion) ServerVersion.class.getField(lesser).get(null); + assertThat(String.format("%s should be greater than %s", greater, lesser), v1.greaterThan(v2)); + assertThat(String.format("%s should be greater than or equal %s", greater, lesser), v1.greaterThanOrEquals(v2)); + } + + @Test + @Parameters({ + "v5_6, v5_5", + "v5_6_1, v5_6", + "v6, v5_6_1", + "v6_0_1, v6", + "v6_1, v6", + "v6_1_1, v6_1", + "v6_2, v6_1_1" + }) + public void testLessThan(String greater, String lesser) throws Exception { + ServerVersion v1 = (ServerVersion) ServerVersion.class.getField(lesser).get(null); + ServerVersion v2 = (ServerVersion) ServerVersion.class.getField(greater).get(null); + assertThat(String.format("%s should be less than %s", lesser, greater), v1.lessThan(v2)); + } + + @Test + @Parameters({ + "v5_6, v5_5", + "v5_6_1, v5_6", + "v6, v5_6_1", + "v6_0_1, v6", + "v6_1, v6", + "v6_1_1, v6_1", + "v6_2, v6_1_1" + }) + public void testLessThanOrEquals(String greater, String lesser) throws Exception { + ServerVersion v1 = (ServerVersion) ServerVersion.class.getField(lesser).get(null); + ServerVersion v2 = (ServerVersion) ServerVersion.class.getField(greater).get(null); + assertThat(String.format("%s should be less than %s", lesser, greater), v1.lessThan(v2)); + assertThat(String.format("%s should be less than or equals %s", lesser, greater), v1.lessThanOrEquals(v2)); + } + + @Test + @Parameters({ + "v5_5, 5.5", + "v5_6, 5.6", + "v5_6_1, 5.6.1", + "v6, 6.0", + "v6_0_1, 6.0.1", + "v6_1, 6.1", + "v6_1_1, 6.1.1", + "v6_2, 6.2", + }) + public void testToString(String version, String expected) throws Exception { + ServerVersion v1 = (ServerVersion) ServerVersion.class.getField(version).get(null); + assertThat(String.format("Raw version should be %s", expected), expected, is(v1.toString())); + } + + @Test(expected = IllegalArgumentException.class) + public void shouldThrowIllegalArgumentExceptionIfVersionMakeNoSense() { + ServerVersion.valueOf("make no sense"); + } +} \ No newline at end of file From 4ae2c7686524e74d983e557c0bfa8f2332926b97 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Dec 2015 14:06:57 +0200 Subject: [PATCH 315/457] Replacing double version code with ServerVersion --- .../sdk/service/data/server/ServerInfo.java | 6 +- .../service/data/server/VersionParser.java | 2 +- .../sdk/service/server/ServerInfoService.java | 5 +- .../service/server/ServerInfoTransformer.java | 3 +- .../sdk/service/server/VersionParser.java | 69 ------------------- .../{ => data}/server/VersionParserTest.java | 7 +- .../server/ServerInfoTransformerTest.java | 3 +- 7 files changed, 14 insertions(+), 81 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java rename core/src/test/java/com/jaspersoft/android/sdk/service/{ => data}/server/VersionParserTest.java (98%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index 63c4556f..a88c977e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -34,7 +34,7 @@ public class ServerInfo { private SimpleDateFormat dateFormatPattern; private SimpleDateFormat datetimeFormatPattern; - private double version; + private ServerVersion version; private String edition; private String licenseType; private String build; @@ -97,11 +97,11 @@ public void setLicenseType(String licenseType) { this.licenseType = licenseType; } - public double getVersion() { + public ServerVersion getVersion() { return version; } - public void setVersion(double version) { + public void setVersion(ServerVersion version) { this.version = version; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java index 4256a976..5bd09a44 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java @@ -30,7 +30,7 @@ * @author Tom Koptel * @since 2.0 */ -public class VersionParser { +final class VersionParser { private VersionParser() { } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index a4c9b739..e8a6a27f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; @@ -73,10 +74,10 @@ public ServerInfo requestServerInfo() throws ServiceException { } } - public double requestServerVersion() throws ServiceException { + public ServerVersion requestServerVersion() throws ServiceException { try { String version = mRestApi.requestVersion(); - return VersionParser.toDouble(version); + return ServerVersion.valueOf(version); } catch (HttpException e) { throw ServiceExceptionMapper.transform(e); } catch (IOException e) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java index 4e01db31..f2725bd2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -60,7 +61,7 @@ public ServerInfo transform(ServerInfoData response) { SimpleDateFormat dateTimeFormat = new SimpleDateFormat(response.getDatetimeFormatPattern()); serverInfo.setDatetimeFormatPattern(dateTimeFormat); - double version = VersionParser.toDouble(response.getVersion()); + ServerVersion version = ServerVersion.valueOf(response.getVersion()); serverInfo.setVersion(version); serverInfo.setEdition(response.getEdition()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java deleted file mode 100644 index adf00649..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/VersionParser.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.server; - -import java.math.BigDecimal; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class VersionParser { - - private VersionParser() { - } - - public static double toDouble(String version) { - if (version != null) { - try { - return Double.parseDouble(version); - } catch (NumberFormatException ex) { - return parseSchema(version); - } - } - return 0d; - } - - private static double parseSchema(String version) { - double versionCode; - String[] subs = version.split("\\."); - - BigDecimal decimalSubVersion, decimalFactor, decimalResult; - BigDecimal decimalVersion = new BigDecimal("0"); - for (int i = 0; i < subs.length; i++) { - try { - decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); - } catch (NumberFormatException ex) { - decimalSubVersion = new BigDecimal("0"); - } - - decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); - decimalResult = decimalSubVersion.multiply(decimalFactor); - decimalVersion = decimalVersion.add(decimalResult); - } - versionCode = decimalVersion.doubleValue(); - return versionCode; - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java similarity index 98% rename from core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java index cb980f0e..c88953e4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/VersionParserTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java @@ -22,13 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.service.server; - -import org.junit.Test; -import org.junit.runner.RunWith; +package com.jaspersoft.android.sdk.service.data.server; import junitparams.JUnitParamsRunner; import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index 942b2ff3..0a5aa7b6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -72,7 +73,7 @@ public void shouldTransform() { assertThat(info.getBuild(), is("20150527_1447")); assertThat(info.getDateFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd"))); assertThat(info.getDatetimeFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"))); - assertThat(info.getVersion(), is(6.1d)); + assertThat(info.getVersion(), is(ServerVersion.v6_1)); assertThat(info.getEdition(), is("PRO")); assertThat(info.getEditionName(), is("Enterprise for AWS")); assertThat(info.getFeatures(), contains("Fusion")); From cfb9833ad8a9e144d96b0b12ee8dfe2c9bb51438 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Dec 2015 14:17:30 +0200 Subject: [PATCH 316/457] VersionParser properly handles strings with numbers --- .../service/data/server/VersionParser.java | 19 ++++++++++-- .../data/server/VersionParserTest.java | 31 ++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java index 5bd09a44..e7582ddc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.service.data.server; import java.math.BigDecimal; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Tom Koptel @@ -40,13 +42,26 @@ public static double toDouble(String version) { try { return Double.parseDouble(version); } catch (NumberFormatException ex) { - return parseSchema(version); + if (version.contains(".")) { + return parseAsVersionName(version); + } else { + return parseAsNumber(version); + } } } return 0d; } - private static double parseSchema(String version) { + private static double parseAsNumber(String version) { + Pattern pattern = Pattern.compile("(\\d+)"); + Matcher matcher = pattern.matcher(version); + if (matcher.find()) { + return Double.valueOf(matcher.group()); + } + return 0; + } + + private static double parseAsVersionName(String version) { double versionCode; String[] subs = version.split("\\."); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java index c88953e4..e6146263 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java @@ -26,11 +26,12 @@ import junitparams.JUnitParamsRunner; import junitparams.Parameters; +import org.hamcrest.core.Is; import org.junit.Test; import org.junit.runner.RunWith; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; +import static org.hamcrest.Matchers.is; /** * @author Tom Koptel @@ -54,7 +55,7 @@ public class VersionParserTest { public void shouldParseSemanticVersioning(String versionCode, String expected) { double expectedCode = Double.valueOf(expected); double resultCode = VersionParser.toDouble(versionCode); - assertThat(resultCode, is(expectedCode)); + assertThat(resultCode, Is.is(expectedCode)); } @Test @@ -65,7 +66,7 @@ public void shouldParseSemanticVersioning(String versionCode, String expected) { public void shouldParseValidDouble(String versionCode, String expected) { double expectedCode = Double.valueOf(expected); double resultCode = VersionParser.toDouble(versionCode); - assertThat(resultCode, is(expectedCode)); + assertThat(resultCode, Is.is(expectedCode)); } @Test @@ -80,6 +81,28 @@ public void shouldParseValidDouble(String versionCode, String expected) { public void shouldParseLongSemanticVersioning(String versionCode, String expected) { double expectedCode = Double.valueOf(expected); double resultCode = VersionParser.toDouble(versionCode); - assertThat(resultCode, is(expectedCode)); + assertThat(resultCode, Is.is(expectedCode)); + } + + @Test + @Parameters({ + "1-asdasdsad, 1", + "1-asdasdsad2, 1", + "12-asdasdsad2, 12", + }) + public void shouldParseIfHasNumber(String version, String result) { + double resultCode = VersionParser.toDouble(version); + assertThat(resultCode, Is.is(Double.valueOf(result))); + } + + @Test + @Parameters({ + "invalid", + ".-", + "" + }) + public void shouldReturnZeroForIncorrectVersion(String invalidVersion) { + assertThat(String.format("Version '%s' should be treated as zero", invalidVersion), + VersionParser.toDouble(invalidVersion), is(0d)); } } \ No newline at end of file From c3e2bcccc31129cc85447ed09348c17294b74fd5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Dec 2015 14:19:36 +0200 Subject: [PATCH 317/457] ServerInfo does not exposes edition --- .../android/sdk/service/data/server/ServerInfo.java | 4 ++-- .../android/sdk/service/server/ServerInfoTransformerTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java index a88c977e..9d8862c8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerInfo.java @@ -65,8 +65,8 @@ public void setDatetimeFormatPattern(SimpleDateFormat datetimeFormatPattern) { this.datetimeFormatPattern = datetimeFormatPattern; } - public String getEdition() { - return edition; + public boolean isEditionPro() { + return "PRO".equals(edition); } public void setEdition(String edition) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java index 0a5aa7b6..d2fe9c33 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java @@ -74,7 +74,7 @@ public void shouldTransform() { assertThat(info.getDateFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd"))); assertThat(info.getDatetimeFormatPattern(), is(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"))); assertThat(info.getVersion(), is(ServerVersion.v6_1)); - assertThat(info.getEdition(), is("PRO")); + assertThat(info.isEditionPro(), is(true)); assertThat(info.getEditionName(), is("Enterprise for AWS")); assertThat(info.getFeatures(), contains("Fusion")); assertThat(info.getLicenseType(), is("Type")); From eb36e511f62b787e5eccfcc004cec1a959e2126f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Dec 2015 14:29:36 +0200 Subject: [PATCH 318/457] Remove ServerVersionCodes --- .../data/server/ServerVersionCodes.java | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java deleted file mode 100644 index efd6fc0f..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionCodes.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.data.server; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class ServerVersionCodes { - public static double v5_5 = 5.5d; - public static double v5_6 = 5.6d; - public static double v5_6_1 = 5.61d; - public static double v6 = 6.0d; - public static double v6_0_1 = 6.01d; - public static double v6_1 = 6.1d; - public static double v6_11 = 6.11d; - public static double v6_2 = 6.2d; - - private ServerVersionCodes() {} -} From 28aaa7ef90f78d453002e0de81224caf0489ee8a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Dec 2015 15:36:06 +0200 Subject: [PATCH 319/457] Update parse exception message for ServerVersion --- .../android/sdk/service/data/server/ServerVersion.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java index 2c9b56c8..784692f8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.data.server; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; /** * @author Tom Koptel @@ -43,6 +44,7 @@ public class ServerVersion implements Comparable { public static ServerVersion v6_1_1 = new ServerVersion("6.1.1", 6.11d); public static ServerVersion v6_2 = new ServerVersion("6.2", 6.2d); + @TestOnly ServerVersion(String versionName, double versionCode) { this.versionName = versionName; this.versionCode = versionCode; @@ -52,7 +54,7 @@ public class ServerVersion implements Comparable { public static ServerVersion valueOf(@NotNull String version) { double code = VersionParser.toDouble(version); if (code == 0) { - throw new IllegalArgumentException(String.format("Version '%s' not defined", version)); + throw new IllegalArgumentException(String.format("Supplied version '%s' invalid", version)); } return new ServerVersion(version, code); } From ef92d909b8767f14aca209aa8d9de8b63bbe8baf Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 2 Dec 2015 15:44:14 +0200 Subject: [PATCH 320/457] Finalize equals contract --- .../service/data/server/ServerVersion.java | 24 ++++++++++--------- .../data/server/ServerVersionTest.java | 8 ++++++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java index 784692f8..fc0de27f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -35,14 +35,14 @@ public class ServerVersion implements Comparable { private final String versionName; private final double versionCode; - public static ServerVersion v5_5 = new ServerVersion("5.5", 5.5d); - public static ServerVersion v5_6 = new ServerVersion("5.6", 5.6d); - public static ServerVersion v5_6_1 = new ServerVersion("5.6.1", 5.61d); - public static ServerVersion v6 = new ServerVersion("6.0", 6d); - public static ServerVersion v6_0_1 = new ServerVersion("6.0.1", 6.01d); - public static ServerVersion v6_1 = new ServerVersion("6.1", 6.1d); - public static ServerVersion v6_1_1 = new ServerVersion("6.1.1", 6.11d); - public static ServerVersion v6_2 = new ServerVersion("6.2", 6.2d); + public static final ServerVersion v5_5 = new ServerVersion("5.5", 5.5d); + public static final ServerVersion v5_6 = new ServerVersion("5.6", 5.6d); + public static final ServerVersion v5_6_1 = new ServerVersion("5.6.1", 5.61d); + public static final ServerVersion v6 = new ServerVersion("6.0", 6d); + public static final ServerVersion v6_0_1 = new ServerVersion("6.0.1", 6.01d); + public static final ServerVersion v6_1 = new ServerVersion("6.1", 6.1d); + public static final ServerVersion v6_1_1 = new ServerVersion("6.1.1", 6.11d); + public static final ServerVersion v6_2 = new ServerVersion("6.2", 6.2d); @TestOnly ServerVersion(String versionName, double versionCode) { @@ -86,9 +86,11 @@ public String toString() { } @Override - public boolean equals(Object o) { + public final boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (!(o instanceof ServerVersion)) { + return false; + } ServerVersion that = (ServerVersion) o; @@ -98,7 +100,7 @@ public boolean equals(Object o) { } @Override - public int hashCode() { + public final int hashCode() { long temp = Double.doubleToLongBits(versionCode); return (int) (temp ^ (temp >>> 32)); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java index 55bf9d51..0dc9d36c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java @@ -26,12 +26,12 @@ import junitparams.JUnitParamsRunner; import junitparams.Parameters; +import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.Test; import org.junit.runner.RunWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; @RunWith(JUnitParamsRunner.class) public class ServerVersionTest { @@ -122,4 +122,10 @@ public void testToString(String version, String expected) throws Exception { public void shouldThrowIllegalArgumentExceptionIfVersionMakeNoSense() { ServerVersion.valueOf("make no sense"); } + + @Test + public void testEquals() { + EqualsVerifier.forClass(ServerVersion.class) + .verify(); + } } \ No newline at end of file From dfd1799b80c3d39d0fb72196b178203e58b11333 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 3 Dec 2015 19:16:30 +0200 Subject: [PATCH 321/457] Reducing public API. Drop managers --- .../android/sdk/service/RestClient.java | 23 ++- .../android/sdk/service/Session.java | 49 +------ .../sdk/service/TokenManagerFactory.java | 68 --------- .../sdk/service/info/InfoCacheManager.java | 37 ----- .../sdk/service/{call => internal}/Call.java | 4 +- .../{call => internal}/CallExecutor.java | 2 +- .../service/internal/DefaultCallExecutor.java | 49 ++----- .../InfoCacheManager.java} | 14 +- .../service/internal/TokenCacheManager.java | 92 ++++++++++++ .../sdk/service/internal/TokenFactory.java | 61 -------- .../report/ReportExecutionUseCase.java | 4 +- .../service/report/ReportExportUseCase.java | 4 +- .../sdk/service/report/ReportService.java | 4 +- .../service/repository/RepositoryService.java | 27 ++-- .../service/repository/SearchTaskImpl.java | 22 +-- .../sdk/service/repository/SearchUseCase.java | 31 ++-- .../sdk/service/token/InMemoryTokenCache.java | 19 +-- .../android/sdk/service/token/TokenCache.java | 12 +- .../sdk/service/token/TokenCacheManager.java | 39 ----- .../android/sdk/service/FakeCallExecutor.java | 4 +- .../sdk/service/InMemoryTokenCacheTest.java | 8 +- .../android/sdk/service/RestClientTest.java | 2 +- .../DefaultCallExecutorTest.java | 64 +++------ .../InfoCacheManagerTest.java} | 7 +- .../internal/TokenCacheManagerTest.java | 134 ++++++++++++++++++ .../service/report/ReportExecutionTest.java | 7 +- .../sdk/service/report/ReportServiceTest.java | 3 +- .../repository/RepositoryServiceTest.java | 8 +- .../repository/SearchTaskImplTest.java | 8 +- .../service/repository/SearchUseCaseTest.java | 2 +- .../StatusChain.java => test/Chain.java} | 24 ++-- 31 files changed, 384 insertions(+), 448 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCacheManager.java rename core/src/main/java/com/jaspersoft/android/sdk/service/{call => internal}/Call.java (91%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{call => internal}/CallExecutor.java (95%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{InfoCacheManagerImpl.java => internal/InfoCacheManager.java} (82%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCacheManager.java rename core/src/test/java/com/jaspersoft/android/sdk/service/{ => internal}/DefaultCallExecutorTest.java (65%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{InfoCacheManagerImplTest.java => internal/InfoCacheManagerTest.java} (91%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java rename core/src/test/java/com/jaspersoft/android/sdk/{service/report/StatusChain.java => test/Chain.java} (63%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index d83989be..f46b30b2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; +import com.jaspersoft.android.sdk.service.info.InfoCache; import java.util.concurrent.TimeUnit; @@ -36,13 +38,15 @@ public final class RestClient { private final String mServerUrl; private final long mReadTimeOut; private final long mConnectionTimeOut; + private final InfoCache mInfoCache; private AnonymousSession mAnonymousSession; - private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut) { + private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, InfoCache infoCache) { mServerUrl = serverUrl; mReadTimeOut = readTimeOut; mConnectionTimeOut = connectionTimeOut; + mInfoCache = infoCache; } public Session.Builder newSession(Credentials credentials) { @@ -68,6 +72,10 @@ public long getConnectionTimeOut() { return mConnectionTimeOut; } + public InfoCache getInfoCache() { + return mInfoCache; + } + public static Builder builder() { return new Builder(); } @@ -84,7 +92,8 @@ public ConditionalBuilder serverUrl(String serverUrl) { public static class ConditionalBuilder { private final String mServerUrl; private long mConnectionReadTimeOut = TimeUnit.SECONDS.toMillis(10); - private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10);; + private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10); + private InfoCache mInfoCache; private ConditionalBuilder(String serverUrl) { mServerUrl = serverUrl; @@ -100,8 +109,16 @@ public ConditionalBuilder connectionTimeOut(int timeOut, TimeUnit unit) { return this; } + public ConditionalBuilder infoCache(InfoCache infoCache) { + mInfoCache = infoCache; + return this; + } + public RestClient create() { - return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut); + if (mInfoCache == null) { + mInfoCache = new InMemoryInfoCache(); + } + return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mInfoCache); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index 7cb15da2..d1a55335 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -25,14 +25,10 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; -import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.report.ReportService; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; import com.jaspersoft.android.sdk.service.token.TokenCache; -import com.jaspersoft.android.sdk.service.token.TokenCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -43,26 +39,20 @@ public final class Session extends AnonymousSession { private final Credentials mCredentials; - private final InfoCacheManager mInfoCacheManager; - private final TokenCacheManager.Factory mTokenCacheManagerFactory; + private final TokenCache mTokenCache; private ReportService mReportService; private RepositoryService mRepositoryService; @TestOnly - Session(RestClient client, Credentials credentials, TokenCacheManager.Factory tokenCacheManagerFactory, InfoCacheManager infoCacheManager) { + Session(RestClient client, Credentials credentials, TokenCache tokenCache) { super(client); mCredentials = credentials; - mTokenCacheManagerFactory = tokenCacheManagerFactory; - mInfoCacheManager = infoCacheManager; + mTokenCache = tokenCache; } - public TokenCacheManager.Factory getTokenCacheManagerFactory() { - return mTokenCacheManagerFactory; - } - - public InfoCacheManager getInfoCacheManager() { - return mInfoCacheManager; + public TokenCache getTokenCache() { + return mTokenCache; } public Credentials getCredentials() { @@ -90,30 +80,12 @@ public static class Builder { private final Credentials mCredentials; private TokenCache mTokenCache; - private InfoCache mInfoCache; - private InfoCacheManager mInfoCacheManager; - private TokenCacheManager.Factory mTokenCacheManagerFactory; Builder(RestClient client, Credentials credentials) { mClient = client; mCredentials = credentials; } - public Builder infoCache(InfoCache infoCache) { - mInfoCache = infoCache; - return this; - } - - public Builder infoCacheManager(InfoCacheManager infoCacheManager) { - mInfoCacheManager = infoCacheManager; - return this; - } - - public Builder tokenCacheManagerFactory(TokenCacheManager.Factory tokenCacheManagerFactory) { - mTokenCacheManagerFactory = tokenCacheManagerFactory; - return this; - } - public Builder tokenCache(TokenCache tokenCache) { mTokenCache = tokenCache; return this; @@ -123,16 +95,7 @@ public Session create() { if (mTokenCache == null) { mTokenCache = new InMemoryTokenCache(); } - if (mInfoCache == null) { - mInfoCache = new InMemoryInfoCache(); - } - if (mInfoCacheManager == null) { - mInfoCacheManager = InfoCacheManagerImpl.create(mClient, mInfoCache); - } - if (mTokenCacheManagerFactory == null) { - mTokenCacheManagerFactory = new TokenManagerFactory(mTokenCache); - } - return new Session(mClient, mCredentials, mTokenCacheManagerFactory, mInfoCacheManager); + return new Session(mClient, mCredentials, mTokenCache); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java deleted file mode 100644 index 0f868193..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/TokenManagerFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.service.token.TokenCache; -import com.jaspersoft.android.sdk.service.token.TokenCacheManager; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class TokenManagerFactory implements TokenCacheManager.Factory { - private final TokenCache mTokenCache; - - public TokenManagerFactory(TokenCache tokenCache) { - mTokenCache = tokenCache; - } - - @Override - public TokenCacheManager create(double versionCode) { - return new DefaultManager(mTokenCache); - } - - private static class DefaultManager implements TokenCacheManager{ - private final TokenCache mTokenCache; - - private DefaultManager(TokenCache tokenCache) { - mTokenCache = tokenCache; - } - - @Override - public String getToken() { - return mTokenCache.get(); - } - - @Override - public void persistToken(String token) { - mTokenCache.put(token); - } - - @Override - public void invalidateToken() { - mTokenCache.evict(); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCacheManager.java deleted file mode 100644 index 3efecf60..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCacheManager.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.info; - -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.exception.ServiceException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface InfoCacheManager { - ServerInfo getInfo() throws ServiceException; - void invalidateInfo(); -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/call/Call.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java similarity index 91% rename from core/src/main/java/com/jaspersoft/android/sdk/service/call/Call.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java index c1b53350..754072c0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/call/Call.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.call; +package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; @@ -33,5 +33,5 @@ * @since 2.0 */ public interface Call { - public T perform(String token) throws IOException, HttpException; + T perform(String token) throws IOException, HttpException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/call/CallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java similarity index 95% rename from core/src/main/java/com/jaspersoft/android/sdk/service/call/CallExecutor.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java index 4a4040d1..3f8ad80b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/call/CallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/CallExecutor.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.call; +package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java index 34250f9d..2c384c57 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java @@ -27,12 +27,8 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.Session; -import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.call.Call; -import com.jaspersoft.android.sdk.service.call.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; -import com.jaspersoft.android.sdk.service.token.TokenCacheManager; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; import java.io.IOException; @@ -42,55 +38,32 @@ * @since 2.0 */ public class DefaultCallExecutor implements CallExecutor { - private final TokenCacheManager.Factory mTokenCacheManagerFactory; - private final InfoCacheManager mInfoCacheManager; - private final TokenFactory mTokenFactory; - private final Credentials mCredentials; + + private final TokenCacheManager mTokenCacheManager; @TestOnly - DefaultCallExecutor(Credentials credentials, - TokenCacheManager.Factory tokenCacheManagerFactory, - InfoCacheManager cacheManager, - TokenFactory tokenFactory) { - mTokenCacheManagerFactory = tokenCacheManagerFactory; - mInfoCacheManager = cacheManager; - mTokenFactory = tokenFactory; - mCredentials = credentials; + DefaultCallExecutor(TokenCacheManager tokenCacheManager) { + mTokenCacheManager = tokenCacheManager; } public static DefaultCallExecutor create(RestClient client, Session session) { - return new DefaultCallExecutor( - session.getCredentials(), - session.getTokenCacheManagerFactory(), - session.getInfoCacheManager(), - new TokenFactory(client) - ); + TokenCacheManager cacheManager = TokenCacheManager.create(client, session); + return new DefaultCallExecutor(cacheManager); } - // TODO: Discuss ServiceException reconsider approach on basis of Status result object -/* - public T execute(Call call) { - } -*/ + @NotNull public T execute(Call call) throws ServiceException { - double versionCode = mInfoCacheManager.getInfo().getVersion(); - TokenCacheManager tokenCacheManager = mTokenCacheManagerFactory.create(versionCode); - String token = tokenCacheManager.getToken(); try { - if (token == null) { - token = mTokenFactory.create(mCredentials); - tokenCacheManager.persistToken(token); - } + String token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e) { throw ServiceExceptionMapper.transform(e); } catch (HttpException e) { if (e.code() == 401) { - tokenCacheManager.invalidateToken(); + mTokenCacheManager.invalidateToken(); try { - token = mTokenFactory.create(mCredentials); - tokenCacheManager.persistToken(token); + String token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e1) { throw ServiceExceptionMapper.transform(e1); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java similarity index 82% rename from core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java index 235f54cd..c477ea24 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java @@ -22,12 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal; +import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.server.ServerInfoService; import org.jetbrains.annotations.TestOnly; @@ -35,22 +35,21 @@ * @author Tom Koptel * @since 2.0 */ -final class InfoCacheManagerImpl implements InfoCacheManager { +public class InfoCacheManager { private final ServerInfoService mInfoService; private final InfoCache mInfoCache; @TestOnly - InfoCacheManagerImpl(ServerInfoService infoService, InfoCache infoCache) { + InfoCacheManager(ServerInfoService infoService, InfoCache infoCache) { mInfoService = infoService; mInfoCache = infoCache; } - public static InfoCacheManager create(RestClient client, InfoCache infoCache) { + public static InfoCacheManager create(RestClient client) { ServerInfoService serverInfoService = ServerInfoService.create(client); - return new InfoCacheManagerImpl(serverInfoService, infoCache); + return new InfoCacheManager(serverInfoService, client.getInfoCache()); } - @Override public ServerInfo getInfo() throws ServiceException { ServerInfo info = mInfoCache.get(); if (info == null) { @@ -60,7 +59,6 @@ public ServerInfo getInfo() throws ServiceException { return info; } - @Override public void invalidateInfo() { mInfoCache.evict(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java new file mode 100644 index 00000000..e50c2c22 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java @@ -0,0 +1,92 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.RestClient; +import com.jaspersoft.android.sdk.service.Session; +import com.jaspersoft.android.sdk.service.auth.AuthenticationService; +import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.token.TokenCache; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class TokenCacheManager { + private final AuthenticationService mAuthService; + private final Credentials mCredentials; + private final TokenCache mTokenCache; + private final String mBaseUrl; + + TokenCacheManager(AuthenticationService authService, + Credentials credentials, + TokenCache tokenCache, + String baseUrl) { + mAuthService = authService; + mCredentials = credentials; + mTokenCache = tokenCache; + mBaseUrl = baseUrl; + } + + @NotNull + public static TokenCacheManager create(RestClient restClient, Session session) { + AuthenticationService service = session.authApi(); + Credentials credentials = session.getCredentials(); + TokenCache cache = session.getTokenCache(); + String baseUrl = restClient.getServerUrl(); + return new TokenCacheManager(service, credentials, cache, baseUrl); + } + + @NotNull + public String loadToken() throws IOException, HttpException { + String token = mTokenCache.get(mBaseUrl); + if (token != null) { + return token; + } + + try { + token = mAuthService.authenticate(mCredentials); + mTokenCache.put(mBaseUrl, token); + return token; + } catch (ServiceException e) { + if (e.getCause() instanceof HttpException) { + throw (HttpException) e.getCause(); + } + if (e.getCause() instanceof IOException) { + throw (IOException) e.getCause(); + } + throw new RuntimeException("Failed to load token", e.getCause()); + } + } + + public void invalidateToken() { + mTokenCache.remove(mBaseUrl); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java deleted file mode 100644 index 2123bf3b..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.internal; - -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.auth.AuthenticationService; -import com.jaspersoft.android.sdk.service.exception.ServiceException; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class TokenFactory { - private final RestClient mRestClient; - - TokenFactory(RestClient restClient) { - mRestClient = restClient; - } - - public String create(Credentials credentials) throws IOException, HttpException { - AuthenticationService auth = mRestClient.getAnonymousSession().authApi(); - try { - return auth.authenticate(credentials); - } catch (ServiceException e) { - Throwable throwable = e.getCause(); - if (throwable instanceof IOException) { - throw (IOException) throwable; - } - if (throwable instanceof HttpException) { - throw (HttpException) throwable; - } - throw new RuntimeException("Boom", throwable); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index fff79b14..4f259325 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -29,8 +29,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.call.Call; -import com.jaspersoft.android.sdk.service.call.CallExecutor; +import com.jaspersoft.android.sdk.service.internal.Call; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 55c68d2b..c2c16c8e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -31,8 +31,8 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.call.Call; -import com.jaspersoft.android.sdk.service.call.CallExecutor; +import com.jaspersoft.android.sdk.service.internal.Call; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 21f619a2..2c8a61de 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -29,12 +29,12 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.call.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; +import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index daec89d9..21e65266 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -25,10 +25,11 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.*; -import com.jaspersoft.android.sdk.service.call.CallExecutor; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; +import com.jaspersoft.android.sdk.service.RestClient; +import com.jaspersoft.android.sdk.service.Session; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.TestOnly; import java.util.concurrent.TimeUnit; @@ -38,14 +39,12 @@ * @since 2.0 */ public class RepositoryService { - private final RepositoryRestApi mRepositoryRestApi; - private final CallExecutor mCallExecutor; + private final SearchUseCase mSearchUseCase; private final InfoCacheManager mInfoCacheManager; @TestOnly - RepositoryService(RepositoryRestApi repositoryRestApi, CallExecutor callExecutor, InfoCacheManager infoCacheManager) { - mRepositoryRestApi = repositoryRestApi; - mCallExecutor = callExecutor; + RepositoryService(SearchUseCase searchUseCase, InfoCacheManager infoCacheManager) { + mSearchUseCase = searchUseCase; mInfoCacheManager = infoCacheManager; } @@ -56,11 +55,19 @@ public static RepositoryService create(RestClient client, Session session) { .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .build(); CallExecutor callExecutor = DefaultCallExecutor.create(client, session); + InfoCacheManager cacheManager = InfoCacheManager.create(client); - return new RepositoryService(repositoryRestApi, callExecutor, session.getInfoCacheManager()); + ResourceMapper resourceMapper = new ResourceMapper(); + SearchUseCase searchUseCase = new SearchUseCase( + resourceMapper, + repositoryRestApi, + cacheManager, + callExecutor + ); + return new RepositoryService(searchUseCase, cacheManager); } public SearchTask search(SearchCriteria criteria) { - return new SearchTaskImpl(InternalCriteria.from(criteria), mRepositoryRestApi, mCallExecutor, mInfoCacheManager); + return new SearchTaskImpl(InternalCriteria.from(criteria), mSearchUseCase, mInfoCacheManager); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java index 1cd01dfd..4db97db5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java @@ -24,11 +24,9 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.call.CallExecutor; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -41,8 +39,7 @@ */ final class SearchTaskImpl implements SearchTask { private final InternalCriteria mCriteria; - private final RepositoryRestApi mRepositoryRestApi; - private final CallExecutor mCallExecutor; + private final SearchUseCase mSearchUseCase; private final InfoCacheManager mInfoCacheManager; @Nullable @@ -50,12 +47,10 @@ final class SearchTaskImpl implements SearchTask { @TestOnly SearchTaskImpl(InternalCriteria criteria, - RepositoryRestApi repositoryRestApi, - CallExecutor callExecutor, + SearchUseCase searchUseCase, InfoCacheManager infoCacheManager) { mCriteria = criteria; - mRepositoryRestApi = repositoryRestApi; - mCallExecutor = callExecutor; + mSearchUseCase = searchUseCase; mInfoCacheManager = infoCacheManager; } @@ -81,15 +76,8 @@ private SearchStrategy defineSearchStrategy() throws ServiceException { if (strategy == null) { double version = mInfoCacheManager.getInfo().getVersion(); - ResourceMapper resourceMapper = new ResourceMapper(); - SearchUseCase searchUseCase = new SearchUseCase( - resourceMapper, - mRepositoryRestApi, - mInfoCacheManager, - mCallExecutor - ); strategy = SearchStrategy.Factory.get( - searchUseCase, + mSearchUseCase, mCriteria, version ); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index a1de4726..88af9b50 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -27,12 +27,12 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.call.Call; -import com.jaspersoft.android.sdk.service.call.CallExecutor; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Call; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -62,33 +62,20 @@ class SearchUseCase { @NotNull public SearchResult performSearch(@NotNull final InternalCriteria internalCriteria) throws ServiceException { + final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call call = new Call() { @Override public SearchResult perform(String token) throws IOException, HttpException { Map criteria = CriteriaMapper.map(internalCriteria); ResourceSearchResult response = mRestApi.searchResources(token, criteria); - SimpleDateFormat dateTimeFormat = null; - try { - dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); + SearchResult searchResult = new SearchResult(); + searchResult.setNextOffset(response.getNextOffset()); - SearchResult searchResult = new SearchResult(); - searchResult.setNextOffset(response.getNextOffset()); + Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); + searchResult.setResources(resources); - Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); - searchResult.setResources(resources); - - return searchResult; - } catch (ServiceException e) { - Throwable cause = e.getCause(); - if (cause instanceof IOException) { - throw (IOException) cause; - } - if (cause instanceof HttpException) { - throw (HttpException) cause; - } - throw new RuntimeException(cause); - } + return searchResult; } }; return mCallExecutor.execute(call); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java index 72870eda..0eb2b5eb 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java @@ -24,27 +24,30 @@ package com.jaspersoft.android.sdk.service.token; -import com.jaspersoft.android.sdk.service.token.TokenCache; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; +import java.util.WeakHashMap; /** * @author Tom Koptel * @since 2.0 */ public final class InMemoryTokenCache implements TokenCache { - private String mCache; + private final Map mCache = new WeakHashMap(); @Override - public String get() { - return mCache; + public String get(String key) { + return mCache.get(key); } @Override - public void put(String token) { - mCache = token; + public void put(@NotNull String key, String token) { + mCache.put(key, token); } @Override - public void evict() { - mCache = null; + public void remove(String key) { + mCache.remove(key); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java index 14edb198..58cca28f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java @@ -24,12 +24,18 @@ package com.jaspersoft.android.sdk.service.token; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * @author Tom Koptel * @since 2.0 */ public interface TokenCache { - String get(); - void put(String token); - void evict(); + @Nullable + String get(String key); + + void put(@NotNull String key, @Nullable String token); + + void remove(@NotNull String key); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCacheManager.java deleted file mode 100644 index efc61f62..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCacheManager.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.token; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface TokenCacheManager { - public String getToken(); - public void persistToken(String token); - public void invalidateToken(); - - interface Factory { - TokenCacheManager create(double versionCode); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java index 585fe1cf..e008e588 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java @@ -25,8 +25,8 @@ package com.jaspersoft.android.sdk.service; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.call.Call; -import com.jaspersoft.android.sdk.service.call.CallExecutor; +import com.jaspersoft.android.sdk.service.internal.Call; +import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java index b071185e..e9f61cd5 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java @@ -43,9 +43,9 @@ public void setUp() throws Exception { @Test public void testCache() throws Exception { - cache.put("token"); - assertThat(cache.get(), is("token")); - cache.evict(); - assertThat(cache.get(), is(nullValue())); + cache.put("http://localhost", "token"); + assertThat(cache.get("http://localhost"), is("token")); + cache.remove("http://localhost"); + assertThat(cache.get("http://localhost"), is(nullValue())); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java index 7ef1c978..c5f5acfc 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java @@ -40,6 +40,7 @@ public void testIntegration() { .serverUrl("http://localhost") .connectionTimeOut(5, TimeUnit.DAYS) .readTimeOut(5, TimeUnit.DAYS) + .infoCache(new InMemoryInfoCache()) .create(); Credentials credentials = SpringCredentials.builder() .username("any") @@ -49,7 +50,6 @@ public void testIntegration() { Session session = client.newSession(credentials) .tokenCache(new InMemoryTokenCache()) - .infoCache(new InMemoryInfoCache()) .create(); session.reportApi(); session.repositoryApi(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/DefaultCallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java similarity index 65% rename from core/src/test/java/com/jaspersoft/android/sdk/service/DefaultCallExecutorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java index 85dbea89..c0abcba5 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/DefaultCallExecutorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java @@ -22,18 +22,13 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.call.Call; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; -import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; -import com.jaspersoft.android.sdk.service.internal.TokenFactory; -import com.jaspersoft.android.sdk.service.token.TokenCacheManager; +import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -43,7 +38,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; public class DefaultCallExecutorTest { @@ -51,15 +45,6 @@ public class DefaultCallExecutorTest { @Mock TokenCacheManager mTokenCacheManager; @Mock - TokenCacheManager.Factory mTokenCacheManagerFactory; - @Mock - InfoCacheManager mInfoCacheManager; - - @Mock - TokenFactory mFactory; - @Mock - Credentials mCredentials; - @Mock Call mCall; @Mock @@ -77,60 +62,51 @@ public void setUp() throws Exception { when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenReturn(mResponse); - when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); - when(mTokenCacheManagerFactory.create(anyDouble())).thenReturn(mTokenCacheManager); - resolver = new DefaultCallExecutor(mCredentials, mTokenCacheManagerFactory, mInfoCacheManager, mFactory); + resolver = new DefaultCallExecutor(mTokenCacheManager); } @Test public void testExecuteWithValidCache() throws Exception { - when(mTokenCacheManager.getToken()).thenReturn("token"); + when(mTokenCacheManager.loadToken()).thenReturn("token"); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mTokenCacheManager).getToken(); + verify(mTokenCacheManager).loadToken(); verify(mCall).perform("token"); verifyNoMoreInteractions(mTokenCacheManager); - verifyZeroInteractions(mFactory); + verifyZeroInteractions(mTokenCacheManager); } @Test public void testExecuteWithEmptyCache() throws Exception { - when(mTokenCacheManager.getToken()).thenReturn(null); - when(mFactory.create(any(Credentials.class))).thenReturn("token"); + when(mTokenCacheManager.loadToken()).thenReturn(null); + when(mTokenCacheManager.loadToken()).thenReturn("token"); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mTokenCacheManager).getToken(); - verify(mFactory).create(mCredentials); - verify(mTokenCacheManager).persistToken("token"); + verify(mTokenCacheManager).loadToken(); verify(mCall).perform("token"); } @Test public void testExecuteWithInvalidCache() throws Exception { - when(mTokenCacheManager.getToken()).thenReturn("invalid token"); + when(mTokenCacheManager.loadToken()).then(Chain.of("invalid token", "valid token")); when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenAnswer(_401ResponseAtFirstInvokation()); - when(mFactory.create(any(Credentials.class))).thenReturn("token"); - assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - verify(mTokenCacheManager).getToken(); + verify(mTokenCacheManager, times(2)).loadToken(); verify(mCall).perform("invalid token"); verify(mTokenCacheManager).invalidateToken(); - verify(mFactory).create(mCredentials); - verify(mTokenCacheManager).persistToken("token"); - verify(mCall).perform("token"); + verify(mCall).perform("valid token"); } @Test public void testExecuteWithInvalidCredentials() throws Exception { - when(mTokenCacheManager.getToken()).thenReturn("invalid token"); + when(mTokenCacheManager.loadToken()).thenReturn("invalid token"); when(mCall.perform(anyString())).thenThrow(_401Exception); - when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); try { resolver.execute(mCall); @@ -138,16 +114,14 @@ public void testExecuteWithInvalidCredentials() throws Exception { assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); } - verify(mTokenCacheManager).getToken(); - verify(mCall).perform("invalid token"); + verify(mTokenCacheManager, times(2)).loadToken(); + verify(mCall, times(2)).perform("invalid token"); verify(mTokenCacheManager).invalidateToken(); - verify(mFactory).create(mCredentials); } @Test public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { - when(mTokenCacheManager.getToken()).thenReturn(null); - when(mFactory.create(any(Credentials.class))).thenThrow(_401Exception); + when(mTokenCacheManager.loadToken()).thenThrow(_401Exception); try { resolver.execute(mCall); @@ -155,12 +129,10 @@ public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); } - verify(mTokenCacheManager).getToken(); verify(mTokenCacheManager).invalidateToken(); - - verify(mFactory, times(2)).create(mCredentials); + verify(mTokenCacheManager, times(2)).loadToken(); + verifyNoMoreInteractions(mTokenCacheManager); verifyNoMoreInteractions(mTokenCacheManager); - verifyNoMoreInteractions(mFactory); verifyZeroInteractions(mCall); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java similarity index 91% rename from core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java index 45ff589d..693a20e6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InfoCacheManagerImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java @@ -22,11 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.server.ServerInfoService; import org.junit.Before; import org.junit.Test; @@ -37,7 +36,7 @@ import static org.mockito.Mockito.when; -public class InfoCacheManagerImplTest { +public class InfoCacheManagerTest { @Mock ServerInfoService mInfoService; @Mock @@ -51,7 +50,7 @@ public class InfoCacheManagerImplTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mInfoService.requestServerInfo()).thenReturn(info); - mManager = new InfoCacheManagerImpl(mInfoService, mInfoCache); + mManager = new InfoCacheManager(mInfoService, mInfoCache); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java new file mode 100644 index 00000000..3404a322 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java @@ -0,0 +1,134 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.auth.AuthenticationService; +import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.token.TokenCache; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.io.IOException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + AuthenticationService.class +}) +public class TokenCacheManagerTest { + @Mock + TokenCache mTokenCache; + @Mock + AuthenticationService mAuthenticationService; + @Mock + Credentials mCredentials; + @Mock + HttpException mHttpException; + + private final String baseUrl = "http://localhost/"; + private TokenCacheManager cacheManager; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + cacheManager = new TokenCacheManager( + mAuthenticationService, + mCredentials, + mTokenCache, + baseUrl + ); + } + + @Test + public void testLoadToken() throws Exception { + when(mTokenCache.get(anyString())).thenReturn(null); + when(mAuthenticationService.authenticate(any(Credentials.class))).thenReturn("token"); + + assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is("token")); + + verify(mTokenCache).get(baseUrl); + verify(mTokenCache).put(baseUrl, "token"); + verify(mAuthenticationService).authenticate(mCredentials); + } + + @Test + public void testLoadTokenReturnsFromCache() throws Exception { + when(mTokenCache.get(anyString())).thenReturn("token"); + + assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is("token")); + verify(mTokenCache).get(baseUrl); + verifyNoMoreInteractions(mTokenCache); + verifyZeroInteractions(mAuthenticationService); + } + + @Test(expected = IOException.class) + public void testLoadTokenRethrowsIOException() throws Exception { + when(mTokenCache.get(anyString())).thenReturn(null); + when(mAuthenticationService.authenticate(any(Credentials.class))) + .thenThrow(new ServiceException("", new IOException(), 0)); + + cacheManager.loadToken(); + } + + @Test(expected = HttpException.class) + public void testLoadTokenRethrowsHttpException() throws Exception { + when(mTokenCache.get(anyString())).thenReturn(null); + when(mAuthenticationService.authenticate(any(Credentials.class))) + .thenThrow(new ServiceException("", mHttpException, 0)); + + cacheManager.loadToken(); + } + + @Test(expected = RuntimeException.class) + public void testLoadTokenThrowsRuntimeForUnexpectedError() throws Exception { + when(mTokenCache.get(anyString())).thenReturn(null); + when(mAuthenticationService.authenticate(any(Credentials.class))) + .thenThrow(new ServiceException("", new NullPointerException(), 0)); + + cacheManager.loadToken(); + } + + @Test + public void testInvalidateToken() throws Exception { + cacheManager.invalidateToken(); + verify(mTokenCache).remove(baseUrl); + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 0f93f9b7..835af705 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -32,6 +32,7 @@ import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -242,7 +243,7 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); - when(mExecutionStatusResponse.getStatus()).then(StatusChain.of(statusChain)); + when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); when(mExecutionStatusResponse.getErrorDescriptor()).thenReturn(mDescriptor); when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(mExecutionStatusResponse); } @@ -250,7 +251,7 @@ private void mockCheckExportExecStatus(String... statusChain) throws Exception { private void mockRunExportExecution(String... statusChain) throws Exception { ensureChain(statusChain); when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).then(StatusChain.of(statusChain)); + when(mExportExecDetails.getStatus()).then(Chain.of(statusChain)); when(mExportExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(mExportRestApi.runExportExecution(anyString(), anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); } @@ -261,7 +262,7 @@ private void mockReportExecutionDetails(String... statusChain) throws Exception when(mExportExecution.getStatus()).thenReturn("execution"); when(mExportExecution.getId()).thenReturn("export_id"); when(mExecDetails.getExports()).thenReturn(exports); - when(mExecDetails.getStatus()).then(StatusChain.of(statusChain)); + when(mExecDetails.getStatus()).then(Chain.of(statusChain)); when(mExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(mExecutionRestApi.requestReportExecutionDetails(anyString(), anyString())).thenReturn(mExecDetails); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 3ab34659..ba2ebbd2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -33,6 +33,7 @@ import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -168,7 +169,7 @@ public void testRunShouldLoopUntilStatusExecution() throws Exception { } private void mockReportExecutionStatus(String... statusChain) throws Exception { - when(statusDetails.getStatus()).then(StatusChain.of(statusChain)); + when(statusDetails.getStatus()).then(Chain.of(statusChain)); when(statusDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(executionApi.requestReportExecutionStatus(anyString(), anyString())).thenReturn(statusDetails); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 5e35ece6..c10379e2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -24,9 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -44,7 +42,7 @@ */ public class RepositoryServiceTest { @Mock - RepositoryRestApi repoApi; + SearchUseCase mCase; @Mock InfoCacheManager mInfoCacheManager; @@ -56,7 +54,7 @@ public class RepositoryServiceTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new RepositoryService(repoApi, new FakeCallExecutor("cookie"), mInfoCacheManager); + objectUnderTest = new RepositoryService(mCase, mInfoCacheManager); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java index 18062e5a..2324fb19 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java @@ -25,10 +25,9 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -62,12 +61,15 @@ public class SearchTaskImplTest { @Mock ServerInfo mServerInfo; + @Mock + SearchUseCase mSearchUseCase; + private SearchTaskImpl objectUnderTest; @Before public void setup() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchTaskImpl(CRITERIA, mRepoApi, new FakeCallExecutor("cookie"), mInfoCacheManager); + objectUnderTest = new SearchTaskImpl(CRITERIA, mSearchUseCase, mInfoCacheManager); when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); when(mSearchStrategy.searchNext()).thenReturn(Collections.emptyList()); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index de1f8792..5005a795 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -28,10 +28,10 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.info.InfoCacheManager; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java similarity index 63% rename from core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java index 3d5642fd..6134ca8f 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/StatusChain.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java @@ -1,28 +1,28 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ -package com.jaspersoft.android.sdk.service.report; +package com.jaspersoft.android.sdk.test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -31,16 +31,16 @@ * @author Tom Koptel * @since 2.0 */ -final class StatusChain implements Answer { +public final class Chain implements Answer { private final String[] mChain; private int invocationCount = 0; - private StatusChain(String... chain) { + private Chain(String... chain) { mChain = chain; } - public static StatusChain of(String... statuses) { - return new StatusChain(statuses); + public static Chain of(java.lang.String... values) { + return new Chain(values); } @Override @@ -52,4 +52,4 @@ public String answer(InvocationOnMock invocation) throws Throwable { invocationCount++; return mChain[statusIndex]; } -} \ No newline at end of file +} From 676c49c8308b38d2029fdaa01c966692507a9eef Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 3 Dec 2015 22:33:20 +0200 Subject: [PATCH 322/457] Add key support for Info cache manager --- .../sdk/service/info/InMemoryInfoCache.java | 17 +++--- .../android/sdk/service/info/InfoCache.java | 9 ++- .../service/internal/InfoCacheManager.java | 13 ++-- .../sdk/service/InMemoryInfoCacheTest.java | 8 +-- .../android/sdk/service/RestClientTest.java | 61 ------------------- .../internal/InfoCacheManagerTest.java | 16 ++--- 6 files changed, 37 insertions(+), 87 deletions(-) delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java index 6f8395ce..ae132aa0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java @@ -26,25 +26,28 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import java.util.Map; +import java.util.WeakHashMap; + /** * @author Tom Koptel * @since 2.0 */ public final class InMemoryInfoCache implements InfoCache { - private ServerInfo mInfoCache; + private Map mCache = new WeakHashMap<>(); @Override - public ServerInfo get() { - return mInfoCache; + public ServerInfo get(String key) { + return mCache.get(key); } @Override - public void put(ServerInfo serverInfo) { - mInfoCache = serverInfo; + public void put(String key, ServerInfo serverInfo) { + mCache.put(key, serverInfo); } @Override - public void evict() { - mInfoCache = null; + public void remove(String key) { + mCache.remove(key); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java index c2d7fdca..ee3883f4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java @@ -25,13 +25,16 @@ package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import org.jetbrains.annotations.NotNull; /** * @author Tom Koptel * @since 2.0 */ public interface InfoCache { - ServerInfo get(); - void put(ServerInfo serverInfo); - void evict(); + ServerInfo get(@NotNull String key); + + void put(@NotNull String key, @NotNull ServerInfo serverInfo); + + void remove(@NotNull String key); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java index c477ea24..c238ade3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java @@ -38,28 +38,31 @@ public class InfoCacheManager { private final ServerInfoService mInfoService; private final InfoCache mInfoCache; + private final String mServerUrl; @TestOnly - InfoCacheManager(ServerInfoService infoService, InfoCache infoCache) { + InfoCacheManager(String serverUrl, ServerInfoService infoService, InfoCache infoCache) { + mServerUrl = serverUrl; mInfoService = infoService; mInfoCache = infoCache; } public static InfoCacheManager create(RestClient client) { ServerInfoService serverInfoService = ServerInfoService.create(client); - return new InfoCacheManager(serverInfoService, client.getInfoCache()); + String baseUrl = client.getServerUrl(); + return new InfoCacheManager(baseUrl, serverInfoService, client.getInfoCache()); } public ServerInfo getInfo() throws ServiceException { - ServerInfo info = mInfoCache.get(); + ServerInfo info = mInfoCache.get(mServerUrl); if (info == null) { info = mInfoService.requestServerInfo(); - mInfoCache.put(info); + mInfoCache.put(mServerUrl, info); } return info; } public void invalidateInfo() { - mInfoCache.evict(); + mInfoCache.remove(mServerUrl); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java index 9afad336..25ff6260 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java @@ -45,9 +45,9 @@ public void setUp() throws Exception { @Test public void testGet() throws Exception { ServerInfo serverInfo = new ServerInfo(); - mInfoCache.put(serverInfo); - assertThat(mInfoCache.get(), is(serverInfo)); - mInfoCache.evict(); - assertThat(mInfoCache.get(), is(nullValue())); + mInfoCache.put("key", serverInfo); + assertThat(mInfoCache.get("key"), is(serverInfo)); + mInfoCache.remove("key"); + assertThat(mInfoCache.get("key"), is(nullValue())); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java deleted file mode 100644 index c5f5acfc..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/RestClientTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.auth.SpringCredentials; -import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; -import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; -import org.junit.Test; - -import java.util.concurrent.TimeUnit; - -public class RestClientTest { - - @Test - public void testIntegration() { - RestClient client = RestClient.builder() - .serverUrl("http://localhost") - .connectionTimeOut(5, TimeUnit.DAYS) - .readTimeOut(5, TimeUnit.DAYS) - .infoCache(new InMemoryInfoCache()) - .create(); - Credentials credentials = SpringCredentials.builder() - .username("any") - .password("any") - .organization("any") - .build(); - - Session session = client.newSession(credentials) - .tokenCache(new InMemoryTokenCache()) - .create(); - session.reportApi(); - session.repositoryApi(); - - AnonymousSession anonymousSession = client.getAnonymousSession(); - anonymousSession.authApi(); - anonymousSession.infoApi(); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java index 693a20e6..7200baf4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java @@ -32,6 +32,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -45,33 +46,34 @@ public class InfoCacheManagerTest { ServerInfo info; private InfoCacheManager mManager; + private final String baseUrl = "http://localhost/"; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mInfoService.requestServerInfo()).thenReturn(info); - mManager = new InfoCacheManager(mInfoService, mInfoCache); + mManager = new InfoCacheManager(baseUrl, mInfoService, mInfoCache); } @Test public void testGetInfoWithCache() throws Exception { - when(mInfoCache.get()).thenReturn(info); + when(mInfoCache.get(baseUrl)).thenReturn(info); mManager.getInfo(); - verify(mInfoCache).get(); + verify(mInfoCache).get(baseUrl); } @Test public void testGetInfoWithoutCache() throws Exception { - when(mInfoCache.get()).thenReturn(null); + when(mInfoCache.get(anyString())).thenReturn(null); mManager.getInfo(); - verify(mInfoCache).get(); + verify(mInfoCache).get(baseUrl); verify(mInfoService).requestServerInfo(); - verify(mInfoCache).put(info); + verify(mInfoCache).put(baseUrl, info); } @Test public void testInvalidateInfo() throws Exception { mManager.invalidateInfo(); - verify(mInfoCache).evict(); + verify(mInfoCache).remove(baseUrl); } } \ No newline at end of file From 23f613e0a3873c3731986eaa0a572bf67c2a2ebc Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 3 Dec 2015 22:40:34 +0200 Subject: [PATCH 323/457] Enforcing nullable/notnull contracts on caches --- .../android/sdk/service/info/InMemoryInfoCache.java | 9 ++++++--- .../jaspersoft/android/sdk/service/info/InfoCache.java | 2 ++ .../android/sdk/service/token/InMemoryTokenCache.java | 8 +++++--- .../jaspersoft/android/sdk/service/token/TokenCache.java | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java index ae132aa0..c4d1da71 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.WeakHashMap; @@ -36,18 +38,19 @@ public final class InMemoryInfoCache implements InfoCache { private Map mCache = new WeakHashMap<>(); + @Nullable @Override - public ServerInfo get(String key) { + public ServerInfo get(@NotNull String key) { return mCache.get(key); } @Override - public void put(String key, ServerInfo serverInfo) { + public void put(@NotNull String key, @NotNull ServerInfo serverInfo) { mCache.put(key, serverInfo); } @Override - public void remove(String key) { + public void remove(@NotNull String key) { mCache.remove(key); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java index ee3883f4..ad539d8b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java @@ -26,12 +26,14 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Tom Koptel * @since 2.0 */ public interface InfoCache { + @Nullable ServerInfo get(@NotNull String key); void put(@NotNull String key, @NotNull ServerInfo serverInfo); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java index 0eb2b5eb..c1b957a2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.token; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.WeakHashMap; @@ -36,18 +37,19 @@ public final class InMemoryTokenCache implements TokenCache { private final Map mCache = new WeakHashMap(); + @Nullable @Override - public String get(String key) { + public String get(@NotNull String key) { return mCache.get(key); } @Override - public void put(@NotNull String key, String token) { + public void put(@NotNull String key, @NotNull String token) { mCache.put(key, token); } @Override - public void remove(String key) { + public void remove(@NotNull String key) { mCache.remove(key); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java index 58cca28f..d3fa99db 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java @@ -33,9 +33,9 @@ */ public interface TokenCache { @Nullable - String get(String key); + String get(@NotNull String key); - void put(@NotNull String key, @Nullable String token); + void put(@NotNull String key, @NotNull String token); void remove(@NotNull String key); } From 94feceb23ac0cdcf895b4371869b87c94434a378 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 4 Dec 2015 14:48:53 +0200 Subject: [PATCH 324/457] Make zero version acceptable --- .../android/sdk/service/data/server/ServerVersion.java | 2 +- .../android/sdk/service/data/server/VersionParser.java | 8 +++++--- .../sdk/service/data/server/ServerVersionTest.java | 6 ++++++ .../sdk/service/data/server/VersionParserTest.java | 4 +++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java index fc0de27f..58b7f3dc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/ServerVersion.java @@ -53,7 +53,7 @@ public class ServerVersion implements Comparable { @NotNull public static ServerVersion valueOf(@NotNull String version) { double code = VersionParser.toDouble(version); - if (code == 0) { + if (code == -1) { throw new IllegalArgumentException(String.format("Supplied version '%s' invalid", version)); } return new ServerVersion(version, code); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java index e7582ddc..21d624dd 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/server/VersionParser.java @@ -34,6 +34,8 @@ */ final class VersionParser { + private static final double INVALID_VERSION = -1d; + private VersionParser() { } @@ -49,7 +51,7 @@ public static double toDouble(String version) { } } } - return 0d; + return INVALID_VERSION; } private static double parseAsNumber(String version) { @@ -58,7 +60,7 @@ private static double parseAsNumber(String version) { if (matcher.find()) { return Double.valueOf(matcher.group()); } - return 0; + return INVALID_VERSION; } private static double parseAsVersionName(String version) { @@ -71,7 +73,7 @@ private static double parseAsVersionName(String version) { try { decimalSubVersion = new BigDecimal(Integer.parseInt(subs[i])); } catch (NumberFormatException ex) { - decimalSubVersion = new BigDecimal("0"); + return INVALID_VERSION; } decimalFactor = new BigDecimal(String.valueOf(Math.pow(10, i * -1))); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java index 0dc9d36c..47cd9082 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/ServerVersionTest.java @@ -123,6 +123,12 @@ public void shouldThrowIllegalArgumentExceptionIfVersionMakeNoSense() { ServerVersion.valueOf("make no sense"); } + @Test + @Parameters({"0", "0.0"}) + public void shouldAcceptZeroAsArgument(String version) { + ServerVersion.valueOf(version); + } + @Test public void testEquals() { EqualsVerifier.forClass(ServerVersion.class) diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java index e6146263..c012bb4c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/server/VersionParserTest.java @@ -86,6 +86,8 @@ public void shouldParseLongSemanticVersioning(String versionCode, String expecte @Test @Parameters({ + "0, 0", + "0.0, 0", "1-asdasdsad, 1", "1-asdasdsad2, 1", "12-asdasdsad2, 12", @@ -103,6 +105,6 @@ public void shouldParseIfHasNumber(String version, String result) { }) public void shouldReturnZeroForIncorrectVersion(String invalidVersion) { assertThat(String.format("Version '%s' should be treated as zero", invalidVersion), - VersionParser.toDouble(invalidVersion), is(0d)); + VersionParser.toDouble(invalidVersion), is(-1d)); } } \ No newline at end of file From ef3aa2caaf8109378421313279b8210db4a3f736 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 9 Dec 2015 12:28:33 +0200 Subject: [PATCH 325/457] Fix info service read timeout issue --- .../android/sdk/service/server/ServerInfoService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 81aa26f1..52b9610a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -57,7 +57,7 @@ public static ServerInfoService create(RestClient client) { ServerRestApi restApi = new ServerRestApi.Builder() .baseUrl(client.getServerUrl()) .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(client.getReadTimeOut(), TimeUnit.MICROSECONDS) + .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .build(); return new ServerInfoService(restApi, ServerInfoTransformer.get()); From 24fec693b0c064e8a29f43388e1cc025e3d0364c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Dec 2015 15:15:29 +0200 Subject: [PATCH 326/457] Introduce report parameter network layer --- .../sdk/network/ReportExecutionRestApi.java | 7 +- .../network/ReportExecutionRestApiImpl.java | 25 ++---- .../execution/ExecutionRequestOptions.java | 10 +-- .../entity/report/ReportParameter.java | 77 +++++++++++++++++++ .../sdk/service/report/RunReportCriteria.java | 16 ++-- .../network/ReportExecutionRestApiTest.java | 12 ++- .../ExecutionOptionsDataMapperTest.java | 7 +- .../api/ReportExecutionRestApiTest.java | 24 ++---- 8 files changed, 115 insertions(+), 63 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index 709b6f53..906650d2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -28,13 +28,12 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; - +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; import java.io.IOException; -import java.util.Collection; +import java.util.List; import java.util.Map; -import java.util.Set; /** * @author Tom Koptel @@ -59,7 +58,7 @@ boolean cancelReportExecution(@NotNull String token, boolean updateReportExecution(@NotNull String token, @NotNull String executionId, - @NotNull Collection>> params) throws HttpException, IOException; + @NotNull List params) throws HttpException, IOException; // TODO: API is broken requires investigation before release @NotNull diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java index 932dd564..a9581e76 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java @@ -28,26 +28,17 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; - +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -import java.io.IOException; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; -import retrofit.http.Body; -import retrofit.http.GET; -import retrofit.http.Header; -import retrofit.http.Headers; -import retrofit.http.POST; -import retrofit.http.PUT; -import retrofit.http.Path; -import retrofit.http.QueryMap; +import retrofit.http.*; + +import java.io.IOException; +import java.util.List; +import java.util.Map; /** * @author Tom Koptel @@ -109,7 +100,7 @@ public boolean cancelReportExecution(@Nullable String token, @Override public boolean updateReportExecution(@Nullable String token, @Nullable String executionId, - @Nullable Collection>> params) throws IOException, HttpException { + @Nullable List params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); @@ -160,7 +151,7 @@ Call requestReportExecutionStatus(@NotNull @Path(value = "execu @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/parameters") Call updateReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, - @NotNull @Body Collection>> params, + @NotNull @Body List params, @Header("Cookie") String cookie); @NotNull diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 016cd355..ddf387b3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -25,9 +25,9 @@ package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import java.util.Map; -import java.util.Set; +import java.util.List; /** * @author Tom Koptel @@ -60,7 +60,7 @@ public class ExecutionRequestOptions { @Expose protected String attachmentsPrefix; @Expose - protected Map> parameters; + protected List parameters; protected ExecutionRequestOptions() {} @@ -93,7 +93,7 @@ public ExecutionRequestOptions withSaveDataSnapshot(boolean saveDataSnapshot) { return this; } - public ExecutionRequestOptions withParameters(Map> parameters) { + public ExecutionRequestOptions withParameters(List parameters) { this.parameters = parameters; return this; } @@ -161,7 +161,7 @@ public String getPages() { return pages; } - public Map> getParameters() { + public List getParameters() { return parameters; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java new file mode 100644 index 00000000..a9acc93f --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.report; + +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportParameter { + private final String name; + private final Set value; + + public ReportParameter(String name, Set value) { + this.name = name; + this.value = value; + } + + public String getName() { + return name; + } + + public Set getValue() { + return value; + } + + @Override + public String toString() { + return "ReportParameter{" + + "name='" + name + '\'' + + ", value=" + value + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ReportParameter that = (ReportParameter) o; + + if (name != null ? !name.equals(that.name) : that.name != null) return false; + if (value != null ? !value.equals(that.value) : that.value != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (value != null ? value.hashCode() : 0); + return result; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index 252d2f6f..155ebaac 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -24,18 +24,18 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; -import java.util.Set; +import java.util.List; /** * @author Tom Koptel * @since 2.0 */ public class RunReportCriteria extends ExecutionCriteria { - private final Map> mParams; + private final List mParams; private RunReportCriteria(boolean freshData, boolean interactive, @@ -43,7 +43,7 @@ private RunReportCriteria(boolean freshData, Format format, String pages, String attachmentPrefix, - Map> params + List params ) { super(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); mParams = params; @@ -55,7 +55,7 @@ public static Builder builder() { } @Nullable - public Map> getParams() { + public List getParams() { return mParams; } @@ -65,8 +65,8 @@ public static class Builder { private boolean saveSnapshot; private Format format; private String pages; - public Map> params; - public String attachmentPrefix; + private List params; + private String attachmentPrefix; public Builder() { interactive = true; @@ -97,7 +97,7 @@ public Builder pages(@Nullable String pages) { return this; } - public Builder params(Map> params) { + public Builder params(List params) { this.params = params; return this; } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index 7691b5de..b728863b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -62,12 +63,9 @@ public class ReportExecutionRestApiTest { private static final Map SEARCH_PARAMS = new HashMap(); - private static final List>> PARAMS = new ArrayList<>(); - static { - Map> reportParameter = new HashMap<>(); - reportParameter.put("key", new HashSet(Collections.singletonList("value"))); - PARAMS.add(reportParameter); - } + private static final List PARAMS = Collections.singletonList( + new ReportParameter("key", new HashSet(Collections.singletonList("value"))) + ); static { SEARCH_PARAMS.put("key", "value"); @@ -183,7 +181,7 @@ public void bodyParameterShouldNotBeEmptyForExecutionUpdate() throws Exception { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Execution params should not be empty"); - restApiUnderTest.updateReportExecution("cookie", "any_id", Collections.>>emptyList()); + restApiUnderTest.updateReportExecution("cookie", "any_id", Collections.emptyList()); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index e3b544b7..dc844ca1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -26,13 +26,12 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; - +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.junit.Before; import org.junit.Test; import java.util.Collections; -import java.util.Map; -import java.util.Set; +import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; @@ -46,7 +45,7 @@ public class ExecutionOptionsDataMapperTest { private static final String REPORT_URI = "/report/uri"; private static final String BASE_URL = "http:://localhost"; - public static final Map> REPORT_PARAMS = Collections.emptyMap(); + public static final List REPORT_PARAMS = Collections.singletonList(null); private ExecutionOptionsDataMapper mapper; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 0ed4c99e..bfb05be1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -29,22 +29,16 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; - import org.jetbrains.annotations.NotNull; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; @@ -59,6 +53,7 @@ public class ReportExecutionRestApiTest { private final String REPORT_URI = "/public/Samples/Reports/ProfitDetailReport"; + private final ReportParameter PRODUCT_FAMILY = new ReportParameter("ProductFamily", new HashSet(Collections.singletonList("Drink"))); ReportExecutionRestApi apiUnderTest; @@ -125,14 +120,9 @@ public void searchForExecutionShouldReturnResult() throws Exception { @Test public void updateOfParametersForExecutionShouldReturnResult() throws Exception { - List>> list = new ArrayList<>(); - - Map> reportParameter = new HashMap<>(); - reportParameter.put("ProductFamily", new HashSet(Collections.singletonList("Drink"))); - list.add(reportParameter); - ReportExecutionDescriptor executionResponse = startExecution(); - boolean success = apiUnderTest.updateReportExecution(mAuthenticator.token(), executionResponse.getExecutionId(), list); + boolean success = apiUnderTest.updateReportExecution(mAuthenticator.token(), executionResponse.getExecutionId(), + Collections.singletonList(PRODUCT_FAMILY)); assertThat(success, is(true)); } @@ -147,9 +137,7 @@ private ReportExecutionDescriptor startExecution() throws Exception { @NotNull private ReportExecutionDescriptor startExecution(String uri) throws Exception { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); - Map> params = new HashMap<>(); - params.put("ProductFamily", new HashSet(Collections.singletonList("Food"))); - executionRequestOptions.withParameters(params); + executionRequestOptions.withParameters(Collections.singletonList(PRODUCT_FAMILY)); return apiUnderTest.runReportExecution(mAuthenticator.token(), executionRequestOptions); } From f5b5f0bb47394a11d9243e94b76b9b8e6de0644f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 10 Dec 2015 15:39:57 +0200 Subject: [PATCH 327/457] Introduce ReportParameter object for network layer --- .../entity/report/ReportParameter.java | 4 ++ .../sdk/network/entity/type/GsonFactory.java | 1 + .../ReportExecutionRequestOptionsFactory.java | 57 +++++++++++++++++++ .../network/ReportExecutionRestApiTest.java | 11 +--- .../entity/report/ReportParameterTest.java | 56 ++++++++++++++++++ .../network/entity/type/GsonFactoryTest.java | 18 +++++- 6 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportExecutionRequestOptionsFactory.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameterTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java index a9acc93f..00bf3261 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameter.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.network.entity.report; +import com.google.gson.annotations.Expose; + import java.util.Set; /** @@ -31,7 +33,9 @@ * @since 2.0 */ public final class ReportParameter { + @Expose private final String name; + @Expose private final Set value; public ReportParameter(String name, Set value) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java index e5bfb274..c60fc111 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactory.java @@ -38,6 +38,7 @@ public static Gson create() { gsonBuilder.disableHtmlEscaping(); gsonBuilder.registerTypeAdapterFactory(new ReportLookupTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new InputControlTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new ReportExecutionRequestOptionsFactory()); return gsonBuilder.create(); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportExecutionRequestOptionsFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportExecutionRequestOptionsFactory.java new file mode 100644 index 00000000..f9efd7b9 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/type/ReportExecutionRequestOptionsFactory.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.type; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExecutionRequestOptionsFactory extends CustomizedTypeAdapterFactory { + public ReportExecutionRequestOptionsFactory() { + super(ReportExecutionRequestOptions.class); + } + + @Override + protected void beforeWrite(ReportExecutionRequestOptions source, JsonElement toSerialize) { + JsonObject response = toSerialize.getAsJsonObject(); + JsonElement parametersElement = response.get("parameters"); + if (!parametersElement.isJsonNull()) { + JsonArray parameters = parametersElement.getAsJsonArray(); + + JsonObject reportParameter = new JsonObject(); + reportParameter.add("reportParameter", parameters); + + response.remove("parameters"); + response.add("parameters", reportParameter); + } + + super.beforeWrite(source, response); + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index b728863b..2ea988ec 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -36,19 +36,12 @@ import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; import com.squareup.okhttp.mockwebserver.RecordedRequest; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.notNullValue; @@ -251,7 +244,7 @@ public void shouldUpdateReportExecution() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/parameters")); assertThat(request.getHeader("Cookie"), is("cookie")); - assertThat(request.getBody().readUtf8(), is("[{\"key\":[\"value\"]}]")); + assertThat(request.getBody().readUtf8(), is("[{\"name\":\"key\",\"value\":[\"value\"]}]")); assertThat(request.getMethod(), is("POST")); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameterTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameterTest.java new file mode 100644 index 00000000..4e7f283f --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/ReportParameterTest.java @@ -0,0 +1,56 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network.entity.report; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class ReportParameterTest { + + @Test + @Parameters({ + "name", + "value", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = ReportParameter.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(ReportParameter.class).verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java index f14a34ef..2f8559e3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/type/GsonFactoryTest.java @@ -26,14 +26,18 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; - +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import org.hamcrest.core.Is; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import static org.hamcrest.core.Is.is; +import java.util.Collections; + +import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.times; @@ -66,6 +70,14 @@ public void shouldDisableHtmlEscaping() throws Exception { @Test public void shouldCreateInstanceOfGson() { Gson gson = GsonFactory.create(); - assertThat(gson, is(notNullValue())); + assertThat(gson, Is.is(notNullValue())); + } + + @Test + public void shouldModifyReportExecutionParametersField() throws Exception { + ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/my/uri"); + options.withParameters(Collections.singletonList(new ReportParameter("key", Collections.singleton("value")))); + Gson gson = GsonFactory.create(); + assertThat(gson.toJson(options), is("{\"reportUnitUri\":\"/my/uri\",\"parameters\":{\"reportParameter\":[{\"name\":\"key\",\"value\":[\"value\"]}]}}")); } } From ce108c74edeedd1def7aa030a23d151301a67cdf Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 11 Dec 2015 15:59:09 +0200 Subject: [PATCH 328/457] Upgrade licenses notes for release 2.0 --- NOTICES.txt | 15 +- licenses/Bouncy-Castle-JDK6-1.4.6-LICENSE.txt | 17 ++ ...E.txt => Equalsverifier-1.7.5-LICENSE.txt} | 2 +- licenses/Hamcrest-Integration-1.3.txt | 27 +++ ... => Intellij-Annotations-12.0-LICENSE.txt} | 3 +- ...ENSE.txt => JUnitParams-1.0.4-LICENSE.txt} | 3 +- licenses/Mockito-1.10.19-LICENSE.txt | 27 +++ .../OkHttp-MockWebServer-2.1.0-LICENSE.txt | 202 ++++++++++++++++++ licenses/Powermock-1.6.2-LICENSE.txt | 202 ++++++++++++++++++ licenses/Retrofit-2.0.0-beta1-LICENSE.txt | 202 ++++++++++++++++++ 10 files changed, 694 insertions(+), 6 deletions(-) create mode 100644 licenses/Bouncy-Castle-JDK6-1.4.6-LICENSE.txt rename licenses/{simple-xml-2.7-LICENSE.txt => Equalsverifier-1.7.5-LICENSE.txt} (99%) create mode 100644 licenses/Hamcrest-Integration-1.3.txt rename licenses/{spring-android-1.0.1.RELEASE-LICENSE.txt => Intellij-Annotations-12.0-LICENSE.txt} (99%) rename licenses/{robospice-1.4.11-LICENSE.txt => JUnitParams-1.0.4-LICENSE.txt} (99%) create mode 100644 licenses/Mockito-1.10.19-LICENSE.txt create mode 100644 licenses/OkHttp-MockWebServer-2.1.0-LICENSE.txt create mode 100644 licenses/Powermock-1.6.2-LICENSE.txt create mode 100644 licenses/Retrofit-2.0.0-beta1-LICENSE.txt diff --git a/NOTICES.txt b/NOTICES.txt index ef806922..fceb29b6 100644 --- a/NOTICES.txt +++ b/NOTICES.txt @@ -25,9 +25,18 @@ along with Jaspersoft Mobile SDK for Android. If not, see THIRD PARTY COMPONENTS ------------------------------- This software includes third party software subject to the associated copyrights, as follows: -- Simple XML 2.7 (Apache 2.0) - http://simple.sourceforge.net/ -- Spring Android 1.0.1 (Apache 2.0) - http://www.springsource.org/spring-android -- RoboSpice 1.4.11 (Apache 2.0) - https://github.com/octo-online/robospice +* Software for developing case +- Intellij Annotations 12.0 (Apache 2.0) - http://mvnrepository.com/artifact/com.intellij/annotations/12.0 +- Retrofit 2.0.0-beta1 (Apache 2.0) - https://github.com/square/retrofit/blob/master/LICENSE.txt + +* Software for testing case +- Equalsverifier 1.7.5 (Apache 2.0) - https://github.com/jqno/equalsverifier/blob/master/LICENSE.md +- JUnitParams 1.0.4 (Apache 2.0) - https://github.com/Pragmatists/JUnitParams/blob/master/LICENSE.txt +- Hamcrest Integration 1.3 (New BSD 3) - http://opensource.org/licenses/BSD-3-Clause +- Powermock 1.6.2 (Apache 2.0) - https://github.com/jayway/powermock/blob/master/LICENSE.txt +- Mockito 1.10.19 (MIT) - https://code.google.com/p/mockito/ +- OkHttp MockWebServer 2.1.0 (Apache 2.0) - https://github.com/square/okhttp/tree/master/mockwebserver +- Bouncy Castle JDK 6.0 - https://github.com/bcgit/bc-java/blob/master/LICENSE.html The text of licenses for the above software is included with the Jaspersoft Mobile SDK for Android package, in the /licenses folder. diff --git a/licenses/Bouncy-Castle-JDK6-1.4.6-LICENSE.txt b/licenses/Bouncy-Castle-JDK6-1.4.6-LICENSE.txt new file mode 100644 index 00000000..7f238111 --- /dev/null +++ b/licenses/Bouncy-Castle-JDK6-1.4.6-LICENSE.txt @@ -0,0 +1,17 @@ +Copyright (c) 2000-2015 The Legion of the Bouncy Castle Inc. (http://www.bouncycastle.org) +

+Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: +

+The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. +

+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/licenses/simple-xml-2.7-LICENSE.txt b/licenses/Equalsverifier-1.7.5-LICENSE.txt similarity index 99% rename from licenses/simple-xml-2.7-LICENSE.txt rename to licenses/Equalsverifier-1.7.5-LICENSE.txt index 261eeb9e..f49a4e16 100644 --- a/licenses/simple-xml-2.7-LICENSE.txt +++ b/licenses/Equalsverifier-1.7.5-LICENSE.txt @@ -198,4 +198,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. + limitations under the License. \ No newline at end of file diff --git a/licenses/Hamcrest-Integration-1.3.txt b/licenses/Hamcrest-Integration-1.3.txt new file mode 100644 index 00000000..05cba8c0 --- /dev/null +++ b/licenses/Hamcrest-Integration-1.3.txt @@ -0,0 +1,27 @@ +The following is a BSD 3-Clause ("BSD New" or "BSD Simplified") license template. To generate your own license, change the values of OWNER, ORGANIZATION and YEAR from their original values as given here, and substitute your own. + +Note: You may omit clause 3 and still be OSD-conformant. Despite its colloquial name "BSD New", this is not the newest version of the BSD license; it was followed by the even newer BSD-2-Clause version, sometimes known as the "Simplified BSD License". On January 9th, 2008 the OSI Board approved BSD-2-Clause, which is used by FreeBSD and others. It omits the final "no-endorsement" clause and is thus roughly equivalent to the MIT License. + +Historical Background: The original license used on BSD Unix had four clauses. The advertising clause (the third of four clauses) required you to acknowledge use of U.C. Berkeley code in your advertising of any product using that code. It was officially rescinded by the Director of the Office of Technology Licensing of the University of California on July 22nd, 1999. He states that clause 3 is "hereby deleted in its entirety." The four clause license has not been approved by OSI. The license below does not contain the advertising clause. + +This prelude is not part of the license. + = Regents of the University of California + = University of California, Berkeley + = 1998 + +In the original BSD license, the occurrence of "copyright holder" in the 3rd clause read "ORGANIZATION", placeholder for "University of California". In the original BSD license, both occurrences of the phrase "COPYRIGHT HOLDERS AND CONTRIBUTORS" in the disclaimer read "REGENTS AND CONTRIBUTORS". + +Here is the license template: + +Copyright (c) , +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/licenses/spring-android-1.0.1.RELEASE-LICENSE.txt b/licenses/Intellij-Annotations-12.0-LICENSE.txt similarity index 99% rename from licenses/spring-android-1.0.1.RELEASE-LICENSE.txt rename to licenses/Intellij-Annotations-12.0-LICENSE.txt index 261eeb9e..7a4a3ea2 100644 --- a/licenses/spring-android-1.0.1.RELEASE-LICENSE.txt +++ b/licenses/Intellij-Annotations-12.0-LICENSE.txt @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -198,4 +199,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. + limitations under the License. \ No newline at end of file diff --git a/licenses/robospice-1.4.11-LICENSE.txt b/licenses/JUnitParams-1.0.4-LICENSE.txt similarity index 99% rename from licenses/robospice-1.4.11-LICENSE.txt rename to licenses/JUnitParams-1.0.4-LICENSE.txt index 2834feda..7a4a3ea2 100644 --- a/licenses/robospice-1.4.11-LICENSE.txt +++ b/licenses/JUnitParams-1.0.4-LICENSE.txt @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (C) 2012 OCTO Technology (http://www.octo.com) + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/licenses/Mockito-1.10.19-LICENSE.txt b/licenses/Mockito-1.10.19-LICENSE.txt new file mode 100644 index 00000000..c3591275 --- /dev/null +++ b/licenses/Mockito-1.10.19-LICENSE.txt @@ -0,0 +1,27 @@ +Copyright (c) + + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + + + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + + + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + diff --git a/licenses/OkHttp-MockWebServer-2.1.0-LICENSE.txt b/licenses/OkHttp-MockWebServer-2.1.0-LICENSE.txt new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/licenses/OkHttp-MockWebServer-2.1.0-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/licenses/Powermock-1.6.2-LICENSE.txt b/licenses/Powermock-1.6.2-LICENSE.txt new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/licenses/Powermock-1.6.2-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/licenses/Retrofit-2.0.0-beta1-LICENSE.txt b/licenses/Retrofit-2.0.0-beta1-LICENSE.txt new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/licenses/Retrofit-2.0.0-beta1-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file From aaf1041b862441a2b20543c588a28389b21dd90c Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 11 Dec 2015 17:17:20 +0200 Subject: [PATCH 329/457] Add update execution API --- .../sdk/service/report/ReportExecution.java | 9 ++ .../report/ReportExecutionUseCase.java | 13 +++ .../sdk/service/report/RunExportCriteria.java | 2 +- .../service/report/ReportExecutionTest.java | 17 +++- .../report/ReportExecutionUseCaseTest.java | 95 +++++++++++++++++++ 5 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 257faf56..d2fb7061 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -35,6 +36,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 @@ -70,6 +73,12 @@ public ReportMetadata waitForReportCompletion() throws ServiceException { return performAwaitFoReport(); } + @NotNull + public ReportExecution updateExecution(List newParameters) throws ServiceException { + mExecutionUseCase.updateExecution(mExecutionId, newParameters); + return this; + } + @NotNull public ReportExport export(RunExportCriteria criteria) throws ServiceException { try { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 4f259325..0c7c56be 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -29,12 +29,14 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import java.io.IOException; +import java.util.List; /** * @author Tom Koptel @@ -86,4 +88,15 @@ public ReportExecutionDescriptor perform(String token) throws IOException, HttpE }; return mCallExecutor.execute(call); } + + public void updateExecution(final String executionId, final List newParameters) throws ServiceException { + Call call = new Call() { + @Override + public Void perform(String token) throws IOException, HttpException { + mExecutionApi.updateReportExecution(token, executionId, newParameters); + return null; + } + }; + mCallExecutor.execute(call); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index 8b9c8416..a18261f9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -47,7 +47,7 @@ public static class Builder { private boolean saveSnapshot; private Format format; private String pages; - public String attachmentPrefix; + private String attachmentPrefix; public Builder() { interactive = true; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 835af705..82fbc06d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.*; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -44,11 +45,12 @@ import org.powermock.modules.junit4.PowerMockRunner; import java.util.Collections; +import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; @@ -65,6 +67,7 @@ ReportExecutionDescriptor.class, ExecutionOptionsDataMapper.class, ExportExecutionDescriptor.class, + ReportExecutionUseCase.class, ExportDescriptor.class, ExecutionStatus.class, ErrorDescriptor.class, @@ -93,6 +96,7 @@ public class ReportExecutionTest { @Rule public ExpectedException mException = ExpectedException.none(); + private ReportExecutionUseCase reportExecutionUseCase; @Before public void setUp() throws Exception { @@ -103,7 +107,9 @@ public void setUp() throws Exception { ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/report/uri"); FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); - ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(mExecutionRestApi, callExecutor, executionOptionsDataMapper); + reportExecutionUseCase = spy( + new ReportExecutionUseCase(mExecutionRestApi, callExecutor, executionOptionsDataMapper) + ); ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, callExecutor, executionOptionsDataMapper); objectUnderTest = new ReportExecution( TimeUnit.SECONDS.toMillis(0), @@ -241,6 +247,13 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception } } + @Test + public void testUpdateExecution() throws Exception { + List params = Collections.emptyList(); + objectUnderTest.updateExecution(params); + verify(reportExecutionUseCase).updateExecution("execution_id", params); + } + private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java new file mode 100644 index 00000000..bf295d04 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java @@ -0,0 +1,95 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Collections; +import java.util.List; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.verify; + + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ExecutionOptionsDataMapper.class}) +public class ReportExecutionUseCaseTest { + + private static final String EXECUTION_ID = "execution_id"; + private static final String TOKEN = "token"; + + @Mock + ReportExecutionRestApi mExecutionRestApi; + @Mock + ExecutionOptionsDataMapper mDataMapper; + + private ReportExecutionUseCase executionUseCase; + private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor("token"); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + executionUseCase = + new ReportExecutionUseCase(mExecutionRestApi, fakeCallExecutor, mDataMapper); + } + + @Test + public void testRunReportExecution() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder().create(); + executionUseCase.runReportExecution("/my/uri", criteria); + verify(mDataMapper).transformRunReportOptions("/my/uri", criteria); + verify(mExecutionRestApi).runReportExecution(eq("token"), any(ReportExecutionRequestOptions.class)); + } + + @Test + public void testRequestStatus() throws Exception { + executionUseCase.requestStatus(EXECUTION_ID); + verify(mExecutionRestApi).requestReportExecutionStatus(TOKEN, EXECUTION_ID); + } + + @Test + public void testRequestExecutionDetails() throws Exception { + executionUseCase.requestExecutionDetails(EXECUTION_ID); + verify(mExecutionRestApi).requestReportExecutionDetails(TOKEN, EXECUTION_ID); + } + + @Test + public void testUpdateExecution() throws Exception { + List params = Collections.emptyList(); + executionUseCase.updateExecution(EXECUTION_ID, params); + verify(mExecutionRestApi).updateReportExecution(TOKEN, EXECUTION_ID, params); + } +} \ No newline at end of file From 833f7b477b6f7ec2a1f71b60ac8925cd5f9e8cad Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 11 Dec 2015 17:55:30 +0200 Subject: [PATCH 330/457] Fix loop issue for report wait details --- .../sdk/service/report/ReportExecution.java | 16 +++--- .../android/sdk/service/report/Status.java | 5 ++ .../service/report/ReportExecutionTest.java | 50 +++++++++++-------- .../jaspersoft/android/sdk/test/Chain.java | 12 ++--- 4 files changed, 48 insertions(+), 35 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 257faf56..80b04c2d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -129,10 +129,10 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) t } @NotNull - private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor details) throws ServiceException { - Status status = Status.wrap(details.getStatus()); - ErrorDescriptor descriptor = details.getErrorDescriptor(); - ReportExecutionDescriptor resultDetails = details; + private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor firstRunDetails) throws ServiceException { + Status status = Status.wrap(firstRunDetails.getStatus()); + ErrorDescriptor descriptor = firstRunDetails.getErrorDescriptor(); + ReportExecutionDescriptor nextDetails = firstRunDetails; while (!status.isReady()) { if (status.isCancelled()) { throw new ServiceException( @@ -147,11 +147,11 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD } catch (InterruptedException ex) { throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - status = Status.wrap(details.getStatus()); - descriptor = details.getErrorDescriptor(); - resultDetails = requestExecutionDetails(); + nextDetails = requestExecutionDetails(); + status = Status.wrap(nextDetails.getStatus()); + descriptor = nextDetails.getErrorDescriptor(); } - return resultDetails; + return nextDetails; } @NotNull diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java index 197702d6..4872e8ef 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java @@ -58,4 +58,9 @@ public boolean isFailed() { public boolean isReady() { return mStatus.equals("ready"); } + + @Override + public String toString() { + return mStatus; + } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 835af705..0ab1adda 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -76,7 +76,9 @@ public class ReportExecutionTest { @Mock ExportExecutionDescriptor mExportExecDetails; @Mock - ReportExecutionDescriptor mExecDetails; + ReportExecutionDescriptor mReportExecDetails1; + @Mock + ReportExecutionDescriptor mReportExecDetails2; @Mock ExportDescriptor mExportExecution; @Mock @@ -98,8 +100,8 @@ public class ReportExecutionTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - when(mExecDetails.getExecutionId()).thenReturn("execution_id"); - when(mExecDetails.getReportURI()).thenReturn("/report/uri"); + when(mReportExecDetails1.getExecutionId()).thenReturn("execution_id"); + when(mReportExecDetails1.getReportURI()).thenReturn("/report/uri"); ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/report/uri"); FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); @@ -113,7 +115,7 @@ public void setUp() throws Exception { "/report/uri"); } - @Test + @Test(timeout = 2000) public void testRequestExportIdealCase() throws Exception { mockReportExecutionDetails("ready"); mockRunExportExecution("ready"); @@ -124,7 +126,7 @@ public void testRequestExportIdealCase() throws Exception { verify(mExecutionRestApi).requestReportExecutionDetails(eq("cookie"), eq("execution_id")); } - @Test + @Test(timeout = 2000) public void testRunThrowsFailedStatusImmediately() throws Exception { // export run request mockRunExportExecution("failed"); @@ -137,7 +139,7 @@ public void testRunThrowsFailedStatusImmediately() throws Exception { } } - @Test + @Test(timeout = 2000) public void testRunShouldThrowFailedIfStatusFailed() throws Exception { mockRunExportExecution("queued"); mockCheckExportExecStatus("failed"); @@ -149,7 +151,7 @@ public void testRunShouldThrowFailedIfStatusFailed() throws Exception { } } - @Test + @Test(timeout = 2000) public void testRunThrowsCancelledStatusImmediately() throws Exception { // export run request mockRunExportExecution("cancelled"); @@ -162,7 +164,7 @@ public void testRunThrowsCancelledStatusImmediately() throws Exception { } } - @Test + @Test(timeout = 2000) public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { mockRunExportExecution("queued"); mockCheckExportExecStatus("cancelled"); @@ -175,7 +177,7 @@ public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { } } - @Test + @Test(timeout = 2000) public void testRunReportPendingCase() throws Exception { mockRunExportExecution("queued"); mockCheckExportExecStatus("queued", "ready"); @@ -186,7 +188,7 @@ public void testRunReportPendingCase() throws Exception { verify(mExportRestApi, times(2)).checkExportExecutionStatus(eq("cookie"), eq("execution_id"), eq("export_id")); } - @Test + @Test(timeout = 2000) public void ensureThatExportCancelledEventWillBeResolved() throws Exception { mockRunExportExecution("cancelled", "ready"); mockReportExecutionDetails("ready"); @@ -196,9 +198,9 @@ public void ensureThatExportCancelledEventWillBeResolved() throws Exception { verify(mExportRestApi, times(2)).runExportExecution(eq("cookie"), eq("execution_id"), any(ExecutionRequestOptions.class)); } - @Test + @Test(timeout = 2000) public void testAwaitCompleteReport() throws Exception { - when(mExecDetails.getTotalPages()).thenReturn(100); + when(mReportExecDetails1.getTotalPages()).thenReturn(100); mockReportExecutionDetails("ready"); ReportMetadata metadata = objectUnderTest.waitForReportCompletion(); @@ -209,7 +211,7 @@ public void testAwaitCompleteReport() throws Exception { verifyNoMoreInteractions(mExecutionRestApi); } - @Test + @Test(timeout = 2000) public void testAwaitCompleteReportShouldLoopCalls() throws Exception { mockReportExecutionDetails("execution", "ready"); @@ -219,7 +221,7 @@ public void testAwaitCompleteReportShouldLoopCalls() throws Exception { verifyNoMoreInteractions(mExecutionRestApi); } - @Test + @Test(timeout = 2000) public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() throws Exception { mockReportExecutionDetails("execution", "cancelled"); @@ -230,7 +232,7 @@ public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() throws Exce } } - @Test + @Test(timeout = 2000) public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception { mockReportExecutionDetails("execution", "failed"); @@ -256,15 +258,21 @@ private void mockRunExportExecution(String... statusChain) throws Exception { when(mExportRestApi.runExportExecution(anyString(), anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); } - private void mockReportExecutionDetails(String... statusChain) throws Exception { - ensureChain(statusChain); + private void mockReportExecutionDetails(String firstStatus, String... statusChain) throws Exception { Set exports = Collections.singleton(mExportExecution); when(mExportExecution.getStatus()).thenReturn("execution"); when(mExportExecution.getId()).thenReturn("export_id"); - when(mExecDetails.getExports()).thenReturn(exports); - when(mExecDetails.getStatus()).then(Chain.of(statusChain)); - when(mExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(mExecutionRestApi.requestReportExecutionDetails(anyString(), anyString())).thenReturn(mExecDetails); + + when(mReportExecDetails1.getStatus()).thenReturn(firstStatus); + when(mReportExecDetails1.getExports()).thenReturn(exports); + when(mReportExecDetails1.getErrorDescriptor()).thenReturn(mDescriptor); + + when(mReportExecDetails2.getStatus()).then(Chain.of(statusChain)); + when(mReportExecDetails2.getExports()).thenReturn(exports); + when(mReportExecDetails2.getErrorDescriptor()).thenReturn(mDescriptor); + + when(mExecutionRestApi.requestReportExecutionDetails(anyString(), anyString())) + .then(Chain.of(mReportExecDetails1, mReportExecDetails2)); } private void ensureChain(String[] statusChain) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java index 6134ca8f..e315c982 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java @@ -31,20 +31,20 @@ * @author Tom Koptel * @since 2.0 */ -public final class Chain implements Answer { - private final String[] mChain; +public final class Chain implements Answer { + private final Response[] mChain; private int invocationCount = 0; - private Chain(String... chain) { + private Chain(Response... chain) { mChain = chain; } - public static Chain of(java.lang.String... values) { - return new Chain(values); + public static Chain of(Response... values) { + return new Chain<>(values); } @Override - public String answer(InvocationOnMock invocation) throws Throwable { + public Response answer(InvocationOnMock invocation) throws Throwable { int statusIndex = invocationCount; if (statusIndex >= mChain.length) { statusIndex = mChain.length - 1; From d61922ab0cfaa05f17633c8dda9b9620f2ff55de Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 11 Dec 2015 19:34:04 +0200 Subject: [PATCH 331/457] Properly delegate error body from Retrofit response --- .../android/sdk/network/HttpException.java | 39 +++++++------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java index abbbad4c..fa86ce6b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java @@ -29,13 +29,13 @@ import com.google.gson.JsonParseException; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; +import com.squareup.okhttp.ResponseBody; +import retrofit.Response; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import retrofit.Response; - /** * Wrapper around exceptions which could pop up during request processing. * Motivation behind class was to incapsulate 3-d party errors in generic interface. @@ -44,36 +44,30 @@ * @since 2.0 */ public class HttpException extends Exception { + private final int mCode; + private final ResponseBody mBody; - static HttpException httpError(Response response) { - return httpError(response.raw()); + HttpException(String responseMessage, int code, ResponseBody responseBody) { + super(responseMessage + " " + code); + mCode = code; + mBody = responseBody; } - static HttpException httpError(com.squareup.okhttp.Response response) { - String message = response.code() + " " + response.message(); - return new HttpException(message, response, null); + static HttpException httpError(Response response) { + return new HttpException(response.message(), response.code(), response.errorBody()); } - private final com.squareup.okhttp.Response response; - - HttpException(String message, com.squareup.okhttp.Response response, Throwable exception) { - super(message, exception); - this.response = response; + static HttpException httpError(com.squareup.okhttp.Response response) { + return new HttpException(response.message(), response.code(), response.body()); } - // HTTP status code. public int code() { - return response.code(); - } - - // HTTP status message. - public String message() { - return response.message(); + return mCode; } public ErrorDescriptor getDescriptor() throws IOException { Gson gson = GsonFactory.create(); - InputStream stream = response.body().byteStream(); + InputStream stream = mBody.byteStream(); InputStreamReader reader = new InputStreamReader(stream); try { return gson.fromJson(reader, ErrorDescriptor.class); @@ -81,9 +75,4 @@ public ErrorDescriptor getDescriptor() throws IOException { return null; } } - - public String urlString() { - return response.request().urlString(); - } - } From db72df2e62bb2490283ca47ed777206c60a342b4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 12:55:11 +0200 Subject: [PATCH 332/457] Filter out baseUrl/allowInlineScripts for v5.5 --- .../report/ExecutionOptionsDataMapper.java | 37 ++++++++++---- .../report/ReportExecutionUseCase.java | 13 ++++- .../service/report/ReportExportUseCase.java | 13 +++-- .../sdk/service/report/ReportService.java | 8 +-- .../ExecutionOptionsDataMapperTest.java | 16 +++++- .../service/report/ReportAttachmentTest.java | 16 +++--- .../service/report/ReportExecutionTest.java | 50 ++++++++----------- .../report/ReportExecutionUseCaseTest.java | 14 +++++- .../sdk/service/report/ReportExportTest.java | 13 ++--- .../sdk/service/report/ReportServiceTest.java | 32 +++++------- .../jaspersoft/android/sdk/test/Chain.java | 17 +++++-- 11 files changed, 135 insertions(+), 94 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index b9e63c6f..bda5c591 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -26,7 +26,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; - +import com.jaspersoft.android.sdk.service.RestClient; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.jetbrains.annotations.NotNull; import java.io.UnsupportedEncodingException; @@ -36,29 +37,33 @@ * @author Tom Koptel * @since 2.0 */ -final class ExecutionOptionsDataMapper { - +class ExecutionOptionsDataMapper { private final String mBaseUrl; - public ExecutionOptionsDataMapper(String mBaseUrl) { - this.mBaseUrl = mBaseUrl; + ExecutionOptionsDataMapper(String baseUrl) { + mBaseUrl = baseUrl; } - public ReportExecutionRequestOptions transformRunReportOptions(@NotNull String reportUri, @NotNull RunReportCriteria criteria) { + public ReportExecutionRequestOptions transformRunReportOptions(@NotNull String reportUri, + @NotNull ServerVersion serverVersion, + @NotNull RunReportCriteria criteria) { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); - mapCommonCriterion(criteria, options); + mapCommonCriterion(criteria, serverVersion, options); options.withAsync(true); options.withParameters(criteria.getParams()); return options; } - public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria configuration) { + public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria configuration, + @NotNull ServerVersion serverVersion) { ExecutionRequestOptions options = ExecutionRequestOptions.create(); - mapCommonCriterion(configuration, options); + mapCommonCriterion(configuration, serverVersion, options); return options; } - private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, ExecutionRequestOptions options) { + private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, + @NotNull ServerVersion version, + @NotNull ExecutionRequestOptions options) { options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); @@ -67,7 +72,17 @@ private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, ExecutionRe options.withInteractive(criteria.isInteractive()); options.withPages(criteria.getPages()); - options.withBaseUrl(mBaseUrl); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + options.withBaseUrl(null); + options.withAllowInlineScripts(null); + } else { + options.withBaseUrl(mBaseUrl); + } + } + + public static ExecutionOptionsDataMapper create(RestClient client) { + String baseUrl = client.getServerUrl(); + return new ExecutionOptionsDataMapper(baseUrl); } static class Helper { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 0c7c56be..63086aea 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -30,9 +30,12 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -42,25 +45,31 @@ * @author Tom Koptel * @since 2.0 */ -final class ReportExecutionUseCase { +class ReportExecutionUseCase { private final ReportExecutionRestApi mExecutionApi; private final CallExecutor mCallExecutor; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + private final InfoCacheManager mCacheManager; ReportExecutionUseCase(ReportExecutionRestApi executionApi, CallExecutor callExecutor, + InfoCacheManager cacheManager, ExecutionOptionsDataMapper executionOptionsMapper) { mExecutionApi = executionApi; mCallExecutor = callExecutor; + mCacheManager = cacheManager; mExecutionOptionsMapper = executionOptionsMapper; } @NotNull public ReportExecutionDescriptor runReportExecution(final String reportUri, final RunReportCriteria criteria) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); Call call = new Call() { @Override public ReportExecutionDescriptor perform(String token) throws IOException, HttpException { - ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); + ReportExecutionRequestOptions options = + mExecutionOptionsMapper.transformRunReportOptions(reportUri, version, criteria); return mExecutionApi.runReportExecution(token, options); } }; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index c2c16c8e..b42ed854 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -31,11 +31,14 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -44,24 +47,28 @@ * @author Tom Koptel * @since 2.0 */ -final class ReportExportUseCase { +class ReportExportUseCase { private final ReportExportRestApi mExportApi; private final CallExecutor mCallExecutor; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + private final InfoCacheManager mCacheManager; ReportExportUseCase(ReportExportRestApi exportApi, - CallExecutor callExecutor, ExecutionOptionsDataMapper executionOptionsMapper) { + CallExecutor callExecutor, InfoCacheManager cacheManager, ExecutionOptionsDataMapper executionOptionsMapper) { mExportApi = exportApi; mCallExecutor = callExecutor; + mCacheManager = cacheManager; mExecutionOptionsMapper = executionOptionsMapper; } @NotNull public ExportExecutionDescriptor runExport(final String executionId, final RunExportCriteria criteria) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); Call call = new Call() { @Override public ExportExecutionDescriptor perform(String token) throws IOException, HttpException { - ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); + ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria, version); return mExportApi.runExportExecution(token, executionId, options); } }; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 2c8a61de..012d7507 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -35,6 +35,7 @@ import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -72,12 +73,13 @@ public static ReportService create(RestClient client, Session session) { .baseUrl(client.getServerUrl()) .build(); CallExecutor callExecutor = DefaultCallExecutor.create(client, session); - ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getServerUrl()); + ExecutionOptionsDataMapper executionOptionsMapper = ExecutionOptionsDataMapper.create(client); + InfoCacheManager cacheManager = InfoCacheManager.create(client); ReportExecutionUseCase reportExecutionUseCase = - new ReportExecutionUseCase(executionApi, callExecutor, executionOptionsMapper); + new ReportExecutionUseCase(executionApi, callExecutor, cacheManager, executionOptionsMapper); ReportExportUseCase reportExportUseCase = - new ReportExportUseCase(exportApi, callExecutor, executionOptionsMapper); + new ReportExportUseCase(exportApi, callExecutor, cacheManager, executionOptionsMapper); return new ReportService( TimeUnit.SECONDS.toMillis(1), diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index dc844ca1..a00d12bf 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -27,8 +27,10 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; +import org.mockito.MockitoAnnotations; import java.util.Collections; import java.util.List; @@ -51,6 +53,7 @@ public class ExecutionOptionsDataMapperTest { @Before public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); mapper = new ExecutionOptionsDataMapper(BASE_URL); } @@ -65,7 +68,7 @@ public void testTransformReportOptions() throws Exception { .params(REPORT_PARAMS) .attachmentPrefix("./") .create(); - ReportExecutionRequestOptions options = mapper.transformRunReportOptions(REPORT_URI, criteria); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions(REPORT_URI, ServerVersion.v6, criteria); assertThat(options.getReportUnitUri(), is(REPORT_URI)); assertThat(options.getParameters(), is(REPORT_PARAMS)); assertThat(options.getAsync(), is(true)); @@ -82,10 +85,19 @@ public void testTransformExportOptions() throws Exception { .pages("1-100") .attachmentPrefix("./") .create(); - ExecutionRequestOptions options = mapper.transformExportOptions(criteria); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v6); assertOptions(options); } + @Test + public void testBaseUrlReducedForServer5_5() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder() + .create(); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); + assertThat(options.getBaseUrl(), is(nullValue())); + assertThat(options.getAllowInlineScripts(), is(nullValue())); + } + private void assertOptions(ExecutionRequestOptions options) { assertThat(options.getFreshData(), is(true)); assertThat(options.getSaveDataSnapshot(), is(true)); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 5fa96eec..2af42253 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import org.junit.Before; import org.junit.Test; @@ -55,27 +54,26 @@ public class ReportAttachmentTest { @Mock ReportExportRestApi mExportRestApi; @Mock - OutputResource input; + ResourceOutput input; + @Mock + ReportExportUseCase mReportExportUseCase; private ReportAttachment objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, new FakeCallExecutor("cookie"), executionOptionsDataMapper); - objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", exportUseCase); + objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", mReportExportUseCase); } @Test public void testDownload() throws Exception { - when(mExportRestApi.requestExportAttachment(anyString(), anyString(), anyString(), anyString())).thenReturn(input); + when(mReportExportUseCase.requestExportAttachmentOutput(anyString(), anyString(), anyString())).thenReturn(input); ResourceOutput result = objectUnderTest.download(); assertThat(result, is(notNullValue())); - verify(mExportRestApi).requestExportAttachment(eq("cookie"), eq("exec_id"), eq("export_id"), eq("1.jpg")); - verifyNoMoreInteractions(mExportRestApi); + verify(mReportExportUseCase).requestExportAttachmentOutput(eq("exec_id"), eq("export_id"), eq("1.jpg")); + verifyNoMoreInteractions(mReportExportUseCase); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 2f19bfed..6ea2f7cd 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -24,12 +24,9 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.*; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; @@ -44,6 +41,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -90,15 +88,14 @@ public class ReportExecutionTest { ErrorDescriptor mDescriptor; @Mock - ReportExportRestApi mExportRestApi; + ReportExecutionUseCase mReportExecutionUseCase; @Mock - ReportExecutionRestApi mExecutionRestApi; + ReportExportUseCase mReportExportUseCase; private ReportExecution objectUnderTest; @Rule public ExpectedException mException = ExpectedException.none(); - private ReportExecutionUseCase reportExecutionUseCase; @Before public void setUp() throws Exception { @@ -107,16 +104,11 @@ public void setUp() throws Exception { when(mReportExecDetails1.getExecutionId()).thenReturn("execution_id"); when(mReportExecDetails1.getReportURI()).thenReturn("/report/uri"); - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/report/uri"); - FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); - reportExecutionUseCase = spy( - new ReportExecutionUseCase(mExecutionRestApi, callExecutor, executionOptionsDataMapper) - ); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, callExecutor, executionOptionsDataMapper); + objectUnderTest = new ReportExecution( TimeUnit.SECONDS.toMillis(0), - reportExecutionUseCase, - exportUseCase, + mReportExecutionUseCase, + mReportExportUseCase, "execution_id", "/report/uri"); } @@ -128,8 +120,8 @@ public void testRequestExportIdealCase() throws Exception { objectUnderTest.export(exportCriteria); - verify(mExportRestApi).runExportExecution(eq("cookie"), eq("execution_id"), any(ExecutionRequestOptions.class)); - verify(mExecutionRestApi).requestReportExecutionDetails(eq("cookie"), eq("execution_id")); + verify(mReportExportUseCase).runExport(eq("execution_id"), any(RunExportCriteria.class)); + verify(mReportExecutionUseCase).requestExecutionDetails(eq("execution_id")); } @Test(timeout = 2000) @@ -191,7 +183,7 @@ public void testRunReportPendingCase() throws Exception { objectUnderTest.export(exportCriteria); - verify(mExportRestApi, times(2)).checkExportExecutionStatus(eq("cookie"), eq("execution_id"), eq("export_id")); + verify(mReportExportUseCase, times(2)).checkExportExecutionStatus(eq("execution_id"), eq("export_id")); } @Test(timeout = 2000) @@ -201,7 +193,7 @@ public void ensureThatExportCancelledEventWillBeResolved() throws Exception { objectUnderTest.export(exportCriteria); - verify(mExportRestApi, times(2)).runExportExecution(eq("cookie"), eq("execution_id"), any(ExecutionRequestOptions.class)); + verify(mReportExportUseCase, times(2)).runExport(eq("execution_id"), any(RunExportCriteria.class)); } @Test(timeout = 2000) @@ -213,8 +205,8 @@ public void testAwaitCompleteReport() throws Exception { assertThat(metadata.getTotalPages(), is(100)); assertThat(metadata.getUri(), is("/report/uri")); - verify(mExecutionRestApi).requestReportExecutionDetails(anyString(), anyString()); - verifyNoMoreInteractions(mExecutionRestApi); + verify(mReportExecutionUseCase).requestExecutionDetails(anyString()); + verifyNoMoreInteractions(mReportExecutionUseCase); } @Test(timeout = 2000) @@ -223,8 +215,8 @@ public void testAwaitCompleteReportShouldLoopCalls() throws Exception { objectUnderTest.waitForReportCompletion(); - verify(mExecutionRestApi, times(2)).requestReportExecutionDetails(anyString(), anyString()); - verifyNoMoreInteractions(mExecutionRestApi); + verify(mReportExecutionUseCase, times(2)).requestExecutionDetails(anyString()); + verifyNoMoreInteractions(mReportExecutionUseCase); } @Test(timeout = 2000) @@ -253,14 +245,16 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception public void testUpdateExecution() throws Exception { List params = Collections.emptyList(); objectUnderTest.updateExecution(params); - verify(reportExecutionUseCase).updateExecution("execution_id", params); + verify(mReportExecutionUseCase).updateExecution("execution_id", params); } private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); - when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); - when(mExecutionStatusResponse.getErrorDescriptor()).thenReturn(mDescriptor); - when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(mExecutionStatusResponse); + List statuses = new ArrayList<>(); + for (String state : statusChain) { + statuses.add(Status.wrap(state)); + } + when(mReportExportUseCase.checkExportExecutionStatus(anyString(), anyString())).then(Chain.of(statuses)); } private void mockRunExportExecution(String... statusChain) throws Exception { @@ -268,7 +262,7 @@ private void mockRunExportExecution(String... statusChain) throws Exception { when(mExportExecDetails.getExportId()).thenReturn("export_id"); when(mExportExecDetails.getStatus()).then(Chain.of(statusChain)); when(mExportExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(mExportRestApi.runExportExecution(anyString(), anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + when(mReportExportUseCase.runExport(anyString(), any(RunExportCriteria.class))).thenReturn(mExportExecDetails); } private void mockReportExecutionDetails(String firstStatus, String... statusChain) throws Exception { @@ -284,7 +278,7 @@ private void mockReportExecutionDetails(String firstStatus, String... statusChai when(mReportExecDetails2.getExports()).thenReturn(exports); when(mReportExecDetails2.getErrorDescriptor()).thenReturn(mDescriptor); - when(mExecutionRestApi.requestReportExecutionDetails(anyString(), anyString())) + when(mReportExecutionUseCase.requestExecutionDetails(anyString())) .then(Chain.of(mReportExecDetails1, mReportExecDetails2)); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java index bf295d04..b4b1ed18 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java @@ -28,6 +28,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,6 +45,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) @@ -55,6 +59,10 @@ public class ReportExecutionUseCaseTest { ReportExecutionRestApi mExecutionRestApi; @Mock ExecutionOptionsDataMapper mDataMapper; + @Mock + InfoCacheManager mInfoCacheManager; + @Mock + ServerInfo mServerInfo; private ReportExecutionUseCase executionUseCase; private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor("token"); @@ -62,15 +70,17 @@ public class ReportExecutionUseCaseTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); executionUseCase = - new ReportExecutionUseCase(mExecutionRestApi, fakeCallExecutor, mDataMapper); + new ReportExecutionUseCase(mExecutionRestApi, fakeCallExecutor, mInfoCacheManager, mDataMapper); } @Test public void testRunReportExecution() throws Exception { RunReportCriteria criteria = RunReportCriteria.builder().create(); executionUseCase.runReportExecution("/my/uri", criteria); - verify(mDataMapper).transformRunReportOptions("/my/uri", criteria); + verify(mDataMapper).transformRunReportOptions("/my/uri", ServerVersion.v6, criteria); verify(mExecutionRestApi).runReportExecution(eq("token"), any(ReportExecutionRequestOptions.class)); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 406eb65c..44991130 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -43,23 +41,20 @@ */ public class ReportExportTest { @Mock - ReportExportRestApi mExportRestApi; + ReportExportUseCase mReportExportUseCase; private ReportExport objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, new FakeCallExecutor("cookie"), executionOptionsDataMapper); - objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), exportUseCase); + objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), mReportExportUseCase); } @Test public void testDownload() throws Exception { objectUnderTest.download(); - verify(mExportRestApi).requestExportOutput(eq("cookie"), eq("report_execution_id"), eq("export_id")); - verifyNoMoreInteractions(mExportRestApi); + verify(mReportExportUseCase).requestExportOutput(eq("report_execution_id"), eq("export_id")); + verifyNoMoreInteractions(mReportExportUseCase); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index ba2ebbd2..8b1f4082 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -24,13 +24,9 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.test.Chain; @@ -67,10 +63,6 @@ ExecutionOptionsDataMapper.class}) public class ReportServiceTest { - @Mock - ReportExecutionRestApi executionApi; - @Mock - ReportExportRestApi exportApi; @Mock ErrorDescriptor mDescriptor; @@ -81,6 +73,11 @@ public class ReportServiceTest { @Mock ExecutionStatus statusDetails; + @Mock + ReportExecutionUseCase mReportExecutionUseCase; + @Mock + ReportExportUseCase mReportExportUseCase; + ReportService objectUnderTest; @Rule @@ -90,15 +87,10 @@ public class ReportServiceTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); - ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, callExecutor, executionOptionsDataMapper); - ReportExportUseCase exportUseCase = new ReportExportUseCase(exportApi, callExecutor, executionOptionsDataMapper); - objectUnderTest = new ReportService( TimeUnit.MILLISECONDS.toMillis(0), - reportExecutionUseCase, - exportUseCase); + mReportExecutionUseCase, + mReportExportUseCase); } @Test @@ -109,8 +101,8 @@ public void testRunShouldCreateActiveSession() throws Exception { ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); - verify(executionApi).runReportExecution(anyString(), any(ReportExecutionRequestOptions.class)); - verifyNoMoreInteractions(executionApi); + verify(mReportExecutionUseCase).runReportExecution(anyString(), any(RunReportCriteria.class)); + verifyNoMoreInteractions(mReportExecutionUseCase); } @Test @@ -165,19 +157,19 @@ public void testRunShouldLoopUntilStatusExecution() throws Exception { mockReportExecutionStatus("queued", "execution"); objectUnderTest.run("/report/uri", configuration); - verify(executionApi, times(2)).requestReportExecutionStatus(anyString(), eq("exec_id")); + verify(mReportExecutionUseCase, times(2)).requestStatus(eq("exec_id")); } private void mockReportExecutionStatus(String... statusChain) throws Exception { when(statusDetails.getStatus()).then(Chain.of(statusChain)); when(statusDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(executionApi.requestReportExecutionStatus(anyString(), anyString())).thenReturn(statusDetails); + when(mReportExecutionUseCase.requestStatus(anyString())).thenReturn(statusDetails); } private void mockRunReportExecution(String execution) throws Exception { when(initDetails.getStatus()).thenReturn(execution); when(initDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(executionApi.runReportExecution(anyString(), any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + when(mReportExecutionUseCase.runReportExecution(anyString(), any(RunReportCriteria.class))).thenReturn(initDetails); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java index e315c982..768e703d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java @@ -27,24 +27,31 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 */ -public final class Chain implements Answer { - private final Response[] mChain; +public final class Chain implements Answer { + private final Value[] mChain; private int invocationCount = 0; - private Chain(Response... chain) { + private Chain(Value... chain) { mChain = chain; } - public static Chain of(Response... values) { + public static Chain of(Value... values) { return new Chain<>(values); } + @SuppressWarnings("unchecked") + public static Chain of(List values) { + return new Chain<>((Value[]) values.toArray()); + } + @Override - public Response answer(InvocationOnMock invocation) throws Throwable { + public Value answer(InvocationOnMock invocation) throws Throwable { int statusIndex = invocationCount; if (statusIndex >= mChain.length) { statusIndex = mChain.length - 1; From 199253a45ec283d9f664f09c552ca1b1f0994226 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 12:58:57 +0200 Subject: [PATCH 333/457] Force default format HTML for export/execution criterium --- .../jaspersoft/android/sdk/service/report/RunExportCriteria.java | 1 + .../jaspersoft/android/sdk/service/report/RunReportCriteria.java | 1 + 2 files changed, 2 insertions(+) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index a18261f9..8a6bc244 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -51,6 +51,7 @@ public static class Builder { public Builder() { interactive = true; + format = Format.HTML; } public Builder freshData(boolean freshData) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index 155ebaac..2ce9f2db 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -70,6 +70,7 @@ public static class Builder { public Builder() { interactive = true; + format = Format.HTML; } public Builder freshData(boolean freshData) { From 2fc97a3e61bf357c1fe12110036a0518f42c2fd2 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 13:05:45 +0200 Subject: [PATCH 334/457] Ignore freshData/interactive flags for 5.5 report execution --- .../entity/execution/ExecutionRequestOptions.java | 10 +++++----- .../sdk/service/report/ExecutionOptionsDataMapper.java | 2 ++ .../service/report/ExecutionOptionsDataMapperTest.java | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index ddf387b3..55f4d8f0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -68,27 +68,27 @@ public static ExecutionRequestOptions create() { return new ExecutionRequestOptions(); } - public ExecutionRequestOptions withAsync(boolean async) { + public ExecutionRequestOptions withAsync(Boolean async) { this.async = async; return this; } - public ExecutionRequestOptions withFreshData(boolean freshData) { + public ExecutionRequestOptions withFreshData(Boolean freshData) { this.freshData = freshData; return this; } - public ExecutionRequestOptions withIgnorePagination(boolean ignorePagination) { + public ExecutionRequestOptions withIgnorePagination(Boolean ignorePagination) { this.ignorePagination = ignorePagination; return this; } - public ExecutionRequestOptions withInteractive(boolean interactive) { + public ExecutionRequestOptions withInteractive(Boolean interactive) { this.interactive = interactive; return this; } - public ExecutionRequestOptions withSaveDataSnapshot(boolean saveDataSnapshot) { + public ExecutionRequestOptions withSaveDataSnapshot(Boolean saveDataSnapshot) { this.saveDataSnapshot = saveDataSnapshot; return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index bda5c591..c35857be 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -75,6 +75,8 @@ private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, if (version.lessThanOrEquals(ServerVersion.v5_5)) { options.withBaseUrl(null); options.withAllowInlineScripts(null); + options.withFreshData(null); + options.withInteractive(null); } else { options.withBaseUrl(mBaseUrl); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index a00d12bf..0d2b1e40 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -90,12 +90,14 @@ public void testTransformExportOptions() throws Exception { } @Test - public void testBaseUrlReducedForServer5_5() throws Exception { + public void testReportExecutionFieldsReducedForServer5_5() throws Exception { RunReportCriteria criteria = RunReportCriteria.builder() .create(); ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); assertThat(options.getBaseUrl(), is(nullValue())); assertThat(options.getAllowInlineScripts(), is(nullValue())); + assertThat(options.getFreshData(), is(nullValue())); + assertThat(options.getInteractive(), is(nullValue())); } private void assertOptions(ExecutionRequestOptions options) { From f1a4fe61474dede2c5087039fa5efedc6d585e85 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 13:13:55 +0200 Subject: [PATCH 335/457] Reduce saveDataSnapshot field for export exection on v5.5 --- .../report/ExecutionOptionsDataMapper.java | 3 +++ .../ExecutionOptionsDataMapperTest.java | 26 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index c35857be..08afac0e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -58,6 +58,9 @@ public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria @NotNull ServerVersion serverVersion) { ExecutionRequestOptions options = ExecutionRequestOptions.create(); mapCommonCriterion(configuration, serverVersion, options); + if (serverVersion.lessThanOrEquals(ServerVersion.v5_5)) { + options.withSaveDataSnapshot(null); + } return options; } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 0d2b1e40..68066617 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -92,12 +92,30 @@ public void testTransformExportOptions() throws Exception { @Test public void testReportExecutionFieldsReducedForServer5_5() throws Exception { RunReportCriteria criteria = RunReportCriteria.builder() + .freshData(true) + .interactive(false) + .saveSnapshot(true) .create(); ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); - assertThat(options.getBaseUrl(), is(nullValue())); - assertThat(options.getAllowInlineScripts(), is(nullValue())); - assertThat(options.getFreshData(), is(nullValue())); - assertThat(options.getInteractive(), is(nullValue())); + assertThat("Should reduce 'baseUrl' from options", options.getBaseUrl(), is(nullValue())); + assertThat("Should reduce 'allowInteractive' from options", options.getAllowInlineScripts(), is(nullValue())); + assertThat("Should reduce 'freshData' from options", options.getFreshData(), is(nullValue())); + assertThat("Should reduce 'interactive' from options", options.getInteractive(), is(nullValue())); + } + + @Test + public void testExportExecutionFieldsReducedForServer5_5() throws Exception { + RunExportCriteria criteria = RunExportCriteria.builder() + .freshData(true) + .interactive(false) + .saveSnapshot(true) + .create(); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_5); + assertThat("Should reduce 'baseUrl' from options", options.getBaseUrl(), is(nullValue())); + assertThat("Should reduce 'allowInteractive' from options", options.getAllowInlineScripts(), is(nullValue())); + assertThat("Should reduce 'freshData' from options",options.getFreshData(), is(nullValue())); + assertThat("Should reduce 'interactive' from options",options.getInteractive(), is(nullValue())); + assertThat("Should reduce 'saveDataSnapshot' from options",options.getSaveDataSnapshot(), is(nullValue())); } private void assertOptions(ExecutionRequestOptions options) { From c3a3f79809e33effd8393c433a20379d9fe23d2f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 18:02:55 +0200 Subject: [PATCH 336/457] Add custom generation of export id for JRS v5.5 --- .../sdk/network/ReportExportRestApiImpl.java | 19 +-- .../sdk/service/report/ExportFactory.java | 18 ++- .../sdk/service/report/ReportAttachment.java | 9 +- .../sdk/service/report/ReportExecution.java | 6 +- .../sdk/service/report/ReportExport.java | 5 +- .../service/report/ReportExportUseCase.java | 43 ++++- .../android/sdk/service/report/Status.java | 17 ++ .../sdk/network/ReportExportRestApiTest.java | 12 +- .../service/report/ReportAttachmentTest.java | 9 +- .../sdk/service/report/ReportExportTest.java | 7 +- .../report/ReportExportUseCaseTest.java | 147 ++++++++++++++++++ 11 files changed, 251 insertions(+), 41 deletions(-) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index 80c15dc3..c9b5a8de 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -30,21 +30,14 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.squareup.okhttp.ResponseBody; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -import java.io.IOException; - import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; -import retrofit.http.Body; -import retrofit.http.GET; -import retrofit.http.Header; -import retrofit.http.Headers; -import retrofit.http.POST; -import retrofit.http.Path; +import retrofit.http.*; + +import java.io.IOException; /** * @author Tom Koptel @@ -132,7 +125,7 @@ Call runReportExportExecution(@NotNull @Path("executi @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") Call checkReportExportStatus(@NotNull @Path("executionId") String executionId, - @NotNull @Path("exportId") String exportId, + @NotNull @Path(value = "exportId", encoded = true) String exportId, @Header("Cookie") String cookie); /** @@ -141,13 +134,13 @@ Call checkReportExportStatus(@NotNull @Path("executionId") Stri @NotNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") Call requestReportExportOutput(@NotNull @Path("executionId") String executionId, - @NotNull @Path("exportId") String exportId, + @NotNull @Path(value = "exportId", encoded = true) String exportId, @Header("Cookie") String cookie); @NotNull @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") Call requestReportExportAttachmentOutput(@NotNull @Path("executionId") String executionId, - @NotNull @Path("exportId") String exportId, + @NotNull @Path(value = "exportId", encoded = true) String exportId, @NotNull @Path("attachmentId") String attachmentId, @Header("Cookie") String cookie); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index ec0db383..0977e9df 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -53,25 +53,31 @@ final class ExportFactory { } @NotNull - public ReportExport create(ReportExecutionDescriptor executionDetails, - ExportExecutionDescriptor exportExecutionDetails) throws ServiceException { + public ReportExport create( + RunExportCriteria criteria, + ReportExecutionDescriptor executionDetails, + ExportExecutionDescriptor exportExecutionDetails) throws ServiceException { String exportId = exportExecutionDetails.getExportId(); ExportDescriptor export = findExportDescriptor(executionDetails, exportId); if (export == null) { throw new ServiceException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); } - Collection attachments = adaptAttachments(export); - return new ReportExport(mExecutionId, exportId, attachments, mExportUseCase); + Collection attachments = adaptAttachments(criteria, export); + return new ReportExport(mExecutionId, exportId, attachments, criteria, mExportUseCase); } @NotNull - private Collection adaptAttachments(ExportDescriptor export) { + private Collection adaptAttachments(RunExportCriteria criteria, ExportDescriptor export) { String exportId = export.getId(); Set rawAttachments = export.getAttachments(); Collection attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { ReportAttachment reportAttachment = new ReportAttachment( - attachment.getFileName(), mExecutionId, exportId, mExportUseCase); + attachment.getFileName(), + mExecutionId, + exportId, + criteria, + mExportUseCase); attachments.add(reportAttachment); } return attachments; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index e444c181..aa7846d1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -38,21 +38,28 @@ public final class ReportAttachment { private final String mExecutionId; private final String mExportId; + private final RunExportCriteria mCriteria; private final ReportExportUseCase mExportUseCase; ReportAttachment(String fileName, String executionId, String exportId, + RunExportCriteria criteria, ReportExportUseCase exportUseCase) { mFileName = fileName; mExecutionId = executionId; mExportId = exportId; + mCriteria = criteria; mExportUseCase = exportUseCase; } @NotNull public ResourceOutput download() throws ServiceException { return mExportUseCase.requestExportAttachmentOutput( - mExecutionId, mExportId, mFileName); + mCriteria, + mExecutionId, + mExportId, + mFileName + ); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 56c2ee7e..afe01c11 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -108,12 +108,12 @@ private ReportMetadata performAwaitFoReport() throws ServiceException { @NotNull private ReportExport performExport(RunExportCriteria criteria) throws ServiceException { ExportExecutionDescriptor exportDetails = runExport(criteria); - waitForExportReadyStatus(exportDetails); + waitForExportReadyStatus(criteria, exportDetails); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); - return mExportFactory.create(currentDetails, exportDetails); + return mExportFactory.create(criteria, currentDetails, exportDetails); } - private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws ServiceException { + private void waitForExportReadyStatus(RunExportCriteria criteria, ExportExecutionDescriptor exportDetails) throws ServiceException { final String exportId = exportDetails.getExportId(); Status status = Status.wrap(exportDetails.getStatus()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index d9c29d65..da335086 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -40,14 +40,17 @@ public final class ReportExport { private final String mExecutionId; private final String mExportId; private final ReportExportUseCase mExportUseCase; + private final RunExportCriteria mCriteria; ReportExport(String executionId, String exportId, Collection attachments, + RunExportCriteria criteria, ReportExportUseCase exportUseCase) { mExecutionId = executionId; mExportId = exportId; mAttachments = attachments; + mCriteria = criteria; mExportUseCase = exportUseCase; } @@ -58,6 +61,6 @@ public Collection getAttachments() { @NotNull public ReportOutput download() throws ServiceException { - return mExportUseCase.requestExportOutput(mExecutionId, mExportId); + return mExportUseCase.requestExportOutput(mCriteria, mExecutionId, mExportId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index b42ed854..cc0169b1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -54,7 +54,9 @@ class ReportExportUseCase { private final InfoCacheManager mCacheManager; ReportExportUseCase(ReportExportRestApi exportApi, - CallExecutor callExecutor, InfoCacheManager cacheManager, ExecutionOptionsDataMapper executionOptionsMapper) { + CallExecutor callExecutor, + InfoCacheManager cacheManager, + ExecutionOptionsDataMapper executionOptionsMapper) { mExportApi = exportApi; mCallExecutor = callExecutor; mCacheManager = cacheManager; @@ -65,6 +67,7 @@ class ReportExportUseCase { public ExportExecutionDescriptor runExport(final String executionId, final RunExportCriteria criteria) throws ServiceException { ServerInfo info = mCacheManager.getInfo(); final ServerVersion version = info.getVersion(); + Call call = new Call() { @Override public ExportExecutionDescriptor perform(String token) throws IOException, HttpException { @@ -76,7 +79,14 @@ public ExportExecutionDescriptor perform(String token) throws IOException, HttpE } @NotNull - public Status checkExportExecutionStatus(final String executionId, final String exportId) throws ServiceException { + public Status checkExportExecutionStatus(final String executionId, + final String exportId) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + return Status.wrap("ready"); + } + Call call = new Call() { @Override public Status perform(String token) throws IOException, HttpException { @@ -89,11 +99,16 @@ public Status perform(String token) throws IOException, HttpException { } @NotNull - public ReportOutput requestExportOutput(final String executionId, final String exportId) throws ServiceException { + public ReportOutput requestExportOutput(RunExportCriteria exportCriteria, + final String executionId, + String exportId) throws ServiceException { + exportId = adaptExportId(exportCriteria, exportId); + final String resultId = exportId; + Call call = new Call() { @Override public ReportOutput perform(String token) throws IOException, HttpException { - ExportOutputResource result = mExportApi.requestExportOutput(token, executionId, exportId); + ExportOutputResource result = mExportApi.requestExportOutput(token, executionId, resultId); return OutputDataMapper.transform(result); } }; @@ -101,16 +116,32 @@ public ReportOutput perform(String token) throws IOException, HttpException { } @NotNull - public ResourceOutput requestExportAttachmentOutput(final String executionId, final String exportId, + public ResourceOutput requestExportAttachmentOutput(RunExportCriteria exportCriteria, + final String executionId, + String exportId, final String fileName) throws ServiceException { + exportId = adaptExportId(exportCriteria, exportId); + final String resultId = exportId; + Call call = new Call() { @Override public ResourceOutput perform(String token) throws IOException, HttpException { OutputResource result = mExportApi.requestExportAttachment( - token, executionId, exportId, fileName); + token, executionId, resultId, fileName); return OutputDataMapper.transform(result); } }; return mCallExecutor.execute(call); } + + private String adaptExportId(RunExportCriteria exportCriteria, String exportId) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); + + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + exportId = String.format("%s;pages=%s", exportCriteria.getFormat(), exportCriteria.getPages()); + exportId = exportId.toLowerCase(); + } + return exportId; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java index 4872e8ef..3f608881 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java @@ -63,4 +63,21 @@ public boolean isReady() { public String toString() { return mStatus; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Status status = (Status) o; + + if (mStatus != null ? !mStatus.equals(status.mStatus) : status.mStatus != null) return false; + + return true; + } + + @Override + public int hashCode() { + return mStatus != null ? mStatus.hashCode() : 0; + } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index ebc61355..24748e10 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -176,10 +176,10 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { public void shouldRequestExportOutput() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportOutput("cookie", "execution_id", "export_id"); + restApiUnderTest.requestExportOutput("cookie", "execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); - assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/outputResource?suppressContentDisposition=true")); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/outputResource?suppressContentDisposition=true")); assertThat(request.getHeader("Cookie"), is("cookie")); } @@ -201,10 +201,10 @@ public void shouldRequestExportAttachment() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportAttachment("cookie", "execution_id", "export_id", "attachment_id"); + restApiUnderTest.requestExportAttachment("cookie", "execution_id", "html;pages=1", "attachment_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); - assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/attachments/attachment_id")); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/attachments/attachment_id")); assertThat(request.getHeader("Cookie"), is("cookie")); } @@ -225,10 +225,10 @@ public void shouldCheckExportExecutionStatus() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.checkExportExecutionStatus("cookie", "execution_id", "export_id"); + restApiUnderTest.checkExportExecutionStatus("cookie", "execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); - assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/status")); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/status")); assertThat(request.getHeader("Cookie"), is("cookie")); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 2af42253..57fdbe42 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -38,6 +38,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; @@ -57,23 +58,25 @@ public class ReportAttachmentTest { ResourceOutput input; @Mock ReportExportUseCase mReportExportUseCase; + @Mock + RunExportCriteria mRunExportCriteria; private ReportAttachment objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", mReportExportUseCase); + objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", mRunExportCriteria, mReportExportUseCase); } @Test public void testDownload() throws Exception { - when(mReportExportUseCase.requestExportAttachmentOutput(anyString(), anyString(), anyString())).thenReturn(input); + when(mReportExportUseCase.requestExportAttachmentOutput(any(RunExportCriteria.class), anyString(), anyString(), anyString())).thenReturn(input); ResourceOutput result = objectUnderTest.download(); assertThat(result, is(notNullValue())); - verify(mReportExportUseCase).requestExportAttachmentOutput(eq("exec_id"), eq("export_id"), eq("1.jpg")); + verify(mReportExportUseCase).requestExportAttachmentOutput(eq(mRunExportCriteria), eq("exec_id"), eq("export_id"), eq("1.jpg")); verifyNoMoreInteractions(mReportExportUseCase); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 44991130..fc178398 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -42,19 +42,22 @@ public class ReportExportTest { @Mock ReportExportUseCase mReportExportUseCase; + @Mock + RunExportCriteria mCriteria; private ReportExport objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), mReportExportUseCase); + objectUnderTest = new ReportExport("report_execution_id", "export_id", + Collections.emptyList(), mCriteria, mReportExportUseCase); } @Test public void testDownload() throws Exception { objectUnderTest.download(); - verify(mReportExportUseCase).requestExportOutput(eq("report_execution_id"), eq("export_id")); + verify(mReportExportUseCase).requestExportOutput(eq(mCriteria), eq("report_execution_id"), eq("export_id")); verifyNoMoreInteractions(mReportExportUseCase); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java new file mode 100644 index 00000000..f3d23fdf --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java @@ -0,0 +1,147 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus.cancelledStatus; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; + +public class ReportExportUseCaseTest { + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + private static final String LEGACY_EXPORT_ID = "html;pages=1"; + + @Mock + ReportExportRestApi mExportApi; + @Mock + ExecutionOptionsDataMapper mExecutionOptionsMapper; + + @Mock + InfoCacheManager mCacheManager; + @Mock + ServerInfo mServerInfo; + + private static final RunExportCriteria EXPORT_HTML_PAGE_1 = RunExportCriteria.builder() + .format(ExecutionCriteria.Format.HTML) + .pages("1") + .create(); + + private ReportExportUseCase useCase; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + when(mCacheManager.getInfo()).thenReturn(mServerInfo); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); + + FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); + useCase = new ReportExportUseCase(mExportApi, callExecutor, mCacheManager, mExecutionOptionsMapper); + } + + @Test + public void testRequestExportOutputOnServer5_5() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); + useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); + verify(mExportApi).requestExportOutput(eq("cookie"), eq(EXEC_ID), eq(LEGACY_EXPORT_ID)); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + } + + @Test + public void testRequestExportOutputOnServer5_6() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); + useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); + verify(mExportApi).requestExportOutput(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID)); + verify(mCacheManager).getInfo(); + } + + @Test + public void testRunExport() throws Exception { + useCase.runExport(EXEC_ID, EXPORT_HTML_PAGE_1); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + verify(mExecutionOptionsMapper).transformExportOptions(EXPORT_HTML_PAGE_1, ServerVersion.v6); + verify(mExportApi).runExportExecution(eq("cookie"), eq(EXEC_ID), any(ExecutionRequestOptions.class)); + } + + @Test + public void testCheckExportExecutionStatusOnServer5_5() throws Exception { + when(mExportApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); + + Status status = useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); + assertThat("For server 5.5 status of export always ready", status, is(Status.wrap("ready"))); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + verifyZeroInteractions(mExportApi); + } + + @Test + public void testCheckExportExecutionStatusOnServer5_6() throws Exception { + when(mExportApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); + + useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + verify(mExportApi).checkExportExecutionStatus(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID)); + } + + @Test + public void testRequestExportAttachmentOutputOnServer5_5() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); + + useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); + verify(mExportApi).requestExportAttachment(eq("cookie"), eq(EXEC_ID), eq(LEGACY_EXPORT_ID), eq("nay")); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + } + + @Test + public void testRequestExportAttachmentOutputOnServer5_6() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); + + useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); + verify(mExportApi).requestExportAttachment(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID), eq("nay")); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + } +} \ No newline at end of file From 25ac1119b28d7e674aae1f301ae99bd923f794d3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 18:45:43 +0200 Subject: [PATCH 337/457] Awaiting report execution valid state after update --- .../sdk/service/report/ReportExecution.java | 32 +++++++++++++++++++ .../service/report/ReportExecutionTest.java | 18 ++++++++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index afe01c11..73f028e7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; @@ -76,6 +77,8 @@ public ReportMetadata waitForReportCompletion() throws ServiceException { @NotNull public ReportExecution updateExecution(List newParameters) throws ServiceException { mExecutionUseCase.updateExecution(mExecutionId, newParameters); + ExecutionStatus statusDetails = requestReportExecutionStatus(); + waitForReportExecutionStart(mReportUri, statusDetails); return this; } @@ -172,4 +175,33 @@ private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws S private ReportExecutionDescriptor requestExecutionDetails() throws ServiceException { return mExecutionUseCase.requestExecutionDetails(mExecutionId); } + + @NotNull + private ExecutionStatus requestReportExecutionStatus() throws ServiceException { + return mExecutionUseCase.requestStatus(mExecutionId); + } + + private void waitForReportExecutionStart(String reportUri, ExecutionStatus details) throws ServiceException { + Status status = Status.wrap(details.getStatus()); + ErrorDescriptor descriptor = details.getErrorDescriptor(); + + while (!status.isReady() && !status.isExecution()) { + if (status.isCancelled()) { + throw new ServiceException( + String.format("Report '%s' execution cancelled", reportUri), null, + StatusCodes.REPORT_EXECUTION_CANCELLED); + } + if (status.isFailed()) { + throw new ServiceException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); + } + try { + Thread.sleep(mDelay); + } catch (InterruptedException ex) { + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); + } + ExecutionStatus statusDetails = requestReportExecutionStatus(); + status = Status.wrap(statusDetails.getStatus()); + descriptor = statusDetails.getErrorDescriptor(); + } + } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 6ea2f7cd..bf178c4c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -47,6 +47,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; +import static com.jaspersoft.android.sdk.test.Chain.of; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.Assert.fail; @@ -241,26 +242,33 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception } } - @Test + @Test(timeout = 2000) public void testUpdateExecution() throws Exception { + mockRunExportExecStatus("queue", "execution"); List params = Collections.emptyList(); objectUnderTest.updateExecution(params); verify(mReportExecutionUseCase).updateExecution("execution_id", params); } + private void mockRunExportExecStatus(String... statusChain) throws Exception { + ensureChain(statusChain); + when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); + when(mReportExecutionUseCase.requestStatus(anyString())).thenReturn(mExecutionStatusResponse); + } + private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); List statuses = new ArrayList<>(); for (String state : statusChain) { statuses.add(Status.wrap(state)); } - when(mReportExportUseCase.checkExportExecutionStatus(anyString(), anyString())).then(Chain.of(statuses)); + when(mReportExportUseCase.checkExportExecutionStatus(anyString(), anyString())).then(of(statuses)); } private void mockRunExportExecution(String... statusChain) throws Exception { ensureChain(statusChain); when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).then(Chain.of(statusChain)); + when(mExportExecDetails.getStatus()).then(of(statusChain)); when(mExportExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(mReportExportUseCase.runExport(anyString(), any(RunExportCriteria.class))).thenReturn(mExportExecDetails); } @@ -274,12 +282,12 @@ private void mockReportExecutionDetails(String firstStatus, String... statusChai when(mReportExecDetails1.getExports()).thenReturn(exports); when(mReportExecDetails1.getErrorDescriptor()).thenReturn(mDescriptor); - when(mReportExecDetails2.getStatus()).then(Chain.of(statusChain)); + when(mReportExecDetails2.getStatus()).then(of(statusChain)); when(mReportExecDetails2.getExports()).thenReturn(exports); when(mReportExecDetails2.getErrorDescriptor()).thenReturn(mDescriptor); when(mReportExecutionUseCase.requestExecutionDetails(anyString())) - .then(Chain.of(mReportExecDetails1, mReportExecDetails2)); + .then(of(mReportExecDetails1, mReportExecDetails2)); } private void ensureChain(String[] statusChain) { From d9f089baff5473ed38c9de4781c3c8f122378bd6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 19:13:03 +0200 Subject: [PATCH 338/457] Handle update report execution for JRS v5.5 --- .../sdk/service/report/ExecutionCriteria.java | 12 ++--- .../sdk/service/report/ReportExecution.java | 54 +++++++++---------- .../sdk/service/report/ReportService.java | 26 +++++---- .../sdk/service/report/RunReportCriteria.java | 12 +++++ .../service/report/ReportExecutionTest.java | 35 ++++++++---- .../sdk/service/report/ReportServiceTest.java | 16 ++++-- 6 files changed, 96 insertions(+), 59 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java index b33d8d45..2c983ca0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java @@ -32,12 +32,12 @@ */ public abstract class ExecutionCriteria { - private final boolean mFreshData; - private final boolean mInteractive; - private final boolean mSaveSnapshot; - private final Format mFormat; - private final String mPages; - private final String mAttachmentPrefix; + protected final boolean mFreshData; + protected final boolean mInteractive; + protected final boolean mSaveSnapshot; + protected final Format mFormat; + protected final String mPages; + protected final String mAttachmentPrefix; protected ExecutionCriteria(boolean freshData, boolean interactive, diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 73f028e7..2062d146 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -31,9 +31,12 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -52,13 +55,23 @@ public final class ReportExecution { private final String mExecutionId; private final String mReportUri; private final ExportFactory mExportFactory; + private final ReportService mService; + private final RunReportCriteria mCriteria; + private final InfoCacheManager mInfoCacheManager; @TestOnly - ReportExecution(long delay, + ReportExecution(ReportService service, + RunReportCriteria criteria, + InfoCacheManager infoCacheManager, + long delay, ReportExecutionUseCase executionUseCase, ReportExportUseCase exportUseCase, String executionId, String reportUri) { + mService = service; + mCriteria = criteria; + mInfoCacheManager = infoCacheManager; + mDelay = delay; mExecutionUseCase = executionUseCase; mExportUseCase = exportUseCase; @@ -76,10 +89,18 @@ public ReportMetadata waitForReportCompletion() throws ServiceException { @NotNull public ReportExecution updateExecution(List newParameters) throws ServiceException { - mExecutionUseCase.updateExecution(mExecutionId, newParameters); - ExecutionStatus statusDetails = requestReportExecutionStatus(); - waitForReportExecutionStart(mReportUri, statusDetails); - return this; + ServerInfo info = mInfoCacheManager.getInfo(); + ServerVersion version = info.getVersion(); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + RunReportCriteria criteria = mCriteria.newBuilder() + .params(newParameters) + .create(); + return mService.run(mReportUri, criteria); + } else { + mExecutionUseCase.updateExecution(mExecutionId, newParameters); + mService.waitForReportExecutionStart(mReportUri, mExecutionId); + return this; + } } @NotNull @@ -181,27 +202,4 @@ private ExecutionStatus requestReportExecutionStatus() throws ServiceException { return mExecutionUseCase.requestStatus(mExecutionId); } - private void waitForReportExecutionStart(String reportUri, ExecutionStatus details) throws ServiceException { - Status status = Status.wrap(details.getStatus()); - ErrorDescriptor descriptor = details.getErrorDescriptor(); - - while (!status.isReady() && !status.isExecution()) { - if (status.isCancelled()) { - throw new ServiceException( - String.format("Report '%s' execution cancelled", reportUri), null, - StatusCodes.REPORT_EXECUTION_CANCELLED); - } - if (status.isFailed()) { - throw new ServiceException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); - } - try { - Thread.sleep(mDelay); - } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); - } - ExecutionStatus statusDetails = requestReportExecutionStatus(); - status = Status.wrap(statusDetails.getStatus()); - descriptor = statusDetails.getErrorDescriptor(); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 012d7507..afcabee9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -48,15 +48,18 @@ public final class ReportService { private final ReportExecutionUseCase mExecutionUseCase; + private final InfoCacheManager mInfoCacheManager; private final ReportExportUseCase mExportUseCase; private final long mDelay; @TestOnly ReportService( long delay, + InfoCacheManager infoCacheManager, ReportExecutionUseCase executionUseCase, ReportExportUseCase exportUseCase) { mDelay = delay; + mInfoCacheManager = infoCacheManager; mExecutionUseCase = executionUseCase; mExportUseCase = exportUseCase; } @@ -83,6 +86,7 @@ public static ReportService create(RestClient client, Session session) { return new ReportService( TimeUnit.SECONDS.toMillis(1), + cacheManager, reportExecutionUseCase, reportExportUseCase); } @@ -95,9 +99,12 @@ public ReportExecution run(String reportUri, RunReportCriteria criteria) throws private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws ServiceException { ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); - waitForReportExecutionStart(reportUri, details); + waitForReportExecutionStart(reportUri, details.getExecutionId()); return new ReportExecution( + this, + criteria, + mInfoCacheManager, mDelay, mExecutionUseCase, mExportUseCase, @@ -105,12 +112,13 @@ private ReportExecution performRun(String reportUri, RunReportCriteria criteria) details.getReportURI()); } - private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) throws ServiceException { - String executionId = details.getExecutionId(); - Status status = Status.wrap(details.getStatus()); - ErrorDescriptor descriptor = details.getErrorDescriptor(); + void waitForReportExecutionStart(String reportUri, String executionId) throws ServiceException { + Status status; + do { + ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); + status = Status.wrap(statusDetails.getStatus()); + ErrorDescriptor descriptor = statusDetails.getErrorDescriptor(); - while (!status.isReady() && !status.isExecution()) { if (status.isCancelled()) { throw new ServiceException( String.format("Report '%s' execution cancelled", reportUri), null, @@ -124,9 +132,7 @@ private void waitForReportExecutionStart(String reportUri, ReportExecutionDescri } catch (InterruptedException ex) { throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); - status = Status.wrap(statusDetails.getStatus()); - descriptor = statusDetails.getErrorDescriptor(); - } + + } while (!status.isReady() && !status.isExecution()); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index 2ce9f2db..483db729 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -49,6 +49,18 @@ private RunReportCriteria(boolean freshData, mParams = params; } + @NotNull + public Builder newBuilder() { + return new Builder() + .freshData(mFreshData) + .interactive(mInteractive) + .saveSnapshot(mSaveSnapshot) + .format(mFormat) + .pages(mPages) + .params(mParams) + .attachmentPrefix(mAttachmentPrefix); + } + @NotNull public static Builder builder() { return new Builder(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index bf178c4c..451110fe 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -24,13 +24,18 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.entity.execution.*; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.test.Chain; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -70,7 +75,9 @@ ExportDescriptor.class, ExecutionStatus.class, ErrorDescriptor.class, - ExecutionOptionsDataMapper.class}) + ExecutionOptionsDataMapper.class, + ReportService.class, +}) public class ReportExecutionTest { @Mock @@ -93,6 +100,16 @@ public class ReportExecutionTest { @Mock ReportExportUseCase mReportExportUseCase; + @Mock + ReportService mReportService; + @Mock + RunReportCriteria mReportCriteria; + + @Mock + InfoCacheManager mInfoCacheManager; + @Mock + ServerInfo mServerInfo; + private ReportExecution objectUnderTest; @Rule @@ -105,8 +122,13 @@ public void setUp() throws Exception { when(mReportExecDetails1.getExecutionId()).thenReturn("execution_id"); when(mReportExecDetails1.getReportURI()).thenReturn("/report/uri"); + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); objectUnderTest = new ReportExecution( + mReportService, + mReportCriteria, + mInfoCacheManager, TimeUnit.SECONDS.toMillis(0), mReportExecutionUseCase, mReportExportUseCase, @@ -244,18 +266,11 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception @Test(timeout = 2000) public void testUpdateExecution() throws Exception { - mockRunExportExecStatus("queue", "execution"); List params = Collections.emptyList(); objectUnderTest.updateExecution(params); verify(mReportExecutionUseCase).updateExecution("execution_id", params); } - private void mockRunExportExecStatus(String... statusChain) throws Exception { - ensureChain(statusChain); - when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); - when(mReportExecutionUseCase.requestStatus(anyString())).thenReturn(mExecutionStatusResponse); - } - private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); List statuses = new ArrayList<>(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index 8b1f4082..a228bb61 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; @@ -78,6 +79,9 @@ public class ReportServiceTest { @Mock ReportExportUseCase mReportExportUseCase; + @Mock + InfoCacheManager mInfoCacheManager; + ReportService objectUnderTest; @Rule @@ -89,25 +93,26 @@ public void setUp() throws Exception { objectUnderTest = new ReportService( TimeUnit.MILLISECONDS.toMillis(0), + mInfoCacheManager, mReportExecutionUseCase, mReportExportUseCase); } @Test public void testRunShouldCreateActiveSession() throws Exception { - mockRunReportExecution("execution"); - mockRunReportExecution("ready"); + mockRunReportExecution("queue"); + mockReportExecutionStatus("execution", "ready"); ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); verify(mReportExecutionUseCase).runReportExecution(anyString(), any(RunReportCriteria.class)); - verifyNoMoreInteractions(mReportExecutionUseCase); } @Test public void testRunThrowsFailedStatusImmediately() throws Exception { - mockRunReportExecution("failed"); + mockRunReportExecution("queue"); + mockReportExecutionStatus("failed"); try { objectUnderTest.run("/report/uri", configuration); @@ -130,7 +135,8 @@ public void testRunShouldThrowFailedIfStatusFailed() throws Exception { @Test public void testRunThrowsCancelledStatusImmediately() throws Exception { - mockRunReportExecution("cancelled"); + mockRunReportExecution("queue"); + mockReportExecutionStatus("cancelled"); try { objectUnderTest.run("/report/uri", configuration); From a19845422ef62315ede5effacf286cdbb412e29b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 21:00:20 +0200 Subject: [PATCH 339/457] Add poll timeout control --- .../android/sdk/service/RestClient.java | 16 ++++++++++++++-- .../sdk/service/report/ReportService.java | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index f46b30b2..2e6358de 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -38,14 +38,16 @@ public final class RestClient { private final String mServerUrl; private final long mReadTimeOut; private final long mConnectionTimeOut; + private final long mPollTimeout; private final InfoCache mInfoCache; private AnonymousSession mAnonymousSession; - private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, InfoCache infoCache) { + private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, long pollTimeout, InfoCache infoCache) { mServerUrl = serverUrl; mReadTimeOut = readTimeOut; mConnectionTimeOut = connectionTimeOut; + mPollTimeout = pollTimeout; mInfoCache = infoCache; } @@ -72,6 +74,10 @@ public long getConnectionTimeOut() { return mConnectionTimeOut; } + public long getPollTimeout() { + return mPollTimeout; + } + public InfoCache getInfoCache() { return mInfoCache; } @@ -93,12 +99,18 @@ public static class ConditionalBuilder { private final String mServerUrl; private long mConnectionReadTimeOut = TimeUnit.SECONDS.toMillis(10); private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10); + private long mPollTimeOut = TimeUnit.SECONDS.toMillis(1); private InfoCache mInfoCache; private ConditionalBuilder(String serverUrl) { mServerUrl = serverUrl; } + public ConditionalBuilder pollTimeOut(int timeOut, TimeUnit unit) { + mPollTimeOut = unit.toMillis(timeOut); + return this; + } + public ConditionalBuilder readTimeOut(int timeOut, TimeUnit unit) { mConnectionReadTimeOut = unit.toMillis(timeOut); return this; @@ -118,7 +130,7 @@ public RestClient create() { if (mInfoCache == null) { mInfoCache = new InMemoryInfoCache(); } - return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mInfoCache); + return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mPollTimeOut, mInfoCache); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index afcabee9..f1a76723 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -85,7 +85,7 @@ public static ReportService create(RestClient client, Session session) { new ReportExportUseCase(exportApi, callExecutor, cacheManager, executionOptionsMapper); return new ReportService( - TimeUnit.SECONDS.toMillis(1), + client.getPollTimeout(), cacheManager, reportExecutionUseCase, reportExportUseCase); From b93e18265b2505e9595493c0480a5efb28f63df7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 22:23:37 +0200 Subject: [PATCH 340/457] Fix NPE for error descriptor during report export status --- .../entity/execution/ExecutionStatus.java | 17 ++++++++++-- .../sdk/service/report/ReportExecution.java | 26 +++++++++++-------- .../service/report/ReportExportUseCase.java | 12 ++++----- .../report/ReportExportUseCaseTest.java | 5 ++-- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java index acc3b0ca..2a290cad 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Tom Koptel @@ -33,24 +35,35 @@ public final class ExecutionStatus { @Expose + @NotNull private String value; @Expose + @Nullable private ErrorDescriptor errorDescriptor; - public ExecutionStatus() {} + public ExecutionStatus() { + } - private ExecutionStatus(String value) { + private ExecutionStatus(@NotNull String value) { this.value = value; } + @NotNull public static ExecutionStatus cancelledStatus() { return new ExecutionStatus("cancelled"); } + @NotNull + public static ExecutionStatus readyStatus() { + return new ExecutionStatus("ready"); + } + + @NotNull public String getStatus() { return value; } + @Nullable public ErrorDescriptor getErrorDescriptor() { return errorDescriptor; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 2062d146..fa4b6414 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -132,12 +132,12 @@ private ReportMetadata performAwaitFoReport() throws ServiceException { @NotNull private ReportExport performExport(RunExportCriteria criteria) throws ServiceException { ExportExecutionDescriptor exportDetails = runExport(criteria); - waitForExportReadyStatus(criteria, exportDetails); + waitForExportReadyStatus(exportDetails); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); return mExportFactory.create(criteria, currentDetails, exportDetails); } - private void waitForExportReadyStatus(RunExportCriteria criteria, ExportExecutionDescriptor exportDetails) throws ServiceException { + private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws ServiceException { final String exportId = exportDetails.getExportId(); Status status = Status.wrap(exportDetails.getStatus()); @@ -149,7 +149,11 @@ private void waitForExportReadyStatus(RunExportCriteria criteria, ExportExecutio StatusCodes.EXPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw new ServiceException(descriptor.getMessage(), null, StatusCodes.EXPORT_EXECUTION_FAILED); + String message = "Failed to export page"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.EXPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); @@ -157,7 +161,9 @@ private void waitForExportReadyStatus(RunExportCriteria criteria, ExportExecutio throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - status = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); + ExecutionStatus executionStatus = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); + status = Status.wrap(executionStatus.getStatus()); + descriptor = executionStatus.getErrorDescriptor(); } } @@ -173,7 +179,11 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD StatusCodes.REPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw new ServiceException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); + String message = "Failed to execute report"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.REPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); @@ -196,10 +206,4 @@ private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws S private ReportExecutionDescriptor requestExecutionDetails() throws ServiceException { return mExecutionUseCase.requestExecutionDetails(mExecutionId); } - - @NotNull - private ExecutionStatus requestReportExecutionStatus() throws ServiceException { - return mExecutionUseCase.requestStatus(mExecutionId); - } - } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index cc0169b1..ca1b6a89 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -79,20 +79,18 @@ public ExportExecutionDescriptor perform(String token) throws IOException, HttpE } @NotNull - public Status checkExportExecutionStatus(final String executionId, + public ExecutionStatus checkExportExecutionStatus(final String executionId, final String exportId) throws ServiceException { ServerInfo info = mCacheManager.getInfo(); final ServerVersion version = info.getVersion(); if (version.lessThanOrEquals(ServerVersion.v5_5)) { - return Status.wrap("ready"); + return ExecutionStatus.readyStatus(); } - Call call = new Call() { + Call call = new Call() { @Override - public Status perform(String token) throws IOException, HttpException { - ExecutionStatus exportStatus = mExportApi - .checkExportExecutionStatus(token, executionId, exportId); - return Status.wrap(exportStatus.getStatus()); + public ExecutionStatus perform(String token) throws IOException, HttpException { + return mExportApi.checkExportExecutionStatus(token, executionId, exportId); } }; return mCallExecutor.execute(call); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java index f3d23fdf..7f34b9b1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; @@ -107,8 +108,8 @@ public void testCheckExportExecutionStatusOnServer5_5() throws Exception { when(mExportApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(cancelledStatus()); when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); - Status status = useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); - assertThat("For server 5.5 status of export always ready", status, is(Status.wrap("ready"))); + ExecutionStatus execStatus = useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); + assertThat("For server 5.5 status of export always ready", execStatus.getStatus(), is("ready")); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); verifyZeroInteractions(mExportApi); From be400b493a72c3374766c4e8bce7b36af6c8562d Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Dec 2015 16:28:36 +0200 Subject: [PATCH 341/457] Handle RESOURCE_NOT_FOUND error --- .../android/sdk/service/exception/StatusCodes.java | 3 +++ .../sdk/service/internal/ServiceExceptionMapper.java | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java index 67c35670..513cfb89 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java @@ -45,5 +45,8 @@ public final class StatusCodes { public static final int REPORT_EXECUTION_CANCELLED = 201; public static final int REPORT_EXECUTION_FAILED = 202; + // RESOURCE + public static final int RESOURCE_NOT_FOUND = 300; + private StatusCodes() {} } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java index c609180b..133c647f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java @@ -47,7 +47,7 @@ public static ServiceException transform(IOException e) { public static ServiceException transform(HttpException e) { try { ErrorDescriptor descriptor = e.getDescriptor(); - if (e.getDescriptor() == null) { + if (descriptor == null) { return mapHttpCodesToState(e); } else { return mapDescriptorToState(e, descriptor); @@ -77,7 +77,9 @@ private static ServiceException mapHttpCodesToState(HttpException e) { @NotNull private static ServiceException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { - if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { + if ("resource.not.found".equals(descriptor.getErrorCode())) { + return new ServiceException(descriptor.getMessage(), e, StatusCodes.RESOURCE_NOT_FOUND); + } else if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { return new ServiceException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); } else { return mapHttpCodesToState(e); From c4dba9a4feae9d135e371d9b42d3ddbdbdfd4d9a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 15 Dec 2015 16:41:00 +0200 Subject: [PATCH 342/457] Disable interactiveness for JRS 5.6 --- .../report/ExecutionOptionsDataMapper.java | 2 ++ .../sdk/service/report/RunExportCriteria.java | 8 ++++++++ .../sdk/service/report/RunReportCriteria.java | 8 ++++++++ .../report/ExecutionOptionsDataMapperTest.java | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 08afac0e..adb338e0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -80,6 +80,8 @@ private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, options.withAllowInlineScripts(null); options.withFreshData(null); options.withInteractive(null); + } else if (version.equals(ServerVersion.v5_6)) { + options.withInteractive(false); } else { options.withBaseUrl(mBaseUrl); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index 8a6bc244..5d4e9989 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -59,6 +59,14 @@ public Builder freshData(boolean freshData) { return this; } + /** + * Configuration for report interactiveness + * + * NOTICE: This flag ignored for JRS 5.6 where we are forcing disable state + * + * @param interactive weather report should be interactive or not + * @return builder instance + */ public Builder interactive(boolean interactive) { this.interactive = interactive; return this; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index 483db729..fb702520 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -90,6 +90,14 @@ public Builder freshData(boolean freshData) { return this; } + /** + * Configuration for report interactiveness + * + * NOTICE: This flag ignored for JRS 5.6 where we are forcing disable state + * + * @param interactive weather report should be interactive or not + * @return builder instance + */ public Builder interactive(boolean interactive) { this.interactive = interactive; return this; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 68066617..70de5f01 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -103,6 +103,24 @@ public void testReportExecutionFieldsReducedForServer5_5() throws Exception { assertThat("Should reduce 'interactive' from options", options.getInteractive(), is(nullValue())); } + @Test + public void testInteractivenessDisabledForReportRun5_6() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder() + .interactive(true) + .create(); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_6, criteria); + assertThat("Should put false for 'interactive' option", options.getInteractive(), is(Boolean.FALSE)); + } + + @Test + public void testInteractivenessDisabledForExportRun5_6() throws Exception { + RunExportCriteria criteria = RunExportCriteria.builder() + .interactive(true) + .create(); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_6); + assertThat("Should put false for 'interactive' option", options.getInteractive(), is(Boolean.FALSE)); + } + @Test public void testExportExecutionFieldsReducedForServer5_5() throws Exception { RunExportCriteria criteria = RunExportCriteria.builder() From 35d2efde8dcd0c5ab62c5d9abfad0382ec9bff24 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 16 Dec 2015 13:04:56 +0200 Subject: [PATCH 343/457] Implement ReportExceptionMapper --- .../sdk/service/auth/SpringCredentials.java | 15 ++-- .../sdk/service/exception/StatusCodes.java | 25 +++--- .../service/internal/DefaultCallExecutor.java | 20 ++--- .../internal/DefaultExceptionMapper.java | 88 +++++++++++++++++++ .../internal/ReportExceptionMapper.java | 60 +++++++++++++ .../internal/ServiceExceptionMapper.java | 64 ++------------ .../service/internal/TokenCacheManager.java | 2 +- .../sdk/service/report/ReportService.java | 10 ++- .../service/repository/RepositoryService.java | 9 +- .../sdk/service/server/ServerInfoService.java | 25 +++--- .../android/sdk/service/FakeCallExecutor.java | 8 +- .../internal/DefaultCallExecutorTest.java | 2 +- ...t.java => DefaultExceptionMapperTest.java} | 21 +++-- .../service/report/ReportExecutionTest.java | 9 +- .../service/server/ServerInfoServiceTest.java | 5 +- 15 files changed, 239 insertions(+), 124 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java rename core/src/test/java/com/jaspersoft/android/sdk/service/internal/{ServiceExceptionMapperTest.java => DefaultExceptionMapperTest.java} (90%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index e56841d0..6041892e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -2,8 +2,8 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -24,6 +24,7 @@ public final class SpringCredentials extends Credentials { private final String mOrganization; private final Locale mLocale; private final TimeZone mTimeZone; + private final ServiceExceptionMapper mServiceExceptionMapper; @TestOnly SpringCredentials( @@ -31,12 +32,14 @@ public final class SpringCredentials extends Credentials { @NotNull String password, @NotNull String organization, @NotNull Locale locale, - @NotNull TimeZone timeZone) { + @NotNull TimeZone timeZone, + @NotNull ServiceExceptionMapper serviceExceptionMapper) { mUsername = username; mPassword = password; mOrganization = organization; mLocale = locale; mTimeZone = timeZone; + mServiceExceptionMapper = serviceExceptionMapper; } public static Builder builder() { @@ -73,9 +76,9 @@ protected String applyPolicy(AuthPolicy policy) throws ServiceException { try { return policy.applyCredentials(this); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } @@ -156,12 +159,14 @@ public Builder locale(@NotNull Locale locale) { public SpringCredentials build() { ensureValidState(); ensureDefaults(); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); return new SpringCredentials( mUsername, mPassword, mOrganization, mLocale, - mTimeZone); + mTimeZone, + serviceExceptionMapper); } private void ensureDefaults() { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java index 513cfb89..e3afec50 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java @@ -29,24 +29,25 @@ * @since 2.0 */ public final class StatusCodes { - public static final int UNDEFINED_ERROR = 1; - public static final int NETWORK_ERROR = 2; - public static final int CLIENT_ERROR = 3; - public static final int INTERNAL_ERROR = 4; - public static final int PERMISSION_DENIED_ERROR = 5; - public static final int AUTHORIZATION_ERROR = 6; + public static final int UNDEFINED_ERROR = 100; + public static final int NETWORK_ERROR = 102; + public static final int CLIENT_ERROR = 103; + public static final int INTERNAL_ERROR = 104; + public static final int PERMISSION_DENIED_ERROR = 105; + public static final int AUTHORIZATION_ERROR = 106; // EXPORT - public static final int EXPORT_PAGE_OUT_OF_RANGE = 100; - public static final int EXPORT_EXECUTION_CANCELLED = 101; - public static final int EXPORT_EXECUTION_FAILED = 102; + public static final int EXPORT_PAGE_OUT_OF_RANGE = 200; + public static final int EXPORT_EXECUTION_CANCELLED = 201; + public static final int EXPORT_EXECUTION_FAILED = 202; // REPORT - public static final int REPORT_EXECUTION_CANCELLED = 201; - public static final int REPORT_EXECUTION_FAILED = 202; + public static final int REPORT_EXECUTION_CANCELLED = 301; + public static final int REPORT_EXECUTION_FAILED = 302; + public static final int REPORT_EXECUTION_INVALID = 303; // RESOURCE - public static final int RESOURCE_NOT_FOUND = 300; + public static final int RESOURCE_NOT_FOUND = 400; private StatusCodes() {} } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java index 2c384c57..932dd6c5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java @@ -25,8 +25,6 @@ package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -40,15 +38,11 @@ public class DefaultCallExecutor implements CallExecutor { private final TokenCacheManager mTokenCacheManager; + private final ServiceExceptionMapper mServiceExceptionMapper; - @TestOnly - DefaultCallExecutor(TokenCacheManager tokenCacheManager) { + public DefaultCallExecutor(TokenCacheManager tokenCacheManager, ServiceExceptionMapper serviceExceptionMapper) { mTokenCacheManager = tokenCacheManager; - } - - public static DefaultCallExecutor create(RestClient client, Session session) { - TokenCacheManager cacheManager = TokenCacheManager.create(client, session); - return new DefaultCallExecutor(cacheManager); + mServiceExceptionMapper = serviceExceptionMapper; } @NotNull @@ -57,7 +51,7 @@ public T execute(Call call) throws ServiceException { String token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (HttpException e) { if (e.code() == 401) { mTokenCacheManager.invalidateToken(); @@ -66,12 +60,12 @@ public T execute(Call call) throws ServiceException { String token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e1) { - throw ServiceExceptionMapper.transform(e1); + throw mServiceExceptionMapper.transform(e1); } catch (HttpException e1) { - throw ServiceExceptionMapper.transform(e1); + throw mServiceExceptionMapper.transform(e1); } } else { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java new file mode 100644 index 00000000..c7ab6527 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.ServiceException; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DefaultExceptionMapper implements ServiceExceptionMapper { + @NotNull + public ServiceException transform(IOException e) { + return new ServiceException("Failed to perform network request. Check network!", e, StatusCodes.NETWORK_ERROR); + } + + @NotNull + public ServiceException transform(HttpException e) { + try { + ErrorDescriptor descriptor = e.getDescriptor(); + if (descriptor == null) { + return mapHttpCodesToState(e); + } else { + return mapDescriptorToState(e, descriptor); + } + } catch (IOException ioEx) { + return transform(ioEx); + } + } + + @NotNull + private static ServiceException mapHttpCodesToState(HttpException e) { + switch (e.code()) { + case 500: + return new ServiceException("Server encountered unexpected error", e, StatusCodes.INTERNAL_ERROR); + case 404: + return new ServiceException("Service exist but requested entity not found", e, StatusCodes.CLIENT_ERROR); + case 403: + return new ServiceException("User has no access to resource", e, StatusCodes.PERMISSION_DENIED_ERROR); + case 401: + return new ServiceException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); + case 400: + return new ServiceException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); + default: + return new ServiceException("The operation failed with no more detailed information", e, StatusCodes.UNDEFINED_ERROR); + } + } + + @NotNull + private static ServiceException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { + if ("resource.not.found".equals(descriptor.getErrorCode())) { + return new ServiceException(descriptor.getMessage(), e, StatusCodes.RESOURCE_NOT_FOUND); + } else if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { + return new ServiceException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); + } else { + return mapHttpCodesToState(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java new file mode 100644 index 00000000..8071e41b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExceptionMapper implements ServiceExceptionMapper { + private final ServiceExceptionMapper mDelegate; + + public ReportExceptionMapper(ServiceExceptionMapper delegate) { + mDelegate = delegate; + } + + @NotNull + @Override + public ServiceException transform(HttpException e) { + ServiceException exception = mDelegate.transform(e); + if (exception.code() == StatusCodes.RESOURCE_NOT_FOUND) { + return new ServiceException(exception.getMessage(), exception.getCause(), StatusCodes.REPORT_EXECUTION_INVALID); + } + return exception; + } + + @NotNull + @Override + public ServiceException transform(IOException e) { + return mDelegate.transform(e); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java index 133c647f..4e1afd1b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java @@ -1,34 +1,31 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -37,52 +34,9 @@ * @author Tom Koptel * @since 2.0 */ -public final class ServiceExceptionMapper { - @NotNull - public static ServiceException transform(IOException e) { - return new ServiceException("Failed to perform network request. Check network!", e, StatusCodes.NETWORK_ERROR); - } - +public interface ServiceExceptionMapper { @NotNull - public static ServiceException transform(HttpException e) { - try { - ErrorDescriptor descriptor = e.getDescriptor(); - if (descriptor == null) { - return mapHttpCodesToState(e); - } else { - return mapDescriptorToState(e, descriptor); - } - } catch (IOException ioEx) { - return transform(ioEx); - } - } - - @NotNull - private static ServiceException mapHttpCodesToState(HttpException e) { - switch (e.code()) { - case 500: - return new ServiceException("Server encountered unexpected error", e, StatusCodes.INTERNAL_ERROR); - case 404: - return new ServiceException("Service exist but requested entity not found", e, StatusCodes.CLIENT_ERROR); - case 403: - return new ServiceException("User has no access to resource", e, StatusCodes.PERMISSION_DENIED_ERROR); - case 401: - return new ServiceException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); - case 400: - return new ServiceException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); - default: - return new ServiceException("The operation failed with no more detailed information", e, StatusCodes.UNDEFINED_ERROR); - } - } - + public ServiceException transform(HttpException e); @NotNull - private static ServiceException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { - if ("resource.not.found".equals(descriptor.getErrorCode())) { - return new ServiceException(descriptor.getMessage(), e, StatusCodes.RESOURCE_NOT_FOUND); - } else if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { - return new ServiceException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); - } else { - return mapHttpCodesToState(e); - } - } + public ServiceException transform(IOException e); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java index e50c2c22..32205200 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java @@ -39,7 +39,7 @@ * @author Tom Koptel * @since 2.0 */ -class TokenCacheManager { +public class TokenCacheManager { private final AuthenticationService mAuthService; private final Credentials mCredentials; private final TokenCache mTokenCache; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index f1a76723..85c2d912 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -33,9 +33,7 @@ import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -75,7 +73,11 @@ public static ReportService create(RestClient client, Session session) { .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .baseUrl(client.getServerUrl()) .build(); - CallExecutor callExecutor = DefaultCallExecutor.create(client, session); + + ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); + ServiceExceptionMapper reportExMapper = new ReportExceptionMapper(defaultExMapper); + TokenCacheManager tokenCacheManager = TokenCacheManager.create(client, session); + CallExecutor callExecutor = new DefaultCallExecutor(tokenCacheManager, reportExMapper); ExecutionOptionsDataMapper executionOptionsMapper = ExecutionOptionsDataMapper.create(client); InfoCacheManager cacheManager = InfoCacheManager.create(client); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 21e65266..043a01e4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -27,9 +27,7 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.Session; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.*; import org.jetbrains.annotations.TestOnly; import java.util.concurrent.TimeUnit; @@ -54,7 +52,10 @@ public static RepositoryService create(RestClient client, Session session) { .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .build(); - CallExecutor callExecutor = DefaultCallExecutor.create(client, session); + ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); + TokenCacheManager tokenCacheManager = TokenCacheManager.create(client, session); + CallExecutor callExecutor = new DefaultCallExecutor(tokenCacheManager, defaultExMapper); + InfoCacheManager cacheManager = InfoCacheManager.create(client); ResourceMapper resourceMapper = new ResourceMapper(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 52b9610a..cf813b91 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -31,8 +31,9 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.TestOnly; import java.io.IOException; @@ -46,11 +47,13 @@ public class ServerInfoService { private final ServerRestApi mRestApi; private final ServerInfoTransformer mTransformer; + private final ServiceExceptionMapper mServiceExceptionMapper; @TestOnly - ServerInfoService(ServerRestApi restApi, ServerInfoTransformer transformer) { + ServerInfoService(ServerRestApi restApi, ServerInfoTransformer transformer, ServiceExceptionMapper serviceExceptionMapper) { mRestApi = restApi; mTransformer = transformer; + mServiceExceptionMapper = serviceExceptionMapper; } public static ServerInfoService create(RestClient client) { @@ -59,12 +62,14 @@ public static ServerInfoService create(RestClient client) { .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .build(); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - return new ServerInfoService(restApi, ServerInfoTransformer.get()); + return new ServerInfoService(restApi, ServerInfoTransformer.get(), serviceExceptionMapper); } public static ServerInfoService create(ServerRestApi restApi) { - return new ServerInfoService(restApi, ServerInfoTransformer.get()); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); + return new ServerInfoService(restApi, ServerInfoTransformer.get(), serviceExceptionMapper); } public ServerInfo requestServerInfo() throws ServiceException { @@ -72,9 +77,9 @@ public ServerInfo requestServerInfo() throws ServiceException { ServerInfoData response = mRestApi.requestServerInfo(); return mTransformer.transform(response); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } @@ -83,9 +88,9 @@ public ServerVersion requestServerVersion() throws ServiceException { String version = mRestApi.requestVersion(); return ServerVersion.valueOf(version); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } @@ -94,9 +99,9 @@ public SimpleDateFormat requestServerDateTimeFormat() throws ServiceException { String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); return new SimpleDateFormat(dateTimeFormat); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java index e008e588..ba9ce605 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java @@ -28,7 +28,7 @@ import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import java.io.IOException; @@ -38,9 +38,11 @@ */ public final class FakeCallExecutor implements CallExecutor { private final String mToken; + private final DefaultExceptionMapper mExMapper; public FakeCallExecutor(String token) { mToken = token; + mExMapper = new DefaultExceptionMapper(); } @Override @@ -48,9 +50,9 @@ public T execute(Call call) throws ServiceException { try { return call.perform(mToken); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mExMapper.transform(e); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mExMapper.transform(e); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java index c0abcba5..e1e491db 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java @@ -62,7 +62,7 @@ public void setUp() throws Exception { when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenReturn(mResponse); - resolver = new DefaultCallExecutor(mTokenCacheManager); + resolver = new DefaultCallExecutor(mTokenCacheManager, new DefaultExceptionMapper()); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapperTest.java similarity index 90% rename from core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapperTest.java index 18129442..5aeb2bcc 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapperTest.java @@ -51,21 +51,24 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({ErrorDescriptor.class}) -public class ServiceExceptionMapperTest { +public class DefaultExceptionMapperTest { @Mock HttpException mHttpException; @Mock ErrorDescriptor mDescriptor; + private DefaultExceptionMapper defaultExceptionMapper; + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); + defaultExceptionMapper = new DefaultExceptionMapper(); } @Test public void testTransformIOException() throws Exception { IOException ioException = new IOException("Socket timed out", new SocketTimeoutException()); - ServiceException serviceException = ServiceExceptionMapper.transform(ioException); + ServiceException serviceException = defaultExceptionMapper.transform(ioException); assertThat(serviceException.code(), is(StatusCodes.NETWORK_ERROR)); assertThat(serviceException.getMessage(), is("Failed to perform network request. Check network!")); assertThat(serviceException.getCause(), is(instanceOf(IOException.class))); @@ -76,7 +79,7 @@ public void testTransform500HttpException() throws Exception { when(mHttpException.code()).thenReturn(500); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.INTERNAL_ERROR)); assertThat(serviceException.getMessage(), is("Server encountered unexpected error")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -87,7 +90,7 @@ public void testTransform404HttpException() throws Exception { when(mHttpException.code()).thenReturn(404); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.CLIENT_ERROR)); assertThat(serviceException.getMessage(), is("Service exist but requested entity not found")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -98,7 +101,7 @@ public void testTransform400HttpException() throws Exception { when(mHttpException.code()).thenReturn(400); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.CLIENT_ERROR)); assertThat(serviceException.getMessage(), is("Some parameters in request not valid")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -109,7 +112,7 @@ public void testTransform403HttpException() throws Exception { when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); assertThat(serviceException.getMessage(), is("User has no access to resource")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -120,7 +123,7 @@ public void testTransform401HttpException() throws Exception { when(mHttpException.code()).thenReturn(401); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.AUTHORIZATION_ERROR)); assertThat(serviceException.getMessage(), is("User is not authorized")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -132,7 +135,7 @@ public void testTransformWithDescriptorWithMissingKey() throws IOException { when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenReturn(mDescriptor); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @@ -143,7 +146,7 @@ public void testTransformWillHandleIOExceptionForDescriptorMapping() throws IOEx when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenThrow(new IOException("Failed IO")); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.NETWORK_ERROR)); assertThat(serviceException.getCause(), is(instanceOf(IOException.class))); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 451110fe..a04b5db5 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -36,6 +36,7 @@ import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -46,7 +47,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -273,11 +273,8 @@ public void testUpdateExecution() throws Exception { private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); - List statuses = new ArrayList<>(); - for (String state : statusChain) { - statuses.add(Status.wrap(state)); - } - when(mReportExportUseCase.checkExportExecutionStatus(anyString(), anyString())).then(of(statuses)); + when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); + when(mReportExportUseCase.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); } private void mockRunExportExecution(String... statusChain) throws Exception { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java index 99645a6d..102f4bfa 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,13 +54,15 @@ public class ServerInfoServiceTest { ServerInfoTransformer mockTransformer; @Mock ServerInfoData mockResponse; + @Mock + ServiceExceptionMapper mockServiceExceptionMapper; private ServerInfoService serviceUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - serviceUnderTest = new ServerInfoService(mockApi, mockTransformer); + serviceUnderTest = new ServerInfoService(mockApi, mockTransformer, mockServiceExceptionMapper); } @Test From be9aac18b2d863d05bfb0e85aa30482fe74598f5 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Dec 2015 20:36:21 +0200 Subject: [PATCH 344/457] Add application/json accept header for export API --- .../jaspersoft/android/sdk/network/ReportExportRestApiImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index c9b5a8de..c61e5e11 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -132,12 +132,14 @@ Call checkReportExportStatus(@NotNull @Path("executionId") Stri * 'suppressContentDisposition' used due to security implications this header has */ @NotNull + @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") Call requestReportExportOutput(@NotNull @Path("executionId") String executionId, @NotNull @Path(value = "exportId", encoded = true) String exportId, @Header("Cookie") String cookie); @NotNull + @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") Call requestReportExportAttachmentOutput(@NotNull @Path("executionId") String executionId, @NotNull @Path(value = "exportId", encoded = true) String exportId, From 0f5f37c85bd6a5817dcbf61ccf67c5b89ed712a8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Dec 2015 20:37:16 +0200 Subject: [PATCH 345/457] Convert attachments Collection to List --- .../android/sdk/service/report/ExportFactory.java | 11 +++++------ .../android/sdk/service/report/ReportExport.java | 9 ++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index 0977e9df..2413571d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -28,14 +28,13 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - +import com.jaspersoft.android.sdk.service.exception.StatusCodes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.Collection; +import java.util.List; import java.util.Set; /** @@ -62,15 +61,15 @@ public ReportExport create( if (export == null) { throw new ServiceException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); } - Collection attachments = adaptAttachments(criteria, export); + List attachments = adaptAttachments(criteria, export); return new ReportExport(mExecutionId, exportId, attachments, criteria, mExportUseCase); } @NotNull - private Collection adaptAttachments(RunExportCriteria criteria, ExportDescriptor export) { + private List adaptAttachments(RunExportCriteria criteria, ExportDescriptor export) { String exportId = export.getId(); Set rawAttachments = export.getAttachments(); - Collection attachments = new ArrayList<>(rawAttachments.size()); + List attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { ReportAttachment reportAttachment = new ReportAttachment( attachment.getFileName(), diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index da335086..7b89698b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -26,17 +26,16 @@ import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; -import java.util.Collection; +import java.util.List; /** * @author Tom Koptel * @since 2.0 */ public final class ReportExport { - private final Collection mAttachments; + private final List mAttachments; private final String mExecutionId; private final String mExportId; private final ReportExportUseCase mExportUseCase; @@ -44,7 +43,7 @@ public final class ReportExport { ReportExport(String executionId, String exportId, - Collection attachments, + List attachments, RunExportCriteria criteria, ReportExportUseCase exportUseCase) { mExecutionId = executionId; @@ -55,7 +54,7 @@ public final class ReportExport { } @NotNull - public Collection getAttachments() { + public List getAttachments() { return mAttachments; } From b43669857012bcd1f7e6472aa762e5ddb2bdb397 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Dec 2015 21:05:33 +0200 Subject: [PATCH 346/457] Update wait conditions for report execution --- .../sdk/service/report/ReportExecution.java | 45 +++++++++---------- .../service/report/ReportExecutionTest.java | 12 +++-- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index fa4b6414..148683de 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -123,8 +123,7 @@ public ReportExport export(RunExportCriteria criteria) throws ServiceException { @NotNull private ReportMetadata performAwaitFoReport() throws ServiceException { - ReportExecutionDescriptor details = requestExecutionDetails(); - ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); + ReportExecutionDescriptor completeDetails = waitForReportReadyStart(); return new ReportMetadata(mReportUri, completeDetails.getTotalPages()); } @@ -132,17 +131,20 @@ private ReportMetadata performAwaitFoReport() throws ServiceException { @NotNull private ReportExport performExport(RunExportCriteria criteria) throws ServiceException { ExportExecutionDescriptor exportDetails = runExport(criteria); - waitForExportReadyStatus(exportDetails); + String exportId = exportDetails.getExportId(); + waitForExportReadyStatus(exportId); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); return mExportFactory.create(criteria, currentDetails, exportDetails); } - private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws ServiceException { - final String exportId = exportDetails.getExportId(); - - Status status = Status.wrap(exportDetails.getStatus()); - ErrorDescriptor descriptor = exportDetails.getErrorDescriptor(); - while (!status.isReady()) { + private void waitForExportReadyStatus(String exportId) throws ServiceException { + ExecutionStatus executionStatus; + ErrorDescriptor descriptor; + Status status; + do { + executionStatus = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); + status = Status.wrap(executionStatus.getStatus()); + descriptor = executionStatus.getErrorDescriptor(); if (status.isCancelled()) { throw new ServiceException( String.format("Export for report '%s' execution cancelled", mReportUri), null, @@ -160,19 +162,19 @@ private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) t } catch (InterruptedException ex) { throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - - ExecutionStatus executionStatus = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); - status = Status.wrap(executionStatus.getStatus()); - descriptor = executionStatus.getErrorDescriptor(); - } + } while (!status.isReady()); } @NotNull - private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor firstRunDetails) throws ServiceException { - Status status = Status.wrap(firstRunDetails.getStatus()); - ErrorDescriptor descriptor = firstRunDetails.getErrorDescriptor(); - ReportExecutionDescriptor nextDetails = firstRunDetails; - while (!status.isReady()) { + private ReportExecutionDescriptor waitForReportReadyStart() throws ServiceException { + ReportExecutionDescriptor nextDetails; + ErrorDescriptor descriptor; + Status status; + do { + nextDetails = requestExecutionDetails(); + descriptor = nextDetails.getErrorDescriptor(); + status = Status.wrap(nextDetails.getStatus()); + if (status.isCancelled()) { throw new ServiceException( String.format("Report '%s' execution cancelled", mReportUri), null, @@ -190,10 +192,7 @@ private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionD } catch (InterruptedException ex) { throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - nextDetails = requestExecutionDetails(); - status = Status.wrap(nextDetails.getStatus()); - descriptor = nextDetails.getErrorDescriptor(); - } + } while (!status.isReady()); return nextDetails; } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index a04b5db5..cd95b563 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -138,8 +138,9 @@ public void setUp() throws Exception { @Test(timeout = 2000) public void testRequestExportIdealCase() throws Exception { + mockRunExportExecution("queued"); + mockCheckExportExecStatus("ready"); mockReportExecutionDetails("ready"); - mockRunExportExecution("ready"); objectUnderTest.export(exportCriteria); @@ -150,7 +151,8 @@ public void testRequestExportIdealCase() throws Exception { @Test(timeout = 2000) public void testRunThrowsFailedStatusImmediately() throws Exception { // export run request - mockRunExportExecution("failed"); + mockRunExportExecution("queued"); + mockCheckExportExecStatus("failed"); try { objectUnderTest.export(exportCriteria); @@ -175,7 +177,8 @@ public void testRunShouldThrowFailedIfStatusFailed() throws Exception { @Test(timeout = 2000) public void testRunThrowsCancelledStatusImmediately() throws Exception { // export run request - mockRunExportExecution("cancelled"); + mockRunExportExecution("queued"); + mockCheckExportExecStatus("cancelled"); try { objectUnderTest.export(exportCriteria); @@ -211,7 +214,8 @@ public void testRunReportPendingCase() throws Exception { @Test(timeout = 2000) public void ensureThatExportCancelledEventWillBeResolved() throws Exception { - mockRunExportExecution("cancelled", "ready"); + mockRunExportExecution("queued"); + mockCheckExportExecStatus("cancelled", "ready"); mockReportExecutionDetails("ready"); objectUnderTest.export(exportCriteria); From 32a9c9470c421145fc78bf91ffae1c8a3572a9a8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Dec 2015 21:14:33 +0200 Subject: [PATCH 347/457] Force HTML format only for server version 5.5 --- .../sdk/service/report/ExecutionOptionsDataMapper.java | 3 +++ .../android/sdk/service/report/RunExportCriteria.java | 1 - .../sdk/service/report/ExecutionOptionsDataMapperTest.java | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index adb338e0..2ec61619 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -60,6 +60,9 @@ public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria mapCommonCriterion(configuration, serverVersion, options); if (serverVersion.lessThanOrEquals(ServerVersion.v5_5)) { options.withSaveDataSnapshot(null); + if (options.getOutputFormat() == null) { + options.withOutputFormat("HTML"); + } } return options; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index 5d4e9989..df0b4ec2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -51,7 +51,6 @@ public static class Builder { public Builder() { interactive = true; - format = Format.HTML; } public Builder freshData(boolean freshData) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 70de5f01..79024a13 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -136,6 +136,13 @@ public void testExportExecutionFieldsReducedForServer5_5() throws Exception { assertThat("Should reduce 'saveDataSnapshot' from options",options.getSaveDataSnapshot(), is(nullValue())); } + @Test + public void testExportExecutionSetsHtmlFormatIfOneUnspecified5_5() throws Exception { + RunExportCriteria criteria = RunExportCriteria.builder().create(); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_5); + assertThat("Should set 'HTML' format", options.getOutputFormat(), is("HTML")); + } + private void assertOptions(ExecutionRequestOptions options) { assertThat(options.getFreshData(), is(true)); assertThat(options.getSaveDataSnapshot(), is(true)); From 35af06eceb68f67975b27301f9b5d1b2ece1e103 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Dec 2015 21:23:14 +0200 Subject: [PATCH 348/457] Force HTML format for report execution on v5.5 --- .../sdk/service/report/ExecutionOptionsDataMapper.java | 6 +++--- .../android/sdk/service/report/RunReportCriteria.java | 1 - .../sdk/service/report/ExecutionOptionsDataMapperTest.java | 7 +++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index 2ec61619..1c85639a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -60,9 +60,6 @@ public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria mapCommonCriterion(configuration, serverVersion, options); if (serverVersion.lessThanOrEquals(ServerVersion.v5_5)) { options.withSaveDataSnapshot(null); - if (options.getOutputFormat() == null) { - options.withOutputFormat("HTML"); - } } return options; } @@ -83,6 +80,9 @@ private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, options.withAllowInlineScripts(null); options.withFreshData(null); options.withInteractive(null); + if (options.getOutputFormat() == null) { + options.withOutputFormat("HTML"); + } } else if (version.equals(ServerVersion.v5_6)) { options.withInteractive(false); } else { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index fb702520..f68c65f1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -82,7 +82,6 @@ public static class Builder { public Builder() { interactive = true; - format = Format.HTML; } public Builder freshData(boolean freshData) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index 79024a13..b90f0348 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -143,6 +143,13 @@ public void testExportExecutionSetsHtmlFormatIfOneUnspecified5_5() throws Except assertThat("Should set 'HTML' format", options.getOutputFormat(), is("HTML")); } + @Test + public void testReportExecutionSetsHtmlFormatIfOneUnspecified5_5() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder().create(); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); + assertThat("Should set 'HTML' format", options.getOutputFormat(), is("HTML")); + } + private void assertOptions(ExecutionRequestOptions options) { assertThat(options.getFreshData(), is(true)); assertThat(options.getSaveDataSnapshot(), is(true)); From f2e792e6c0a0e5be6578e78b7ee5ed84a80e853b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 17 Dec 2015 22:35:32 +0200 Subject: [PATCH 349/457] Implement Cookies abstraction --- .../sdk/network/AuthenticationRestApi.java | 2 +- .../network/AuthenticationRestApiImpl.java | 22 ++--- .../android/sdk/network/CookieExtractor.java | 27 +++--- .../android/sdk/network/Cookies.java | 92 +++++++++++++++++++ .../sdk/network/InputControlRestApi.java | 6 +- .../sdk/network/InputControlRestApiImpl.java | 32 +++---- .../sdk/network/ReportExecutionRestApi.java | 12 +-- .../network/ReportExecutionRestApiImpl.java | 36 ++++---- .../sdk/network/ReportExportRestApi.java | 8 +- .../sdk/network/ReportExportRestApiImpl.java | 24 ++--- .../sdk/network/ReportOptionRestApi.java | 10 +- .../sdk/network/ReportOptionRestApiImpl.java | 40 +++----- .../sdk/network/RepositoryRestApi.java | 6 +- .../sdk/network/RepositoryRestApiImpl.java | 35 +++---- .../android/sdk/service/auth/AuthPolicy.java | 5 +- .../service/auth/AuthenticationService.java | 3 +- .../android/sdk/service/auth/Credentials.java | 3 +- .../sdk/service/auth/SpringAuthService.java | 4 +- .../sdk/service/auth/SpringCredentials.java | 3 +- .../android/sdk/service/internal/Call.java | 3 +- .../service/internal/DefaultCallExecutor.java | 5 +- .../service/internal/TokenCacheManager.java | 15 +-- .../report/ReportExecutionUseCase.java | 19 ++-- .../service/report/ReportExportUseCase.java | 23 ++--- .../sdk/service/repository/SearchUseCase.java | 5 +- .../sdk/service/token/InMemoryTokenCache.java | 15 +-- .../android/sdk/service/token/TokenCache.java | 7 +- .../network/AuthenticationRestApiTest.java | 8 +- .../sdk/network/CookieExtractorTest.java | 10 +- .../sdk/network/InputControlRestApiTest.java | 46 ++++------ .../network/ReportExecutionRestApiTest.java | 61 ++++++------ .../sdk/network/ReportExportRestApiTest.java | 57 ++++++------ .../sdk/network/ReportOptionRestApiTest.java | 57 ++++++------ .../sdk/network/RepositoryRestApiTest.java | 47 +++++----- .../android/sdk/service/FakeCallExecutor.java | 9 +- .../sdk/service/InMemoryTokenCacheTest.java | 6 +- .../auth/AuthenticationServiceTest.java | 4 +- .../service/auth/SpringAuthServiceTest.java | 4 +- .../internal/DefaultCallExecutorTest.java | 28 +++--- .../internal/TokenCacheManagerTest.java | 12 ++- .../report/ReportExecutionUseCaseTest.java | 13 +-- .../report/ReportExportUseCaseTest.java | 21 +++-- .../service/repository/SearchUseCaseTest.java | 9 +- .../api/AuthenticationRestApiTest.java | 5 +- .../api/ReportOptionRestApiTest.java | 9 +- .../api/utils/DummyTokenProvider.java | 9 +- 46 files changed, 484 insertions(+), 393 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index e6723fbc..5ebd19b8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -40,7 +40,7 @@ */ public interface AuthenticationRestApi { @NotNull - String authenticate(@NotNull String username, + Cookies authenticate(@NotNull String username, @NotNull String password, @Nullable String organization, @Nullable Map params) throws HttpException, IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java index e3674cbf..cf5d8e98 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java @@ -26,24 +26,18 @@ import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; -import com.squareup.okhttp.Call; -import com.squareup.okhttp.FormEncodingBuilder; -import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; - +import com.squareup.okhttp.*; import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.util.Map; -import java.util.Set; - import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; import retrofit.http.Header; import retrofit.http.Headers; +import java.io.IOException; +import java.util.Map; +import java.util.Set; + /** * TODO refactor following module in easy testable units * @@ -63,7 +57,7 @@ final class AuthenticationRestApiImpl implements AuthenticationRestApi { @NotNull @Override - public String authenticate(@NotNull final String username, + public Cookies authenticate(@NotNull final String username, @NotNull final String password, final String organization, final Map params) throws HttpException, IOException { @@ -99,12 +93,12 @@ public String authenticate(@NotNull final String username, public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { RestApi api = mRestAdapterBuilder.build().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); - String anonymousToken = CookieExtractor.extract(response.raw()); + Cookies anonymousCookies = CookieExtractor.extract(response.raw()); RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); try { - return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata(anonymousToken)).body(); + return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata(anonymousCookies.toString())).body(); } catch (JsonSyntaxException ex) { /** * This possible when security option is disabled on JRS side. diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java index 2e1545b3..e65b52c5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java @@ -26,7 +26,8 @@ import com.squareup.okhttp.Response; -import java.util.Iterator; +import java.net.HttpCookie; +import java.util.ArrayList; import java.util.List; @@ -38,21 +39,21 @@ final class CookieExtractor { private CookieExtractor() { } - public static String extract(Response response) { - List parts = response.headers().values("Set-Cookie"); - return joinCookieParts(parts).toString(); + public static Cookies extract(Response response) { + List headers = response.headers().values("Set-Cookie"); + List cookies = joinCookieHeaders(headers); + return new Cookies(cookies); } - private static StringBuilder joinCookieParts(List parts) { - StringBuilder stringBuilder = new StringBuilder(); - Iterator iterator = parts.iterator(); - while (iterator.hasNext()) { - String cookie = iterator.next(); - stringBuilder.append(cookie); - if (iterator.hasNext()) { - stringBuilder.append(";"); + private static List joinCookieHeaders(List headers) { + List cookies; + List result = new ArrayList<>(headers.size()); + for (String header : headers) { + cookies = HttpCookie.parse(header); + if (!cookies.isEmpty()) { + result.add(cookies.get(0).toString()); } } - return stringBuilder; + return result; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java new file mode 100644 index 00000000..46074ffa --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java @@ -0,0 +1,92 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + +import java.util.*; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class Cookies { + + private final List mCookies = new ArrayList<>(3); + + @TestOnly + Cookies(List cookies) { + mCookies.addAll(cookies); + } + + @NotNull + public List get() { + return mCookies; + } + + public static Cookies parse(String cookiesString) { + Utils.checkNotNull(cookiesString, "Cookies should not be null"); + Utils.checkNotNull(cookiesString.length() > 0, "Cookies should not be empty String"); + if (cookiesString.contains(";")) { + String[] cookies = cookiesString.split(";"); + if (cookies.length == 0) { + return new Cookies(Collections.emptyList()); + } + return new Cookies(Arrays.asList(cookies)); + } + return new Cookies(Collections.singletonList(cookiesString)); + } + + @Override + public String toString() { + Iterator iterator = mCookies.iterator(); + StringBuilder result = new StringBuilder(); + while (iterator.hasNext()) { + result.append(iterator.next()); + if (iterator.hasNext()) { + result.append(";"); + } + } + return result.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Cookies cookies = (Cookies) o; + + if (mCookies != null ? !mCookies.equals(cookies.mCookies) : cookies.mCookies != null) return false; + + return true; + } + + @Override + public int hashCode() { + return mCookies != null ? mCookies.hashCode() : 0; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index df389bc6..c8eab006 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -51,12 +51,12 @@ public interface InputControlRestApi { * @return unmodifiable list of {@link InputControl} */ @NotNull - Collection requestInputControls(@NotNull String token, + Collection requestInputControls(@NotNull Cookies cookies, @NotNull String reportUri, boolean excludeState) throws HttpException, IOException; @NotNull - Collection requestInputControlsInitialStates(@NotNull String token, + Collection requestInputControlsInitialStates(@NotNull Cookies cookies, @NotNull String reportUri, boolean freshData) throws HttpException, IOException; @@ -71,7 +71,7 @@ Collection requestInputControlsInitialStates(@NotNull String * @return unmodifiable list of {@link InputControlState} */ @NotNull - Collection requestInputControlsStates(@NotNull String token, + Collection requestInputControlsStates(@NotNull Cookies cookies, @NotNull String reportUri, @NotNull Map> controlsValues, boolean freshData) throws HttpException, IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java index a5fbce6b..87fae285 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java @@ -29,25 +29,17 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; import java.util.Collection; import java.util.Map; import java.util.Set; -import retrofit.Call; -import retrofit.Retrofit; -import retrofit.http.Body; -import retrofit.http.GET; -import retrofit.http.Header; -import retrofit.http.Headers; -import retrofit.http.POST; -import retrofit.http.Path; -import retrofit.http.Query; - /** * @author Tom Koptel * @since 2.0 @@ -61,43 +53,43 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NotNull @Override - public Collection requestInputControls(@Nullable String token, + public Collection requestInputControls(@Nullable Cookies cookies, @Nullable String reportUri, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); String state = (excludeState ? "state" : null); - Call call = mRestApi.requestInputControls(reportUri, state, token); + Call call = mRestApi.requestInputControls(reportUri, state, cookies.toString()); InputControlCollection response = CallWrapper.wrap(call).body(); return response.get(); } @NotNull @Override - public Collection requestInputControlsInitialStates(@Nullable String token, + public Collection requestInputControlsInitialStates(@Nullable Cookies cookies, @Nullable String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData, token); + Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData, cookies.toString()); InputControlStateCollection response = CallWrapper.wrap(call).body(); return response.get(); } @NotNull @Override - public Collection requestInputControlsStates(@Nullable String token, + public Collection requestInputControlsStates(@Nullable Cookies cookies, @Nullable String reportUri, @Nullable Map> controlsValues, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); String ids = Utils.joinString(";", controlsValues.keySet()); - Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData, token); + Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData, cookies.toString()); InputControlStateCollection response = CallWrapper.wrap(call).body(); return response.get(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index 906650d2..361b4bea 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -42,27 +42,27 @@ public interface ReportExecutionRestApi { @NotNull - ReportExecutionDescriptor runReportExecution(@NotNull String token, + ReportExecutionDescriptor runReportExecution(@NotNull Cookies cookies, @NotNull ReportExecutionRequestOptions executionOptions) throws HttpException, IOException; @NotNull - ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String token, + ReportExecutionDescriptor requestReportExecutionDetails(@NotNull Cookies cookies, @NotNull String executionId) throws HttpException, IOException; @NotNull - ExecutionStatus requestReportExecutionStatus(@NotNull String token, + ExecutionStatus requestReportExecutionStatus(@NotNull Cookies cookies, @NotNull String executionId) throws HttpException, IOException; - boolean cancelReportExecution(@NotNull String token, + boolean cancelReportExecution(@NotNull Cookies cookies, @NotNull String executionId) throws HttpException, IOException; - boolean updateReportExecution(@NotNull String token, + boolean updateReportExecution(@NotNull Cookies cookies, @NotNull String executionId, @NotNull List params) throws HttpException, IOException; // TODO: API is broken requires investigation before release @NotNull - ReportExecutionSearchResponse searchReportExecution(@NotNull String token, Map params) throws HttpException, IOException; + ReportExecutionSearchResponse searchReportExecution(@NotNull Cookies cookies, Map params) throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java index a9581e76..5accfd41 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java @@ -54,59 +54,59 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NotNull @Override - public ReportExecutionDescriptor runReportExecution(@Nullable String token, + public ReportExecutionDescriptor runReportExecution(@Nullable Cookies cookies, @Nullable ReportExecutionRequestOptions executionOptions) throws IOException, HttpException { Utils.checkNotNull(executionOptions, "Execution options should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.runReportExecution(executionOptions, token); + Call call = mRestApi.runReportExecution(executionOptions, cookies.toString()); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String token, + public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable Cookies cookies, @Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExecutionDetails(executionId, token); + Call call = mRestApi.requestReportExecutionDetails(executionId, cookies.toString()); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ExecutionStatus requestReportExecutionStatus(@Nullable String token, + public ExecutionStatus requestReportExecutionStatus(@Nullable Cookies cookies, @Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExecutionStatus(executionId, token); + Call call = mRestApi.requestReportExecutionStatus(executionId, cookies.toString()); return CallWrapper.wrap(call).body(); } @Override - public boolean cancelReportExecution(@Nullable String token, + public boolean cancelReportExecution(@Nullable Cookies cookies, @Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus(), token); + Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus(), cookies.toString()); Response response = CallWrapper.wrap(call).response(); int status = response.code(); return status != 204; } @Override - public boolean updateReportExecution(@Nullable String token, + public boolean updateReportExecution(@Nullable Cookies cookies, @Nullable String executionId, @Nullable List params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.updateReportExecution(executionId, params, token); + Call call = mRestApi.updateReportExecution(executionId, params, cookies.toString()); Response response = CallWrapper.wrap(call).response(); int status = response.code(); return status == 204; @@ -114,13 +114,13 @@ public boolean updateReportExecution(@Nullable String token, @NotNull @Override - public ReportExecutionSearchResponse searchReportExecution(@Nullable String token, + public ReportExecutionSearchResponse searchReportExecution(@Nullable Cookies cookies, @Nullable Map params) throws IOException, HttpException { Utils.checkNotNull(params, "Search params should not be null"); Utils.checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.searchReportExecution(params, token); + Call call = mRestApi.searchReportExecution(params, cookies.toString()); ReportExecutionSearchResponse body = CallWrapper.wrap(call).body(); if (body == null) { return ReportExecutionSearchResponse.empty(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java index 9d0c9ed8..632ccfaa 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java @@ -42,22 +42,22 @@ public interface ReportExportRestApi { @NotNull - ExportExecutionDescriptor runExportExecution(@NotNull String token, + ExportExecutionDescriptor runExportExecution(@NotNull Cookies cookies, @NotNull String executionId, @NotNull ExecutionRequestOptions executionOptions) throws HttpException, IOException; @NotNull - ExecutionStatus checkExportExecutionStatus(@NotNull String token, + ExecutionStatus checkExportExecutionStatus(@NotNull Cookies cookies, @NotNull String executionId, @NotNull String exportId) throws HttpException, IOException; @NotNull - ExportOutputResource requestExportOutput(@NotNull String token, + ExportOutputResource requestExportOutput(@NotNull Cookies cookies, @NotNull String executionId, @NotNull String exportId) throws HttpException, IOException; @NotNull - OutputResource requestExportAttachment(@NotNull String token, + OutputResource requestExportAttachment(@NotNull Cookies cookies, @NotNull String executionId, @NotNull String exportId, @NotNull String attachmentId) throws HttpException, IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index c61e5e11..bef2094b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -52,40 +52,40 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @NotNull @Override - public ExportExecutionDescriptor runExportExecution(@Nullable String token, + public ExportExecutionDescriptor runExportExecution(@Nullable Cookies cookies, @Nullable String executionId, @Nullable ExecutionRequestOptions executionOptions) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(executionOptions, "Execution options should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.runReportExportExecution(executionId, executionOptions, token); + Call call = mRestApi.runReportExportExecution(executionId, executionOptions, cookies.toString()); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ExecutionStatus checkExportExecutionStatus(@Nullable String token, + public ExecutionStatus checkExportExecutionStatus(@Nullable Cookies cookies, @Nullable String executionId, @Nullable String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.checkReportExportStatus(executionId, exportId, token); + Call call = mRestApi.checkReportExportStatus(executionId, exportId, cookies.toString()); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ExportOutputResource requestExportOutput(@Nullable String token, + public ExportOutputResource requestExportOutput(@Nullable Cookies cookies, @Nullable String executionId, @Nullable String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExportOutput(executionId, exportId, token); + Call call = mRestApi.requestReportExportOutput(executionId, exportId, cookies.toString()); Response rawResponse = CallWrapper.wrap(call).response(); com.squareup.okhttp.Headers headers = rawResponse.headers(); @@ -98,16 +98,16 @@ public ExportOutputResource requestExportOutput(@Nullable String token, @NotNull @Override - public OutputResource requestExportAttachment(@Nullable String token, + public OutputResource requestExportAttachment(@Nullable Cookies cookies, @Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); Utils.checkNotNull(attachmentId, "Attachment id should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId, token); + Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId, cookies.toString()); Response rawResponse = CallWrapper.wrap(call).response(); ResponseBody body = rawResponse.body(); return new RetrofitOutputResource(body); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java index 26b35cc1..d11f1efb 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java @@ -39,21 +39,21 @@ public interface ReportOptionRestApi { @NotNull - Set requestReportOptionsList(@NotNull String reportUnitUri, - @NotNull String token) throws HttpException, IOException; + Set requestReportOptionsList(@NotNull Cookies cookies, + @NotNull String reportUnitUri) throws HttpException, IOException; @NotNull - ReportOption createReportOption(@NotNull String token, @NotNull String reportUnitUri, + ReportOption createReportOption(@NotNull Cookies cookies, @NotNull String reportUnitUri, @NotNull String optionLabel, @NotNull Map> controlsValues, boolean overwrite) throws HttpException, IOException; - void updateReportOption(@NotNull String token, + void updateReportOption(@NotNull Cookies cookies, @NotNull String reportUnitUri, @NotNull String optionId, @NotNull Map> controlsValues) throws HttpException, IOException; - void deleteReportOption(@NotNull String token, + void deleteReportOption(@NotNull Cookies cookies, @NotNull String reportUnitUri, @NotNull String optionId) throws HttpException, IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java index 409a1934..9f35d442 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java @@ -28,27 +28,17 @@ import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import com.squareup.okhttp.Response; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.Set; -import retrofit.Call; -import retrofit.Retrofit; -import retrofit.http.Body; -import retrofit.http.DELETE; -import retrofit.http.GET; -import retrofit.http.Header; -import retrofit.http.Headers; -import retrofit.http.POST; -import retrofit.http.PUT; -import retrofit.http.Path; -import retrofit.http.Query; - /** * @author Tom Koptel * @since 2.0 @@ -62,12 +52,12 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { @NotNull @Override - public Set requestReportOptionsList(@Nullable String token, + public Set requestReportOptionsList(@Nullable Cookies cookies, @Nullable String reportUnitUri) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportOptionsList(reportUnitUri, token); + Call call = mRestApi.requestReportOptionsList(reportUnitUri, cookies.toString()); try { ReportOptionSet options = CallWrapper.wrap(call).body(); return options.get(); @@ -83,7 +73,7 @@ public Set requestReportOptionsList(@Nullable String token, @NotNull @Override - public ReportOption createReportOption(@Nullable String token, + public ReportOption createReportOption(@Nullable Cookies cookies, @Nullable String reportUnitUri, @Nullable String optionLabel, @Nullable Map> controlsValues, @@ -91,35 +81,35 @@ public ReportOption createReportOption(@Nullable String token, Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionLabel, "Option label should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite, token); + Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite, cookies.toString()); return CallWrapper.wrap(call).body(); } @Override - public void updateReportOption(@Nullable String token, + public void updateReportOption(@Nullable Cookies cookies, @Nullable String reportUnitUri, @Nullable String optionId, @Nullable Map> controlsValues) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues, token); + Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues, cookies.toString()); CallWrapper.wrap(call).body(); } @Override - public void deleteReportOption(@Nullable String token, + public void deleteReportOption(@Nullable Cookies cookies, @Nullable String reportUnitUri, @Nullable String optionId) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.deleteReportOption(reportUnitUri, optionId, token); + Call call = mRestApi.deleteReportOption(reportUnitUri, optionId, cookies.toString()); CallWrapper.wrap(call).body(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java index e4415ced..2409b5c6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java @@ -41,15 +41,15 @@ */ public interface RepositoryRestApi { @NotNull - ResourceSearchResult searchResources(@NotNull String token, + ResourceSearchResult searchResources(@NotNull Cookies cookies, @Nullable Map searchParams) throws HttpException, IOException; @NotNull - ReportLookup requestReportResource(@NotNull String token, + ReportLookup requestReportResource(@NotNull Cookies cookies, @NotNull String resourceUri) throws HttpException, IOException; @NotNull - FolderLookup requestFolderResource(@NotNull String token, + FolderLookup requestFolderResource(@NotNull Cookies cookies, @NotNull String resourceUri) throws HttpException, IOException; final class Builder extends GenericBuilder { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java index a5f47e37..2492473c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java @@ -27,24 +27,17 @@ import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import retrofit.Call; -import retrofit.Response; -import retrofit.Retrofit; -import retrofit.http.GET; -import retrofit.http.Header; -import retrofit.http.Headers; -import retrofit.http.Path; -import retrofit.http.Query; -import retrofit.http.QueryMap; - /** * @author Tom Koptel * @since 2.0 @@ -58,15 +51,15 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NotNull @Override - public ResourceSearchResult searchResources(@Nullable String token, + public ResourceSearchResult searchResources(@Nullable Cookies cookies, @Nullable Map searchParams) throws IOException, HttpException { - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); Iterable types = null; Call call; if (searchParams == null) { - call = mRestApi.searchResources(null, null, token); + call = mRestApi.searchResources(null, null, cookies.toString()); } else { Map copy = new HashMap<>(searchParams); Object typeValues = copy.get("type"); @@ -79,7 +72,7 @@ public ResourceSearchResult searchResources(@Nullable String token, types = (Iterable) typeValues; } - call = mRestApi.searchResources(copy, types, token); + call = mRestApi.searchResources(copy, types, cookies.toString()); } Response rawResponse = CallWrapper.wrap(call).response(); @@ -107,23 +100,23 @@ public ResourceSearchResult searchResources(@Nullable String token, @NotNull @Override - public ReportLookup requestReportResource(@Nullable String token, + public ReportLookup requestReportResource(@Nullable Cookies cookies, @Nullable String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Report uri should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportResource(resourceUri, token); + Call call = mRestApi.requestReportResource(resourceUri, cookies.toString()); return CallWrapper.wrap(call).body(); } @NotNull @Override - public FolderLookup requestFolderResource(@Nullable String token, + public FolderLookup requestFolderResource(@Nullable Cookies cookies, @Nullable String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Folder uri should not be null"); - Utils.checkNotNull(token, "Request token should not be null"); + Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestFolderResource(resourceUri, token); + Call call = mRestApi.requestFolderResource(resourceUri, cookies.toString()); return CallWrapper.wrap(call).body(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java index ceebd9cd..8a5b48f8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java @@ -1,6 +1,7 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import org.jetbrains.annotations.NotNull; @@ -12,7 +13,7 @@ * @since 2.0 */ interface AuthPolicy { - String applyCredentials(SpringCredentials credentials) throws IOException, HttpException; + Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException; class Default implements AuthPolicy { private final SpringAuthService mSpringService; @@ -34,7 +35,7 @@ public static Default create(@NotNull String baseUrl) { } @Override - public String applyCredentials(SpringCredentials credentials) throws IOException, HttpException { + public Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException { return mSpringService.authenticate(credentials); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java index 2dc7a820..76616be4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java @@ -1,6 +1,7 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -35,7 +36,7 @@ public static AuthenticationService create(@NotNull RestClient mClient) { } @NotNull - public String authenticate(@NotNull Credentials credentials) throws ServiceException { + public Cookies authenticate(@NotNull Credentials credentials) throws ServiceException { checkNotNull(credentials, "Credentials should not be null"); return credentials.applyPolicy(mAuthPolicy); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java index 8436dca0..0bb0ba9a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java @@ -1,5 +1,6 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.service.exception.ServiceException; /** @@ -7,5 +8,5 @@ * @since 2.0 */ public abstract class Credentials { - protected abstract String applyPolicy(AuthPolicy authPolicy) throws ServiceException; + protected abstract Cookies applyPolicy(AuthPolicy authPolicy) throws ServiceException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java index 3ddc5e04..3f7c7f30 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java @@ -25,10 +25,10 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -71,7 +71,7 @@ public static SpringAuthService create(@NotNull AuthenticationRestApi restApi) { } @NotNull - public String authenticate(SpringCredentials credentials) throws IOException, HttpException { + public Cookies authenticate(SpringCredentials credentials) throws IOException, HttpException { String password = credentials.getPassword(); EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index 6041892e..38f71268 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -1,5 +1,6 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; @@ -72,7 +73,7 @@ public Locale getLocale() { } @Override - protected String applyPolicy(AuthPolicy policy) throws ServiceException { + protected Cookies applyPolicy(AuthPolicy policy) throws ServiceException { try { return policy.applyCredentials(this); } catch (HttpException e) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java index 754072c0..093cb99c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.internal; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import java.io.IOException; @@ -33,5 +34,5 @@ * @since 2.0 */ public interface Call { - T perform(String token) throws IOException, HttpException; + T perform(Cookies cookies) throws IOException, HttpException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java index 932dd6c5..f76131ba 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.internal; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -48,7 +49,7 @@ public DefaultCallExecutor(TokenCacheManager tokenCacheManager, ServiceException @NotNull public T execute(Call call) throws ServiceException { try { - String token = mTokenCacheManager.loadToken(); + Cookies token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e) { throw mServiceExceptionMapper.transform(e); @@ -57,7 +58,7 @@ public T execute(Call call) throws ServiceException { mTokenCacheManager.invalidateToken(); try { - String token = mTokenCacheManager.loadToken(); + Cookies token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e1) { throw mServiceExceptionMapper.transform(e1); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java index 32205200..d279ac6f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.internal; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.Session; @@ -65,16 +66,16 @@ public static TokenCacheManager create(RestClient restClient, Session session) { } @NotNull - public String loadToken() throws IOException, HttpException { - String token = mTokenCache.get(mBaseUrl); - if (token != null) { - return token; + public Cookies loadToken() throws IOException, HttpException { + Cookies cookies = mTokenCache.get(mBaseUrl); + if (cookies != null) { + return cookies; } try { - token = mAuthService.authenticate(mCredentials); - mTokenCache.put(mBaseUrl, token); - return token; + cookies = mAuthService.authenticate(mCredentials); + mTokenCache.put(mBaseUrl, cookies); + return cookies; } catch (ServiceException e) { if (e.getCause() instanceof HttpException) { throw (HttpException) e.getCause(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 63086aea..743e25ee 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -32,9 +33,9 @@ import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; @@ -67,10 +68,10 @@ public ReportExecutionDescriptor runReportExecution(final String reportUri, fina final ServerVersion version = info.getVersion(); Call call = new Call() { @Override - public ReportExecutionDescriptor perform(String token) throws IOException, HttpException { + public ReportExecutionDescriptor perform(Cookies cookies) throws IOException, HttpException { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, version, criteria); - return mExecutionApi.runReportExecution(token, options); + return mExecutionApi.runReportExecution(cookies, options); } }; return mCallExecutor.execute(call); @@ -80,8 +81,8 @@ public ReportExecutionDescriptor perform(String token) throws IOException, HttpE public ExecutionStatus requestStatus(final String executionId) throws ServiceException { Call call = new Call() { @Override - public ExecutionStatus perform(String token) throws IOException, HttpException { - return mExecutionApi.requestReportExecutionStatus(token, executionId); + public ExecutionStatus perform(Cookies cookies) throws IOException, HttpException { + return mExecutionApi.requestReportExecutionStatus(cookies, executionId); } }; return mCallExecutor.execute(call); @@ -91,8 +92,8 @@ public ExecutionStatus perform(String token) throws IOException, HttpException { public ReportExecutionDescriptor requestExecutionDetails(final String executionId) throws ServiceException { Call call = new Call() { @Override - public ReportExecutionDescriptor perform(String token) throws IOException, HttpException { - return mExecutionApi.requestReportExecutionDetails(token, executionId); + public ReportExecutionDescriptor perform(Cookies cookies) throws IOException, HttpException { + return mExecutionApi.requestReportExecutionDetails(cookies, executionId); } }; return mCallExecutor.execute(call); @@ -101,8 +102,8 @@ public ReportExecutionDescriptor perform(String token) throws IOException, HttpE public void updateExecution(final String executionId, final List newParameters) throws ServiceException { Call call = new Call() { @Override - public Void perform(String token) throws IOException, HttpException { - mExecutionApi.updateReportExecution(token, executionId, newParameters); + public Void perform(Cookies cookies) throws IOException, HttpException { + mExecutionApi.updateReportExecution(cookies, executionId, newParameters); return null; } }; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index ca1b6a89..38261712 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; @@ -31,13 +32,13 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.ReportOutput; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.data.report.ReportOutput; -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; @@ -70,9 +71,9 @@ public ExportExecutionDescriptor runExport(final String executionId, final RunEx Call call = new Call() { @Override - public ExportExecutionDescriptor perform(String token) throws IOException, HttpException { + public ExportExecutionDescriptor perform(Cookies cookies) throws IOException, HttpException { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria, version); - return mExportApi.runExportExecution(token, executionId, options); + return mExportApi.runExportExecution(cookies, executionId, options); } }; return mCallExecutor.execute(call); @@ -89,8 +90,8 @@ public ExecutionStatus checkExportExecutionStatus(final String executionId, Call call = new Call() { @Override - public ExecutionStatus perform(String token) throws IOException, HttpException { - return mExportApi.checkExportExecutionStatus(token, executionId, exportId); + public ExecutionStatus perform(Cookies cookies) throws IOException, HttpException { + return mExportApi.checkExportExecutionStatus(cookies, executionId, exportId); } }; return mCallExecutor.execute(call); @@ -105,8 +106,8 @@ public ReportOutput requestExportOutput(RunExportCriteria exportCriteria, Call call = new Call() { @Override - public ReportOutput perform(String token) throws IOException, HttpException { - ExportOutputResource result = mExportApi.requestExportOutput(token, executionId, resultId); + public ReportOutput perform(Cookies cookies) throws IOException, HttpException { + ExportOutputResource result = mExportApi.requestExportOutput(cookies, executionId, resultId); return OutputDataMapper.transform(result); } }; @@ -123,9 +124,9 @@ public ResourceOutput requestExportAttachmentOutput(RunExportCriteria exportCrit Call call = new Call() { @Override - public ResourceOutput perform(String token) throws IOException, HttpException { + public ResourceOutput perform(Cookies cookies) throws IOException, HttpException { OutputResource result = mExportApi.requestExportAttachment( - token, executionId, resultId, fileName); + cookies, executionId, resultId, fileName); return OutputDataMapper.transform(result); } }; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 88af9b50..849f0160 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; @@ -65,9 +66,9 @@ public SearchResult performSearch(@NotNull final InternalCriteria internalCriter final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call call = new Call() { @Override - public SearchResult perform(String token) throws IOException, HttpException { + public SearchResult perform(Cookies cookies) throws IOException, HttpException { Map criteria = CriteriaMapper.map(internalCriteria); - ResourceSearchResult response = mRestApi.searchResources(token, criteria); + ResourceSearchResult response = mRestApi.searchResources(cookies, criteria); SearchResult searchResult = new SearchResult(); searchResult.setNextOffset(response.getNextOffset()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java index c1b957a2..e117fdd6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.token; +import com.jaspersoft.android.sdk.network.Cookies; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,21 +36,21 @@ * @since 2.0 */ public final class InMemoryTokenCache implements TokenCache { - private final Map mCache = new WeakHashMap(); + private final Map mCache = new WeakHashMap(); @Nullable @Override - public String get(@NotNull String key) { - return mCache.get(key); + public Cookies get(@NotNull String host) { + return mCache.get(host); } @Override - public void put(@NotNull String key, @NotNull String token) { - mCache.put(key, token); + public void put(@NotNull String host, @NotNull Cookies cookies) { + mCache.put(host, cookies); } @Override - public void remove(@NotNull String key) { - mCache.remove(key); + public void remove(@NotNull String host) { + mCache.remove(host); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java index d3fa99db..d78681ea 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.token; +import com.jaspersoft.android.sdk.network.Cookies; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,9 +34,9 @@ */ public interface TokenCache { @Nullable - String get(@NotNull String key); + Cookies get(@NotNull String host); - void put(@NotNull String key, @NotNull String token); + void put(@NotNull String host, @NotNull Cookies cookies); - void remove(@NotNull String key); + void remove(@NotNull String host); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index 6794a2d9..c90d05f5 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -70,11 +70,11 @@ public void setup() { @Test public void shouldReturnResponseForSuccessRedirect() throws Exception { MockResponse mockResponse = MockResponseFactory.create302() - .addHeader("Set-Cookie", "cookie1") + .addHeader("Set-Cookie", "cookie1=12") .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - String response = mRestApi.authenticate("joeuser", "joeuser", null, null); + Cookies response = mRestApi.authenticate("joeuser", "joeuser", null, null); assertThat(response, is(notNullValue())); } @@ -103,7 +103,7 @@ public void shouldRiseErrorForHttpException() throws Exception { public void shouldReturnEncryptionKeyIfApiAvailable() throws Exception { MockResponse anonymousCookie = MockResponseFactory.create200() .setBody("6.1") - .addHeader("Set-Cookie", "cookie1"); + .addHeader("Set-Cookie", "cookie1=12"); MockResponse encryptionKey = MockResponseFactory.create200() .setBody(mKey.asString()); mWebMockRule.enqueue(anonymousCookie); @@ -117,7 +117,7 @@ public void shouldReturnEncryptionKeyIfApiAvailable() throws Exception { public void shouldReturnEmptyEncryptionKeyIfApiNotAvailable() throws Exception { MockResponse anonymousCookie = MockResponseFactory.create200() .setBody("6.1") - .addHeader("Set-Cookie", "cookie1"); + .addHeader("Set-Cookie", "cookie1=12"); String malformedJson = "{Error: Key generation is off}"; MockResponse encryptionKey = MockResponseFactory.create200() diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java index dae9b752..0b9e4ff5 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java @@ -24,11 +24,9 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.CookieExtractor; import com.squareup.okhttp.Protocol; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; - import org.junit.Before; import org.junit.Test; @@ -53,14 +51,14 @@ public void setup() { @Test public void shouldExtractTokenFromNetworkResponse() { Response mockResponse = new Response.Builder() - .addHeader("Set-Cookie", "cookie1") - .addHeader("Set-Cookie", "cookie2") + .addHeader("Set-Cookie", "cookie1=12") + .addHeader("Set-Cookie", "cookie2=34") .code(200) .protocol(Protocol.HTTP_1_1) .request(mRequest) .build(); - String token = CookieExtractor.extract(mockResponse); - assertThat(token, is("cookie1;cookie2")); + Cookies cookies = CookieExtractor.extract(mockResponse); + assertThat(cookies.toString(), is("cookie1=12;cookie2=34")); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index 3f34409e..f7c6be06 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -33,20 +33,13 @@ import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; import com.squareup.okhttp.mockwebserver.RecordedRequest; - import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.nullValue; @@ -67,6 +60,7 @@ public class InputControlRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private InputControlRestApi restApiUnderTest; + private final Cookies fakeCookies = Cookies.parse("key=value"); @ResourceFile("json/input_controls_states_list.json") TestResource icsStates; @@ -87,13 +81,13 @@ public void setup() { public void requestInputControlsShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControls("cookie", null, false); + restApiUnderTest.requestInputControls(fakeCookies, null, false); } @Test - public void requestInputControlsInitialStatesShouldNotAllowNullToken() throws Exception { + public void requestInputControlsInitialStatesShouldNotAllowNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestInputControlsInitialStates(null, "/uri", false); } @@ -101,20 +95,20 @@ public void requestInputControlsInitialStatesShouldNotAllowNullToken() throws Ex public void requestInputControlsStatesShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsStates("cookie", null, Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates(fakeCookies, null, Collections.EMPTY_MAP, true); } @Test public void requestInputControlsStatesShouldNotAllowNullControlParams() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.requestInputControlsStates("cookie", "any_id", null, true); + restApiUnderTest.requestInputControlsStates(fakeCookies, "any_id", null, true); } @Test - public void requestInputControlsStatesShouldNotAllowNullToken() throws Exception { + public void requestInputControlsStatesShouldNotAllowNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestInputControlsStates(null, "any_id", Collections.EMPTY_MAP, true); } @@ -122,21 +116,21 @@ public void requestInputControlsStatesShouldNotAllowNullToken() throws Exception public void requestInputControlsShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControls("cookie", "any_id", true); + restApiUnderTest.requestInputControls(fakeCookies, "any_id", true); } @Test public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsInitialStates("cookie", "any_id", true); + restApiUnderTest.requestInputControlsInitialStates(fakeCookies, "any_id", true); } @Test public void requestInputControlsStatesShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsStates("cookie", "any_id", Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates(fakeCookies, "any_id", Collections.EMPTY_MAP, true); } @Test @@ -145,12 +139,12 @@ public void apiShouldProvideListOfInputControlsInitialStatesWithFreshData() thro .setBody(icsStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection states = restApiUnderTest.requestInputControlsInitialStates("cookie", "/my/uri", true); + Collection states = restApiUnderTest.requestInputControlsInitialStates(fakeCookies, "/my/uri", true); assertThat(states, is(not(empty()))); RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls/values?freshData=true")); - assertThat(response.getHeader("Cookie"), is("cookie")); + assertThat(response.getHeader("Cookie"), is("key=value")); } @Test @@ -164,12 +158,12 @@ public void apiShouldProvideFreshStatesForInputControls() throws Exception { .setBody(icsStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection states = restApiUnderTest.requestInputControlsStates("cookie", "/my/uri", parameters, true); + Collection states = restApiUnderTest.requestInputControlsStates(fakeCookies, "/my/uri", parameters, true); assertThat(states, Matchers.is(not(Matchers.empty()))); RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls/sales_fact_ALL__store_sales_2013_1/values?freshData=true")); - assertThat(response.getHeader("Cookie"), is("cookie")); + assertThat(response.getHeader("Cookie"), is("key=value")); } @Test @@ -178,13 +172,13 @@ public void apiShouldProvideInputControlsListIfStateExcluded() throws Exception .setBody(icsWithoutStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection controls = restApiUnderTest.requestInputControls("cookie", "/my/uri", true); + Collection controls = restApiUnderTest.requestInputControls(fakeCookies, "/my/uri", true); assertThat(controls, Matchers.is(not(Matchers.empty()))); assertThat(new ArrayList<>(controls).get(0).getState(), is(nullValue())); RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls?exclude=state")); - assertThat(response.getHeader("Cookie"), is("cookie")); + assertThat(response.getHeader("Cookie"), is("key=value")); } @Test @@ -193,12 +187,12 @@ public void apiShouldProvideInputControlsWithStates() throws Exception { .setBody(icsWithStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection controls = restApiUnderTest.requestInputControls("cookie", "/my/uri", false); + Collection controls = restApiUnderTest.requestInputControls(fakeCookies, "/my/uri", false); assertThat(controls, Matchers.is(not(Matchers.empty()))); assertThat(new ArrayList<>(controls).get(0).getState(), is(not(nullValue()))); RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls")); - assertThat(response.getHeader("Cookie"), is("cookie")); + assertThat(response.getHeader("Cookie"), is("key=value")); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index 2ea988ec..bca752f8 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -78,6 +78,7 @@ public class ReportExecutionRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); private ReportExecutionRestApi restApiUnderTest; + private final Cookies fakeCookies = Cookies.parse("key=value"); @Before public void setup() { @@ -93,7 +94,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() throws Exception mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runReportExecution("cookie", ReportExecutionRequestOptions.newRequest("/any/uri")); + restApiUnderTest.runReportExecution(fakeCookies, ReportExecutionRequestOptions.newRequest("/any/uri")); } @Test @@ -101,13 +102,13 @@ public void bodyParameterShouldNotBeNullForRunReportExecution() throws Exception mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runReportExecution("cookie", null); + restApiUnderTest.runReportExecution(fakeCookies, null); } @Test - public void tokenShouldNotBeNullForRunReportExecution() throws Exception { + public void cookiesShouldNotBeNullForRunReportExecution() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/uri"); restApiUnderTest.runReportExecution(null, options); @@ -118,13 +119,13 @@ public void executionIdShouldNotBeNullForRequestExecutionDetails() throws Except mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionDetails("cookie", null); + restApiUnderTest.requestReportExecutionDetails(fakeCookies, null); } @Test - public void tokenShouldNotBeNullForRequestExecutionDetails() throws Exception { + public void cookiesShouldNotBeNullForRequestExecutionDetails() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestReportExecutionDetails(null, "exec_id"); } @@ -134,13 +135,13 @@ public void executionIdShouldNotBeNullForRequestExecutionStatus() throws Excepti mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionStatus("cookie", null); + restApiUnderTest.requestReportExecutionStatus(fakeCookies, null); } @Test - public void tokenShouldNotBeNullForRequestExecutionStatus() throws Exception { + public void cookiesShouldNotBeNullForRequestExecutionStatus() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestReportExecutionStatus(null, "exec_id"); } @@ -150,13 +151,13 @@ public void executionIdShouldNotBeNullForCancelRequestExecution() throws Excepti mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.cancelReportExecution("cookie", null); + restApiUnderTest.cancelReportExecution(fakeCookies, null); } @Test - public void tokenShouldNotBeNullForCancelRequestExecution() throws Exception { + public void cookiesShouldNotBeNullForCancelRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.cancelReportExecution(null, "exec_id"); } @@ -166,7 +167,7 @@ public void bodyParameterShouldNotBeNullForExecutionUpdate() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution params should not be null"); - restApiUnderTest.updateReportExecution("cookie", "any_id", null); + restApiUnderTest.updateReportExecution(fakeCookies, "any_id", null); } @Test @@ -174,7 +175,7 @@ public void bodyParameterShouldNotBeEmptyForExecutionUpdate() throws Exception { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Execution params should not be empty"); - restApiUnderTest.updateReportExecution("cookie", "any_id", Collections.emptyList()); + restApiUnderTest.updateReportExecution(fakeCookies, "any_id", Collections.emptyList()); } @Test @@ -183,12 +184,12 @@ public void shouldStartReportExecution() throws Exception { mWebMockRule.enqueue(response); ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/my/uri"); - restApiUnderTest.runReportExecution("cookie", options); + restApiUnderTest.runReportExecution(fakeCookies, options); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions")); assertThat(request.getBody().readUtf8(), is("{\"reportUnitUri\":\"/my/uri\"}")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getMethod(), is("POST")); } @@ -197,12 +198,12 @@ public void shouldRequestReportExecutionDetails() throws Exception { MockResponse response = MockResponseFactory.create200().setBody(reportExecutionDetailsResponse.asString()); mWebMockRule.enqueue(response); - ReportExecutionDescriptor details = restApiUnderTest.requestReportExecutionDetails("cookie", "exec_id"); + ReportExecutionDescriptor details = restApiUnderTest.requestReportExecutionDetails(fakeCookies, "exec_id"); assertThat(details, is(notNullValue())); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getMethod(), is("GET")); } @@ -211,12 +212,12 @@ public void shouldRequestReportExecutionStatus() throws Exception { MockResponse response = MockResponseFactory.create200().setBody("{\"value\":\"execution\"}"); mWebMockRule.enqueue(response); - ExecutionStatus status = restApiUnderTest.requestReportExecutionStatus("cookie", "exec_id"); + ExecutionStatus status = restApiUnderTest.requestReportExecutionStatus(fakeCookies, "exec_id"); assertThat(status, is(notNullValue())); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getMethod(), is("GET")); } @@ -225,11 +226,11 @@ public void shouldCancelReportExecution() throws Exception { MockResponse response = MockResponseFactory.create200(); mWebMockRule.enqueue(response); - restApiUnderTest.cancelReportExecution("cookie", "exec_id"); + restApiUnderTest.cancelReportExecution(fakeCookies, "exec_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getBody().readUtf8(), is("{\"value\":\"cancelled\"}")); assertThat(request.getMethod(), is("PUT")); } @@ -239,11 +240,11 @@ public void shouldUpdateReportExecution() throws Exception { MockResponse response = MockResponseFactory.create204(); mWebMockRule.enqueue(response); - restApiUnderTest.updateReportExecution("cookie", "exec_id", PARAMS); + restApiUnderTest.updateReportExecution(fakeCookies, "exec_id", PARAMS); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/parameters")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getBody().readUtf8(), is("[{\"name\":\"key\",\"value\":[\"value\"]}]")); assertThat(request.getMethod(), is("POST")); } @@ -252,7 +253,7 @@ public void shouldUpdateReportExecution() throws Exception { public void responseShouldNotBeCancelledIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - boolean cancelled = restApiUnderTest.cancelReportExecution("cookie", "any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution(fakeCookies, "any_id"); assertThat(cancelled, is(false)); } @@ -262,7 +263,7 @@ public void responseShouldBeCancelledIfResponseIs200() throws Exception { MockResponse response = MockResponseFactory.create200().setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); - boolean cancelled = restApiUnderTest.cancelReportExecution("cookie", "any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution(fakeCookies, "any_id"); assertThat(cancelled, is(true)); } @@ -271,7 +272,7 @@ public void responseShouldBeCancelledIfResponseIs200() throws Exception { public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution("cookie", SEARCH_PARAMS); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(fakeCookies, SEARCH_PARAMS); assertThat(response.getItems(), is(empty())); } @@ -281,14 +282,14 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws Exce mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution("cookie", SEARCH_PARAMS); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(fakeCookies, SEARCH_PARAMS); assertThat(response.getItems(), is(not(empty()))); } @Test public void executionUpdateRequestShouldBeSuccessIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - boolean response = restApiUnderTest.updateReportExecution("cookie", "any_id", PARAMS); + boolean response = restApiUnderTest.updateReportExecution(fakeCookies, "any_id", PARAMS); assertThat(response, is(true)); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index 24748e10..5fac4e1e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -58,6 +58,7 @@ public class ReportExportRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private ReportExportRestApi restApiUnderTest; + private final Cookies fakeCookies = Cookies.parse("key=value"); @ResourceFile("json/root_folder.json") TestResource mResource; @@ -75,7 +76,7 @@ public void executionIdShouldNotBeNullForRunRequestExecution() throws Exception mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.runExportExecution("cookie", null, ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution(fakeCookies, null, ExecutionRequestOptions.create()); } @Test @@ -83,13 +84,13 @@ public void bodyShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runExportExecution("cookie", "any_id", null); + restApiUnderTest.runExportExecution(fakeCookies, "any_id", null); } @Test - public void tokenShouldNotBeNullForRunRequestExecution() throws Exception { + public void cookiesShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.runExportExecution(null, "any_id", ExecutionRequestOptions.create()); } @@ -99,7 +100,7 @@ public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() throws Ex mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.checkExportExecutionStatus("cookie", null, "any_id"); + restApiUnderTest.checkExportExecutionStatus(fakeCookies, null, "any_id"); } @Test @@ -107,13 +108,13 @@ public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() throws Excep mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.checkExportExecutionStatus("cookie", "any_id", null); + restApiUnderTest.checkExportExecutionStatus(fakeCookies, "any_id", null); } @Test - public void tokenShouldNotBeNullForCheckRequestExecutionStatus() throws Exception { + public void cookiesShouldNotBeNullForCheckRequestExecutionStatus() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.checkExportExecutionStatus(null, "any_id", "any_id"); } @@ -123,7 +124,7 @@ public void executionIdParameterShouldNotBeNullForAttachmentRequest() throws Exc mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestExportAttachment("cookie", null, "any_id", "any_id"); + restApiUnderTest.requestExportAttachment(fakeCookies, null, "any_id", "any_id"); } @Test @@ -131,7 +132,7 @@ public void exportIdParameterShouldNotBeNullForAttachmentRequest() throws Except mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.requestExportAttachment("cookie", "any_id", null, "any_id"); + restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", null, "any_id"); } @Test @@ -139,13 +140,13 @@ public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() throws Ex mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Attachment id should not be null"); - restApiUnderTest.requestExportAttachment("cookie", "any_id", "any_id", null); + restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", "any_id", null); } @Test - public void tokenIdParameterShouldNotBeNullForAttachmentRequest() throws Exception { + public void cookiesIdParameterShouldNotBeNullForAttachmentRequest() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestExportAttachment(null, "any_id", "any_id", "any_id"); } @@ -157,7 +158,7 @@ public void requestForOutputShouldParsePagesFromHeader() throws Exception { .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput("cookie", "any_id", "any_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput(fakeCookies, "any_id", "any_id"); assertThat(resource.getPages(), is("1-10")); } @@ -168,7 +169,7 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput("cookie", "execution_id", "export_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput(fakeCookies, "execution_id", "export_id"); assertThat(resource.isFinal(), is(true)); } @@ -176,11 +177,11 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { public void shouldRequestExportOutput() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportOutput("cookie", "execution_id", "html;pages=1"); + restApiUnderTest.requestExportOutput(fakeCookies, "execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/outputResource?suppressContentDisposition=true")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -189,7 +190,7 @@ public void requestForAttachmentShouldBeWrappedInsideInput() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - OutputResource resource = restApiUnderTest.requestExportAttachment("cookie", "any_id", "any_id", "any_id"); + OutputResource resource = restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", "any_id", "any_id"); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); @@ -201,11 +202,11 @@ public void shouldRequestExportAttachment() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportAttachment("cookie", "execution_id", "html;pages=1", "attachment_id"); + restApiUnderTest.requestExportAttachment(fakeCookies, "execution_id", "html;pages=1", "attachment_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/attachments/attachment_id")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -213,11 +214,11 @@ public void shouldRunExportExecution() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.runExportExecution("cookie", "execution_id", ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution(fakeCookies, "execution_id", ExecutionRequestOptions.create()); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -225,11 +226,11 @@ public void shouldCheckExportExecutionStatus() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.checkExportExecutionStatus("cookie", "execution_id", "html;pages=1"); + restApiUnderTest.checkExportExecutionStatus(fakeCookies, "execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/status")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -238,7 +239,7 @@ public void runExportExecutionShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runExportExecution("cookie", "any_id", ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution(fakeCookies, "any_id", ExecutionRequestOptions.create()); } @Test @@ -247,7 +248,7 @@ public void checkExportExecutionStatusShouldThrowRestErrorOn500() throws Excepti mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.checkExportExecutionStatus("cookie", "any_id", "any_id"); + restApiUnderTest.checkExportExecutionStatus(fakeCookies, "any_id", "any_id"); } @Test @@ -256,7 +257,7 @@ public void requestExportOutputShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportOutput("cookie", "any_id", "any_id"); + restApiUnderTest.requestExportOutput(fakeCookies, "any_id", "any_id"); } @Test @@ -265,6 +266,6 @@ public void requestExportAttachmentShouldThrowRestErrorOn500() throws Exception mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportAttachment("cookie", "any_id", "any_id", "any_id"); + restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", "any_id", "any_id"); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 1040117e..20e18dd1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -60,6 +60,7 @@ public class ReportOptionRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private ReportOptionRestApi restApiUnderTest; + private final Cookies fakeCookies = Cookies.parse("key=value"); @ResourceFile("json/report_option.json") TestResource reportOption; @@ -78,13 +79,13 @@ public void setup() { public void requestReportOptionsListShouldNotAllowNullReportUnitUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportOptionsList("cookie", null); + restApiUnderTest.requestReportOptionsList(fakeCookies, null); } @Test - public void requestReportOptionsListShouldNotAllowNullToken() throws Exception { + public void requestReportOptionsListShouldNotAllowNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestReportOptionsList(null, "/my/uri"); } @@ -92,13 +93,13 @@ public void requestReportOptionsListShouldNotAllowNullToken() throws Exception { public void createReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.createReportOption("cookie", null, "label", Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption(fakeCookies, null, "label", Collections.EMPTY_MAP, false); } @Test - public void createReportOptionShouldNotAllowNullToken() throws Exception { + public void createReportOptionShouldNotAllowNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.createReportOption(null, "/my/uri", "label", Collections.EMPTY_MAP, false); } @@ -106,41 +107,41 @@ public void createReportOptionShouldNotAllowNullToken() throws Exception { public void createReportOptionShouldNotAllowNullOptionLabel() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option label should not be null"); - restApiUnderTest.createReportOption("cookie", "any_id", null, Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption(fakeCookies, "any_id", null, Collections.EMPTY_MAP, false); } @Test public void createReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.createReportOption("cookie", "any_id", "label", null, false); + restApiUnderTest.createReportOption(fakeCookies, "any_id", "label", null, false); } @Test public void updateReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.updateReportOption("cookie", null, "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption(fakeCookies, null, "option_id", Collections.EMPTY_MAP); } @Test public void updateReportOptionShouldNotAllowNullOptionId() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.updateReportOption("cookie", "any_id", null, Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption(fakeCookies, "any_id", null, Collections.EMPTY_MAP); } @Test public void updateReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.updateReportOption("cookie", "any_id", "option_id", null); + restApiUnderTest.updateReportOption(fakeCookies, "any_id", "option_id", null); } @Test - public void updateReportOptionShouldNotAllowNullToken() throws Exception { + public void updateReportOptionShouldNotAllowNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.updateReportOption(null, "any_id", "option_id", Collections.EMPTY_MAP); } @@ -148,20 +149,20 @@ public void updateReportOptionShouldNotAllowNullToken() throws Exception { public void deleteReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.deleteReportOption("cookie", null, "option_id"); + restApiUnderTest.deleteReportOption(fakeCookies, null, "option_id"); } @Test public void deleteReportOptionShouldNotAllowNullOptionId() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.deleteReportOption("cookie", "any_id", null); + restApiUnderTest.deleteReportOption(fakeCookies, "any_id", null); } @Test - public void deleteReportOptionShouldNotAllowNullToken() throws Exception { + public void deleteReportOptionShouldNotAllowNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.deleteReportOption(null, "any_id", "option_id"); } @@ -170,12 +171,12 @@ public void apiShouldListReportOptions() throws Exception { MockResponse mockResponse = MockResponseFactory.create200().setBody(reportOptionsList.asString()); mWebMockRule.enqueue(mockResponse); - Set response = restApiUnderTest.requestReportOptionsList("cookie", "/any/uri"); + Set response = restApiUnderTest.requestReportOptionsList(fakeCookies, "/any/uri"); assertThat(response, is(not(empty()))); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -186,7 +187,7 @@ public void apiShouldCreateReportOption() throws Exception { Map> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19")); - ReportOption reportOption = restApiUnderTest.createReportOption("cookie", "/any/uri", "my label", params, true); + ReportOption reportOption = restApiUnderTest.createReportOption(fakeCookies, "/any/uri", "my label", params, true); assertThat(reportOption.getId(), is("my_label")); assertThat(reportOption.getLabel(), is("my label")); assertThat(reportOption.getUri(), is("/public/Samples/Reports/my_label")); @@ -194,7 +195,7 @@ public void apiShouldCreateReportOption() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options?label=my%20label&overwrite=true")); assertThat(request.getBody().readUtf8(), is("{\"sales_fact_ALL__store_sales_2013_1\":[\"19\"]}")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -204,24 +205,24 @@ public void apiShouldUpdateReportOption() throws Exception { Map> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("22")); - restApiUnderTest.updateReportOption("cookie", "/any/uri", "option_id", params); + restApiUnderTest.updateReportOption(fakeCookies, "/any/uri", "option_id", params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); assertThat(request.getMethod(), is("PUT")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test public void apiShouldDeleteReportOption() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.deleteReportOption("cookie", "/any/uri", "option_id"); + restApiUnderTest.deleteReportOption(fakeCookies, "/any/uri", "option_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); assertThat(request.getMethod(), is("DELETE")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -230,7 +231,7 @@ public void requestReportOptionsListShouldThrow500Error() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestReportOptionsList("cookie", "any_id"); + restApiUnderTest.requestReportOptionsList(fakeCookies, "any_id"); } @Test @@ -239,7 +240,7 @@ public void updateReportOptionShouldThrowRestErrorFor500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.updateReportOption("cookie", "any_id", "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption(fakeCookies, "any_id", "option_id", Collections.EMPTY_MAP); } @Test @@ -248,6 +249,6 @@ public void deleteReportOptionShouldThrowRestErrorFor500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.deleteReportOption("cookie", "any_id", "option_id"); + restApiUnderTest.deleteReportOption(fakeCookies, "any_id", "option_id"); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index d4300ee5..b71a445e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -64,6 +64,7 @@ public class RepositoryRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private RepositoryRestApi restApiUnderTest; + private final Cookies fakeCookies = Cookies.parse("key=value"); @Before public void setup() { @@ -78,7 +79,7 @@ public void setup() { public void shouldReturnEmptyResponseForNoContentResponse() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); + ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); assertThat(response.getResources(), is(empty())); } @@ -89,7 +90,7 @@ public void requestForSearchShouldParseHeaderResultCount() throws Exception { .addHeader("Result-Count", "100"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); + ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); assertThat(response.getResultCount(), is(100)); } @@ -100,7 +101,7 @@ public void requestForSearchShouldParseHeaderTotalCount() throws Exception { .addHeader("Total-Count", "1000"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); + ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); assertThat(response.getTotalCount(), is(1000)); } @@ -111,7 +112,7 @@ public void requestForSearchShouldParseHeaderStartIndex() throws Exception { .addHeader("Start-Index", "5"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); + ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); assertThat(response.getStartIndex(), is(5)); } @@ -122,14 +123,14 @@ public void requestForSearchShouldParseHeaderNextOffset() throws Exception { .addHeader("Next-Offset", "10"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources("cookie", null); + ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); assertThat(response.getNextOffset(), is(10)); } @Test - public void searchResourcesShouldNotAcceptNullToken() throws Exception { + public void searchResourcesShouldNotAcceptNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.searchResources(null, null); } @@ -139,13 +140,13 @@ public void requestForReportResourceShouldNotAcceptNullUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportResource("cookie", null); + restApiUnderTest.requestReportResource(fakeCookies, null); } @Test - public void requestForReportResourceShouldNotAcceptNullToken() throws Exception { + public void requestForReportResourceShouldNotAcceptNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestReportResource(null, "/uri"); } @@ -155,13 +156,13 @@ public void requestForFolderResourceShouldNotAcceptNullUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Folder uri should not be null"); - restApiUnderTest.requestFolderResource("cookie", null); + restApiUnderTest.requestFolderResource(fakeCookies, null); } @Test - public void requestForFolderResourceShouldNotAcceptNullToken() throws Exception { + public void requestForFolderResourceShouldNotAcceptNullCookies() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request token should not be null"); + mExpectedException.expectMessage("Request cookies should not be null"); restApiUnderTest.requestFolderResource(null, "/my/uri"); } @@ -172,7 +173,7 @@ public void searchResourcesShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.searchResources("cookie", null); + restApiUnderTest.searchResources(fakeCookies, null); } @Test @@ -181,7 +182,7 @@ public void requestReportResourceShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestReportResource("cookie", "any_id"); + restApiUnderTest.requestReportResource(fakeCookies, "any_id"); } @Test @@ -190,7 +191,7 @@ public void requestFolderResourceShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestFolderResource("cookie", "any_id"); + restApiUnderTest.requestFolderResource(fakeCookies, "any_id"); } @Test @@ -207,7 +208,7 @@ public void searchEndpointShouldHandleMultipleResourceTypes() throws Exception { types.add("dashboard"); params.put("type", types); - restApiUnderTest.searchResources("cookie", params); + restApiUnderTest.searchResources(fakeCookies, params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?folderUri=/&type=reportUnit&type=dashboard")); @@ -220,34 +221,34 @@ public void shouldSearchResources() throws Exception { Map params = new LinkedHashMap<>(); params.put("limit", 100); params.put("offset", 100); - restApiUnderTest.searchResources("cookie", params); + restApiUnderTest.searchResources(fakeCookies, params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?limit=100&offset=100")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test public void shouldRequestReportResources() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.requestReportResource("cookie", "/my/uri"); + restApiUnderTest.requestReportResource(fakeCookies, "/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); assertThat(request.getHeader("Accept"), is("application/repository.reportUnit+json")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } @Test public void shouldRequestFolderResource() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.requestFolderResource("cookie", "/my/uri"); + restApiUnderTest.requestFolderResource(fakeCookies, "/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); assertThat(request.getHeader("Accept"), is("application/repository.folder+json")); - assertThat(request.getHeader("Cookie"), is("cookie")); + assertThat(request.getHeader("Cookie"), is("key=value")); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java index ba9ce605..652f3ab2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; @@ -37,18 +38,18 @@ * @since 2.0 */ public final class FakeCallExecutor implements CallExecutor { - private final String mToken; + private final Cookies mCookies; private final DefaultExceptionMapper mExMapper; - public FakeCallExecutor(String token) { - mToken = token; + public FakeCallExecutor(Cookies cookies) { + mCookies = cookies; mExMapper = new DefaultExceptionMapper(); } @Override public T execute(Call call) throws ServiceException { try { - return call.perform(mToken); + return call.perform(mCookies); } catch (IOException e) { throw mExMapper.transform(e); } catch (HttpException e) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java index e9f61cd5..723c9ed5 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; import org.junit.Before; import org.junit.Test; @@ -43,8 +44,9 @@ public void setUp() throws Exception { @Test public void testCache() throws Exception { - cache.put("http://localhost", "token"); - assertThat(cache.get("http://localhost"), is("token")); + Cookies cookies = Cookies.parse("key;name"); + cache.put("http://localhost", cookies); + assertThat(cache.get("http://localhost"), is(cookies)); cache.remove("http://localhost"); assertThat(cache.get("http://localhost"), is(nullValue())); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java index a61b6555..cd5ffc8f 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java @@ -1,5 +1,6 @@ package com.jaspersoft.android.sdk.service.auth; +import com.jaspersoft.android.sdk.network.Cookies; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -26,11 +27,12 @@ public class AuthenticationServiceTest { @Rule public ExpectedException mExpectedException = ExpectedException.none(); + private final Cookies fakeCookies = Cookies.parse("key=value"); @Before public void setupMocks() throws Exception { MockitoAnnotations.initMocks(this); - when(mCredentials.applyPolicy(any(AuthPolicy.class))).thenReturn("cookie"); + when(mCredentials.applyPolicy(any(AuthPolicy.class))).thenReturn(fakeCookies); authenticatorUnderTest = new AuthenticationService(mAuthPolicy); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java index ea6a4fb3..617714a1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; @@ -71,6 +72,7 @@ public class SpringAuthServiceTest { private SpringAuthService objectUnderTest; private SpringCredentials credentials; + private final Cookies fakeCookies = Cookies.parse("key=value"); private static final Map sOptionals = new HashMap<>(); static { @@ -96,7 +98,7 @@ public void setup() throws Exception { when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); - when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn("cookie"); + when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(fakeCookies); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java index e1e491db..59c8c77a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.internal; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -56,23 +57,26 @@ public class DefaultCallExecutorTest { private DefaultCallExecutor resolver; private Object mResponse = new Object(); + private final Cookies validCookies = Cookies.parse("key=value"); + private final Cookies inValidCookies = Cookies.parse("key=value1"); + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(_401Exception.code()).thenReturn(401); - when(mCall.perform(anyString())).thenReturn(mResponse); + when(mCall.perform(any(Cookies.class))).thenReturn(mResponse); resolver = new DefaultCallExecutor(mTokenCacheManager, new DefaultExceptionMapper()); } @Test public void testExecuteWithValidCache() throws Exception { - when(mTokenCacheManager.loadToken()).thenReturn("token"); + when(mTokenCacheManager.loadToken()).thenReturn(validCookies); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); verify(mTokenCacheManager).loadToken(); - verify(mCall).perform("token"); + verify(mCall).perform(validCookies); verifyNoMoreInteractions(mTokenCacheManager); verifyZeroInteractions(mTokenCacheManager); } @@ -80,33 +84,33 @@ public void testExecuteWithValidCache() throws Exception { @Test public void testExecuteWithEmptyCache() throws Exception { when(mTokenCacheManager.loadToken()).thenReturn(null); - when(mTokenCacheManager.loadToken()).thenReturn("token"); + when(mTokenCacheManager.loadToken()).thenReturn(validCookies); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); verify(mTokenCacheManager).loadToken(); - verify(mCall).perform("token"); + verify(mCall).perform(validCookies); } @Test public void testExecuteWithInvalidCache() throws Exception { - when(mTokenCacheManager.loadToken()).then(Chain.of("invalid token", "valid token")); + when(mTokenCacheManager.loadToken()).then(Chain.of(inValidCookies, validCookies)); when(_401Exception.code()).thenReturn(401); - when(mCall.perform(anyString())).thenAnswer(_401ResponseAtFirstInvokation()); + when(mCall.perform(any(Cookies.class))).thenAnswer(_401ResponseAtFirstInvokation()); assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); verify(mTokenCacheManager, times(2)).loadToken(); - verify(mCall).perform("invalid token"); + verify(mCall).perform(inValidCookies); verify(mTokenCacheManager).invalidateToken(); - verify(mCall).perform("valid token"); + verify(mCall).perform(validCookies); } @Test public void testExecuteWithInvalidCredentials() throws Exception { - when(mTokenCacheManager.loadToken()).thenReturn("invalid token"); - when(mCall.perform(anyString())).thenThrow(_401Exception); + when(mTokenCacheManager.loadToken()).thenReturn(inValidCookies); + when(mCall.perform(any(Cookies.class))).thenThrow(_401Exception); try { resolver.execute(mCall); @@ -115,7 +119,7 @@ public void testExecuteWithInvalidCredentials() throws Exception { } verify(mTokenCacheManager, times(2)).loadToken(); - verify(mCall, times(2)).perform("invalid token"); + verify(mCall, times(2)).perform(inValidCookies); verify(mTokenCacheManager).invalidateToken(); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java index 3404a322..8c1b6388 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.internal; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.auth.AuthenticationService; import com.jaspersoft.android.sdk.service.auth.Credentials; @@ -63,6 +64,7 @@ public class TokenCacheManagerTest { @Mock HttpException mHttpException; + private final Cookies fakeCookies = Cookies.parse("key=value"); private final String baseUrl = "http://localhost/"; private TokenCacheManager cacheManager; @@ -80,20 +82,20 @@ public void setUp() throws Exception { @Test public void testLoadToken() throws Exception { when(mTokenCache.get(anyString())).thenReturn(null); - when(mAuthenticationService.authenticate(any(Credentials.class))).thenReturn("token"); + when(mAuthenticationService.authenticate(any(Credentials.class))).thenReturn(fakeCookies); - assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is("token")); + assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is(fakeCookies)); verify(mTokenCache).get(baseUrl); - verify(mTokenCache).put(baseUrl, "token"); + verify(mTokenCache).put(baseUrl, fakeCookies); verify(mAuthenticationService).authenticate(mCredentials); } @Test public void testLoadTokenReturnsFromCache() throws Exception { - when(mTokenCache.get(anyString())).thenReturn("token"); + when(mTokenCache.get(anyString())).thenReturn(fakeCookies); - assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is("token")); + assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is(fakeCookies)); verify(mTokenCache).get(baseUrl); verifyNoMoreInteractions(mTokenCache); verifyZeroInteractions(mAuthenticationService); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java index b4b1ed18..bd9facb0 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; @@ -53,7 +54,6 @@ public class ReportExecutionUseCaseTest { private static final String EXECUTION_ID = "execution_id"; - private static final String TOKEN = "token"; @Mock ReportExecutionRestApi mExecutionRestApi; @@ -65,7 +65,8 @@ public class ReportExecutionUseCaseTest { ServerInfo mServerInfo; private ReportExecutionUseCase executionUseCase; - private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor("token"); + private final Cookies fakeCookies = Cookies.parse("key=value"); + private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor(fakeCookies); @Before public void setUp() throws Exception { @@ -81,25 +82,25 @@ public void testRunReportExecution() throws Exception { RunReportCriteria criteria = RunReportCriteria.builder().create(); executionUseCase.runReportExecution("/my/uri", criteria); verify(mDataMapper).transformRunReportOptions("/my/uri", ServerVersion.v6, criteria); - verify(mExecutionRestApi).runReportExecution(eq("token"), any(ReportExecutionRequestOptions.class)); + verify(mExecutionRestApi).runReportExecution(eq(fakeCookies), any(ReportExecutionRequestOptions.class)); } @Test public void testRequestStatus() throws Exception { executionUseCase.requestStatus(EXECUTION_ID); - verify(mExecutionRestApi).requestReportExecutionStatus(TOKEN, EXECUTION_ID); + verify(mExecutionRestApi).requestReportExecutionStatus(fakeCookies, EXECUTION_ID); } @Test public void testRequestExecutionDetails() throws Exception { executionUseCase.requestExecutionDetails(EXECUTION_ID); - verify(mExecutionRestApi).requestReportExecutionDetails(TOKEN, EXECUTION_ID); + verify(mExecutionRestApi).requestReportExecutionDetails(fakeCookies, EXECUTION_ID); } @Test public void testUpdateExecution() throws Exception { List params = Collections.emptyList(); executionUseCase.updateExecution(EXECUTION_ID, params); - verify(mExecutionRestApi).updateReportExecution(TOKEN, EXECUTION_ID, params); + verify(mExecutionRestApi).updateReportExecution(fakeCookies, EXECUTION_ID, params); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java index 7f34b9b1..0be159d4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -58,6 +59,8 @@ public class ReportExportUseCaseTest { InfoCacheManager mCacheManager; @Mock ServerInfo mServerInfo; + + private final Cookies fakeCookies = Cookies.parse("key=value"); private static final RunExportCriteria EXPORT_HTML_PAGE_1 = RunExportCriteria.builder() .format(ExecutionCriteria.Format.HTML) @@ -73,7 +76,7 @@ public void setUp() throws Exception { when(mCacheManager.getInfo()).thenReturn(mServerInfo); when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); - FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); + FakeCallExecutor callExecutor = new FakeCallExecutor(fakeCookies); useCase = new ReportExportUseCase(mExportApi, callExecutor, mCacheManager, mExecutionOptionsMapper); } @@ -81,7 +84,7 @@ public void setUp() throws Exception { public void testRequestExportOutputOnServer5_5() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); - verify(mExportApi).requestExportOutput(eq("cookie"), eq(EXEC_ID), eq(LEGACY_EXPORT_ID)); + verify(mExportApi).requestExportOutput(eq(fakeCookies), eq(EXEC_ID), eq(LEGACY_EXPORT_ID)); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); } @@ -90,7 +93,7 @@ public void testRequestExportOutputOnServer5_5() throws Exception { public void testRequestExportOutputOnServer5_6() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); - verify(mExportApi).requestExportOutput(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID)); + verify(mExportApi).requestExportOutput(eq(fakeCookies), eq(EXEC_ID), eq(EXPORT_ID)); verify(mCacheManager).getInfo(); } @@ -100,12 +103,12 @@ public void testRunExport() throws Exception { verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); verify(mExecutionOptionsMapper).transformExportOptions(EXPORT_HTML_PAGE_1, ServerVersion.v6); - verify(mExportApi).runExportExecution(eq("cookie"), eq(EXEC_ID), any(ExecutionRequestOptions.class)); + verify(mExportApi).runExportExecution(eq(fakeCookies), eq(EXEC_ID), any(ExecutionRequestOptions.class)); } @Test public void testCheckExportExecutionStatusOnServer5_5() throws Exception { - when(mExportApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mExportApi.checkExportExecutionStatus(any(Cookies.class), anyString(), anyString())).thenReturn(cancelledStatus()); when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); ExecutionStatus execStatus = useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); @@ -117,13 +120,13 @@ public void testCheckExportExecutionStatusOnServer5_5() throws Exception { @Test public void testCheckExportExecutionStatusOnServer5_6() throws Exception { - when(mExportApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mExportApi.checkExportExecutionStatus(any(Cookies.class), anyString(), anyString())).thenReturn(cancelledStatus()); when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); - verify(mExportApi).checkExportExecutionStatus(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID)); + verify(mExportApi).checkExportExecutionStatus(eq(fakeCookies), eq(EXEC_ID), eq(EXPORT_ID)); } @Test @@ -131,7 +134,7 @@ public void testRequestExportAttachmentOutputOnServer5_5() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); - verify(mExportApi).requestExportAttachment(eq("cookie"), eq(EXEC_ID), eq(LEGACY_EXPORT_ID), eq("nay")); + verify(mExportApi).requestExportAttachment(eq(fakeCookies), eq(EXEC_ID), eq(LEGACY_EXPORT_ID), eq("nay")); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); } @@ -141,7 +144,7 @@ public void testRequestExportAttachmentOutputOnServer5_6() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); - verify(mExportApi).requestExportAttachment(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID), eq("nay")); + verify(mExportApi).requestExportAttachment(eq(fakeCookies), eq(EXEC_ID), eq(EXPORT_ID), eq("nay")); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 5005a795..9240df20 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; @@ -40,7 +41,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; -import java.util.Map; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; @@ -76,6 +76,7 @@ public class SearchUseCaseTest { ResourceSearchResult mResult; private SearchUseCase objectUnderTest; + private final Cookies fakeCookies = Cookies.parse("key=value"); @Before public void setup() throws Exception { @@ -88,14 +89,14 @@ public void setup() throws Exception { mDataMapper, mRepositoryRestApi, mInfoCacheManager, - new FakeCallExecutor("cookie") + new FakeCallExecutor(fakeCookies) ); } @Test public void shouldProvideAndAdaptSearchResult() throws Exception { when(mResult.getNextOffset()).thenReturn(100); - when(mRepositoryRestApi.searchResources(anyString(), any(Map.class))).thenReturn(mResult); + when(mRepositoryRestApi.searchResources(any(Cookies.class), anyMap())).thenReturn(mResult); Collection resources = new ArrayList(); when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); @@ -105,6 +106,6 @@ public void shouldProvideAndAdaptSearchResult() throws Exception { assertThat(result.getNextOffset(), is(100)); assertThat(result.getResources(), is(resources)); - verify(mRepositoryRestApi).searchResources(anyString(), any(Map.class)); + verify(mRepositoryRestApi).searchResources(any(Cookies.class), anyMap()); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java index 06a5145e..c1e0e984 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.jaspersoft.android.sdk.test.TestLogger; @@ -55,7 +56,7 @@ public void shouldEncryptWithPassword() throws Exception { JSEncryptionAlgorithm generator = JSEncryptionAlgorithm.create(new BouncyCastleProvider()); String cipher = generator.encrypt(key.getModulus(), key.getExponent(), "superuser"); - String authResponse = restApi.authenticate("superuser", cipher, null, null); + Cookies authResponse = restApi.authenticate("superuser", cipher, null, null); assertThat(authResponse, is(notNullValue())); } @@ -65,7 +66,7 @@ public void shouldReturnResponseForSpringRequest() throws Exception { .baseUrl(mobileDemo2) .logger(TestLogger.get(this)) .build(); - String response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); + Cookies response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); assertThat(response, is(notNullValue())); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index f9630376..5251fe2b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -29,9 +29,8 @@ import com.jaspersoft.android.sdk.test.TestLogger; import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; - +import jdk.nashorn.internal.ir.annotations.Ignore; import org.junit.Before; -import org.junit.Test; import java.util.HashMap; import java.util.HashSet; @@ -72,13 +71,15 @@ public void setup() { } } - @Test + // TODO: fix this by providing proper integration tests + @Ignore public void shouldRequestReportOptionsList() throws Exception { Set response = apiUnderTest.requestReportOptionsList(mAuthenticator.token(), REPORT_URI); assertThat(response, is(not(nullValue()))); } - @Test + // TODO: fix this by providing proper integration tests + @Ignore public void apiSupportsCrudForReportOption() throws Exception { ReportOption response = apiUnderTest.createReportOption(mAuthenticator.token(), REPORT_URI, "label", CONTROL_PARAMETERS, true); assertThat(response.getLabel(), is("label")); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index 9872884a..5c6a50c8 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.Cookies; import org.jetbrains.annotations.NotNull; /** @@ -35,7 +36,7 @@ public final class DummyTokenProvider { private final JrsMetadata mJrsMetadata; - private String mToken; + private Cookies mToken; public DummyTokenProvider(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; @@ -46,7 +47,7 @@ public static DummyTokenProvider create(JrsMetadata metadata) { } @NotNull - public String provideToken() throws Exception { + public Cookies provideCookies() throws Exception { if (mToken == null) { AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() .baseUrl(mJrsMetadata.getServerUrl()) @@ -57,7 +58,7 @@ public String provideToken() throws Exception { return mToken; } - public String token() throws Exception { - return provideToken(); + public Cookies token() throws Exception { + return provideCookies(); } } From 08ad53567b4b7fdad920f89784b23198a2a8ff4b Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 14 Dec 2015 12:55:11 +0200 Subject: [PATCH 350/457] Add support of ReportService on JRS v5.5 Filter out baseUrl/allowInlineScripts for v5.5 Force default format HTML for export/execution criterium Ignore freshData/interactive flags for 5.5 report execution Reduce saveDataSnapshot field for export exection on v5.5 Add custom generation of export id for JRS v5.5 Awaiting report execution valid state after update Handle update report execution for JRS v5.5 Add poll timeout control Fix NPE for error descriptor during report export status Handle RESOURCE_NOT_FOUND error Disable interactiveness for JRS 5.6 Implement ReportExceptionMapper Add application/json accept header for export API Convert attachments Collection to List Update wait conditions for report execution Force HTML format only for server version 5.5 Force HTML format for report execution on v5.5 Update default messages for report execution Cache error descriptor accross calls Set nullability for 'organization' field for SpringCredentials Adapt Service API to reflect compatibility with JRS 5.5 --- .../android/sdk/network/HttpException.java | 11 ++ .../sdk/network/ReportExportRestApiImpl.java | 21 +-- .../execution/ExecutionRequestOptions.java | 10 +- .../entity/execution/ExecutionStatus.java | 17 +- .../android/sdk/service/RestClient.java | 16 +- .../sdk/service/auth/SpringCredentials.java | 17 +- .../sdk/service/exception/StatusCodes.java | 26 +-- .../service/internal/DefaultCallExecutor.java | 20 +-- .../internal/DefaultExceptionMapper.java | 88 +++++++++++ .../internal/ReportExceptionMapper.java | 60 +++++++ .../internal/ServiceExceptionMapper.java | 62 ++------ .../service/internal/TokenCacheManager.java | 2 +- .../sdk/service/report/ExecutionCriteria.java | 12 +- .../report/ExecutionOptionsDataMapper.java | 47 ++++-- .../sdk/service/report/ExportFactory.java | 25 +-- .../sdk/service/report/ReportAttachment.java | 9 +- .../sdk/service/report/ReportExecution.java | 87 ++++++---- .../report/ReportExecutionUseCase.java | 13 +- .../sdk/service/report/ReportExport.java | 14 +- .../service/report/ReportExportUseCase.java | 62 ++++++-- .../sdk/service/report/ReportService.java | 44 ++++-- .../sdk/service/report/RunExportCriteria.java | 8 + .../sdk/service/report/RunReportCriteria.java | 20 +++ .../android/sdk/service/report/Status.java | 17 ++ .../service/repository/RepositoryService.java | 9 +- .../sdk/service/server/ServerInfoService.java | 25 +-- .../sdk/network/ReportExportRestApiTest.java | 12 +- .../android/sdk/service/FakeCallExecutor.java | 8 +- .../internal/DefaultCallExecutorTest.java | 2 +- ...t.java => DefaultExceptionMapperTest.java} | 21 +-- .../ExecutionOptionsDataMapperTest.java | 66 +++++++- .../service/report/ReportAttachmentTest.java | 19 +-- .../service/report/ReportExecutionTest.java | 92 ++++++----- .../report/ReportExecutionUseCaseTest.java | 14 +- .../sdk/service/report/ReportExportTest.java | 16 +- .../report/ReportExportUseCaseTest.java | 148 ++++++++++++++++++ .../sdk/service/report/ReportServiceTest.java | 46 +++--- .../service/server/ServerInfoServiceTest.java | 5 +- .../jaspersoft/android/sdk/test/Chain.java | 17 +- 39 files changed, 887 insertions(+), 321 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java rename core/src/test/java/com/jaspersoft/android/sdk/service/internal/{ServiceExceptionMapperTest.java => DefaultExceptionMapperTest.java} (90%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java index fa86ce6b..8e523717 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpException.java @@ -30,6 +30,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import com.squareup.okhttp.ResponseBody; +import org.jetbrains.annotations.Nullable; import retrofit.Response; import java.io.IOException; @@ -47,6 +48,8 @@ public class HttpException extends Exception { private final int mCode; private final ResponseBody mBody; + private ErrorDescriptor mDescriptor; + HttpException(String responseMessage, int code, ResponseBody responseBody) { super(responseMessage + " " + code); mCode = code; @@ -65,7 +68,15 @@ public int code() { return mCode; } + @Nullable public ErrorDescriptor getDescriptor() throws IOException { + if (mDescriptor == null) { + mDescriptor = parseErrorDescriptor(); + } + return mDescriptor; + } + + private ErrorDescriptor parseErrorDescriptor() throws IOException { Gson gson = GsonFactory.create(); InputStream stream = mBody.byteStream(); InputStreamReader reader = new InputStreamReader(stream); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index 80c15dc3..c61e5e11 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -30,21 +30,14 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.squareup.okhttp.ResponseBody; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - -import java.io.IOException; - import retrofit.Call; import retrofit.Response; import retrofit.Retrofit; -import retrofit.http.Body; -import retrofit.http.GET; -import retrofit.http.Header; -import retrofit.http.Headers; -import retrofit.http.POST; -import retrofit.http.Path; +import retrofit.http.*; + +import java.io.IOException; /** * @author Tom Koptel @@ -132,22 +125,24 @@ Call runReportExportExecution(@NotNull @Path("executi @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") Call checkReportExportStatus(@NotNull @Path("executionId") String executionId, - @NotNull @Path("exportId") String exportId, + @NotNull @Path(value = "exportId", encoded = true) String exportId, @Header("Cookie") String cookie); /** * 'suppressContentDisposition' used due to security implications this header has */ @NotNull + @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") Call requestReportExportOutput(@NotNull @Path("executionId") String executionId, - @NotNull @Path("exportId") String exportId, + @NotNull @Path(value = "exportId", encoded = true) String exportId, @Header("Cookie") String cookie); @NotNull + @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") Call requestReportExportAttachmentOutput(@NotNull @Path("executionId") String executionId, - @NotNull @Path("exportId") String exportId, + @NotNull @Path(value = "exportId", encoded = true) String exportId, @NotNull @Path("attachmentId") String attachmentId, @Header("Cookie") String cookie); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index ddf387b3..55f4d8f0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -68,27 +68,27 @@ public static ExecutionRequestOptions create() { return new ExecutionRequestOptions(); } - public ExecutionRequestOptions withAsync(boolean async) { + public ExecutionRequestOptions withAsync(Boolean async) { this.async = async; return this; } - public ExecutionRequestOptions withFreshData(boolean freshData) { + public ExecutionRequestOptions withFreshData(Boolean freshData) { this.freshData = freshData; return this; } - public ExecutionRequestOptions withIgnorePagination(boolean ignorePagination) { + public ExecutionRequestOptions withIgnorePagination(Boolean ignorePagination) { this.ignorePagination = ignorePagination; return this; } - public ExecutionRequestOptions withInteractive(boolean interactive) { + public ExecutionRequestOptions withInteractive(Boolean interactive) { this.interactive = interactive; return this; } - public ExecutionRequestOptions withSaveDataSnapshot(boolean saveDataSnapshot) { + public ExecutionRequestOptions withSaveDataSnapshot(Boolean saveDataSnapshot) { this.saveDataSnapshot = saveDataSnapshot; return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java index acc3b0ca..2a290cad 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionStatus.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.network.entity.execution; import com.google.gson.annotations.Expose; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Tom Koptel @@ -33,24 +35,35 @@ public final class ExecutionStatus { @Expose + @NotNull private String value; @Expose + @Nullable private ErrorDescriptor errorDescriptor; - public ExecutionStatus() {} + public ExecutionStatus() { + } - private ExecutionStatus(String value) { + private ExecutionStatus(@NotNull String value) { this.value = value; } + @NotNull public static ExecutionStatus cancelledStatus() { return new ExecutionStatus("cancelled"); } + @NotNull + public static ExecutionStatus readyStatus() { + return new ExecutionStatus("ready"); + } + + @NotNull public String getStatus() { return value; } + @Nullable public ErrorDescriptor getErrorDescriptor() { return errorDescriptor; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index f46b30b2..2e6358de 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -38,14 +38,16 @@ public final class RestClient { private final String mServerUrl; private final long mReadTimeOut; private final long mConnectionTimeOut; + private final long mPollTimeout; private final InfoCache mInfoCache; private AnonymousSession mAnonymousSession; - private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, InfoCache infoCache) { + private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, long pollTimeout, InfoCache infoCache) { mServerUrl = serverUrl; mReadTimeOut = readTimeOut; mConnectionTimeOut = connectionTimeOut; + mPollTimeout = pollTimeout; mInfoCache = infoCache; } @@ -72,6 +74,10 @@ public long getConnectionTimeOut() { return mConnectionTimeOut; } + public long getPollTimeout() { + return mPollTimeout; + } + public InfoCache getInfoCache() { return mInfoCache; } @@ -93,12 +99,18 @@ public static class ConditionalBuilder { private final String mServerUrl; private long mConnectionReadTimeOut = TimeUnit.SECONDS.toMillis(10); private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10); + private long mPollTimeOut = TimeUnit.SECONDS.toMillis(1); private InfoCache mInfoCache; private ConditionalBuilder(String serverUrl) { mServerUrl = serverUrl; } + public ConditionalBuilder pollTimeOut(int timeOut, TimeUnit unit) { + mPollTimeOut = unit.toMillis(timeOut); + return this; + } + public ConditionalBuilder readTimeOut(int timeOut, TimeUnit unit) { mConnectionReadTimeOut = unit.toMillis(timeOut); return this; @@ -118,7 +130,7 @@ public RestClient create() { if (mInfoCache == null) { mInfoCache = new InMemoryInfoCache(); } - return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mInfoCache); + return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mPollTimeOut, mInfoCache); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java index e56841d0..6236d086 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java @@ -2,8 +2,8 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -24,19 +24,22 @@ public final class SpringCredentials extends Credentials { private final String mOrganization; private final Locale mLocale; private final TimeZone mTimeZone; + private final ServiceExceptionMapper mServiceExceptionMapper; @TestOnly SpringCredentials( @NotNull String username, @NotNull String password, - @NotNull String organization, + @Nullable String organization, @NotNull Locale locale, - @NotNull TimeZone timeZone) { + @NotNull TimeZone timeZone, + @NotNull ServiceExceptionMapper serviceExceptionMapper) { mUsername = username; mPassword = password; mOrganization = organization; mLocale = locale; mTimeZone = timeZone; + mServiceExceptionMapper = serviceExceptionMapper; } public static Builder builder() { @@ -73,9 +76,9 @@ protected String applyPolicy(AuthPolicy policy) throws ServiceException { try { return policy.applyCredentials(this); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } @@ -156,12 +159,14 @@ public Builder locale(@NotNull Locale locale) { public SpringCredentials build() { ensureValidState(); ensureDefaults(); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); return new SpringCredentials( mUsername, mPassword, mOrganization, mLocale, - mTimeZone); + mTimeZone, + serviceExceptionMapper); } private void ensureDefaults() { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java index 67c35670..e3afec50 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/exception/StatusCodes.java @@ -29,21 +29,25 @@ * @since 2.0 */ public final class StatusCodes { - public static final int UNDEFINED_ERROR = 1; - public static final int NETWORK_ERROR = 2; - public static final int CLIENT_ERROR = 3; - public static final int INTERNAL_ERROR = 4; - public static final int PERMISSION_DENIED_ERROR = 5; - public static final int AUTHORIZATION_ERROR = 6; + public static final int UNDEFINED_ERROR = 100; + public static final int NETWORK_ERROR = 102; + public static final int CLIENT_ERROR = 103; + public static final int INTERNAL_ERROR = 104; + public static final int PERMISSION_DENIED_ERROR = 105; + public static final int AUTHORIZATION_ERROR = 106; // EXPORT - public static final int EXPORT_PAGE_OUT_OF_RANGE = 100; - public static final int EXPORT_EXECUTION_CANCELLED = 101; - public static final int EXPORT_EXECUTION_FAILED = 102; + public static final int EXPORT_PAGE_OUT_OF_RANGE = 200; + public static final int EXPORT_EXECUTION_CANCELLED = 201; + public static final int EXPORT_EXECUTION_FAILED = 202; // REPORT - public static final int REPORT_EXECUTION_CANCELLED = 201; - public static final int REPORT_EXECUTION_FAILED = 202; + public static final int REPORT_EXECUTION_CANCELLED = 301; + public static final int REPORT_EXECUTION_FAILED = 302; + public static final int REPORT_EXECUTION_INVALID = 303; + + // RESOURCE + public static final int RESOURCE_NOT_FOUND = 400; private StatusCodes() {} } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java index 2c384c57..932dd6c5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java @@ -25,8 +25,6 @@ package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -40,15 +38,11 @@ public class DefaultCallExecutor implements CallExecutor { private final TokenCacheManager mTokenCacheManager; + private final ServiceExceptionMapper mServiceExceptionMapper; - @TestOnly - DefaultCallExecutor(TokenCacheManager tokenCacheManager) { + public DefaultCallExecutor(TokenCacheManager tokenCacheManager, ServiceExceptionMapper serviceExceptionMapper) { mTokenCacheManager = tokenCacheManager; - } - - public static DefaultCallExecutor create(RestClient client, Session session) { - TokenCacheManager cacheManager = TokenCacheManager.create(client, session); - return new DefaultCallExecutor(cacheManager); + mServiceExceptionMapper = serviceExceptionMapper; } @NotNull @@ -57,7 +51,7 @@ public T execute(Call call) throws ServiceException { String token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (HttpException e) { if (e.code() == 401) { mTokenCacheManager.invalidateToken(); @@ -66,12 +60,12 @@ public T execute(Call call) throws ServiceException { String token = mTokenCacheManager.loadToken(); return call.perform(token); } catch (IOException e1) { - throw ServiceExceptionMapper.transform(e1); + throw mServiceExceptionMapper.transform(e1); } catch (HttpException e1) { - throw ServiceExceptionMapper.transform(e1); + throw mServiceExceptionMapper.transform(e1); } } else { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java new file mode 100644 index 00000000..c7ab6527 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.exception.ServiceException; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class DefaultExceptionMapper implements ServiceExceptionMapper { + @NotNull + public ServiceException transform(IOException e) { + return new ServiceException("Failed to perform network request. Check network!", e, StatusCodes.NETWORK_ERROR); + } + + @NotNull + public ServiceException transform(HttpException e) { + try { + ErrorDescriptor descriptor = e.getDescriptor(); + if (descriptor == null) { + return mapHttpCodesToState(e); + } else { + return mapDescriptorToState(e, descriptor); + } + } catch (IOException ioEx) { + return transform(ioEx); + } + } + + @NotNull + private static ServiceException mapHttpCodesToState(HttpException e) { + switch (e.code()) { + case 500: + return new ServiceException("Server encountered unexpected error", e, StatusCodes.INTERNAL_ERROR); + case 404: + return new ServiceException("Service exist but requested entity not found", e, StatusCodes.CLIENT_ERROR); + case 403: + return new ServiceException("User has no access to resource", e, StatusCodes.PERMISSION_DENIED_ERROR); + case 401: + return new ServiceException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); + case 400: + return new ServiceException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); + default: + return new ServiceException("The operation failed with no more detailed information", e, StatusCodes.UNDEFINED_ERROR); + } + } + + @NotNull + private static ServiceException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { + if ("resource.not.found".equals(descriptor.getErrorCode())) { + return new ServiceException(descriptor.getMessage(), e, StatusCodes.RESOURCE_NOT_FOUND); + } else if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { + return new ServiceException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); + } else { + return mapHttpCodesToState(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java new file mode 100644 index 00000000..8071e41b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ReportExceptionMapper.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.internal; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExceptionMapper implements ServiceExceptionMapper { + private final ServiceExceptionMapper mDelegate; + + public ReportExceptionMapper(ServiceExceptionMapper delegate) { + mDelegate = delegate; + } + + @NotNull + @Override + public ServiceException transform(HttpException e) { + ServiceException exception = mDelegate.transform(e); + if (exception.code() == StatusCodes.RESOURCE_NOT_FOUND) { + return new ServiceException(exception.getMessage(), exception.getCause(), StatusCodes.REPORT_EXECUTION_INVALID); + } + return exception; + } + + @NotNull + @Override + public ServiceException transform(IOException e) { + return mDelegate.transform(e); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java index c609180b..4e1afd1b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapper.java @@ -1,34 +1,31 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -37,50 +34,9 @@ * @author Tom Koptel * @since 2.0 */ -public final class ServiceExceptionMapper { - @NotNull - public static ServiceException transform(IOException e) { - return new ServiceException("Failed to perform network request. Check network!", e, StatusCodes.NETWORK_ERROR); - } - +public interface ServiceExceptionMapper { @NotNull - public static ServiceException transform(HttpException e) { - try { - ErrorDescriptor descriptor = e.getDescriptor(); - if (e.getDescriptor() == null) { - return mapHttpCodesToState(e); - } else { - return mapDescriptorToState(e, descriptor); - } - } catch (IOException ioEx) { - return transform(ioEx); - } - } - - @NotNull - private static ServiceException mapHttpCodesToState(HttpException e) { - switch (e.code()) { - case 500: - return new ServiceException("Server encountered unexpected error", e, StatusCodes.INTERNAL_ERROR); - case 404: - return new ServiceException("Service exist but requested entity not found", e, StatusCodes.CLIENT_ERROR); - case 403: - return new ServiceException("User has no access to resource", e, StatusCodes.PERMISSION_DENIED_ERROR); - case 401: - return new ServiceException("User is not authorized", e, StatusCodes.AUTHORIZATION_ERROR); - case 400: - return new ServiceException("Some parameters in request not valid", e, StatusCodes.CLIENT_ERROR); - default: - return new ServiceException("The operation failed with no more detailed information", e, StatusCodes.UNDEFINED_ERROR); - } - } - + public ServiceException transform(HttpException e); @NotNull - private static ServiceException mapDescriptorToState(HttpException e, ErrorDescriptor descriptor) { - if ("export.pages.out.of.range".equals(descriptor.getErrorCode())) { - return new ServiceException(descriptor.getMessage(), e, StatusCodes.EXPORT_PAGE_OUT_OF_RANGE); - } else { - return mapHttpCodesToState(e); - } - } + public ServiceException transform(IOException e); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java index e50c2c22..32205200 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java @@ -39,7 +39,7 @@ * @author Tom Koptel * @since 2.0 */ -class TokenCacheManager { +public class TokenCacheManager { private final AuthenticationService mAuthService; private final Credentials mCredentials; private final TokenCache mTokenCache; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java index b33d8d45..2c983ca0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java @@ -32,12 +32,12 @@ */ public abstract class ExecutionCriteria { - private final boolean mFreshData; - private final boolean mInteractive; - private final boolean mSaveSnapshot; - private final Format mFormat; - private final String mPages; - private final String mAttachmentPrefix; + protected final boolean mFreshData; + protected final boolean mInteractive; + protected final boolean mSaveSnapshot; + protected final Format mFormat; + protected final String mPages; + protected final String mAttachmentPrefix; protected ExecutionCriteria(boolean freshData, boolean interactive, diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index b9e63c6f..b5b8d346 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -26,7 +26,8 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; - +import com.jaspersoft.android.sdk.service.RestClient; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.jetbrains.annotations.NotNull; import java.io.UnsupportedEncodingException; @@ -36,29 +37,38 @@ * @author Tom Koptel * @since 2.0 */ -final class ExecutionOptionsDataMapper { - +class ExecutionOptionsDataMapper { private final String mBaseUrl; - public ExecutionOptionsDataMapper(String mBaseUrl) { - this.mBaseUrl = mBaseUrl; + ExecutionOptionsDataMapper(String baseUrl) { + mBaseUrl = baseUrl; } - public ReportExecutionRequestOptions transformRunReportOptions(@NotNull String reportUri, @NotNull RunReportCriteria criteria) { + public ReportExecutionRequestOptions transformRunReportOptions(@NotNull String reportUri, + @NotNull ServerVersion serverVersion, + @NotNull RunReportCriteria criteria) { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); - mapCommonCriterion(criteria, options); + mapCommonCriterion(criteria, serverVersion, options); options.withAsync(true); options.withParameters(criteria.getParams()); return options; } - public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria configuration) { + public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria configuration, + @NotNull ServerVersion serverVersion) { ExecutionRequestOptions options = ExecutionRequestOptions.create(); - mapCommonCriterion(configuration, options); + mapCommonCriterion(configuration, serverVersion, options); + if (serverVersion.lessThanOrEquals(ServerVersion.v5_5)) { + options.withSaveDataSnapshot(null); + options.withFreshData(null); + options.withInteractive(null); + } return options; } - private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, ExecutionRequestOptions options) { + private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, + @NotNull ServerVersion version, + @NotNull ExecutionRequestOptions options) { options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); @@ -67,7 +77,22 @@ private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, ExecutionRe options.withInteractive(criteria.isInteractive()); options.withPages(criteria.getPages()); - options.withBaseUrl(mBaseUrl); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + options.withBaseUrl(null); + options.withAllowInlineScripts(null); + if (options.getOutputFormat() == null) { + options.withOutputFormat("HTML"); + } + } else if (version.equals(ServerVersion.v5_6)) { + options.withInteractive(false); + } else { + options.withBaseUrl(mBaseUrl); + } + } + + public static ExecutionOptionsDataMapper create(RestClient client) { + String baseUrl = client.getServerUrl(); + return new ExecutionOptionsDataMapper(baseUrl); } static class Helper { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index ec0db383..2413571d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -28,14 +28,13 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - +import com.jaspersoft.android.sdk.service.exception.StatusCodes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.Collection; +import java.util.List; import java.util.Set; /** @@ -53,25 +52,31 @@ final class ExportFactory { } @NotNull - public ReportExport create(ReportExecutionDescriptor executionDetails, - ExportExecutionDescriptor exportExecutionDetails) throws ServiceException { + public ReportExport create( + RunExportCriteria criteria, + ReportExecutionDescriptor executionDetails, + ExportExecutionDescriptor exportExecutionDetails) throws ServiceException { String exportId = exportExecutionDetails.getExportId(); ExportDescriptor export = findExportDescriptor(executionDetails, exportId); if (export == null) { throw new ServiceException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); } - Collection attachments = adaptAttachments(export); - return new ReportExport(mExecutionId, exportId, attachments, mExportUseCase); + List attachments = adaptAttachments(criteria, export); + return new ReportExport(mExecutionId, exportId, attachments, criteria, mExportUseCase); } @NotNull - private Collection adaptAttachments(ExportDescriptor export) { + private List adaptAttachments(RunExportCriteria criteria, ExportDescriptor export) { String exportId = export.getId(); Set rawAttachments = export.getAttachments(); - Collection attachments = new ArrayList<>(rawAttachments.size()); + List attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { ReportAttachment reportAttachment = new ReportAttachment( - attachment.getFileName(), mExecutionId, exportId, mExportUseCase); + attachment.getFileName(), + mExecutionId, + exportId, + criteria, + mExportUseCase); attachments.add(reportAttachment); } return attachments; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index e444c181..aa7846d1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -38,21 +38,28 @@ public final class ReportAttachment { private final String mExecutionId; private final String mExportId; + private final RunExportCriteria mCriteria; private final ReportExportUseCase mExportUseCase; ReportAttachment(String fileName, String executionId, String exportId, + RunExportCriteria criteria, ReportExportUseCase exportUseCase) { mFileName = fileName; mExecutionId = executionId; mExportId = exportId; + mCriteria = criteria; mExportUseCase = exportUseCase; } @NotNull public ResourceOutput download() throws ServiceException { return mExportUseCase.requestExportAttachmentOutput( - mExecutionId, mExportId, mFileName); + mCriteria, + mExecutionId, + mExportId, + mFileName + ); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 56c2ee7e..66ec3d23 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -26,13 +26,17 @@ import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -51,13 +55,23 @@ public final class ReportExecution { private final String mExecutionId; private final String mReportUri; private final ExportFactory mExportFactory; + private final ReportService mService; + private final RunReportCriteria mCriteria; + private final InfoCacheManager mInfoCacheManager; @TestOnly - ReportExecution(long delay, + ReportExecution(ReportService service, + RunReportCriteria criteria, + InfoCacheManager infoCacheManager, + long delay, ReportExecutionUseCase executionUseCase, ReportExportUseCase exportUseCase, String executionId, String reportUri) { + mService = service; + mCriteria = criteria; + mInfoCacheManager = infoCacheManager; + mDelay = delay; mExecutionUseCase = executionUseCase; mExportUseCase = exportUseCase; @@ -75,8 +89,18 @@ public ReportMetadata waitForReportCompletion() throws ServiceException { @NotNull public ReportExecution updateExecution(List newParameters) throws ServiceException { - mExecutionUseCase.updateExecution(mExecutionId, newParameters); - return this; + ServerInfo info = mInfoCacheManager.getInfo(); + ServerVersion version = info.getVersion(); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + RunReportCriteria criteria = mCriteria.newBuilder() + .params(newParameters) + .create(); + return mService.run(mReportUri, criteria); + } else { + mExecutionUseCase.updateExecution(mExecutionId, newParameters); + mService.waitForReportExecutionStart(mReportUri, mExecutionId); + return this; + } } @NotNull @@ -99,8 +123,7 @@ public ReportExport export(RunExportCriteria criteria) throws ServiceException { @NotNull private ReportMetadata performAwaitFoReport() throws ServiceException { - ReportExecutionDescriptor details = requestExecutionDetails(); - ReportExecutionDescriptor completeDetails = waitForReportReadyStart(details); + ReportExecutionDescriptor completeDetails = waitForReportReadyStart(); return new ReportMetadata(mReportUri, completeDetails.getTotalPages()); } @@ -108,58 +131,68 @@ private ReportMetadata performAwaitFoReport() throws ServiceException { @NotNull private ReportExport performExport(RunExportCriteria criteria) throws ServiceException { ExportExecutionDescriptor exportDetails = runExport(criteria); - waitForExportReadyStatus(exportDetails); + String exportId = exportDetails.getExportId(); + waitForExportReadyStatus(exportId); ReportExecutionDescriptor currentDetails = requestExecutionDetails(); - return mExportFactory.create(currentDetails, exportDetails); + return mExportFactory.create(criteria, currentDetails, exportDetails); } - private void waitForExportReadyStatus(ExportExecutionDescriptor exportDetails) throws ServiceException { - final String exportId = exportDetails.getExportId(); - - Status status = Status.wrap(exportDetails.getStatus()); - ErrorDescriptor descriptor = exportDetails.getErrorDescriptor(); - while (!status.isReady()) { + private void waitForExportReadyStatus(String exportId) throws ServiceException { + ExecutionStatus executionStatus; + ErrorDescriptor descriptor; + Status status; + do { + executionStatus = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); + status = Status.wrap(executionStatus.getStatus()); + descriptor = executionStatus.getErrorDescriptor(); if (status.isCancelled()) { throw new ServiceException( String.format("Export for report '%s' execution cancelled", mReportUri), null, StatusCodes.EXPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw new ServiceException(descriptor.getMessage(), null, StatusCodes.EXPORT_EXECUTION_FAILED); + String message = "Failed to perform report export"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.EXPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - - status = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); - } + } while (!status.isReady()); } @NotNull - private ReportExecutionDescriptor waitForReportReadyStart(final ReportExecutionDescriptor firstRunDetails) throws ServiceException { - Status status = Status.wrap(firstRunDetails.getStatus()); - ErrorDescriptor descriptor = firstRunDetails.getErrorDescriptor(); - ReportExecutionDescriptor nextDetails = firstRunDetails; - while (!status.isReady()) { + private ReportExecutionDescriptor waitForReportReadyStart() throws ServiceException { + ReportExecutionDescriptor nextDetails; + ErrorDescriptor descriptor; + Status status; + do { + nextDetails = requestExecutionDetails(); + descriptor = nextDetails.getErrorDescriptor(); + status = Status.wrap(nextDetails.getStatus()); + if (status.isCancelled()) { throw new ServiceException( String.format("Report '%s' execution cancelled", mReportUri), null, StatusCodes.REPORT_EXECUTION_CANCELLED); } if (status.isFailed()) { - throw new ServiceException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); + String message = "Failed to perform report execute"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.REPORT_EXECUTION_FAILED); } try { Thread.sleep(mDelay); } catch (InterruptedException ex) { throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - nextDetails = requestExecutionDetails(); - status = Status.wrap(nextDetails.getStatus()); - descriptor = nextDetails.getErrorDescriptor(); - } + } while (!status.isReady()); return nextDetails; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 0c7c56be..63086aea 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -30,9 +30,12 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -42,25 +45,31 @@ * @author Tom Koptel * @since 2.0 */ -final class ReportExecutionUseCase { +class ReportExecutionUseCase { private final ReportExecutionRestApi mExecutionApi; private final CallExecutor mCallExecutor; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + private final InfoCacheManager mCacheManager; ReportExecutionUseCase(ReportExecutionRestApi executionApi, CallExecutor callExecutor, + InfoCacheManager cacheManager, ExecutionOptionsDataMapper executionOptionsMapper) { mExecutionApi = executionApi; mCallExecutor = callExecutor; + mCacheManager = cacheManager; mExecutionOptionsMapper = executionOptionsMapper; } @NotNull public ReportExecutionDescriptor runReportExecution(final String reportUri, final RunReportCriteria criteria) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); Call call = new Call() { @Override public ReportExecutionDescriptor perform(String token) throws IOException, HttpException { - ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, criteria); + ReportExecutionRequestOptions options = + mExecutionOptionsMapper.transformRunReportOptions(reportUri, version, criteria); return mExecutionApi.runReportExecution(token, options); } }; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index d9c29d65..7b89698b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -26,38 +26,40 @@ import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; -import java.util.Collection; +import java.util.List; /** * @author Tom Koptel * @since 2.0 */ public final class ReportExport { - private final Collection mAttachments; + private final List mAttachments; private final String mExecutionId; private final String mExportId; private final ReportExportUseCase mExportUseCase; + private final RunExportCriteria mCriteria; ReportExport(String executionId, String exportId, - Collection attachments, + List attachments, + RunExportCriteria criteria, ReportExportUseCase exportUseCase) { mExecutionId = executionId; mExportId = exportId; mAttachments = attachments; + mCriteria = criteria; mExportUseCase = exportUseCase; } @NotNull - public Collection getAttachments() { + public List getAttachments() { return mAttachments; } @NotNull public ReportOutput download() throws ServiceException { - return mExportUseCase.requestExportOutput(mExecutionId, mExportId); + return mExportUseCase.requestExportOutput(mCriteria, mExecutionId, mExportId); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index c2c16c8e..ca1b6a89 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -31,11 +31,14 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -44,24 +47,31 @@ * @author Tom Koptel * @since 2.0 */ -final class ReportExportUseCase { +class ReportExportUseCase { private final ReportExportRestApi mExportApi; private final CallExecutor mCallExecutor; private final ExecutionOptionsDataMapper mExecutionOptionsMapper; + private final InfoCacheManager mCacheManager; ReportExportUseCase(ReportExportRestApi exportApi, - CallExecutor callExecutor, ExecutionOptionsDataMapper executionOptionsMapper) { + CallExecutor callExecutor, + InfoCacheManager cacheManager, + ExecutionOptionsDataMapper executionOptionsMapper) { mExportApi = exportApi; mCallExecutor = callExecutor; + mCacheManager = cacheManager; mExecutionOptionsMapper = executionOptionsMapper; } @NotNull public ExportExecutionDescriptor runExport(final String executionId, final RunExportCriteria criteria) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); + Call call = new Call() { @Override public ExportExecutionDescriptor perform(String token) throws IOException, HttpException { - ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria); + ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria, version); return mExportApi.runExportExecution(token, executionId, options); } }; @@ -69,24 +79,34 @@ public ExportExecutionDescriptor perform(String token) throws IOException, HttpE } @NotNull - public Status checkExportExecutionStatus(final String executionId, final String exportId) throws ServiceException { - Call call = new Call() { + public ExecutionStatus checkExportExecutionStatus(final String executionId, + final String exportId) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + return ExecutionStatus.readyStatus(); + } + + Call call = new Call() { @Override - public Status perform(String token) throws IOException, HttpException { - ExecutionStatus exportStatus = mExportApi - .checkExportExecutionStatus(token, executionId, exportId); - return Status.wrap(exportStatus.getStatus()); + public ExecutionStatus perform(String token) throws IOException, HttpException { + return mExportApi.checkExportExecutionStatus(token, executionId, exportId); } }; return mCallExecutor.execute(call); } @NotNull - public ReportOutput requestExportOutput(final String executionId, final String exportId) throws ServiceException { + public ReportOutput requestExportOutput(RunExportCriteria exportCriteria, + final String executionId, + String exportId) throws ServiceException { + exportId = adaptExportId(exportCriteria, exportId); + final String resultId = exportId; + Call call = new Call() { @Override public ReportOutput perform(String token) throws IOException, HttpException { - ExportOutputResource result = mExportApi.requestExportOutput(token, executionId, exportId); + ExportOutputResource result = mExportApi.requestExportOutput(token, executionId, resultId); return OutputDataMapper.transform(result); } }; @@ -94,16 +114,32 @@ public ReportOutput perform(String token) throws IOException, HttpException { } @NotNull - public ResourceOutput requestExportAttachmentOutput(final String executionId, final String exportId, + public ResourceOutput requestExportAttachmentOutput(RunExportCriteria exportCriteria, + final String executionId, + String exportId, final String fileName) throws ServiceException { + exportId = adaptExportId(exportCriteria, exportId); + final String resultId = exportId; + Call call = new Call() { @Override public ResourceOutput perform(String token) throws IOException, HttpException { OutputResource result = mExportApi.requestExportAttachment( - token, executionId, exportId, fileName); + token, executionId, resultId, fileName); return OutputDataMapper.transform(result); } }; return mCallExecutor.execute(call); } + + private String adaptExportId(RunExportCriteria exportCriteria, String exportId) throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + final ServerVersion version = info.getVersion(); + + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + exportId = String.format("%s;pages=%s", exportCriteria.getFormat(), exportCriteria.getPages()); + exportId = exportId.toLowerCase(); + } + return exportId; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 2c8a61de..85c2d912 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -33,8 +33,7 @@ import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; +import com.jaspersoft.android.sdk.service.internal.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -47,15 +46,18 @@ public final class ReportService { private final ReportExecutionUseCase mExecutionUseCase; + private final InfoCacheManager mInfoCacheManager; private final ReportExportUseCase mExportUseCase; private final long mDelay; @TestOnly ReportService( long delay, + InfoCacheManager infoCacheManager, ReportExecutionUseCase executionUseCase, ReportExportUseCase exportUseCase) { mDelay = delay; + mInfoCacheManager = infoCacheManager; mExecutionUseCase = executionUseCase; mExportUseCase = exportUseCase; } @@ -71,16 +73,22 @@ public static ReportService create(RestClient client, Session session) { .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .baseUrl(client.getServerUrl()) .build(); - CallExecutor callExecutor = DefaultCallExecutor.create(client, session); - ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getServerUrl()); + ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); + ServiceExceptionMapper reportExMapper = new ReportExceptionMapper(defaultExMapper); + TokenCacheManager tokenCacheManager = TokenCacheManager.create(client, session); + CallExecutor callExecutor = new DefaultCallExecutor(tokenCacheManager, reportExMapper); + ExecutionOptionsDataMapper executionOptionsMapper = ExecutionOptionsDataMapper.create(client); + + InfoCacheManager cacheManager = InfoCacheManager.create(client); ReportExecutionUseCase reportExecutionUseCase = - new ReportExecutionUseCase(executionApi, callExecutor, executionOptionsMapper); + new ReportExecutionUseCase(executionApi, callExecutor, cacheManager, executionOptionsMapper); ReportExportUseCase reportExportUseCase = - new ReportExportUseCase(exportApi, callExecutor, executionOptionsMapper); + new ReportExportUseCase(exportApi, callExecutor, cacheManager, executionOptionsMapper); return new ReportService( - TimeUnit.SECONDS.toMillis(1), + client.getPollTimeout(), + cacheManager, reportExecutionUseCase, reportExportUseCase); } @@ -93,9 +101,12 @@ public ReportExecution run(String reportUri, RunReportCriteria criteria) throws private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws ServiceException { ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); - waitForReportExecutionStart(reportUri, details); + waitForReportExecutionStart(reportUri, details.getExecutionId()); return new ReportExecution( + this, + criteria, + mInfoCacheManager, mDelay, mExecutionUseCase, mExportUseCase, @@ -103,12 +114,13 @@ private ReportExecution performRun(String reportUri, RunReportCriteria criteria) details.getReportURI()); } - private void waitForReportExecutionStart(String reportUri, ReportExecutionDescriptor details) throws ServiceException { - String executionId = details.getExecutionId(); - Status status = Status.wrap(details.getStatus()); - ErrorDescriptor descriptor = details.getErrorDescriptor(); + void waitForReportExecutionStart(String reportUri, String executionId) throws ServiceException { + Status status; + do { + ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); + status = Status.wrap(statusDetails.getStatus()); + ErrorDescriptor descriptor = statusDetails.getErrorDescriptor(); - while (!status.isReady() && !status.isExecution()) { if (status.isCancelled()) { throw new ServiceException( String.format("Report '%s' execution cancelled", reportUri), null, @@ -122,9 +134,7 @@ private void waitForReportExecutionStart(String reportUri, ReportExecutionDescri } catch (InterruptedException ex) { throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); } - ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); - status = Status.wrap(statusDetails.getStatus()); - descriptor = statusDetails.getErrorDescriptor(); - } + + } while (!status.isReady() && !status.isExecution()); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java index a18261f9..df0b4ec2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java @@ -58,6 +58,14 @@ public Builder freshData(boolean freshData) { return this; } + /** + * Configuration for report interactiveness + * + * NOTICE: This flag ignored for JRS 5.6 where we are forcing disable state + * + * @param interactive weather report should be interactive or not + * @return builder instance + */ public Builder interactive(boolean interactive) { this.interactive = interactive; return this; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java index 155ebaac..f68c65f1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java @@ -49,6 +49,18 @@ private RunReportCriteria(boolean freshData, mParams = params; } + @NotNull + public Builder newBuilder() { + return new Builder() + .freshData(mFreshData) + .interactive(mInteractive) + .saveSnapshot(mSaveSnapshot) + .format(mFormat) + .pages(mPages) + .params(mParams) + .attachmentPrefix(mAttachmentPrefix); + } + @NotNull public static Builder builder() { return new Builder(); @@ -77,6 +89,14 @@ public Builder freshData(boolean freshData) { return this; } + /** + * Configuration for report interactiveness + * + * NOTICE: This flag ignored for JRS 5.6 where we are forcing disable state + * + * @param interactive weather report should be interactive or not + * @return builder instance + */ public Builder interactive(boolean interactive) { this.interactive = interactive; return this; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java index 4872e8ef..3f608881 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java @@ -63,4 +63,21 @@ public boolean isReady() { public String toString() { return mStatus; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Status status = (Status) o; + + if (mStatus != null ? !mStatus.equals(status.mStatus) : status.mStatus != null) return false; + + return true; + } + + @Override + public int hashCode() { + return mStatus != null ? mStatus.hashCode() : 0; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 21e65266..043a01e4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -27,9 +27,7 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.Session; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.DefaultCallExecutor; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.*; import org.jetbrains.annotations.TestOnly; import java.util.concurrent.TimeUnit; @@ -54,7 +52,10 @@ public static RepositoryService create(RestClient client, Session session) { .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .build(); - CallExecutor callExecutor = DefaultCallExecutor.create(client, session); + ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); + TokenCacheManager tokenCacheManager = TokenCacheManager.create(client, session); + CallExecutor callExecutor = new DefaultCallExecutor(tokenCacheManager, defaultExMapper); + InfoCacheManager cacheManager = InfoCacheManager.create(client); ResourceMapper resourceMapper = new ResourceMapper(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 52b9610a..cf813b91 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -31,8 +31,9 @@ import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.TestOnly; import java.io.IOException; @@ -46,11 +47,13 @@ public class ServerInfoService { private final ServerRestApi mRestApi; private final ServerInfoTransformer mTransformer; + private final ServiceExceptionMapper mServiceExceptionMapper; @TestOnly - ServerInfoService(ServerRestApi restApi, ServerInfoTransformer transformer) { + ServerInfoService(ServerRestApi restApi, ServerInfoTransformer transformer, ServiceExceptionMapper serviceExceptionMapper) { mRestApi = restApi; mTransformer = transformer; + mServiceExceptionMapper = serviceExceptionMapper; } public static ServerInfoService create(RestClient client) { @@ -59,12 +62,14 @@ public static ServerInfoService create(RestClient client) { .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) .build(); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - return new ServerInfoService(restApi, ServerInfoTransformer.get()); + return new ServerInfoService(restApi, ServerInfoTransformer.get(), serviceExceptionMapper); } public static ServerInfoService create(ServerRestApi restApi) { - return new ServerInfoService(restApi, ServerInfoTransformer.get()); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); + return new ServerInfoService(restApi, ServerInfoTransformer.get(), serviceExceptionMapper); } public ServerInfo requestServerInfo() throws ServiceException { @@ -72,9 +77,9 @@ public ServerInfo requestServerInfo() throws ServiceException { ServerInfoData response = mRestApi.requestServerInfo(); return mTransformer.transform(response); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } @@ -83,9 +88,9 @@ public ServerVersion requestServerVersion() throws ServiceException { String version = mRestApi.requestVersion(); return ServerVersion.valueOf(version); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } @@ -94,9 +99,9 @@ public SimpleDateFormat requestServerDateTimeFormat() throws ServiceException { String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); return new SimpleDateFormat(dateTimeFormat); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mServiceExceptionMapper.transform(e); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index ebc61355..24748e10 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -176,10 +176,10 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { public void shouldRequestExportOutput() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportOutput("cookie", "execution_id", "export_id"); + restApiUnderTest.requestExportOutput("cookie", "execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); - assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/outputResource?suppressContentDisposition=true")); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/outputResource?suppressContentDisposition=true")); assertThat(request.getHeader("Cookie"), is("cookie")); } @@ -201,10 +201,10 @@ public void shouldRequestExportAttachment() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportAttachment("cookie", "execution_id", "export_id", "attachment_id"); + restApiUnderTest.requestExportAttachment("cookie", "execution_id", "html;pages=1", "attachment_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); - assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/attachments/attachment_id")); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/attachments/attachment_id")); assertThat(request.getHeader("Cookie"), is("cookie")); } @@ -225,10 +225,10 @@ public void shouldCheckExportExecutionStatus() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.checkExportExecutionStatus("cookie", "execution_id", "export_id"); + restApiUnderTest.checkExportExecutionStatus("cookie", "execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); - assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/export_id/status")); + assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/status")); assertThat(request.getHeader("Cookie"), is("cookie")); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java index e008e588..ba9ce605 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java @@ -28,7 +28,7 @@ import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import java.io.IOException; @@ -38,9 +38,11 @@ */ public final class FakeCallExecutor implements CallExecutor { private final String mToken; + private final DefaultExceptionMapper mExMapper; public FakeCallExecutor(String token) { mToken = token; + mExMapper = new DefaultExceptionMapper(); } @Override @@ -48,9 +50,9 @@ public T execute(Call call) throws ServiceException { try { return call.perform(mToken); } catch (IOException e) { - throw ServiceExceptionMapper.transform(e); + throw mExMapper.transform(e); } catch (HttpException e) { - throw ServiceExceptionMapper.transform(e); + throw mExMapper.transform(e); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java index c0abcba5..e1e491db 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java @@ -62,7 +62,7 @@ public void setUp() throws Exception { when(_401Exception.code()).thenReturn(401); when(mCall.perform(anyString())).thenReturn(mResponse); - resolver = new DefaultCallExecutor(mTokenCacheManager); + resolver = new DefaultCallExecutor(mTokenCacheManager, new DefaultExceptionMapper()); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapperTest.java similarity index 90% rename from core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapperTest.java index 18129442..5aeb2bcc 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/ServiceExceptionMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapperTest.java @@ -51,21 +51,24 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({ErrorDescriptor.class}) -public class ServiceExceptionMapperTest { +public class DefaultExceptionMapperTest { @Mock HttpException mHttpException; @Mock ErrorDescriptor mDescriptor; + private DefaultExceptionMapper defaultExceptionMapper; + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); + defaultExceptionMapper = new DefaultExceptionMapper(); } @Test public void testTransformIOException() throws Exception { IOException ioException = new IOException("Socket timed out", new SocketTimeoutException()); - ServiceException serviceException = ServiceExceptionMapper.transform(ioException); + ServiceException serviceException = defaultExceptionMapper.transform(ioException); assertThat(serviceException.code(), is(StatusCodes.NETWORK_ERROR)); assertThat(serviceException.getMessage(), is("Failed to perform network request. Check network!")); assertThat(serviceException.getCause(), is(instanceOf(IOException.class))); @@ -76,7 +79,7 @@ public void testTransform500HttpException() throws Exception { when(mHttpException.code()).thenReturn(500); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.INTERNAL_ERROR)); assertThat(serviceException.getMessage(), is("Server encountered unexpected error")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -87,7 +90,7 @@ public void testTransform404HttpException() throws Exception { when(mHttpException.code()).thenReturn(404); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.CLIENT_ERROR)); assertThat(serviceException.getMessage(), is("Service exist but requested entity not found")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -98,7 +101,7 @@ public void testTransform400HttpException() throws Exception { when(mHttpException.code()).thenReturn(400); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.CLIENT_ERROR)); assertThat(serviceException.getMessage(), is("Some parameters in request not valid")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -109,7 +112,7 @@ public void testTransform403HttpException() throws Exception { when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); assertThat(serviceException.getMessage(), is("User has no access to resource")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -120,7 +123,7 @@ public void testTransform401HttpException() throws Exception { when(mHttpException.code()).thenReturn(401); when(mHttpException.getDescriptor()).thenReturn(null); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.AUTHORIZATION_ERROR)); assertThat(serviceException.getMessage(), is("User is not authorized")); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); @@ -132,7 +135,7 @@ public void testTransformWithDescriptorWithMissingKey() throws IOException { when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenReturn(mDescriptor); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.PERMISSION_DENIED_ERROR)); assertThat(serviceException.getCause(), is(instanceOf(HttpException.class))); } @@ -143,7 +146,7 @@ public void testTransformWillHandleIOExceptionForDescriptorMapping() throws IOEx when(mHttpException.code()).thenReturn(403); when(mHttpException.getDescriptor()).thenThrow(new IOException("Failed IO")); - ServiceException serviceException = ServiceExceptionMapper.transform(mHttpException); + ServiceException serviceException = defaultExceptionMapper.transform(mHttpException); assertThat(serviceException.code(), is(StatusCodes.NETWORK_ERROR)); assertThat(serviceException.getCause(), is(instanceOf(IOException.class))); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java index dc844ca1..94be8dd6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java @@ -27,8 +27,10 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; import org.junit.Test; +import org.mockito.MockitoAnnotations; import java.util.Collections; import java.util.List; @@ -51,6 +53,7 @@ public class ExecutionOptionsDataMapperTest { @Before public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); mapper = new ExecutionOptionsDataMapper(BASE_URL); } @@ -65,7 +68,7 @@ public void testTransformReportOptions() throws Exception { .params(REPORT_PARAMS) .attachmentPrefix("./") .create(); - ReportExecutionRequestOptions options = mapper.transformRunReportOptions(REPORT_URI, criteria); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions(REPORT_URI, ServerVersion.v6, criteria); assertThat(options.getReportUnitUri(), is(REPORT_URI)); assertThat(options.getParameters(), is(REPORT_PARAMS)); assertThat(options.getAsync(), is(true)); @@ -82,10 +85,69 @@ public void testTransformExportOptions() throws Exception { .pages("1-100") .attachmentPrefix("./") .create(); - ExecutionRequestOptions options = mapper.transformExportOptions(criteria); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v6); assertOptions(options); } + @Test + public void testReportExecutionFieldsReducedForServer5_5() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder() + .freshData(true) + .interactive(false) + .saveSnapshot(true) + .create(); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); + assertThat("Should reduce 'baseUrl' from options", options.getBaseUrl(), is(nullValue())); + assertThat("Should reduce 'allowInteractive' from options", options.getAllowInlineScripts(), is(nullValue())); + } + + @Test + public void testInteractivenessDisabledForReportRun5_6() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder() + .interactive(true) + .create(); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_6, criteria); + assertThat("Should put false for 'interactive' option", options.getInteractive(), is(Boolean.FALSE)); + } + + @Test + public void testInteractivenessDisabledForExportRun5_6() throws Exception { + RunExportCriteria criteria = RunExportCriteria.builder() + .interactive(true) + .create(); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_6); + assertThat("Should put false for 'interactive' option", options.getInteractive(), is(Boolean.FALSE)); + } + + @Test + public void testExportExecutionFieldsReducedForServer5_5() throws Exception { + RunExportCriteria criteria = RunExportCriteria.builder() + .freshData(true) + .interactive(false) + .saveSnapshot(true) + .create(); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_5); + assertThat("Should reduce 'baseUrl' from options", options.getBaseUrl(), is(nullValue())); + assertThat("Should reduce 'allowInteractive' from options", options.getAllowInlineScripts(), is(nullValue())); + assertThat("Should reduce 'freshData' from options",options.getFreshData(), is(nullValue())); + assertThat("Should reduce 'interactive' from options",options.getInteractive(), is(nullValue())); + assertThat("Should reduce 'saveDataSnapshot' from options",options.getSaveDataSnapshot(), is(nullValue())); + } + + @Test + public void testExportExecutionSetsHtmlFormatIfOneUnspecified5_5() throws Exception { + RunExportCriteria criteria = RunExportCriteria.builder().create(); + ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_5); + assertThat("Should set 'HTML' format", options.getOutputFormat(), is("HTML")); + } + + @Test + public void testReportExecutionSetsHtmlFormatIfOneUnspecified5_5() throws Exception { + RunReportCriteria criteria = RunReportCriteria.builder().create(); + ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); + assertThat("Should set 'HTML' format", options.getOutputFormat(), is("HTML")); + } + private void assertOptions(ExecutionRequestOptions options) { assertThat(options.getFreshData(), is(true)); assertThat(options.getSaveDataSnapshot(), is(true)); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 5fa96eec..57fdbe42 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import org.junit.Before; import org.junit.Test; @@ -39,6 +38,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; @@ -55,27 +55,28 @@ public class ReportAttachmentTest { @Mock ReportExportRestApi mExportRestApi; @Mock - OutputResource input; + ResourceOutput input; + @Mock + ReportExportUseCase mReportExportUseCase; + @Mock + RunExportCriteria mRunExportCriteria; private ReportAttachment objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, new FakeCallExecutor("cookie"), executionOptionsDataMapper); - objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", exportUseCase); + objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", mRunExportCriteria, mReportExportUseCase); } @Test public void testDownload() throws Exception { - when(mExportRestApi.requestExportAttachment(anyString(), anyString(), anyString(), anyString())).thenReturn(input); + when(mReportExportUseCase.requestExportAttachmentOutput(any(RunExportCriteria.class), anyString(), anyString(), anyString())).thenReturn(input); ResourceOutput result = objectUnderTest.download(); assertThat(result, is(notNullValue())); - verify(mExportRestApi).requestExportAttachment(eq("cookie"), eq("exec_id"), eq("export_id"), eq("1.jpg")); - verifyNoMoreInteractions(mExportRestApi); + verify(mReportExportUseCase).requestExportAttachmentOutput(eq(mRunExportCriteria), eq("exec_id"), eq("export_id"), eq("1.jpg")); + verifyNoMoreInteractions(mReportExportUseCase); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java index 2f19bfed..cd95b563 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java @@ -24,15 +24,18 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.*; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; @@ -49,6 +52,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; +import static com.jaspersoft.android.sdk.test.Chain.of; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.Assert.fail; @@ -71,7 +75,9 @@ ExportDescriptor.class, ExecutionStatus.class, ErrorDescriptor.class, - ExecutionOptionsDataMapper.class}) + ExecutionOptionsDataMapper.class, + ReportService.class, +}) public class ReportExecutionTest { @Mock @@ -90,15 +96,24 @@ public class ReportExecutionTest { ErrorDescriptor mDescriptor; @Mock - ReportExportRestApi mExportRestApi; + ReportExecutionUseCase mReportExecutionUseCase; + @Mock + ReportExportUseCase mReportExportUseCase; + + @Mock + ReportService mReportService; @Mock - ReportExecutionRestApi mExecutionRestApi; + RunReportCriteria mReportCriteria; + + @Mock + InfoCacheManager mInfoCacheManager; + @Mock + ServerInfo mServerInfo; private ReportExecution objectUnderTest; @Rule public ExpectedException mException = ExpectedException.none(); - private ReportExecutionUseCase reportExecutionUseCase; @Before public void setUp() throws Exception { @@ -107,35 +122,37 @@ public void setUp() throws Exception { when(mReportExecDetails1.getExecutionId()).thenReturn("execution_id"); when(mReportExecDetails1.getReportURI()).thenReturn("/report/uri"); - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/report/uri"); - FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); - reportExecutionUseCase = spy( - new ReportExecutionUseCase(mExecutionRestApi, callExecutor, executionOptionsDataMapper) - ); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, callExecutor, executionOptionsDataMapper); + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); + objectUnderTest = new ReportExecution( + mReportService, + mReportCriteria, + mInfoCacheManager, TimeUnit.SECONDS.toMillis(0), - reportExecutionUseCase, - exportUseCase, + mReportExecutionUseCase, + mReportExportUseCase, "execution_id", "/report/uri"); } @Test(timeout = 2000) public void testRequestExportIdealCase() throws Exception { + mockRunExportExecution("queued"); + mockCheckExportExecStatus("ready"); mockReportExecutionDetails("ready"); - mockRunExportExecution("ready"); objectUnderTest.export(exportCriteria); - verify(mExportRestApi).runExportExecution(eq("cookie"), eq("execution_id"), any(ExecutionRequestOptions.class)); - verify(mExecutionRestApi).requestReportExecutionDetails(eq("cookie"), eq("execution_id")); + verify(mReportExportUseCase).runExport(eq("execution_id"), any(RunExportCriteria.class)); + verify(mReportExecutionUseCase).requestExecutionDetails(eq("execution_id")); } @Test(timeout = 2000) public void testRunThrowsFailedStatusImmediately() throws Exception { // export run request - mockRunExportExecution("failed"); + mockRunExportExecution("queued"); + mockCheckExportExecStatus("failed"); try { objectUnderTest.export(exportCriteria); @@ -160,7 +177,8 @@ public void testRunShouldThrowFailedIfStatusFailed() throws Exception { @Test(timeout = 2000) public void testRunThrowsCancelledStatusImmediately() throws Exception { // export run request - mockRunExportExecution("cancelled"); + mockRunExportExecution("queued"); + mockCheckExportExecStatus("cancelled"); try { objectUnderTest.export(exportCriteria); @@ -191,17 +209,18 @@ public void testRunReportPendingCase() throws Exception { objectUnderTest.export(exportCriteria); - verify(mExportRestApi, times(2)).checkExportExecutionStatus(eq("cookie"), eq("execution_id"), eq("export_id")); + verify(mReportExportUseCase, times(2)).checkExportExecutionStatus(eq("execution_id"), eq("export_id")); } @Test(timeout = 2000) public void ensureThatExportCancelledEventWillBeResolved() throws Exception { - mockRunExportExecution("cancelled", "ready"); + mockRunExportExecution("queued"); + mockCheckExportExecStatus("cancelled", "ready"); mockReportExecutionDetails("ready"); objectUnderTest.export(exportCriteria); - verify(mExportRestApi, times(2)).runExportExecution(eq("cookie"), eq("execution_id"), any(ExecutionRequestOptions.class)); + verify(mReportExportUseCase, times(2)).runExport(eq("execution_id"), any(RunExportCriteria.class)); } @Test(timeout = 2000) @@ -213,8 +232,8 @@ public void testAwaitCompleteReport() throws Exception { assertThat(metadata.getTotalPages(), is(100)); assertThat(metadata.getUri(), is("/report/uri")); - verify(mExecutionRestApi).requestReportExecutionDetails(anyString(), anyString()); - verifyNoMoreInteractions(mExecutionRestApi); + verify(mReportExecutionUseCase).requestExecutionDetails(anyString()); + verifyNoMoreInteractions(mReportExecutionUseCase); } @Test(timeout = 2000) @@ -223,8 +242,8 @@ public void testAwaitCompleteReportShouldLoopCalls() throws Exception { objectUnderTest.waitForReportCompletion(); - verify(mExecutionRestApi, times(2)).requestReportExecutionDetails(anyString(), anyString()); - verifyNoMoreInteractions(mExecutionRestApi); + verify(mReportExecutionUseCase, times(2)).requestExecutionDetails(anyString()); + verifyNoMoreInteractions(mReportExecutionUseCase); } @Test(timeout = 2000) @@ -249,26 +268,25 @@ public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception } } - @Test + @Test(timeout = 2000) public void testUpdateExecution() throws Exception { List params = Collections.emptyList(); objectUnderTest.updateExecution(params); - verify(reportExecutionUseCase).updateExecution("execution_id", params); + verify(mReportExecutionUseCase).updateExecution("execution_id", params); } private void mockCheckExportExecStatus(String... statusChain) throws Exception { ensureChain(statusChain); when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); - when(mExecutionStatusResponse.getErrorDescriptor()).thenReturn(mDescriptor); - when(mExportRestApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(mExecutionStatusResponse); + when(mReportExportUseCase.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); } private void mockRunExportExecution(String... statusChain) throws Exception { ensureChain(statusChain); when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).then(Chain.of(statusChain)); + when(mExportExecDetails.getStatus()).then(of(statusChain)); when(mExportExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(mExportRestApi.runExportExecution(anyString(), anyString(), any(ExecutionRequestOptions.class))).thenReturn(mExportExecDetails); + when(mReportExportUseCase.runExport(anyString(), any(RunExportCriteria.class))).thenReturn(mExportExecDetails); } private void mockReportExecutionDetails(String firstStatus, String... statusChain) throws Exception { @@ -280,12 +298,12 @@ private void mockReportExecutionDetails(String firstStatus, String... statusChai when(mReportExecDetails1.getExports()).thenReturn(exports); when(mReportExecDetails1.getErrorDescriptor()).thenReturn(mDescriptor); - when(mReportExecDetails2.getStatus()).then(Chain.of(statusChain)); + when(mReportExecDetails2.getStatus()).then(of(statusChain)); when(mReportExecDetails2.getExports()).thenReturn(exports); when(mReportExecDetails2.getErrorDescriptor()).thenReturn(mDescriptor); - when(mExecutionRestApi.requestReportExecutionDetails(anyString(), anyString())) - .then(Chain.of(mReportExecDetails1, mReportExecDetails2)); + when(mReportExecutionUseCase.requestExecutionDetails(anyString())) + .then(of(mReportExecDetails1, mReportExecDetails2)); } private void ensureChain(String[] statusChain) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java index bf295d04..b4b1ed18 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java @@ -28,6 +28,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,6 +45,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) @@ -55,6 +59,10 @@ public class ReportExecutionUseCaseTest { ReportExecutionRestApi mExecutionRestApi; @Mock ExecutionOptionsDataMapper mDataMapper; + @Mock + InfoCacheManager mInfoCacheManager; + @Mock + ServerInfo mServerInfo; private ReportExecutionUseCase executionUseCase; private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor("token"); @@ -62,15 +70,17 @@ public class ReportExecutionUseCaseTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); executionUseCase = - new ReportExecutionUseCase(mExecutionRestApi, fakeCallExecutor, mDataMapper); + new ReportExecutionUseCase(mExecutionRestApi, fakeCallExecutor, mInfoCacheManager, mDataMapper); } @Test public void testRunReportExecution() throws Exception { RunReportCriteria criteria = RunReportCriteria.builder().create(); executionUseCase.runReportExecution("/my/uri", criteria); - verify(mDataMapper).transformRunReportOptions("/my/uri", criteria); + verify(mDataMapper).transformRunReportOptions("/my/uri", ServerVersion.v6, criteria); verify(mExecutionRestApi).runReportExecution(eq("token"), any(ReportExecutionRequestOptions.class)); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 406eb65c..fc178398 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -24,8 +24,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -43,23 +41,23 @@ */ public class ReportExportTest { @Mock - ReportExportRestApi mExportRestApi; + ReportExportUseCase mReportExportUseCase; + @Mock + RunExportCriteria mCriteria; private ReportExport objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - ReportExportUseCase exportUseCase = new ReportExportUseCase(mExportRestApi, new FakeCallExecutor("cookie"), executionOptionsDataMapper); - objectUnderTest = new ReportExport("report_execution_id", "export_id", Collections.emptyList(), exportUseCase); + objectUnderTest = new ReportExport("report_execution_id", "export_id", + Collections.emptyList(), mCriteria, mReportExportUseCase); } @Test public void testDownload() throws Exception { objectUnderTest.download(); - verify(mExportRestApi).requestExportOutput(eq("cookie"), eq("report_execution_id"), eq("export_id")); - verifyNoMoreInteractions(mExportRestApi); + verify(mReportExportUseCase).requestExportOutput(eq(mCriteria), eq("report_execution_id"), eq("export_id")); + verifyNoMoreInteractions(mReportExportUseCase); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java new file mode 100644 index 00000000..7f34b9b1 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java @@ -0,0 +1,148 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus.cancelledStatus; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; + +public class ReportExportUseCaseTest { + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + private static final String LEGACY_EXPORT_ID = "html;pages=1"; + + @Mock + ReportExportRestApi mExportApi; + @Mock + ExecutionOptionsDataMapper mExecutionOptionsMapper; + + @Mock + InfoCacheManager mCacheManager; + @Mock + ServerInfo mServerInfo; + + private static final RunExportCriteria EXPORT_HTML_PAGE_1 = RunExportCriteria.builder() + .format(ExecutionCriteria.Format.HTML) + .pages("1") + .create(); + + private ReportExportUseCase useCase; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + + when(mCacheManager.getInfo()).thenReturn(mServerInfo); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); + + FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); + useCase = new ReportExportUseCase(mExportApi, callExecutor, mCacheManager, mExecutionOptionsMapper); + } + + @Test + public void testRequestExportOutputOnServer5_5() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); + useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); + verify(mExportApi).requestExportOutput(eq("cookie"), eq(EXEC_ID), eq(LEGACY_EXPORT_ID)); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + } + + @Test + public void testRequestExportOutputOnServer5_6() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); + useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); + verify(mExportApi).requestExportOutput(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID)); + verify(mCacheManager).getInfo(); + } + + @Test + public void testRunExport() throws Exception { + useCase.runExport(EXEC_ID, EXPORT_HTML_PAGE_1); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + verify(mExecutionOptionsMapper).transformExportOptions(EXPORT_HTML_PAGE_1, ServerVersion.v6); + verify(mExportApi).runExportExecution(eq("cookie"), eq(EXEC_ID), any(ExecutionRequestOptions.class)); + } + + @Test + public void testCheckExportExecutionStatusOnServer5_5() throws Exception { + when(mExportApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); + + ExecutionStatus execStatus = useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); + assertThat("For server 5.5 status of export always ready", execStatus.getStatus(), is("ready")); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + verifyZeroInteractions(mExportApi); + } + + @Test + public void testCheckExportExecutionStatusOnServer5_6() throws Exception { + when(mExportApi.checkExportExecutionStatus(anyString(), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); + + useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + verify(mExportApi).checkExportExecutionStatus(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID)); + } + + @Test + public void testRequestExportAttachmentOutputOnServer5_5() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); + + useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); + verify(mExportApi).requestExportAttachment(eq("cookie"), eq(EXEC_ID), eq(LEGACY_EXPORT_ID), eq("nay")); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + } + + @Test + public void testRequestExportAttachmentOutputOnServer5_6() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); + + useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); + verify(mExportApi).requestExportAttachment(eq("cookie"), eq(EXEC_ID), eq(EXPORT_ID), eq("nay")); + verify(mCacheManager).getInfo(); + verify(mServerInfo).getVersion(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index ba2ebbd2..a228bb61 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -24,15 +24,12 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; @@ -67,10 +64,6 @@ ExecutionOptionsDataMapper.class}) public class ReportServiceTest { - @Mock - ReportExecutionRestApi executionApi; - @Mock - ReportExportRestApi exportApi; @Mock ErrorDescriptor mDescriptor; @@ -81,6 +74,14 @@ public class ReportServiceTest { @Mock ExecutionStatus statusDetails; + @Mock + ReportExecutionUseCase mReportExecutionUseCase; + @Mock + ReportExportUseCase mReportExportUseCase; + + @Mock + InfoCacheManager mInfoCacheManager; + ReportService objectUnderTest; @Rule @@ -90,32 +91,28 @@ public class ReportServiceTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - ExecutionOptionsDataMapper executionOptionsDataMapper = new ExecutionOptionsDataMapper("/my/uri"); - FakeCallExecutor callExecutor = new FakeCallExecutor("cookie"); - ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, callExecutor, executionOptionsDataMapper); - ReportExportUseCase exportUseCase = new ReportExportUseCase(exportApi, callExecutor, executionOptionsDataMapper); - objectUnderTest = new ReportService( TimeUnit.MILLISECONDS.toMillis(0), - reportExecutionUseCase, - exportUseCase); + mInfoCacheManager, + mReportExecutionUseCase, + mReportExportUseCase); } @Test public void testRunShouldCreateActiveSession() throws Exception { - mockRunReportExecution("execution"); - mockRunReportExecution("ready"); + mockRunReportExecution("queue"); + mockReportExecutionStatus("execution", "ready"); ReportExecution session = objectUnderTest.run("/report/uri", configuration); assertThat(session, is(notNullValue())); - verify(executionApi).runReportExecution(anyString(), any(ReportExecutionRequestOptions.class)); - verifyNoMoreInteractions(executionApi); + verify(mReportExecutionUseCase).runReportExecution(anyString(), any(RunReportCriteria.class)); } @Test public void testRunThrowsFailedStatusImmediately() throws Exception { - mockRunReportExecution("failed"); + mockRunReportExecution("queue"); + mockReportExecutionStatus("failed"); try { objectUnderTest.run("/report/uri", configuration); @@ -138,7 +135,8 @@ public void testRunShouldThrowFailedIfStatusFailed() throws Exception { @Test public void testRunThrowsCancelledStatusImmediately() throws Exception { - mockRunReportExecution("cancelled"); + mockRunReportExecution("queue"); + mockReportExecutionStatus("cancelled"); try { objectUnderTest.run("/report/uri", configuration); @@ -165,19 +163,19 @@ public void testRunShouldLoopUntilStatusExecution() throws Exception { mockReportExecutionStatus("queued", "execution"); objectUnderTest.run("/report/uri", configuration); - verify(executionApi, times(2)).requestReportExecutionStatus(anyString(), eq("exec_id")); + verify(mReportExecutionUseCase, times(2)).requestStatus(eq("exec_id")); } private void mockReportExecutionStatus(String... statusChain) throws Exception { when(statusDetails.getStatus()).then(Chain.of(statusChain)); when(statusDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(executionApi.requestReportExecutionStatus(anyString(), anyString())).thenReturn(statusDetails); + when(mReportExecutionUseCase.requestStatus(anyString())).thenReturn(statusDetails); } private void mockRunReportExecution(String execution) throws Exception { when(initDetails.getStatus()).thenReturn(execution); when(initDetails.getErrorDescriptor()).thenReturn(mDescriptor); when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(executionApi.runReportExecution(anyString(), any(ReportExecutionRequestOptions.class))).thenReturn(initDetails); + when(mReportExecutionUseCase.runReportExecution(anyString(), any(RunReportCriteria.class))).thenReturn(initDetails); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java index 99645a6d..102f4bfa 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,13 +54,15 @@ public class ServerInfoServiceTest { ServerInfoTransformer mockTransformer; @Mock ServerInfoData mockResponse; + @Mock + ServiceExceptionMapper mockServiceExceptionMapper; private ServerInfoService serviceUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - serviceUnderTest = new ServerInfoService(mockApi, mockTransformer); + serviceUnderTest = new ServerInfoService(mockApi, mockTransformer, mockServiceExceptionMapper); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java index e315c982..768e703d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/Chain.java @@ -27,24 +27,31 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 */ -public final class Chain implements Answer { - private final Response[] mChain; +public final class Chain implements Answer { + private final Value[] mChain; private int invocationCount = 0; - private Chain(Response... chain) { + private Chain(Value... chain) { mChain = chain; } - public static Chain of(Response... values) { + public static Chain of(Value... values) { return new Chain<>(values); } + @SuppressWarnings("unchecked") + public static Chain of(List values) { + return new Chain<>((Value[]) values.toArray()); + } + @Override - public Response answer(InvocationOnMock invocation) throws Throwable { + public Value answer(InvocationOnMock invocation) throws Throwable { int statusIndex = invocationCount; if (statusIndex >= mChain.length) { statusIndex = mChain.length - 1; From d26a14dc9d63460773f16fa0f6d942d06414d8ca Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 18 Dec 2015 15:32:29 +0200 Subject: [PATCH 351/457] Introduce client centered API --- .../android/sdk/network/AnonymousClient.java | 81 +++++++++ .../sdk/network/AnonymousClientImpl.java | 37 +++++ .../android/sdk/network/AuthPolicy.java | 17 ++ .../android/sdk/network/AuthPolicyImpl.java | 54 ++++++ .../sdk/network/AuthenticationRestApi.java | 125 ++++++++++++-- .../network/AuthenticationRestApiImpl.java | 154 ----------------- .../android/sdk/network/Authenticator.java | 49 ++++++ .../android/sdk/network/AuthorizedClient.java | 41 +++++ .../sdk/network/AuthorizedClientImpl.java | 48 ++++++ .../android/sdk/network/ClientFactory.java | 60 +++++++ .../android/sdk/network/Credentials.java | 11 ++ .../android/sdk/network/Server.java | 65 ++++++++ .../auth => network}/SpringAuthService.java | 27 +-- .../auth => network}/SpringCredentials.java | 24 +-- .../android/sdk/service/AnonymousSession.java | 13 +- .../android/sdk/service/RestClient.java | 13 +- .../android/sdk/service/Session.java | 2 +- .../android/sdk/service/auth/AuthPolicy.java | 42 ----- .../service/auth/AuthenticationService.java | 61 +++---- .../android/sdk/service/auth/Credentials.java | 12 -- .../service/internal/DefaultCallExecutor.java | 27 +-- .../service/internal/TokenCacheManager.java | 46 +----- .../AuthenticationRestApiBuilderTest.java | 74 --------- .../network/AuthenticationRestApiTest.java | 13 +- .../AuthenticatorTest.java} | 13 +- .../SpringAuthServiceTest.java | 21 +-- .../SpringCredentialsTest.java | 3 +- .../internal/DefaultCallExecutorTest.java | 156 ------------------ .../internal/TokenCacheManagerTest.java | 136 --------------- .../api/AuthenticationRestApiTest.java | 72 -------- .../api/utils/DummyTokenProvider.java | 10 +- 31 files changed, 632 insertions(+), 875 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicyImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/Authenticator.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/Server.java rename core/src/main/java/com/jaspersoft/android/sdk/{service/auth => network}/SpringAuthService.java (74%) rename core/src/main/java/com/jaspersoft/android/sdk/{service/auth => network}/SpringCredentials.java (84%) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java rename core/src/test/java/com/jaspersoft/android/sdk/{service/auth/AuthenticationServiceTest.java => network/AuthenticatorTest.java} (69%) rename core/src/test/java/com/jaspersoft/android/sdk/{service/auth => network}/SpringAuthServiceTest.java (83%) rename core/src/test/java/com/jaspersoft/android/sdk/{service/auth => network}/SpringCredentialsTest.java (96%) delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java new file mode 100644 index 00000000..163c2036 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java @@ -0,0 +1,81 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; +import com.squareup.okhttp.OkHttpClient; +import org.jetbrains.annotations.NotNull; +import retrofit.Retrofit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class AnonymousClient { + private final OkHttpClient mOkHttpClient; + private final String mBaseUrl; + + private Retrofit mRetrofit; + + AnonymousClient(String baseUrl, OkHttpClient okHttpClient) { + mOkHttpClient = okHttpClient; + mBaseUrl = baseUrl; + } + + OkHttpClient getClient() { + return mOkHttpClient; + } + + String getBaseUrl() { + return mBaseUrl; + } + + Retrofit getRetrofit() { + if (mRetrofit == null) { + mRetrofit = configureRetrofit(); + } + return mRetrofit; + } + + private Retrofit configureRetrofit() { + Retrofit.Builder builder = new Retrofit.Builder(); + builder.baseUrl(mBaseUrl); + + Gson configuredGson = GsonFactory.create(); + GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); + StringConverterFactory stringConverterFactory = StringConverterFactory.create(); + + builder.addConverterFactory(gsonConverterFactory); + builder.addConverterFactory(stringConverterFactory); + + return builder.build(); + } + + @NotNull + public final ServerRestApi infoApi() { + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java new file mode 100644 index 00000000..33cd1134 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.squareup.okhttp.OkHttpClient; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class AnonymousClientImpl extends AnonymousClient { + AnonymousClientImpl(String baseUrl, OkHttpClient okHttpClient) { + super(baseUrl, okHttpClient); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java new file mode 100644 index 00000000..5e9532ea --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java @@ -0,0 +1,17 @@ +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class AuthPolicy { + protected final AnonymousClient mAnonymousClient; + + protected AuthPolicy(AnonymousClient anonymousClient) { + mAnonymousClient = anonymousClient; + } + + abstract Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicyImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicyImpl.java new file mode 100644 index 00000000..15a334fa --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicyImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class AuthPolicyImpl extends AuthPolicy { + + private SpringAuthService springAuthService; + + protected AuthPolicyImpl(AnonymousClient anonymousClient) { + super(anonymousClient); + } + + @Override + Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException { + if (springAuthService == null) { + springAuthService = createSpringAuthService(); + } + return springAuthService.authenticate(credentials); + } + + private SpringAuthService createSpringAuthService() { + AuthenticationRestApi restApi = new AuthenticationRestApi(mAnonymousClient); + JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); + return new SpringAuthService(restApi, encryptionAlgorithm); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 5ebd19b8..4fceacc5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -24,37 +24,126 @@ package com.jaspersoft.android.sdk.network; +import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; -import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.OkHttpClient; - +import com.squareup.okhttp.*; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import retrofit.Response; +import retrofit.Retrofit; +import retrofit.http.GET; +import retrofit.http.Header; +import retrofit.http.Headers; import java.io.IOException; import java.util.Map; +import java.util.Set; /** + * TODO refactor following module in easy testable units + * * @author Tom Koptel * @since 2.0 */ -public interface AuthenticationRestApi { +class AuthenticationRestApi { + private final AnonymousClient mClient; + + AuthenticationRestApi(AnonymousClient anonymousClient) { + mClient = anonymousClient; + } + @NotNull - Cookies authenticate(@NotNull String username, - @NotNull String password, - @Nullable String organization, - @Nullable Map params) throws HttpException, IOException; + public Cookies springAuth(@NotNull final String username, + @NotNull final String password, + final String organization, + final Map params) throws HttpException, IOException { + Request request = createAuthRequest(username, password, organization, params); + Call call = mClient.getClient().newCall(request); + com.squareup.okhttp.Response response = call.execute(); + int statusCode = response.code(); + if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request + return CookieExtractor.extract(response); + } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request + String location = response.headers().get("Location"); + HttpUrl url = HttpUrl.parse(location); + String errorQueryParameter = url.queryParameter("error"); + if (errorQueryParameter == null) { + return CookieExtractor.extract(response); + } else { + com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() + .protocol(response.protocol()) + .request(response.request()) + .headers(response.headers()) + .body(response.body()) + .code(401) + .build(); + throw HttpException.httpError(response401); + } + } else { + throw HttpException.httpError(response); + } + } @NotNull - EncryptionKey requestEncryptionMetadata() throws HttpException, IOException; - - final class Builder extends GenericBuilder { - @Override - AuthenticationRestApi createApi() { - HttpUrl baseUrl = adapterBuilder.baseUrl; - OkHttpClient okHttpClient = clientBuilder.getClient(); - okHttpClient.setFollowRedirects(false); - return new AuthenticationRestApiImpl(baseUrl, okHttpClient, getAdapter()); + public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { + Retrofit retrofit = mClient.getRetrofit(); + RestApi api = retrofit.create(RestApi.class); + Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); + Cookies anonymousCookies = CookieExtractor.extract(response.raw()); + + RestApi modifiedApi = retrofit.create(RestApi.class); + + try { + return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata(anonymousCookies.toString())).body(); + } catch (JsonSyntaxException ex) { + /** + * This possible when security option is disabled on JRS side. + * API responds with malformed json. E.g. {Error: Key generation is off}. As you can see no quotes + * As soon as there 2 options to resolve this we decide to swallow exception and return empty object + */ + return EncryptionKey.empty(); + } + } + + private Request createAuthRequest( + @NotNull final String username, + @NotNull final String password, + final String organization, + final Map params) { + + OkHttpClient client = new OkHttpClient(); + client.setFollowRedirects(false); + + FormEncodingBuilder formBody = new FormEncodingBuilder() + .add("j_password", password) + .add("j_username", username); + + if (organization != null) { + formBody.add("orgId", organization); } + + if (params != null) { + Set> entrySet = params.entrySet(); + for (Map.Entry entry : entrySet) { + formBody.add(entry.getKey(), entry.getValue()); + } + } + /** + * Constructs url http[s]://some.jrs/j_spring_security_check + */ + return new Request.Builder() + .url(mClient.getBaseUrl() + "j_spring_security_check") + .post(formBody.build()) + .build(); + } + + private interface RestApi { + @NotNull + @Headers("Accept: text/plain") + @GET("rest_v2/serverInfo/edition") + retrofit.Call requestAnonymousCookie(); + + @NotNull + @GET("GetEncryptionKey") + retrofit.Call requestEncryptionMetadata(@NotNull @Header("Cookie") String cookie); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java deleted file mode 100644 index cf5d8e98..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.google.gson.JsonSyntaxException; -import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; -import com.squareup.okhttp.*; -import org.jetbrains.annotations.NotNull; -import retrofit.Response; -import retrofit.Retrofit; -import retrofit.http.GET; -import retrofit.http.Header; -import retrofit.http.Headers; - -import java.io.IOException; -import java.util.Map; -import java.util.Set; - -/** - * TODO refactor following module in easy testable units - * - * @author Tom Koptel - * @since 2.0 - */ -final class AuthenticationRestApiImpl implements AuthenticationRestApi { - private final HttpUrl mBaseUrl; - private final OkHttpClient mClient; - private final Retrofit.Builder mRestAdapterBuilder; - - AuthenticationRestApiImpl(HttpUrl baseUrl, OkHttpClient okHttpClient, Retrofit.Builder retrofit) { - mBaseUrl = baseUrl; - mClient = okHttpClient; - mRestAdapterBuilder = retrofit; - } - - @NotNull - @Override - public Cookies authenticate(@NotNull final String username, - @NotNull final String password, - final String organization, - final Map params) throws HttpException, IOException { - Request request = createAuthRequest(username, password, organization, params); - Call call = mClient.newCall(request); - com.squareup.okhttp.Response response = call.execute(); - int statusCode = response.code(); - if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request - return CookieExtractor.extract(response); - } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request - String location = response.headers().get("Location"); - HttpUrl url = HttpUrl.parse(location); - String errorQueryParameter = url.queryParameter("error"); - if (errorQueryParameter == null) { - return CookieExtractor.extract(response); - } else { - com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() - .protocol(response.protocol()) - .request(response.request()) - .headers(response.headers()) - .body(response.body()) - .code(401) - .build(); - throw HttpException.httpError(response401); - } - } else { - throw HttpException.httpError(response); - } - } - - @NotNull - @Override - public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { - RestApi api = mRestAdapterBuilder.build().create(RestApi.class); - Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); - Cookies anonymousCookies = CookieExtractor.extract(response.raw()); - - RestApi modifiedApi = mRestAdapterBuilder.build().create(RestApi.class); - - try { - return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata(anonymousCookies.toString())).body(); - } catch (JsonSyntaxException ex) { - /** - * This possible when security option is disabled on JRS side. - * API responds with malformed json. E.g. {Error: Key generation is off}. As you can see no quotes - * As soon as there 2 options to resolve this we decide to swallow exception and return empty object - */ - return EncryptionKey.empty(); - } - } - - private Request createAuthRequest( - @NotNull final String username, - @NotNull final String password, - final String organization, - final Map params) { - - OkHttpClient client = new OkHttpClient(); - client.setFollowRedirects(false); - - FormEncodingBuilder formBody = new FormEncodingBuilder() - .add("j_password", password) - .add("j_username", username); - - if (organization != null) { - formBody.add("orgId", organization); - } - - if (params != null) { - Set> entrySet = params.entrySet(); - for (Map.Entry entry : entrySet) { - formBody.add(entry.getKey(), entry.getValue()); - } - } - /** - * Constructs url http[s]://some.jrs/j_spring_security_check - */ - return new Request.Builder() - .url(mBaseUrl + "j_spring_security_check") - .post(formBody.build()) - .build(); - } - - private interface RestApi { - @NotNull - @Headers("Accept: text/plain") - @GET("rest_v2/serverInfo/edition") - retrofit.Call requestAnonymousCookie(); - - @NotNull - @GET("GetEncryptionKey") - retrofit.Call requestEncryptionMetadata(@NotNull @Header("Cookie") String cookie); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Authenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Authenticator.java new file mode 100644 index 00000000..e44eb872 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Authenticator.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; + +import static com.jaspersoft.android.sdk.service.internal.Preconditions.checkNotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class Authenticator { + private final AuthPolicy mPolicy; + + Authenticator(AuthPolicy policy) { + mPolicy = policy; + } + + @NotNull + public Cookies authenticate(@NotNull Credentials credentials) throws HttpException, IOException { + checkNotNull(credentials, "Credentials should not be null"); + return credentials.applyPolicy(mPolicy); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java new file mode 100644 index 00000000..f7df269d --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.squareup.okhttp.OkHttpClient; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class AuthorizedClient extends AnonymousClient { + AuthorizedClient(String baseUrl, OkHttpClient client) { + super(baseUrl, client); + } + + public abstract void authorize() throws IOException, HttpException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java new file mode 100644 index 00000000..6aecf2d7 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.squareup.okhttp.OkHttpClient; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class AuthorizedClientImpl extends AuthorizedClient { + private final Credentials mCredentials; + + AuthorizedClientImpl(String baseUrl, OkHttpClient client, Credentials credentials) { + super(baseUrl, client); + mCredentials = credentials; + } + + public void authorize() throws IOException, HttpException { + AuthPolicy authPolicy = new AuthPolicyImpl(this); + Authenticator authenticator = new Authenticator(authPolicy); + authenticator.authenticate(mCredentials); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java new file mode 100644 index 00000000..a300bc99 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.squareup.okhttp.OkHttpClient; +import org.jetbrains.annotations.TestOnly; + +import java.util.concurrent.TimeUnit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class ClientFactory { + private long connectTimeout = 10000; + private long readTimeout = 10000; + + final String mBaseUrl; + final OkHttpClient mOkHttpClient; + + @TestOnly + ClientFactory(String baseUrl, OkHttpClient okHttpClient) { + mBaseUrl = baseUrl; + mOkHttpClient = okHttpClient; + } + + public ClientFactory withConnectionTimeOut(long timeout, TimeUnit unit) { + connectTimeout = unit.toMillis(timeout); + return this; + } + + public ClientFactory withReadTimeout(long timeout, TimeUnit unit) { + readTimeout = unit.toMillis(timeout); + return this; + } + + public abstract Client create(); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java new file mode 100644 index 00000000..c0fcb330 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java @@ -0,0 +1,11 @@ +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class Credentials { + protected abstract Cookies applyPolicy(AuthPolicy authPolicy) throws IOException, HttpException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java new file mode 100644 index 00000000..8d1a5cde --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.squareup.okhttp.OkHttpClient; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class Server { + + private final String mBaseUrl; + + public Server(String baseUrl) { + mBaseUrl = baseUrl; + } + + public ClientFactory newClient() { + final OkHttpClient okHttpClient = new OkHttpClient(); + okHttpClient.setFollowRedirects(false); + return new ClientFactory(mBaseUrl, okHttpClient) { + @Override + public AnonymousClient create() { + return new AnonymousClientImpl(mBaseUrl, okHttpClient); + } + }; + } + + public ClientFactory newClient(final Credentials credentials) { + final OkHttpClient okHttpClient = new OkHttpClient(); + return new ClientFactory(mBaseUrl, okHttpClient) { + @Override + public AuthorizedClient create() { + return new AuthorizedClientImpl(mBaseUrl, mOkHttpClient, credentials); + } + }; + } + + public static Server create(String baseUrl) { + return new Server(baseUrl); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java similarity index 74% rename from core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java index 3f7c7f30..807a7eb3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java @@ -22,12 +22,8 @@ * . */ -package com.jaspersoft.android.sdk.service.auth; +package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -49,27 +45,12 @@ final class SpringAuthService { @TestOnly SpringAuthService( - @NotNull JSEncryptionAlgorithm generator, - @NotNull AuthenticationRestApi restApi) { + @NotNull AuthenticationRestApi restApi, + @NotNull JSEncryptionAlgorithm generator) { mEncryptionAlgorithm = generator; mRestApi = restApi; } - @NotNull - public static SpringAuthService create(@NotNull String baseUrl) { - JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() - .baseUrl(baseUrl) - .build(); - return new SpringAuthService(algorithm, restApi); - } - - @NotNull - public static SpringAuthService create(@NotNull AuthenticationRestApi restApi) { - JSEncryptionAlgorithm algorithm = JSEncryptionAlgorithm.create(); - return new SpringAuthService(algorithm, restApi); - } - @NotNull public Cookies authenticate(SpringCredentials credentials) throws IOException, HttpException { String password = credentials.getPassword(); @@ -80,7 +61,7 @@ public Cookies authenticate(SpringCredentials credentials) throws IOException, H } Map params = prepareOptionals(credentials); - return mRestApi.authenticate( + return mRestApi.springAuth( credentials.getUsername(), password, credentials.getOrganization(), diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java similarity index 84% rename from core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java index 5a434cf4..4c50cf05 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java @@ -1,8 +1,5 @@ -package com.jaspersoft.android.sdk.service.auth; +package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.NotNull; @@ -25,7 +22,6 @@ public final class SpringCredentials extends Credentials { private final String mOrganization; private final Locale mLocale; private final TimeZone mTimeZone; - private final ServiceExceptionMapper mServiceExceptionMapper; @TestOnly SpringCredentials( @@ -33,14 +29,12 @@ public final class SpringCredentials extends Credentials { @NotNull String password, @Nullable String organization, @NotNull Locale locale, - @NotNull TimeZone timeZone, - @NotNull ServiceExceptionMapper serviceExceptionMapper) { + @NotNull TimeZone timeZone) { mUsername = username; mPassword = password; mOrganization = organization; mLocale = locale; mTimeZone = timeZone; - mServiceExceptionMapper = serviceExceptionMapper; } public static Builder builder() { @@ -73,14 +67,8 @@ public Locale getLocale() { } @Override - protected Cookies applyPolicy(AuthPolicy policy) throws ServiceException { - try { - return policy.applyCredentials(this); - } catch (HttpException e) { - throw mServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw mServiceExceptionMapper.transform(e); - } + protected Cookies applyPolicy(AuthPolicy policy) throws IOException, HttpException { + return policy.applyCredentials(this); } @Override @@ -160,14 +148,12 @@ public Builder locale(@NotNull Locale locale) { public SpringCredentials build() { ensureValidState(); ensureDefaults(); - ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); return new SpringCredentials( mUsername, mPassword, mOrganization, mLocale, - mTimeZone, - serviceExceptionMapper); + mTimeZone); } private void ensureDefaults() { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java index 9d2bef0b..cd1ce453 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java @@ -35,26 +35,17 @@ public class AnonymousSession { protected final RestClient mClient; - private AuthenticationService mAuthenticator; - private ServerInfoService mInfoService; - protected AnonymousSession(RestClient client) { mClient = client; } @NotNull public final AuthenticationService authApi() { - if (mAuthenticator == null) { - mAuthenticator = AuthenticationService.create(mClient); - } - return mAuthenticator; + throw new UnsupportedOperationException("Not yet implemented"); } @NotNull public final ServerInfoService infoApi() { - if (mInfoService == null) { - mInfoService = ServerInfoService.create(mClient); - } - return mInfoService; + throw new UnsupportedOperationException("Not yet implemented"); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index 2e6358de..b959b848 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; import com.jaspersoft.android.sdk.service.info.InfoCache; @@ -41,7 +41,6 @@ public final class RestClient { private final long mPollTimeout; private final InfoCache mInfoCache; - private AnonymousSession mAnonymousSession; private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, long pollTimeout, InfoCache infoCache) { mServerUrl = serverUrl; @@ -51,16 +50,6 @@ private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, l mInfoCache = infoCache; } - public Session.Builder newSession(Credentials credentials) { - return new Session.Builder(this, credentials); - } - - public AnonymousSession getAnonymousSession() { - if (mAnonymousSession == null) { - mAnonymousSession = new AnonymousSession(this); - } - return mAnonymousSession; - } public String getServerUrl() { return mServerUrl; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index d1a55335..919b166d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.service.auth.Credentials; +import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.service.report.ReportService; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java deleted file mode 100644 index 8a5b48f8..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthPolicy.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jaspersoft.android.sdk.service.auth; - -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.HttpException; - -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -interface AuthPolicy { - Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException; - - class Default implements AuthPolicy { - private final SpringAuthService mSpringService; - - private Default(SpringAuthService springService) { - mSpringService = springService; - } - - @NotNull - public static AuthPolicy create(@NotNull AuthenticationRestApi restApi) { - SpringAuthService springService = SpringAuthService.create(restApi); - return new Default(springService); - } - - @NotNull - public static Default create(@NotNull String baseUrl) { - SpringAuthService springService = SpringAuthService.create(baseUrl); - return new Default(springService); - } - - @Override - public Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException { - return mSpringService.authenticate(credentials); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java index 76616be4..14b4dc7f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java @@ -1,43 +1,32 @@ -package com.jaspersoft.android.sdk.service.auth; - -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.exception.ServiceException; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; - -import java.util.concurrent.TimeUnit; +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ -import static com.jaspersoft.android.sdk.service.internal.Preconditions.checkNotNull; +package com.jaspersoft.android.sdk.service.auth; /** * @author Tom Koptel * @since 2.0 */ -public final class AuthenticationService { - private final AuthPolicy mAuthPolicy; - - @TestOnly - AuthenticationService(AuthPolicy authPolicy) { - mAuthPolicy = authPolicy; - } - - @NotNull - public static AuthenticationService create(@NotNull RestClient mClient) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() - .connectionTimeOut(mClient.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(mClient.getReadTimeOut(), TimeUnit.MILLISECONDS) - .baseUrl(mClient.getServerUrl()) - .build(); - AuthPolicy policyImpl = AuthPolicy.Default.create(restApi); - return new AuthenticationService(policyImpl); - } - - @NotNull - public Cookies authenticate(@NotNull Credentials credentials) throws ServiceException { - checkNotNull(credentials, "Credentials should not be null"); - return credentials.applyPolicy(mAuthPolicy); - } +public interface AuthenticationService { } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java deleted file mode 100644 index 0bb0ba9a..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/Credentials.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.jaspersoft.android.sdk.service.auth; - -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.service.exception.ServiceException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public abstract class Credentials { - protected abstract Cookies applyPolicy(AuthPolicy authPolicy) throws ServiceException; -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java index f76131ba..662d38b8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java @@ -24,13 +24,8 @@ package com.jaspersoft.android.sdk.service.internal; -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; - -import java.io.IOException; /** * @author Tom Koptel @@ -48,26 +43,6 @@ public DefaultCallExecutor(TokenCacheManager tokenCacheManager, ServiceException @NotNull public T execute(Call call) throws ServiceException { - try { - Cookies token = mTokenCacheManager.loadToken(); - return call.perform(token); - } catch (IOException e) { - throw mServiceExceptionMapper.transform(e); - } catch (HttpException e) { - if (e.code() == 401) { - mTokenCacheManager.invalidateToken(); - - try { - Cookies token = mTokenCacheManager.loadToken(); - return call.perform(token); - } catch (IOException e1) { - throw mServiceExceptionMapper.transform(e1); - } catch (HttpException e1) { - throw mServiceExceptionMapper.transform(e1); - } - } else { - throw mServiceExceptionMapper.transform(e); - } - } + throw new UnsupportedOperationException("Not yet implemented"); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java index d279ac6f..ede25e81 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java @@ -28,10 +28,6 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.Session; -import com.jaspersoft.android.sdk.service.auth.AuthenticationService; -import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.token.TokenCache; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -41,53 +37,15 @@ * @since 2.0 */ public class TokenCacheManager { - private final AuthenticationService mAuthService; - private final Credentials mCredentials; - private final TokenCache mTokenCache; - private final String mBaseUrl; - TokenCacheManager(AuthenticationService authService, - Credentials credentials, - TokenCache tokenCache, - String baseUrl) { - mAuthService = authService; - mCredentials = credentials; - mTokenCache = tokenCache; - mBaseUrl = baseUrl; - } @NotNull public static TokenCacheManager create(RestClient restClient, Session session) { - AuthenticationService service = session.authApi(); - Credentials credentials = session.getCredentials(); - TokenCache cache = session.getTokenCache(); - String baseUrl = restClient.getServerUrl(); - return new TokenCacheManager(service, credentials, cache, baseUrl); + throw new UnsupportedOperationException("Not yet implemented"); } @NotNull public Cookies loadToken() throws IOException, HttpException { - Cookies cookies = mTokenCache.get(mBaseUrl); - if (cookies != null) { - return cookies; - } - - try { - cookies = mAuthService.authenticate(mCredentials); - mTokenCache.put(mBaseUrl, cookies); - return cookies; - } catch (ServiceException e) { - if (e.getCause() instanceof HttpException) { - throw (HttpException) e.getCause(); - } - if (e.getCause() instanceof IOException) { - throw (IOException) e.getCause(); - } - throw new RuntimeException("Failed to load token", e.getCause()); - } - } - - public void invalidateToken() { - mTokenCache.remove(mBaseUrl); + throw new UnsupportedOperationException("Not yet implemented"); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java deleted file mode 100644 index 225baa54..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiBuilderTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class AuthenticationRestApiBuilderTest { - - private AuthenticationRestApi.Builder builderUnderTest; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setup() { - builderUnderTest = new AuthenticationRestApi.Builder(); - } - - @Test - public void builderShouldNotAllowNullBaseUrl() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("baseUrl == null"); - - builderUnderTest.baseUrl(null); - } - - @Test - public void builderShouldNotAllowEmptyUrl() { - expectedException.expect(IllegalArgumentException.class); - builderUnderTest.baseUrl(""); - } - - @Test - public void builderShouldAllowNullLogLevel() { - builderUnderTest.logger(null); - } - - @Test - public void builderShouldEnsureBaseUrlNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Base url should be supplied to work with JRS API"); - - builderUnderTest.build(); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index c90d05f5..04a5f988 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -31,7 +31,6 @@ import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; import com.squareup.okhttp.mockwebserver.MockResponse; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -62,9 +61,9 @@ public class AuthenticationRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - mRestApi = new AuthenticationRestApi.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .build(); + Server server = Server.create(mWebMockRule.getRootUrl()); + AnonymousClient client = server.newClient().create(); + mRestApi = new AuthenticationRestApi(client); } @Test @@ -74,7 +73,7 @@ public void shouldReturnResponseForSuccessRedirect() throws Exception { .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - Cookies response = mRestApi.authenticate("joeuser", "joeuser", null, null); + Cookies response = mRestApi.springAuth("joeuser", "joeuser", null, null); assertThat(response, is(notNullValue())); } @@ -87,7 +86,7 @@ public void shouldRiseErrorForErrorRedirect() throws Exception { .addHeader("Set-Cookie", "cookie1"); mWebMockRule.enqueue(mockResponse); - mRestApi.authenticate("joeuser", "joeuser", "null", null); + mRestApi.springAuth("joeuser", "joeuser", "null", null); } @Test @@ -96,7 +95,7 @@ public void shouldRiseErrorForHttpException() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - mRestApi.authenticate("joeuser", "joeuser", "null", null); + mRestApi.springAuth("joeuser", "joeuser", "null", null); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticatorTest.java similarity index 69% rename from core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticatorTest.java index cd5ffc8f..3188ffb7 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthenticationServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticatorTest.java @@ -1,6 +1,5 @@ -package com.jaspersoft.android.sdk.service.auth; +package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.Cookies; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -9,21 +8,19 @@ import org.mockito.MockitoAnnotations; import static org.mockito.Matchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; /** * @author Tom Koptel */ -public class AuthenticationServiceTest { +public class AuthenticatorTest { @Mock AuthPolicy mAuthPolicy; @Mock Credentials mCredentials; - private AuthenticationService authenticatorUnderTest; + private Authenticator authenticatorUnderTest; @Rule public ExpectedException mExpectedException = ExpectedException.none(); @@ -33,7 +30,7 @@ public class AuthenticationServiceTest { public void setupMocks() throws Exception { MockitoAnnotations.initMocks(this); when(mCredentials.applyPolicy(any(AuthPolicy.class))).thenReturn(fakeCookies); - authenticatorUnderTest = new AuthenticationService(mAuthPolicy); + authenticatorUnderTest = new Authenticator(mAuthPolicy); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java similarity index 83% rename from core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java index 617714a1..1078db85 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringAuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java @@ -22,13 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.service.auth; +package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -44,10 +40,7 @@ import static org.mockito.Matchers.anyMap; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; /** * @author Tom Koptel @@ -84,8 +77,8 @@ public class SpringAuthServiceTest { public void setup() throws Exception { MockitoAnnotations.initMocks(this); objectUnderTest = new SpringAuthService( - mAlgorithm, - mRestApi + mRestApi, + mAlgorithm ); credentials = SpringCredentials.builder() @@ -98,7 +91,7 @@ public void setup() throws Exception { when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); - when(mRestApi.authenticate(anyString(), anyString(), anyString(), anyMap())).thenReturn(fakeCookies); + when(mRestApi.springAuth(anyString(), anyString(), anyString(), anyMap())).thenReturn(fakeCookies); } @Test @@ -110,7 +103,7 @@ public void shouldAuthenticateWithHashedPasswordIfEncryptionKeyIsMissing() throw objectUnderTest.authenticate(credentials); - verify(mRestApi, times(1)).authenticate("user", "hashed password", "organization", sOptionals); + verify(mRestApi, times(1)).springAuth("user", "hashed password", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); verify(mAlgorithm, times(1)).encrypt("m", "e", "1234"); } @@ -121,7 +114,7 @@ public void shouldAuthenticateWithOpenPasswordIfEncryptionKeyIsMissing() throws objectUnderTest.authenticate(credentials); - verify(mRestApi, times(1)).authenticate("user", "1234", "organization", sOptionals); + verify(mRestApi, times(1)).springAuth("user", "1234", "organization", sOptionals); verify(mRestApi, times(1)).requestEncryptionMetadata(); verifyZeroInteractions(mAlgorithm); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java similarity index 96% rename from core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java index 02e39e01..1047b424 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/SpringCredentialsTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java @@ -22,10 +22,11 @@ * . */ -package com.jaspersoft.android.sdk.service.auth; +package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.SpringCredentials; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java deleted file mode 100644 index 59c8c77a..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutorTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.internal; - -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.test.Chain; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.mockito.Mockito.*; - -public class DefaultCallExecutorTest { - - @Mock - TokenCacheManager mTokenCacheManager; - @Mock - Call mCall; - - @Mock - HttpException _401Exception; - - @Mock - ServerInfo mServerInfo; - - private DefaultCallExecutor resolver; - private Object mResponse = new Object(); - - private final Cookies validCookies = Cookies.parse("key=value"); - private final Cookies inValidCookies = Cookies.parse("key=value1"); - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - when(_401Exception.code()).thenReturn(401); - when(mCall.perform(any(Cookies.class))).thenReturn(mResponse); - - resolver = new DefaultCallExecutor(mTokenCacheManager, new DefaultExceptionMapper()); - } - - @Test - public void testExecuteWithValidCache() throws Exception { - when(mTokenCacheManager.loadToken()).thenReturn(validCookies); - - assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - - verify(mTokenCacheManager).loadToken(); - verify(mCall).perform(validCookies); - verifyNoMoreInteractions(mTokenCacheManager); - verifyZeroInteractions(mTokenCacheManager); - } - - @Test - public void testExecuteWithEmptyCache() throws Exception { - when(mTokenCacheManager.loadToken()).thenReturn(null); - when(mTokenCacheManager.loadToken()).thenReturn(validCookies); - - assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - - verify(mTokenCacheManager).loadToken(); - verify(mCall).perform(validCookies); - } - - @Test - public void testExecuteWithInvalidCache() throws Exception { - when(mTokenCacheManager.loadToken()).then(Chain.of(inValidCookies, validCookies)); - - when(_401Exception.code()).thenReturn(401); - when(mCall.perform(any(Cookies.class))).thenAnswer(_401ResponseAtFirstInvokation()); - - assertThat("Failed to return response from call operation", resolver.execute(mCall), is(mResponse)); - - verify(mTokenCacheManager, times(2)).loadToken(); - verify(mCall).perform(inValidCookies); - verify(mTokenCacheManager).invalidateToken(); - verify(mCall).perform(validCookies); - } - - @Test - public void testExecuteWithInvalidCredentials() throws Exception { - when(mTokenCacheManager.loadToken()).thenReturn(inValidCookies); - when(mCall.perform(any(Cookies.class))).thenThrow(_401Exception); - - try { - resolver.execute(mCall); - } catch (ServiceException exception) { - assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); - } - - verify(mTokenCacheManager, times(2)).loadToken(); - verify(mCall, times(2)).perform(inValidCookies); - verify(mTokenCacheManager).invalidateToken(); - } - - @Test - public void testExecuteWithInvalidCredentialsAndEmptyCache() throws Exception { - when(mTokenCacheManager.loadToken()).thenThrow(_401Exception); - - try { - resolver.execute(mCall); - } catch (ServiceException exception) { - assertThat(exception.code(), is(StatusCodes.AUTHORIZATION_ERROR)); - } - - verify(mTokenCacheManager).invalidateToken(); - verify(mTokenCacheManager, times(2)).loadToken(); - verifyNoMoreInteractions(mTokenCacheManager); - verifyNoMoreInteractions(mTokenCacheManager); - verifyZeroInteractions(mCall); - } - - private Answer _401ResponseAtFirstInvokation() { - return new Answer() { - int invocationCount = 0; - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - if (invocationCount == 0) { - invocationCount++; - throw _401Exception; - } - return mResponse; - } - }; - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java deleted file mode 100644 index 8c1b6388..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManagerTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.internal; - -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.auth.AuthenticationService; -import com.jaspersoft.android.sdk.service.auth.Credentials; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.token.TokenCache; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.io.IOException; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.*; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ - AuthenticationService.class -}) -public class TokenCacheManagerTest { - @Mock - TokenCache mTokenCache; - @Mock - AuthenticationService mAuthenticationService; - @Mock - Credentials mCredentials; - @Mock - HttpException mHttpException; - - private final Cookies fakeCookies = Cookies.parse("key=value"); - private final String baseUrl = "http://localhost/"; - private TokenCacheManager cacheManager; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - cacheManager = new TokenCacheManager( - mAuthenticationService, - mCredentials, - mTokenCache, - baseUrl - ); - } - - @Test - public void testLoadToken() throws Exception { - when(mTokenCache.get(anyString())).thenReturn(null); - when(mAuthenticationService.authenticate(any(Credentials.class))).thenReturn(fakeCookies); - - assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is(fakeCookies)); - - verify(mTokenCache).get(baseUrl); - verify(mTokenCache).put(baseUrl, fakeCookies); - verify(mAuthenticationService).authenticate(mCredentials); - } - - @Test - public void testLoadTokenReturnsFromCache() throws Exception { - when(mTokenCache.get(anyString())).thenReturn(fakeCookies); - - assertThat("Cache manager has not returned 'token'", cacheManager.loadToken(), is(fakeCookies)); - verify(mTokenCache).get(baseUrl); - verifyNoMoreInteractions(mTokenCache); - verifyZeroInteractions(mAuthenticationService); - } - - @Test(expected = IOException.class) - public void testLoadTokenRethrowsIOException() throws Exception { - when(mTokenCache.get(anyString())).thenReturn(null); - when(mAuthenticationService.authenticate(any(Credentials.class))) - .thenThrow(new ServiceException("", new IOException(), 0)); - - cacheManager.loadToken(); - } - - @Test(expected = HttpException.class) - public void testLoadTokenRethrowsHttpException() throws Exception { - when(mTokenCache.get(anyString())).thenReturn(null); - when(mAuthenticationService.authenticate(any(Credentials.class))) - .thenThrow(new ServiceException("", mHttpException, 0)); - - cacheManager.loadToken(); - } - - @Test(expected = RuntimeException.class) - public void testLoadTokenThrowsRuntimeForUnexpectedError() throws Exception { - when(mTokenCache.get(anyString())).thenReturn(null); - when(mAuthenticationService.authenticate(any(Credentials.class))) - .thenThrow(new ServiceException("", new NullPointerException(), 0)); - - cacheManager.loadToken(); - } - - @Test - public void testInvalidateToken() throws Exception { - cacheManager.invalidateToken(); - verify(mTokenCache).remove(baseUrl); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java deleted file mode 100644 index c1e0e984..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthenticationRestApiTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.test.integration.api; - -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; -import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; -import com.jaspersoft.android.sdk.test.TestLogger; - -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.junit.Ignore; -import org.junit.Test; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class AuthenticationRestApiTest { - String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; - - @Ignore - public void shouldEncryptWithPassword() throws Exception { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() - .baseUrl("http://192.168.88.55:8085/jasperserver-pro-61/") - .logger(TestLogger.get(this)) - .build(); - EncryptionKey key = restApi.requestEncryptionMetadata(); - - JSEncryptionAlgorithm generator = JSEncryptionAlgorithm.create(new BouncyCastleProvider()); - String cipher = generator.encrypt(key.getModulus(), key.getExponent(), "superuser"); - - Cookies authResponse = restApi.authenticate("superuser", cipher, null, null); - assertThat(authResponse, is(notNullValue())); - } - - @Test - public void shouldReturnResponseForSpringRequest() throws Exception { - AuthenticationRestApi authApi = new AuthenticationRestApi.Builder() - .baseUrl(mobileDemo2) - .logger(TestLogger.get(this)) - .build(); - Cookies response = authApi.authenticate("joeuser", "joeuser", "organization_1", null); - assertThat(response, is(notNullValue())); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java index 5c6a50c8..09c70876 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.test.integration.api.utils; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.Cookies; import org.jetbrains.annotations.NotNull; @@ -48,14 +47,7 @@ public static DummyTokenProvider create(JrsMetadata metadata) { @NotNull public Cookies provideCookies() throws Exception { - if (mToken == null) { - AuthenticationRestApi restApi = new AuthenticationRestApi.Builder() - .baseUrl(mJrsMetadata.getServerUrl()) - .build(); - mToken = restApi - .authenticate(mJrsMetadata.getUsername(), mJrsMetadata.getPassword(), mJrsMetadata.getOrganization(), null); - } - return mToken; + throw new UnsupportedOperationException("Not yet implemented"); } public Cookies token() throws Exception { From ce1f4c1958083aa1a7b55000547be7266744c57e Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 11:08:58 +0200 Subject: [PATCH 352/457] Move auth logic inside network layer --- .../android/sdk/network/AuthPolicy.java | 36 +++++++++++++------ .../{Authenticator.java => AuthService.java} | 6 ++-- .../android/sdk/network/AuthStrategy.java | 17 +++++++++ ...hPolicyImpl.java => AuthStrategyImpl.java} | 4 +-- .../sdk/network/AuthorizedClientImpl.java | 8 ++--- .../android/sdk/network/ClientFactory.java | 18 ++++++---- .../android/sdk/network/Credentials.java | 2 +- .../android/sdk/network/Server.java | 2 +- .../sdk/network/SpringCredentials.java | 4 +-- ...nticatorTest.java => AuthServiceTest.java} | 16 ++++----- 10 files changed, 74 insertions(+), 39 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/network/{Authenticator.java => AuthService.java} (94%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java rename core/src/main/java/com/jaspersoft/android/sdk/network/{AuthPolicyImpl.java => AuthStrategyImpl.java} (94%) rename core/src/test/java/com/jaspersoft/android/sdk/network/{AuthenticatorTest.java => AuthServiceTest.java} (64%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java index 5e9532ea..4aec0d97 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicy.java @@ -1,17 +1,33 @@ -package com.jaspersoft.android.sdk.network; +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ -import java.io.IOException; +package com.jaspersoft.android.sdk.network; /** * @author Tom Koptel * @since 2.0 */ -abstract class AuthPolicy { - protected final AnonymousClient mAnonymousClient; - - protected AuthPolicy(AnonymousClient anonymousClient) { - mAnonymousClient = anonymousClient; - } - - abstract Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException; +public enum AuthPolicy { + FAIL_FAST, RETRY; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Authenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java similarity index 94% rename from core/src/main/java/com/jaspersoft/android/sdk/network/Authenticator.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java index e44eb872..dcabf17f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Authenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java @@ -34,10 +34,10 @@ * @author Tom Koptel * @since 2.0 */ -class Authenticator { - private final AuthPolicy mPolicy; +class AuthService { + private final AuthStrategy mPolicy; - Authenticator(AuthPolicy policy) { + AuthService(AuthStrategy policy) { mPolicy = policy; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java new file mode 100644 index 00000000..69ea9a18 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java @@ -0,0 +1,17 @@ +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class AuthStrategy { + protected final AnonymousClient mAnonymousClient; + + protected AuthStrategy(AnonymousClient anonymousClient) { + mAnonymousClient = anonymousClient; + } + + abstract Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicyImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategyImpl.java similarity index 94% rename from core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicyImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategyImpl.java index 15a334fa..e903120a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthPolicyImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategyImpl.java @@ -30,11 +30,11 @@ * @author Tom Koptel * @since 2.0 */ -class AuthPolicyImpl extends AuthPolicy { +class AuthStrategyImpl extends AuthStrategy { private SpringAuthService springAuthService; - protected AuthPolicyImpl(AnonymousClient anonymousClient) { + protected AuthStrategyImpl(AnonymousClient anonymousClient) { super(anonymousClient); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java index 6aecf2d7..2e03e62e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java @@ -33,16 +33,16 @@ * @since 2.0 */ class AuthorizedClientImpl extends AuthorizedClient { + private final AuthPolicy mAuthPolicy; private final Credentials mCredentials; - AuthorizedClientImpl(String baseUrl, OkHttpClient client, Credentials credentials) { + AuthorizedClientImpl(String baseUrl, OkHttpClient client, AuthPolicy authPolicy, Credentials credentials) { super(baseUrl, client); + mAuthPolicy = authPolicy; mCredentials = credentials; } public void authorize() throws IOException, HttpException { - AuthPolicy authPolicy = new AuthPolicyImpl(this); - Authenticator authenticator = new Authenticator(authPolicy); - authenticator.authenticate(mCredentials); + throw new UnsupportedOperationException("Not yet implemented"); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java index a300bc99..381e4616 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java @@ -34,25 +34,29 @@ * @since 2.0 */ public abstract class ClientFactory { - private long connectTimeout = 10000; - private long readTimeout = 10000; - final String mBaseUrl; final OkHttpClient mOkHttpClient; + AuthPolicy mAuthPolicy; @TestOnly ClientFactory(String baseUrl, OkHttpClient okHttpClient) { mBaseUrl = baseUrl; mOkHttpClient = okHttpClient; + mAuthPolicy = AuthPolicy.RETRY; + } + + public ClientFactory withConnectionTimeOut(long timeout, TimeUnit unit) { + mOkHttpClient.setConnectTimeout(timeout, unit); + return this; } - public ClientFactory withConnectionTimeOut(long timeout, TimeUnit unit) { - connectTimeout = unit.toMillis(timeout); + public ClientFactory withReadTimeout(long timeout, TimeUnit unit) { + mOkHttpClient.setReadTimeout(timeout, unit); return this; } - public ClientFactory withReadTimeout(long timeout, TimeUnit unit) { - readTimeout = unit.toMillis(timeout); + public ClientFactory withRetryPolicy(final AuthPolicy authPolicy) { + mAuthPolicy = authPolicy; return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java index c0fcb330..fbc821cf 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java @@ -7,5 +7,5 @@ * @since 2.0 */ public abstract class Credentials { - protected abstract Cookies applyPolicy(AuthPolicy authPolicy) throws IOException, HttpException; + protected abstract Cookies applyPolicy(AuthStrategy authStrategy) throws IOException, HttpException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index 8d1a5cde..7917bc1a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -54,7 +54,7 @@ public ClientFactory newClient(final Credentials credentials) return new ClientFactory(mBaseUrl, okHttpClient) { @Override public AuthorizedClient create() { - return new AuthorizedClientImpl(mBaseUrl, mOkHttpClient, credentials); + return new AuthorizedClientImpl(mBaseUrl, mOkHttpClient, mAuthPolicy, credentials); } }; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java index 4c50cf05..f1d47a41 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java @@ -1,7 +1,5 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -67,7 +65,7 @@ public Locale getLocale() { } @Override - protected Cookies applyPolicy(AuthPolicy policy) throws IOException, HttpException { + protected Cookies applyPolicy(AuthStrategy policy) throws IOException, HttpException { return policy.applyCredentials(this); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticatorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java similarity index 64% rename from core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticatorTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java index 3188ffb7..888333d8 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticatorTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java @@ -13,14 +13,14 @@ /** * @author Tom Koptel */ -public class AuthenticatorTest { +public class AuthServiceTest { @Mock - AuthPolicy mAuthPolicy; + AuthStrategy mAuthStrategy; @Mock Credentials mCredentials; - private Authenticator authenticatorUnderTest; + private AuthService mAuthServiceUnderTest; @Rule public ExpectedException mExpectedException = ExpectedException.none(); @@ -29,16 +29,16 @@ public class AuthenticatorTest { @Before public void setupMocks() throws Exception { MockitoAnnotations.initMocks(this); - when(mCredentials.applyPolicy(any(AuthPolicy.class))).thenReturn(fakeCookies); - authenticatorUnderTest = new Authenticator(mAuthPolicy); + when(mCredentials.applyPolicy(any(AuthStrategy.class))).thenReturn(fakeCookies); + mAuthServiceUnderTest = new AuthService(mAuthStrategy); } @Test public void testAuthenticate() throws Exception { - authenticatorUnderTest.authenticate(mCredentials); + mAuthServiceUnderTest.authenticate(mCredentials); - verify(mCredentials).applyPolicy(mAuthPolicy); + verify(mCredentials).applyPolicy(mAuthStrategy); verifyNoMoreInteractions(mCredentials); - verifyNoMoreInteractions(mAuthPolicy); + verifyNoMoreInteractions(mAuthStrategy); } } \ No newline at end of file From a538f0e88751b015f027d595515bd0dfc4e86d60 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 11:12:21 +0200 Subject: [PATCH 353/457] Introduce Client object --- .../sdk/network/{Server.java => Client.java} | 42 ++++++++----------- .../network/AuthenticationRestApiTest.java | 2 +- 2 files changed, 19 insertions(+), 25 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/network/{Server.java => Client.java} (54%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java similarity index 54% rename from core/src/main/java/com/jaspersoft/android/sdk/network/Server.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index 7917bc1a..ecbf1401 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -24,42 +24,36 @@ package com.jaspersoft.android.sdk.network; -import com.squareup.okhttp.OkHttpClient; - /** * @author Tom Koptel * @since 2.0 */ -public final class Server { - +public final class Client { private final String mBaseUrl; - public Server(String baseUrl) { + public Client(String baseUrl) { mBaseUrl = baseUrl; } - public ClientFactory newClient() { - final OkHttpClient okHttpClient = new OkHttpClient(); - okHttpClient.setFollowRedirects(false); - return new ClientFactory(mBaseUrl, okHttpClient) { - @Override - public AnonymousClient create() { - return new AnonymousClientImpl(mBaseUrl, okHttpClient); - } - }; + public static GenericBuilder newBuilder() { + return new GenericBuilder(); } - public ClientFactory newClient(final Credentials credentials) { - final OkHttpClient okHttpClient = new OkHttpClient(); - return new ClientFactory(mBaseUrl, okHttpClient) { - @Override - public AuthorizedClient create() { - return new AuthorizedClientImpl(mBaseUrl, mOkHttpClient, mAuthPolicy, credentials); - } - }; + public static class GenericBuilder { + public OptionalBuilder withBaseUrl(String baseUrl) { + return new OptionalBuilder(baseUrl); + } } - public static Server create(String baseUrl) { - return new Server(baseUrl); + public static class OptionalBuilder { + private final String mBaseUrl; + + private OptionalBuilder(String baseUrl) { + mBaseUrl = baseUrl; + } + + public Client create() { + return new Client(mBaseUrl); + } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index 04a5f988..8b72deca 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -61,7 +61,7 @@ public class AuthenticationRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Server server = Server.create(mWebMockRule.getRootUrl()); + Client server = Client.create(mWebMockRule.getRootUrl()); AnonymousClient client = server.newClient().create(); mRestApi = new AuthenticationRestApi(client); } From 9cbf44d25cdd82d36b340641c9aaf051b2236b35 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 11:24:39 +0200 Subject: [PATCH 354/457] Add State abstraction for client objects --- .../android/sdk/network/AuthClientState.java | 36 ++++++++++++++ .../network/AuthorizedAuthClientState.java | 43 ++++++++++++++++ .../android/sdk/network/AuthorizedClient.java | 49 +++++++++++++++++-- .../sdk/network/InitialAuthClientState.java | 41 ++++++++++++++++ 4 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java new file mode 100644 index 00000000..9d294d93 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +interface AuthClientState { + void connect(AuthorizedClient client) throws IOException, HttpException; + ReportExecutionRestApi makeReportExecutionApi(); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java new file mode 100644 index 00000000..cf0ef29d --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -0,0 +1,43 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class AuthorizedAuthClientState implements AuthClientState { + @Override + public void connect(AuthorizedClient client) throws IOException, HttpException { + // do nothing we already connected + } + + @Override + public ReportExecutionRestApi makeReportExecutionApi() { + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index f7df269d..67b511b3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -24,18 +24,57 @@ package com.jaspersoft.android.sdk.network; -import com.squareup.okhttp.OkHttpClient; +import org.jetbrains.annotations.TestOnly; import java.io.IOException; +import java.lang.reflect.Proxy; /** * @author Tom Koptel * @since 2.0 */ -public abstract class AuthorizedClient extends AnonymousClient { - AuthorizedClient(String baseUrl, OkHttpClient client) { - super(baseUrl, client); +public final class AuthorizedClient { + private final Client mClient; + private final Credentials mCredentials; + + private AuthClientState mAuthClientState; + + @TestOnly + AuthorizedClient(Client client, Credentials credentials, AuthClientState authClientState) { + mClient = client; + mCredentials = credentials; + + mAuthClientState = authClientState; + } + + public void connect() throws IOException, HttpException { + mAuthClientState.connect(this); + } + + public ReportExecutionRestApi reportExecutionApi() { + return mAuthClientState.makeReportExecutionApi(); } - public abstract void authorize() throws IOException, HttpException; + void setAuthClientState(AuthClientState authClientState) { + mAuthClientState = authClientState; + } + + public static class GenericBuilder { + private final Client mClient; + private final Credentials mCredentials; + + GenericBuilder(Client client, Credentials credentials) { + mClient = client; + mCredentials = credentials; + } + + public GenericBuilder withProxy(Proxy proxy) { + return this; + } + + public AuthorizedClient create() { + AuthClientState state = new InitialAuthClientState(); + return new AuthorizedClient(mClient, mCredentials, state); + } + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java new file mode 100644 index 00000000..8637d90e --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class InitialAuthClientState implements AuthClientState { + @Override + public void connect(AuthorizedClient client) { + client.setAuthClientState(new AuthorizedAuthClientState()); + } + + @Override + public ReportExecutionRestApi makeReportExecutionApi() { + throw new IllegalStateException("Unauthorized state. Please, connect client before usage"); + } +} From 881a98e75823b71bf1e0fcf7786a02b30fb7eccb Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 11:38:32 +0200 Subject: [PATCH 355/457] Connect Client abstraction with InfoApi --- .../android/sdk/network/Client.java | 25 +++++++++ .../sdk/network/HttpClientFactory.java | 43 +++++++++++++++ .../android/sdk/network/RetrofitFactory.java | 54 +++++++++++++++++++ .../sdk/network/ServerRestApiImpl.java | 52 ++++++++++++------ 4 files changed, 157 insertions(+), 17 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index ecbf1401..5316d398 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -31,14 +31,39 @@ public final class Client { private final String mBaseUrl; + private RetrofitFactory mRetrofitFactory; + private HttpClientFactory mHttpClientFactory; + public Client(String baseUrl) { mBaseUrl = baseUrl; } + public ServerRestApi infoApi() { + return new ServerRestApiImpl(this); + } + public static GenericBuilder newBuilder() { return new GenericBuilder(); } + public String getBaseUrl() { + return mBaseUrl; + } + + RetrofitFactory getRetrofitFactory() { + if (mRetrofitFactory == null) { + mRetrofitFactory = new RetrofitFactory(this); + } + return mRetrofitFactory; + } + + HttpClientFactory getClientFactory() { + if (mHttpClientFactory == null) { + mHttpClientFactory = new HttpClientFactory(this); + } + return mHttpClientFactory; + } + public static class GenericBuilder { public OptionalBuilder withBaseUrl(String baseUrl) { return new OptionalBuilder(baseUrl); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java new file mode 100644 index 00000000..4f67efdc --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java @@ -0,0 +1,43 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.squareup.okhttp.OkHttpClient; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class HttpClientFactory { + private final Client mClient; + + HttpClientFactory(Client client) { + mClient = client; + } + + public OkHttpClient newHttpClient() { + return new OkHttpClient(); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java new file mode 100644 index 00000000..764ddef8 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; +import org.jetbrains.annotations.TestOnly; +import retrofit.Retrofit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RetrofitFactory { + private final Client mClient; + + @TestOnly + RetrofitFactory(Client client) { + mClient = client; + } + + public Retrofit.Builder newRetrofit() { + Gson configuredGson = GsonFactory.create(); + GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); + StringConverterFactory stringConverterFactory = StringConverterFactory.create(); + + return new Retrofit.Builder() + .baseUrl(mClient.getBaseUrl()) + .addConverterFactory(gsonConverterFactory) + .addConverterFactory(stringConverterFactory); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java index 1d46bb7b..a5b27464 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java @@ -25,87 +25,96 @@ package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; - import org.jetbrains.annotations.NotNull; - -import java.io.IOException; - import retrofit.Call; import retrofit.Retrofit; import retrofit.http.GET; import retrofit.http.Headers; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 */ final class ServerRestApiImpl implements ServerRestApi { - private final RestApi mApi; + private final Client mClient; + + private RestApi mApi; - public ServerRestApiImpl(Retrofit retrofit) { - mApi = retrofit.create(RestApi.class); + public ServerRestApiImpl(Client client) { + mClient = client; } @NotNull @Override public ServerInfoData requestServerInfo() throws IOException, HttpException { - Call call = mApi.requestServerInfo(); + Call call = getApi().requestServerInfo(); return CallWrapper.wrap(call).body(); } @NotNull @Override public String requestEdition() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestEdition()).body(); + return CallWrapper.wrap(getApi().requestEdition()).body(); } @NotNull @Override public String requestVersion() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestVersion()).body(); + return CallWrapper.wrap(getApi().requestVersion()).body(); } @NotNull @Override public String requestBuild() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestBuild()).body(); + return CallWrapper.wrap(getApi().requestBuild()).body(); } @NotNull @Override public String requestFeatures() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestFeatures()).body(); + return CallWrapper.wrap(getApi().requestFeatures()).body(); } @NotNull @Override public String requestEditionName() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestEditionName()).body(); + return CallWrapper.wrap(getApi().requestEditionName()).body(); } @NotNull @Override public String requestLicenseType() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestLicenseType()).body(); + return CallWrapper.wrap(getApi().requestLicenseType()).body(); } @NotNull @Override public String requestExpiration() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestExpiration()).body(); + return CallWrapper.wrap(getApi().requestExpiration()).body(); } @NotNull @Override public String requestDateFormatPattern() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestDateFormatPattern()).body(); + return CallWrapper.wrap(getApi().requestDateFormatPattern()).body(); } @NotNull @Override public String requestDateTimeFormatPattern() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestDateTimeFormatPattern()).body(); + return CallWrapper.wrap(getApi().requestDateTimeFormatPattern()).body(); + } + + private RestApi getApi() { + if (mApi == null) { + RetrofitFactory retrofitFactory = mClient.getRetrofitFactory(); + Retrofit retrofit = retrofitFactory.newRetrofit().build(); + return retrofit.create(RestApi.class); + } + return mApi; } private interface RestApi { @@ -113,30 +122,39 @@ private interface RestApi { @Headers("Accept: application/json") @GET(value = "rest_v2/serverInfo") Call requestServerInfo(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/edition") Call requestEdition(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/version") Call requestVersion(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/build") Call requestBuild(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/features") Call requestFeatures(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/editionName") Call requestEditionName(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/licenseType") Call requestLicenseType(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/expiration") Call requestExpiration(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/dateFormatPattern") Call requestDateFormatPattern(); + @Headers("Accept: text/plain") @GET(value = "rest_v2/serverInfo/datetimeFormatPattern") Call requestDateTimeFormatPattern(); From 492d0d3e97537f7e95e4aa87dfc20f7e8c516f52 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 11:41:21 +0200 Subject: [PATCH 356/457] Add public API for creating auth client --- .../jaspersoft/android/sdk/network/AuthorizedClient.java | 6 +++--- .../java/com/jaspersoft/android/sdk/network/Client.java | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index 67b511b3..d755893a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -59,16 +59,16 @@ void setAuthClientState(AuthClientState authClientState) { mAuthClientState = authClientState; } - public static class GenericBuilder { + public static class Builder { private final Client mClient; private final Credentials mCredentials; - GenericBuilder(Client client, Credentials credentials) { + Builder(Client client, Credentials credentials) { mClient = client; mCredentials = credentials; } - public GenericBuilder withProxy(Proxy proxy) { + public Builder withProxy(Proxy proxy) { return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index 5316d398..ba85716b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -42,6 +42,10 @@ public ServerRestApi infoApi() { return new ServerRestApiImpl(this); } + public AuthorizedClient.Builder makeAuthorizedClient(Credentials credentials) { + return new AuthorizedClient.Builder(this, credentials); + } + public static GenericBuilder newBuilder() { return new GenericBuilder(); } From d568be16c19553b7425a9127aec197fe90ee930f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 11:56:11 +0200 Subject: [PATCH 357/457] Implement connect() method for InitialAuthClientState --- .../android/sdk/network/AnonymousClient.java | 81 ------------------- .../sdk/network/AnonymousClientImpl.java | 37 --------- .../android/sdk/network/AuthService.java | 2 +- .../android/sdk/network/AuthStrategy.java | 52 ++++++++++-- .../android/sdk/network/AuthStrategyImpl.java | 54 ------------- .../sdk/network/AuthenticationRestApi.java | 40 +++++++-- .../android/sdk/network/AuthorizedClient.java | 8 +- .../android/sdk/network/Credentials.java | 2 +- .../sdk/network/InitialAuthClientState.java | 12 ++- .../sdk/network/SpringAuthService.java | 5 +- .../sdk/network/SpringCredentials.java | 4 +- .../android/sdk/network/AuthServiceTest.java | 4 +- 12 files changed, 102 insertions(+), 199 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategyImpl.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java deleted file mode 100644 index 163c2036..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; -import com.squareup.okhttp.OkHttpClient; -import org.jetbrains.annotations.NotNull; -import retrofit.Retrofit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public abstract class AnonymousClient { - private final OkHttpClient mOkHttpClient; - private final String mBaseUrl; - - private Retrofit mRetrofit; - - AnonymousClient(String baseUrl, OkHttpClient okHttpClient) { - mOkHttpClient = okHttpClient; - mBaseUrl = baseUrl; - } - - OkHttpClient getClient() { - return mOkHttpClient; - } - - String getBaseUrl() { - return mBaseUrl; - } - - Retrofit getRetrofit() { - if (mRetrofit == null) { - mRetrofit = configureRetrofit(); - } - return mRetrofit; - } - - private Retrofit configureRetrofit() { - Retrofit.Builder builder = new Retrofit.Builder(); - builder.baseUrl(mBaseUrl); - - Gson configuredGson = GsonFactory.create(); - GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); - StringConverterFactory stringConverterFactory = StringConverterFactory.create(); - - builder.addConverterFactory(gsonConverterFactory); - builder.addConverterFactory(stringConverterFactory); - - return builder.build(); - } - - @NotNull - public final ServerRestApi infoApi() { - throw new UnsupportedOperationException("Not yet implemented"); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java deleted file mode 100644 index 33cd1134..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.OkHttpClient; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class AnonymousClientImpl extends AnonymousClient { - AnonymousClientImpl(String baseUrl, OkHttpClient okHttpClient) { - super(baseUrl, okHttpClient); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java index dcabf17f..e356dc61 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java @@ -44,6 +44,6 @@ class AuthService { @NotNull public Cookies authenticate(@NotNull Credentials credentials) throws HttpException, IOException { checkNotNull(credentials, "Credentials should not be null"); - return credentials.applyPolicy(mPolicy); + return credentials.apply(mPolicy); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java index 69ea9a18..0314a3e4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java @@ -1,17 +1,59 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + package com.jaspersoft.android.sdk.network; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.io.IOException; /** * @author Tom Koptel * @since 2.0 */ -abstract class AuthStrategy { - protected final AnonymousClient mAnonymousClient; +class AuthStrategy { + @NotNull + private final Client mClient; + + @Nullable + private SpringAuthService springAuthService; - protected AuthStrategy(AnonymousClient anonymousClient) { - mAnonymousClient = anonymousClient; + AuthStrategy(@NotNull Client client) { + mClient = client; } - abstract Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException; + void apply(SpringCredentials credentials) throws IOException, HttpException { + if (springAuthService == null) { + springAuthService = createSpringAuthService(); + } + springAuthService.authenticate(credentials); + } + + private SpringAuthService createSpringAuthService() { + AuthenticationRestApi restApi = new AuthenticationRestApi(mClient); + JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); + return new SpringAuthService(restApi, encryptionAlgorithm); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategyImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategyImpl.java deleted file mode 100644 index e903120a..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategyImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class AuthStrategyImpl extends AuthStrategy { - - private SpringAuthService springAuthService; - - protected AuthStrategyImpl(AnonymousClient anonymousClient) { - super(anonymousClient); - } - - @Override - Cookies applyCredentials(SpringCredentials credentials) throws IOException, HttpException { - if (springAuthService == null) { - springAuthService = createSpringAuthService(); - } - return springAuthService.authenticate(credentials); - } - - private SpringAuthService createSpringAuthService() { - AuthenticationRestApi restApi = new AuthenticationRestApi(mAnonymousClient); - JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); - return new SpringAuthService(restApi, encryptionAlgorithm); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 4fceacc5..8e4b60c5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.*; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; @@ -45,10 +46,16 @@ * @since 2.0 */ class AuthenticationRestApi { - private final AnonymousClient mClient; + @NotNull + private final Client mClient; + + @Nullable + private OkHttpClient mOkHttpClient; + @Nullable + private Retrofit mRetrofit; - AuthenticationRestApi(AnonymousClient anonymousClient) { - mClient = anonymousClient; + AuthenticationRestApi(@NotNull Client client) { + mClient = client; } @NotNull @@ -57,7 +64,7 @@ public Cookies springAuth(@NotNull final String username, final String organization, final Map params) throws HttpException, IOException { Request request = createAuthRequest(username, password, organization, params); - Call call = mClient.getClient().newCall(request); + Call call = getHttpClient().newCall(request); com.squareup.okhttp.Response response = call.execute(); int statusCode = response.code(); if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request @@ -85,12 +92,11 @@ public Cookies springAuth(@NotNull final String username, @NotNull public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { - Retrofit retrofit = mClient.getRetrofit(); - RestApi api = retrofit.create(RestApi.class); + RestApi api = getRetrofit().create(RestApi.class); Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); Cookies anonymousCookies = CookieExtractor.extract(response.raw()); - RestApi modifiedApi = retrofit.create(RestApi.class); + RestApi modifiedApi = getRetrofit().create(RestApi.class); try { return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata(anonymousCookies.toString())).body(); @@ -104,6 +110,26 @@ public EncryptionKey requestEncryptionMetadata() throws IOException, HttpExcepti } } + private OkHttpClient getHttpClient() { + if (mOkHttpClient == null) { + HttpClientFactory clientFactory = mClient.getClientFactory(); + OkHttpClient okHttpClient = clientFactory.newHttpClient(); + okHttpClient.setFollowRedirects(false); + mOkHttpClient = okHttpClient; + } + return mOkHttpClient; + } + + private Retrofit getRetrofit() { + if (mRetrofit == null) { + RetrofitFactory retrofitFactory = mClient.getRetrofitFactory(); + Retrofit retrofit = retrofitFactory.newRetrofit().build(); + mRetrofit = retrofit; + } + + return mRetrofit; + } + private Request createAuthRequest( @NotNull final String username, @NotNull final String password, diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index d755893a..491861e1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -34,15 +34,15 @@ * @since 2.0 */ public final class AuthorizedClient { - private final Client mClient; - private final Credentials mCredentials; + final Client anonymousClient; + final Credentials credentials; private AuthClientState mAuthClientState; @TestOnly AuthorizedClient(Client client, Credentials credentials, AuthClientState authClientState) { - mClient = client; - mCredentials = credentials; + anonymousClient = client; + this.credentials = credentials; mAuthClientState = authClientState; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java index fbc821cf..b436e81f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java @@ -7,5 +7,5 @@ * @since 2.0 */ public abstract class Credentials { - protected abstract Cookies applyPolicy(AuthStrategy authStrategy) throws IOException, HttpException; + protected abstract Cookies apply(AuthStrategy authStrategy) throws IOException, HttpException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java index 8637d90e..efb98dfe 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -24,14 +24,22 @@ package com.jaspersoft.android.sdk.network; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 */ final class InitialAuthClientState implements AuthClientState { @Override - public void connect(AuthorizedClient client) { - client.setAuthClientState(new AuthorizedAuthClientState()); + public void connect(AuthorizedClient context) throws IOException, HttpException { + Client client = context.anonymousClient; + Credentials credentials = context.credentials; + + AuthStrategy authStrategy = new AuthStrategy(client); + credentials.apply(authStrategy); + + context.setAuthClientState(new AuthorizedAuthClientState()); } @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java index 807a7eb3..4ae7f263 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java @@ -51,8 +51,7 @@ final class SpringAuthService { mRestApi = restApi; } - @NotNull - public Cookies authenticate(SpringCredentials credentials) throws IOException, HttpException { + public void authenticate(SpringCredentials credentials) throws IOException, HttpException { String password = credentials.getPassword(); EncryptionKey encryptionKey = mRestApi.requestEncryptionMetadata(); @@ -61,7 +60,7 @@ public Cookies authenticate(SpringCredentials credentials) throws IOException, H } Map params = prepareOptionals(credentials); - return mRestApi.springAuth( + mRestApi.springAuth( credentials.getUsername(), password, credentials.getOrganization(), diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java index f1d47a41..27a7ac5c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java @@ -65,8 +65,8 @@ public Locale getLocale() { } @Override - protected Cookies applyPolicy(AuthStrategy policy) throws IOException, HttpException { - return policy.applyCredentials(this); + protected Cookies apply(AuthStrategy policy) throws IOException, HttpException { + return policy.authorize(this); } @Override diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java index 888333d8..e2e545ad 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java @@ -29,7 +29,7 @@ public class AuthServiceTest { @Before public void setupMocks() throws Exception { MockitoAnnotations.initMocks(this); - when(mCredentials.applyPolicy(any(AuthStrategy.class))).thenReturn(fakeCookies); + when(mCredentials.apply(any(AuthStrategy.class))).thenReturn(fakeCookies); mAuthServiceUnderTest = new AuthService(mAuthStrategy); } @@ -37,7 +37,7 @@ public void setupMocks() throws Exception { public void testAuthenticate() throws Exception { mAuthServiceUnderTest.authenticate(mCredentials); - verify(mCredentials).applyPolicy(mAuthStrategy); + verify(mCredentials).apply(mAuthStrategy); verifyNoMoreInteractions(mCredentials); verifyNoMoreInteractions(mAuthStrategy); } From e89d8d964063b0655f73227cf8d160cb0f6526db Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 12:21:13 +0200 Subject: [PATCH 358/457] Configure http client on the basis of AuthPolicy --- .../android/sdk/network/AuthClientState.java | 2 +- .../network/AuthorizedAuthClientState.java | 59 ++++++++++++++++++- .../android/sdk/network/AuthorizedClient.java | 17 ++++-- .../sdk/network/InitialAuthClientState.java | 11 ++-- 4 files changed, 75 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java index 9d294d93..9c7cbe33 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java @@ -31,6 +31,6 @@ * @since 2.0 */ interface AuthClientState { - void connect(AuthorizedClient client) throws IOException, HttpException; + void connect(AuthorizedClient context) throws IOException, HttpException; ReportExecutionRestApi makeReportExecutionApi(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index cf0ef29d..63e38cef 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -24,20 +24,75 @@ package com.jaspersoft.android.sdk.network; +import com.squareup.okhttp.Authenticator; +import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; +import retrofit.Retrofit; + import java.io.IOException; +import java.net.Proxy; /** * @author Tom Koptel * @since 2.0 */ final class AuthorizedAuthClientState implements AuthClientState { + private AuthorizedClient mAuthorizedClient; + private Retrofit mRetrofit; + @Override - public void connect(AuthorizedClient client) throws IOException, HttpException { - // do nothing we already connected + public void connect(AuthorizedClient context) throws IOException, HttpException { + mAuthorizedClient = context; + makeAuthCall(); + } + + private void makeAuthCall() throws IOException, HttpException { + Client client = mAuthorizedClient.anonymousClient; + Credentials credentials = mAuthorizedClient.credentials; + AuthStrategy authStrategy = new AuthStrategy(client); + credentials.apply(authStrategy); } @Override public ReportExecutionRestApi makeReportExecutionApi() { throw new UnsupportedOperationException("Not yet implemented"); } + + Retrofit getRetrofit() { + if (mRetrofit == null) { + RetrofitFactory retrofitFactory = new RetrofitFactory(mAuthorizedClient.anonymousClient); + Retrofit.Builder builder = retrofitFactory.newRetrofit(); + + OkHttpClient okHttpClient = configureOkHttp(); + builder.client(okHttpClient); + + mRetrofit = builder.build(); + } + + return mRetrofit; + } + + private OkHttpClient configureOkHttp() { + OkHttpClient okHttpClient = new OkHttpClient(); + if (mAuthorizedClient.authenticationPolicy == AuthPolicy.RETRY) { + okHttpClient.setAuthenticator(new Authenticator() { + @Override + public Request authenticate(Proxy proxy, Response response) throws IOException { + try { + makeAuthCall(); + } catch (HttpException code) { + return null; + } + return null; + } + + @Override + public Request authenticateProxy(Proxy proxy, Response response) throws IOException { + return null; + } + }); + } + return okHttpClient; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index 491861e1..f44af29e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -27,7 +27,6 @@ import org.jetbrains.annotations.TestOnly; import java.io.IOException; -import java.lang.reflect.Proxy; /** * @author Tom Koptel @@ -36,13 +35,15 @@ public final class AuthorizedClient { final Client anonymousClient; final Credentials credentials; + final AuthPolicy authenticationPolicy; private AuthClientState mAuthClientState; @TestOnly - AuthorizedClient(Client client, Credentials credentials, AuthClientState authClientState) { + AuthorizedClient(Client client, Credentials credentials, AuthPolicy authenticationPolicy, AuthClientState authClientState) { anonymousClient = client; this.credentials = credentials; + this.authenticationPolicy = authenticationPolicy; mAuthClientState = authClientState; } @@ -63,18 +64,26 @@ public static class Builder { private final Client mClient; private final Credentials mCredentials; + private AuthPolicy mAuthenticationPolicy; + Builder(Client client, Credentials credentials) { mClient = client; mCredentials = credentials; } - public Builder withProxy(Proxy proxy) { + public Builder withAuthenticationPolicy(AuthPolicy authenticationPolicy) { + mAuthenticationPolicy = authenticationPolicy; return this; } public AuthorizedClient create() { + ensureSaneDefaults(); AuthClientState state = new InitialAuthClientState(); - return new AuthorizedClient(mClient, mCredentials, state); + return new AuthorizedClient(mClient, mCredentials, mAuthenticationPolicy, state); + } + + private void ensureSaneDefaults() { + mAuthenticationPolicy = AuthPolicy.RETRY; } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java index efb98dfe..bbcb7b5a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -33,17 +33,14 @@ final class InitialAuthClientState implements AuthClientState { @Override public void connect(AuthorizedClient context) throws IOException, HttpException { - Client client = context.anonymousClient; - Credentials credentials = context.credentials; - - AuthStrategy authStrategy = new AuthStrategy(client); - credentials.apply(authStrategy); - - context.setAuthClientState(new AuthorizedAuthClientState()); + AuthClientState state = new AuthorizedAuthClientState(); + state.connect(context); + context.setAuthClientState(state); } @Override public ReportExecutionRestApi makeReportExecutionApi() { throw new IllegalStateException("Unauthorized state. Please, connect client before usage"); } + } From 4348dbf1cc93bb87193ba56352cd4d4a433fde95 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 12:24:50 +0200 Subject: [PATCH 359/457] Reduce cookies api for ReportExecutionRestApi --- .../network/AuthorizedAuthClientState.java | 9 +++- .../sdk/network/ReportExecutionRestApi.java | 17 +++--- .../network/ReportExecutionRestApiImpl.java | 54 +++++++------------ 3 files changed, 31 insertions(+), 49 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index 63e38cef..c8d5fbe4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -38,8 +38,10 @@ * @since 2.0 */ final class AuthorizedAuthClientState implements AuthClientState { - private AuthorizedClient mAuthorizedClient; + private Retrofit mRetrofit; + private AuthorizedClient mAuthorizedClient; + private ReportExecutionRestApi mReportExecutionRestApi; @Override public void connect(AuthorizedClient context) throws IOException, HttpException { @@ -56,7 +58,10 @@ private void makeAuthCall() throws IOException, HttpException { @Override public ReportExecutionRestApi makeReportExecutionApi() { - throw new UnsupportedOperationException("Not yet implemented"); + if (mReportExecutionRestApi == null) { + mReportExecutionRestApi = new ReportExecutionRestApiImpl(getRetrofit()); + } + return mReportExecutionRestApi; } Retrofit getRetrofit() { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index 361b4bea..a4612c01 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -42,27 +42,22 @@ public interface ReportExecutionRestApi { @NotNull - ReportExecutionDescriptor runReportExecution(@NotNull Cookies cookies, - @NotNull ReportExecutionRequestOptions executionOptions) throws HttpException, IOException; + ReportExecutionDescriptor runReportExecution(@NotNull ReportExecutionRequestOptions executionOptions) throws HttpException, IOException; @NotNull - ReportExecutionDescriptor requestReportExecutionDetails(@NotNull Cookies cookies, - @NotNull String executionId) throws HttpException, IOException; + ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String executionId) throws HttpException, IOException; @NotNull - ExecutionStatus requestReportExecutionStatus(@NotNull Cookies cookies, - @NotNull String executionId) throws HttpException, IOException; + ExecutionStatus requestReportExecutionStatus(@NotNull String executionId) throws HttpException, IOException; - boolean cancelReportExecution(@NotNull Cookies cookies, - @NotNull String executionId) throws HttpException, IOException; + boolean cancelReportExecution(@NotNull String executionId) throws HttpException, IOException; - boolean updateReportExecution(@NotNull Cookies cookies, - @NotNull String executionId, + boolean updateReportExecution(@NotNull String executionId, @NotNull List params) throws HttpException, IOException; // TODO: API is broken requires investigation before release @NotNull - ReportExecutionSearchResponse searchReportExecution(@NotNull Cookies cookies, Map params) throws HttpException, IOException; + ReportExecutionSearchResponse searchReportExecution(Map params) throws HttpException, IOException; final class Builder extends GenericBuilder { @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java index 5accfd41..7e7f7109 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java @@ -54,59 +54,49 @@ final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { @NotNull @Override - public ReportExecutionDescriptor runReportExecution(@Nullable Cookies cookies, - @Nullable ReportExecutionRequestOptions executionOptions) throws IOException, HttpException { + public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) throws IOException, HttpException { Utils.checkNotNull(executionOptions, "Execution options should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.runReportExecution(executionOptions, cookies.toString()); + Call call = mRestApi.runReportExecution(executionOptions); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable Cookies cookies, - @Nullable String executionId) throws IOException, HttpException { + public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExecutionDetails(executionId, cookies.toString()); + Call call = mRestApi.requestReportExecutionDetails(executionId); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ExecutionStatus requestReportExecutionStatus(@Nullable Cookies cookies, - @Nullable String executionId) throws IOException, HttpException { + public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExecutionStatus(executionId, cookies.toString()); + Call call = mRestApi.requestReportExecutionStatus(executionId); return CallWrapper.wrap(call).body(); } @Override - public boolean cancelReportExecution(@Nullable Cookies cookies, - @Nullable String executionId) throws IOException, HttpException { + public boolean cancelReportExecution(@Nullable String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus(), cookies.toString()); + Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus()); Response response = CallWrapper.wrap(call).response(); int status = response.code(); return status != 204; } @Override - public boolean updateReportExecution(@Nullable Cookies cookies, - @Nullable String executionId, + public boolean updateReportExecution(@Nullable String executionId, @Nullable List params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.updateReportExecution(executionId, params, cookies.toString()); + Call call = mRestApi.updateReportExecution(executionId, params); Response response = CallWrapper.wrap(call).response(); int status = response.code(); return status == 204; @@ -114,13 +104,11 @@ public boolean updateReportExecution(@Nullable Cookies cookies, @NotNull @Override - public ReportExecutionSearchResponse searchReportExecution(@Nullable Cookies cookies, - @Nullable Map params) throws IOException, HttpException { + public ReportExecutionSearchResponse searchReportExecution(@Nullable Map params) throws IOException, HttpException { Utils.checkNotNull(params, "Search params should not be null"); Utils.checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.searchReportExecution(params, cookies.toString()); + Call call = mRestApi.searchReportExecution(params); ReportExecutionSearchResponse body = CallWrapper.wrap(call).body(); if (body == null) { return ReportExecutionSearchResponse.empty(); @@ -132,38 +120,32 @@ interface RestApi { @NotNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions") - Call runReportExecution(@NotNull @Body ReportExecutionRequestOptions executionOptions, - @Header("Cookie") String cookie); + Call runReportExecution(@NotNull @Body ReportExecutionRequestOptions executionOptions); @NotNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}") - Call requestReportExecutionDetails(@NotNull @Path(value = "executionId", encoded = true) String executionId, - @Header("Cookie") String cookie); + Call requestReportExecutionDetails(@NotNull @Path(value = "executionId", encoded = true) String executionId); @NotNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/status") - Call requestReportExecutionStatus(@NotNull @Path(value = "executionId", encoded = true) String executionId, - @Header("Cookie") String cookie); + Call requestReportExecutionStatus(@NotNull @Path(value = "executionId", encoded = true) String executionId); @NotNull @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/parameters") Call updateReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, - @NotNull @Body List params, - @Header("Cookie") String cookie); + @NotNull @Body List params); @NotNull @Headers("Accept: application/json") @PUT("rest_v2/reportExecutions/{executionId}/status") Call cancelReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, - @NotNull @Body ExecutionStatus statusResponse, - @Header("Cookie") String cookie); + @NotNull @Body ExecutionStatus statusResponse); @Headers("Accept: application/json") @GET("rest_v2/reportExecutions") - Call searchReportExecution(@Nullable @QueryMap(encoded = true) Map params, - @Header("Cookie") String cookie); + Call searchReportExecution(@Nullable @QueryMap(encoded = true) Map params); } } From 615b53fcc21dda67a377f0d71a91772ca4a64de4 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 12:29:32 +0200 Subject: [PATCH 360/457] Reduce Cookies for ReportExportRestApi --- .../android/sdk/network/AuthClientState.java | 1 + .../network/AuthorizedAuthClientState.java | 10 +++++ .../android/sdk/network/AuthorizedClient.java | 4 ++ .../sdk/network/InitialAuthClientState.java | 8 +++- .../sdk/network/ReportExecutionRestApi.java | 7 ---- .../sdk/network/ReportExportRestApi.java | 20 ++-------- .../sdk/network/ReportExportRestApiImpl.java | 37 +++++++------------ 7 files changed, 39 insertions(+), 48 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java index 9c7cbe33..31978203 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java @@ -33,4 +33,5 @@ interface AuthClientState { void connect(AuthorizedClient context) throws IOException, HttpException; ReportExecutionRestApi makeReportExecutionApi(); + ReportExportRestApi makeReportExportRestApi(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index c8d5fbe4..b114db45 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -41,7 +41,9 @@ final class AuthorizedAuthClientState implements AuthClientState { private Retrofit mRetrofit; private AuthorizedClient mAuthorizedClient; + private ReportExecutionRestApi mReportExecutionRestApi; + private ReportExportRestApi mReportExportRestApi; @Override public void connect(AuthorizedClient context) throws IOException, HttpException { @@ -64,6 +66,14 @@ public ReportExecutionRestApi makeReportExecutionApi() { return mReportExecutionRestApi; } + @Override + public ReportExportRestApi makeReportExportRestApi() { + if (mReportExportRestApi == null) { + mReportExportRestApi = new ReportExportRestApiImpl(getRetrofit()); + } + return mReportExportRestApi; + } + Retrofit getRetrofit() { if (mRetrofit == null) { RetrofitFactory retrofitFactory = new RetrofitFactory(mAuthorizedClient.anonymousClient); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index f44af29e..53e2fc76 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -56,6 +56,10 @@ public ReportExecutionRestApi reportExecutionApi() { return mAuthClientState.makeReportExecutionApi(); } + public ReportExportRestApi reportExportApi() { + return mAuthClientState.makeReportExportRestApi(); + } + void setAuthClientState(AuthClientState authClientState) { mAuthClientState = authClientState; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java index bbcb7b5a..cbe0f2a3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -31,6 +31,8 @@ * @since 2.0 */ final class InitialAuthClientState implements AuthClientState { + private static final String MESSAGE = "Unauthorized state. Please, connect client before usage"; + @Override public void connect(AuthorizedClient context) throws IOException, HttpException { AuthClientState state = new AuthorizedAuthClientState(); @@ -40,7 +42,11 @@ public void connect(AuthorizedClient context) throws IOException, HttpException @Override public ReportExecutionRestApi makeReportExecutionApi() { - throw new IllegalStateException("Unauthorized state. Please, connect client before usage"); + throw new IllegalStateException(MESSAGE); } + @Override + public ReportExportRestApi makeReportExportRestApi() { + throw new IllegalStateException(MESSAGE); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index a4612c01..9caec167 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -58,11 +58,4 @@ boolean updateReportExecution(@NotNull String executionId, // TODO: API is broken requires investigation before release @NotNull ReportExecutionSearchResponse searchReportExecution(Map params) throws HttpException, IOException; - - final class Builder extends GenericBuilder { - @Override - ReportExecutionRestApi createApi() { - return new ReportExecutionRestApiImpl(getAdapter().build()); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java index 632ccfaa..85c5349f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java @@ -40,32 +40,20 @@ * @since 2.0 */ public interface ReportExportRestApi { - @NotNull - ExportExecutionDescriptor runExportExecution(@NotNull Cookies cookies, - @NotNull String executionId, + ExportExecutionDescriptor runExportExecution(@NotNull String executionId, @NotNull ExecutionRequestOptions executionOptions) throws HttpException, IOException; @NotNull - ExecutionStatus checkExportExecutionStatus(@NotNull Cookies cookies, - @NotNull String executionId, + ExecutionStatus checkExportExecutionStatus(@NotNull String executionId, @NotNull String exportId) throws HttpException, IOException; @NotNull - ExportOutputResource requestExportOutput(@NotNull Cookies cookies, - @NotNull String executionId, + ExportOutputResource requestExportOutput(@NotNull String executionId, @NotNull String exportId) throws HttpException, IOException; @NotNull - OutputResource requestExportAttachment(@NotNull Cookies cookies, - @NotNull String executionId, + OutputResource requestExportAttachment(@NotNull String executionId, @NotNull String exportId, @NotNull String attachmentId) throws HttpException, IOException; - - final class Builder extends GenericBuilder { - @Override - ReportExportRestApi createApi() { - return new ReportExportRestApiImpl(getAdapter().build()); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java index bef2094b..a12adb51 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java @@ -52,40 +52,35 @@ public ReportExportRestApiImpl(Retrofit restAdapter) { @NotNull @Override - public ExportExecutionDescriptor runExportExecution(@Nullable Cookies cookies, - @Nullable String executionId, + public ExportExecutionDescriptor runExportExecution(@Nullable String executionId, @Nullable ExecutionRequestOptions executionOptions) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(executionOptions, "Execution options should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.runReportExportExecution(executionId, executionOptions, cookies.toString()); + Call call = mRestApi.runReportExportExecution(executionId, executionOptions); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ExecutionStatus checkExportExecutionStatus(@Nullable Cookies cookies, - @Nullable String executionId, + public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, @Nullable String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); + - Call call = mRestApi.checkReportExportStatus(executionId, exportId, cookies.toString()); + Call call = mRestApi.checkReportExportStatus(executionId, exportId); return CallWrapper.wrap(call).body(); } @NotNull @Override - public ExportOutputResource requestExportOutput(@Nullable Cookies cookies, - @Nullable String executionId, + public ExportOutputResource requestExportOutput(@Nullable String executionId, @Nullable String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExportOutput(executionId, exportId, cookies.toString()); + Call call = mRestApi.requestReportExportOutput(executionId, exportId); Response rawResponse = CallWrapper.wrap(call).response(); com.squareup.okhttp.Headers headers = rawResponse.headers(); @@ -98,16 +93,14 @@ public ExportOutputResource requestExportOutput(@Nullable Cookies cookies, @NotNull @Override - public OutputResource requestExportAttachment(@Nullable Cookies cookies, - @Nullable String executionId, + public OutputResource requestExportAttachment(@Nullable String executionId, @Nullable String exportId, @Nullable String attachmentId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); Utils.checkNotNull(attachmentId, "Attachment id should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId, cookies.toString()); + Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); Response rawResponse = CallWrapper.wrap(call).response(); ResponseBody body = rawResponse.body(); return new RetrofitOutputResource(body); @@ -118,15 +111,13 @@ private interface RestApi { @Headers("Accept: application/json") @POST("rest_v2/reportExecutions/{executionId}/exports") Call runReportExportExecution(@NotNull @Path("executionId") String executionId, - @NotNull @Body ExecutionRequestOptions executionOptions, - @Header("Cookie") String cookie); + @NotNull @Body ExecutionRequestOptions executionOptions); @NotNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") Call checkReportExportStatus(@NotNull @Path("executionId") String executionId, - @NotNull @Path(value = "exportId", encoded = true) String exportId, - @Header("Cookie") String cookie); + @NotNull @Path(value = "exportId", encoded = true) String exportId); /** * 'suppressContentDisposition' used due to security implications this header has @@ -135,15 +126,13 @@ Call checkReportExportStatus(@NotNull @Path("executionId") Stri @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") Call requestReportExportOutput(@NotNull @Path("executionId") String executionId, - @NotNull @Path(value = "exportId", encoded = true) String exportId, - @Header("Cookie") String cookie); + @NotNull @Path(value = "exportId", encoded = true) String exportId); @NotNull @Headers("Accept: application/json") @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") Call requestReportExportAttachmentOutput(@NotNull @Path("executionId") String executionId, @NotNull @Path(value = "exportId", encoded = true) String exportId, - @NotNull @Path("attachmentId") String attachmentId, - @Header("Cookie") String cookie); + @NotNull @Path("attachmentId") String attachmentId); } } From 7a5487922dab77f74f3d32efcc256aa937127b17 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 12:32:35 +0200 Subject: [PATCH 361/457] Reduce Cookies for ReportOptionRestApi --- .../android/sdk/network/AuthClientState.java | 1 + .../network/AuthorizedAuthClientState.java | 9 ++++++ .../sdk/network/InitialAuthClientState.java | 5 +++ .../sdk/network/ReportOptionRestApi.java | 18 +++-------- .../sdk/network/ReportOptionRestApiImpl.java | 32 +++++++------------ 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java index 31978203..225cba59 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java @@ -34,4 +34,5 @@ interface AuthClientState { void connect(AuthorizedClient context) throws IOException, HttpException; ReportExecutionRestApi makeReportExecutionApi(); ReportExportRestApi makeReportExportRestApi(); + ReportOptionRestApi makeReportOptionRestApi(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index b114db45..26018598 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -44,6 +44,7 @@ final class AuthorizedAuthClientState implements AuthClientState { private ReportExecutionRestApi mReportExecutionRestApi; private ReportExportRestApi mReportExportRestApi; + private ReportOptionRestApi mReportOptionRestApi; @Override public void connect(AuthorizedClient context) throws IOException, HttpException { @@ -74,6 +75,14 @@ public ReportExportRestApi makeReportExportRestApi() { return mReportExportRestApi; } + @Override + public ReportOptionRestApi makeReportOptionRestApi() { + if (mReportOptionRestApi == null) { + mReportOptionRestApi = new ReportOptionRestApiImpl(getRetrofit()); + } + return mReportOptionRestApi; + } + Retrofit getRetrofit() { if (mRetrofit == null) { RetrofitFactory retrofitFactory = new RetrofitFactory(mAuthorizedClient.anonymousClient); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java index cbe0f2a3..63e22fb3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -49,4 +49,9 @@ public ReportExecutionRestApi makeReportExecutionApi() { public ReportExportRestApi makeReportExportRestApi() { throw new IllegalStateException(MESSAGE); } + + @Override + public ReportOptionRestApi makeReportOptionRestApi() { + throw new IllegalStateException(MESSAGE); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java index d11f1efb..c7b2597c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java @@ -39,28 +39,18 @@ public interface ReportOptionRestApi { @NotNull - Set requestReportOptionsList(@NotNull Cookies cookies, - @NotNull String reportUnitUri) throws HttpException, IOException; + Set requestReportOptionsList(@NotNull String reportUnitUri) throws HttpException, IOException; @NotNull - ReportOption createReportOption(@NotNull Cookies cookies, @NotNull String reportUnitUri, + ReportOption createReportOption(@NotNull String reportUnitUri, @NotNull String optionLabel, @NotNull Map> controlsValues, boolean overwrite) throws HttpException, IOException; - void updateReportOption(@NotNull Cookies cookies, - @NotNull String reportUnitUri, + void updateReportOption(@NotNull String reportUnitUri, @NotNull String optionId, @NotNull Map> controlsValues) throws HttpException, IOException; - void deleteReportOption(@NotNull Cookies cookies, - @NotNull String reportUnitUri, + void deleteReportOption(@NotNull String reportUnitUri, @NotNull String optionId) throws HttpException, IOException; - - final class Builder extends GenericBuilder { - @Override - ReportOptionRestApi createApi() { - return new ReportOptionRestApiImpl(getAdapter().build()); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java index 9f35d442..7a8e85f5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java @@ -52,12 +52,11 @@ final class ReportOptionRestApiImpl implements ReportOptionRestApi { @NotNull @Override - public Set requestReportOptionsList(@Nullable Cookies cookies, + public Set requestReportOptionsList( @Nullable String reportUnitUri) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportOptionsList(reportUnitUri, cookies.toString()); + Call call = mRestApi.requestReportOptionsList(reportUnitUri); try { ReportOptionSet options = CallWrapper.wrap(call).body(); return options.get(); @@ -73,7 +72,7 @@ public Set requestReportOptionsList(@Nullable Cookies cookies, @NotNull @Override - public ReportOption createReportOption(@Nullable Cookies cookies, + public ReportOption createReportOption( @Nullable String reportUnitUri, @Nullable String optionLabel, @Nullable Map> controlsValues, @@ -81,35 +80,32 @@ public ReportOption createReportOption(@Nullable Cookies cookies, Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionLabel, "Option label should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite, cookies.toString()); + Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite); return CallWrapper.wrap(call).body(); } @Override - public void updateReportOption(@Nullable Cookies cookies, + public void updateReportOption( @Nullable String reportUnitUri, @Nullable String optionId, @Nullable Map> controlsValues) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues, cookies.toString()); + Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues); CallWrapper.wrap(call).body(); } @Override - public void deleteReportOption(@Nullable Cookies cookies, + public void deleteReportOption( @Nullable String reportUnitUri, @Nullable String optionId) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.deleteReportOption(reportUnitUri, optionId, cookies.toString()); + Call call = mRestApi.deleteReportOption(reportUnitUri, optionId); CallWrapper.wrap(call).body(); } @@ -118,8 +114,7 @@ private interface RestApi { @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitUri}/options") Call requestReportOptionsList( - @NotNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri, - @Header("Cookie") String cookie); + @NotNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); @NotNull @Headers("Accept: application/json") @@ -128,8 +123,7 @@ Call createReportOption( @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NotNull @Query("label") String optionLabel, @NotNull @Body Map> controlsValues, - @Query("overwrite") boolean overwrite, - @Header("Cookie") String cookie); + @Query("overwrite") boolean overwrite); @NotNull @Headers("Accept: application/json") @@ -137,15 +131,13 @@ Call createReportOption( Call updateReportOption( @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, @NotNull @Path(value = "optionId", encoded = true) String optionId, - @NotNull @Body Map> controlsValues, - @Header("Cookie") String cookie); + @NotNull @Body Map> controlsValues); @NotNull @Headers("Accept: application/json") @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") Call deleteReportOption( @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NotNull @Path(value = "optionId", encoded = true) String optionId, - @Header("Cookie") String cookie); + @NotNull @Path(value = "optionId", encoded = true) String optionI); } } From c9fe922a6f1c3d3314e0b78437b0e127dca683bd Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 12:36:17 +0200 Subject: [PATCH 362/457] Reduce Cookies for InputControlRestApi --- .../android/sdk/network/AuthClientState.java | 1 + .../network/AuthorizedAuthClientState.java | 9 +++++++ .../android/sdk/network/AuthorizedClient.java | 8 ++++++ .../sdk/network/InitialAuthClientState.java | 5 ++++ .../sdk/network/InputControlRestApi.java | 18 +++---------- .../sdk/network/InputControlRestApiImpl.java | 27 +++++++------------ 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java index 225cba59..96c4de6c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java @@ -35,4 +35,5 @@ interface AuthClientState { ReportExecutionRestApi makeReportExecutionApi(); ReportExportRestApi makeReportExportRestApi(); ReportOptionRestApi makeReportOptionRestApi(); + InputControlRestApi makeInputControlRestApi(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index 26018598..afbc39fd 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -45,6 +45,7 @@ final class AuthorizedAuthClientState implements AuthClientState { private ReportExecutionRestApi mReportExecutionRestApi; private ReportExportRestApi mReportExportRestApi; private ReportOptionRestApi mReportOptionRestApi; + private InputControlRestApi mInputControlRestApi; @Override public void connect(AuthorizedClient context) throws IOException, HttpException { @@ -83,6 +84,14 @@ public ReportOptionRestApi makeReportOptionRestApi() { return mReportOptionRestApi; } + @Override + public InputControlRestApi makeInputControlRestApi() { + if (mInputControlRestApi == null) { + mInputControlRestApi = new InputControlRestApiImpl(getRetrofit()); + } + return mInputControlRestApi; + } + Retrofit getRetrofit() { if (mRetrofit == null) { RetrofitFactory retrofitFactory = new RetrofitFactory(mAuthorizedClient.anonymousClient); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index 53e2fc76..1a23abe7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -60,6 +60,14 @@ public ReportExportRestApi reportExportApi() { return mAuthClientState.makeReportExportRestApi(); } + public ReportOptionRestApi reportOptionsApi() { + return mAuthClientState.makeReportOptionRestApi(); + } + + public InputControlRestApi inputControlApi() { + return mAuthClientState.makeInputControlRestApi(); + } + void setAuthClientState(AuthClientState authClientState) { mAuthClientState = authClientState; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java index 63e22fb3..b76bd3d1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -54,4 +54,9 @@ public ReportExportRestApi makeReportExportRestApi() { public ReportOptionRestApi makeReportOptionRestApi() { throw new IllegalStateException(MESSAGE); } + + @Override + public InputControlRestApi makeInputControlRestApi() { + throw new IllegalStateException(MESSAGE); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index c8eab006..b259bc44 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -45,41 +45,29 @@ public interface InputControlRestApi { * * ATTENTION: Exclude flag works only on JRS instances 6.0+ * - * @param token is a key API sends to authorize client * @param reportUri uri of report * @param excludeState exclude field state which incorporates options values for control * @return unmodifiable list of {@link InputControl} */ @NotNull - Collection requestInputControls(@NotNull Cookies cookies, - @NotNull String reportUri, + Collection requestInputControls(@NotNull String reportUri, boolean excludeState) throws HttpException, IOException; @NotNull - Collection requestInputControlsInitialStates(@NotNull Cookies cookies, - @NotNull String reportUri, + Collection requestInputControlsInitialStates(@NotNull String reportUri, boolean freshData) throws HttpException, IOException; /** * Provides values for specified controls. This API helpful to * delegate cascading resolving for the server, also should handle non-cascading cases * - * @param token is a key API sends to authorize client * @param reportUri uri of report * @param controlsValues map of {control_id: [value, value]} associated input controls metadata * @param freshData whether data should be retrieved from cache or not * @return unmodifiable list of {@link InputControlState} */ @NotNull - Collection requestInputControlsStates(@NotNull Cookies cookies, - @NotNull String reportUri, + Collection requestInputControlsStates(@NotNull String reportUri, @NotNull Map> controlsValues, boolean freshData) throws HttpException, IOException; - - final class Builder extends GenericBuilder { - @Override - InputControlRestApi createApi() { - return new InputControlRestApiImpl(getAdapter().build()); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java index 87fae285..556f7a1f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java @@ -53,43 +53,37 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NotNull @Override - public Collection requestInputControls(@Nullable Cookies cookies, - @Nullable String reportUri, + public Collection requestInputControls(@Nullable String reportUri, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); String state = (excludeState ? "state" : null); - Call call = mRestApi.requestInputControls(reportUri, state, cookies.toString()); + Call call = mRestApi.requestInputControls(reportUri, state); InputControlCollection response = CallWrapper.wrap(call).body(); return response.get(); } @NotNull @Override - public Collection requestInputControlsInitialStates(@Nullable Cookies cookies, - @Nullable String reportUri, + public Collection requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData, cookies.toString()); + Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); InputControlStateCollection response = CallWrapper.wrap(call).body(); return response.get(); } @NotNull @Override - public Collection requestInputControlsStates(@Nullable Cookies cookies, - @Nullable String reportUri, + public Collection requestInputControlsStates(@Nullable String reportUri, @Nullable Map> controlsValues, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); Utils.checkNotNull(controlsValues, "Controls values should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); String ids = Utils.joinString(";", controlsValues.keySet()); - Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData, cookies.toString()); + Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); InputControlStateCollection response = CallWrapper.wrap(call).body(); return response.get(); } @@ -100,16 +94,14 @@ private interface RestApi { @GET("rest_v2/reports{reportUnitURI}/inputControls") Call requestInputControls( @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @Query("exclude") String state, - @Header("Cookie") String cookie); + @Query("exclude") String state); @NotNull @Headers("Accept: application/json") @GET("rest_v2/reports{reportUnitURI}/inputControls/values") Call requestInputControlsInitialValues( @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @Query("freshData") boolean freshData, - @Header("Cookie") String cookie); + @Query("freshData") boolean freshData); @NotNull @Headers("Accept: application/json") @@ -118,7 +110,6 @@ Call requestInputControlsValues( @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, @NotNull @Path(value = "controlsId", encoded = true) String ids, @NotNull @Body Map> controlsValues, - @Query("freshData") boolean freshData, - @Header("Cookie") String cookie); + @Query("freshData") boolean freshData); } } From 633137fca85e4ece056caee871633c31f293ba59 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 12:40:00 +0200 Subject: [PATCH 363/457] Reduce Cookies for RepositoryRestApi --- .../android/sdk/network/AuthClientState.java | 1 + .../network/AuthorizedAuthClientState.java | 9 ++++++ .../android/sdk/network/AuthorizedClient.java | 4 +++ .../sdk/network/InitialAuthClientState.java | 5 ++++ .../sdk/network/RepositoryRestApi.java | 16 ++-------- .../sdk/network/RepositoryRestApiImpl.java | 30 +++++++------------ .../android/sdk/network/ServerRestApi.java | 7 ----- 7 files changed, 32 insertions(+), 40 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java index 96c4de6c..8442400d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java @@ -36,4 +36,5 @@ interface AuthClientState { ReportExportRestApi makeReportExportRestApi(); ReportOptionRestApi makeReportOptionRestApi(); InputControlRestApi makeInputControlRestApi(); + RepositoryRestApi makeRepositoryRestApi(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index afbc39fd..cbd59d5c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -46,6 +46,7 @@ final class AuthorizedAuthClientState implements AuthClientState { private ReportExportRestApi mReportExportRestApi; private ReportOptionRestApi mReportOptionRestApi; private InputControlRestApi mInputControlRestApi; + private RepositoryRestApi mRepositoryRestApi; @Override public void connect(AuthorizedClient context) throws IOException, HttpException { @@ -92,6 +93,14 @@ public InputControlRestApi makeInputControlRestApi() { return mInputControlRestApi; } + @Override + public RepositoryRestApi makeRepositoryRestApi() { + if (mRepositoryRestApi == null) { + mRepositoryRestApi = new RepositoryRestApiImpl(getRetrofit()); + } + return mRepositoryRestApi; + } + Retrofit getRetrofit() { if (mRetrofit == null) { RetrofitFactory retrofitFactory = new RetrofitFactory(mAuthorizedClient.anonymousClient); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index 1a23abe7..74dec4a1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -68,6 +68,10 @@ public InputControlRestApi inputControlApi() { return mAuthClientState.makeInputControlRestApi(); } + public RepositoryRestApi repositoryApi() { + return mAuthClientState.makeRepositoryRestApi(); + } + void setAuthClientState(AuthClientState authClientState) { mAuthClientState = authClientState; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java index b76bd3d1..2b22ef26 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -59,4 +59,9 @@ public ReportOptionRestApi makeReportOptionRestApi() { public InputControlRestApi makeInputControlRestApi() { throw new IllegalStateException(MESSAGE); } + + @Override + public RepositoryRestApi makeRepositoryRestApi() { + throw new IllegalStateException(MESSAGE); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java index 2409b5c6..4a39440a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java @@ -41,21 +41,11 @@ */ public interface RepositoryRestApi { @NotNull - ResourceSearchResult searchResources(@NotNull Cookies cookies, - @Nullable Map searchParams) throws HttpException, IOException; + ResourceSearchResult searchResources(@Nullable Map searchParams) throws HttpException, IOException; @NotNull - ReportLookup requestReportResource(@NotNull Cookies cookies, - @NotNull String resourceUri) throws HttpException, IOException; + ReportLookup requestReportResource(@NotNull String resourceUri) throws HttpException, IOException; @NotNull - FolderLookup requestFolderResource(@NotNull Cookies cookies, - @NotNull String resourceUri) throws HttpException, IOException; - - final class Builder extends GenericBuilder { - @Override - RepositoryRestApi createApi() { - return new RepositoryRestApiImpl(getAdapter().build()); - } - } + FolderLookup requestFolderResource(@NotNull String resourceUri) throws HttpException, IOException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java index 2492473c..8441f3fa 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java @@ -51,15 +51,12 @@ final class RepositoryRestApiImpl implements RepositoryRestApi { @NotNull @Override - public ResourceSearchResult searchResources(@Nullable Cookies cookies, - @Nullable Map searchParams) throws IOException, HttpException { - Utils.checkNotNull(cookies, "Request cookies should not be null"); - + public ResourceSearchResult searchResources(@Nullable Map searchParams) throws IOException, HttpException { Iterable types = null; Call call; if (searchParams == null) { - call = mRestApi.searchResources(null, null, cookies.toString()); + call = mRestApi.searchResources(null, null); } else { Map copy = new HashMap<>(searchParams); Object typeValues = copy.get("type"); @@ -72,7 +69,7 @@ public ResourceSearchResult searchResources(@Nullable Cookies cookies, types = (Iterable) typeValues; } - call = mRestApi.searchResources(copy, types, cookies.toString()); + call = mRestApi.searchResources(copy, types); } Response rawResponse = CallWrapper.wrap(call).response(); @@ -100,23 +97,19 @@ public ResourceSearchResult searchResources(@Nullable Cookies cookies, @NotNull @Override - public ReportLookup requestReportResource(@Nullable Cookies cookies, - @Nullable String resourceUri) throws IOException, HttpException { + public ReportLookup requestReportResource(@Nullable String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Report uri should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestReportResource(resourceUri, cookies.toString()); + Call call = mRestApi.requestReportResource(resourceUri); return CallWrapper.wrap(call).body(); } @NotNull @Override - public FolderLookup requestFolderResource(@Nullable Cookies cookies, - @Nullable String resourceUri) throws IOException, HttpException { + public FolderLookup requestFolderResource(@Nullable String resourceUri) throws IOException, HttpException { Utils.checkNotNull(resourceUri, "Folder uri should not be null"); - Utils.checkNotNull(cookies, "Request cookies should not be null"); - Call call = mRestApi.requestFolderResource(resourceUri, cookies.toString()); + Call call = mRestApi.requestFolderResource(resourceUri); return CallWrapper.wrap(call).body(); } @@ -126,21 +119,18 @@ private interface RestApi { @GET("rest_v2/resources") Call searchResources( @Nullable @QueryMap Map searchParams, - @Nullable @Query("type") Iterable types, - @Header("Cookie") String cookie); + @Nullable @Query("type") Iterable types); @NotNull @Headers("Accept: application/repository.reportUnit+json") @GET("rest_v2/resources{resourceUri}") Call requestReportResource( - @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri, - @Header("Cookie") String cookie); + @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri); @NotNull @Headers("Accept: application/repository.folder+json") @GET("rest_v2/resources{resourceUri}") Call requestFolderResource( - @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri, - @Header("Cookie") String cookie); + @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java index 5a37bd51..2400332a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java @@ -65,11 +65,4 @@ public interface ServerRestApi { @NotNull String requestExpiration() throws HttpException, IOException; - - final class Builder extends GenericBuilder { - @Override - ServerRestApi createApi() { - return new ServerRestApiImpl(getAdapter().build()); - } - } } From 7610b754c6e7b2009f969d3dd43a382eed21bf90 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 12:49:44 +0200 Subject: [PATCH 364/457] Reduce obsolete internal api(builders/cookies) --- .../android/sdk/network/AdapterBuilder.java | 85 ----------------- .../android/sdk/network/AuthService.java | 49 ---------- .../sdk/network/AuthenticationRestApi.java | 70 ++++++-------- .../sdk/network/AuthorizedClientImpl.java | 48 ---------- .../android/sdk/network/Client.java | 31 ++++++- .../android/sdk/network/ClientBuilder.java | 76 --------------- .../android/sdk/network/ClientFactory.java | 64 ------------- .../android/sdk/network/CookieExtractor.java | 59 ------------ .../android/sdk/network/Cookies.java | 92 ------------------- .../android/sdk/network/Credentials.java | 2 +- .../android/sdk/network/GenericBuilder.java | 83 ----------------- .../sdk/network/SpringCredentials.java | 4 +- 12 files changed, 58 insertions(+), 605 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java deleted file mode 100644 index dc1f1c85..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AdapterBuilder.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; -import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.OkHttpClient; - -import retrofit.Converter; -import retrofit.Retrofit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class AdapterBuilder { - private final Retrofit.Builder mRestAdapterBuilder; - private final Converter.Factory mGsonConverterFactory; - private final Converter.Factory mStringConverterFactory; - - final ClientBuilder clientBuilder; - HttpUrl baseUrl; - - public AdapterBuilder(ClientBuilder clientBuilder){ - mRestAdapterBuilder = new Retrofit.Builder(); - - Gson configuredGson = GsonFactory.create(); - mGsonConverterFactory = GsonConverterFactory.create(configuredGson); - mStringConverterFactory = StringConverterFactory.create(); - - this.clientBuilder = clientBuilder; - } - - @SuppressWarnings("unchecked") - public AdapterBuilder baseUrl(String baseUrl) { - Utils.checkNotNull(baseUrl, "baseUrl == null"); - baseUrl = Utils.normalizeBaseUrl(baseUrl); - HttpUrl httpUrl = HttpUrl.parse(baseUrl); - if (httpUrl == null) { - throw new IllegalArgumentException("Illegal URL: " + baseUrl); - } - this.baseUrl = httpUrl; - return this; - } - - public void ensureDefaults() { - if (baseUrl == null) { - throw new IllegalStateException("Base url should be supplied to work with JRS API"); - } - } - - Retrofit.Builder getAdapter() { - OkHttpClient client = clientBuilder.build(); - mRestAdapterBuilder.client(client); - mRestAdapterBuilder.baseUrl(baseUrl); - - mRestAdapterBuilder.addConverterFactory(mStringConverterFactory); - mRestAdapterBuilder.addConverterFactory(mGsonConverterFactory); - - return mRestAdapterBuilder; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java deleted file mode 100644 index e356dc61..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthService.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; - -import static com.jaspersoft.android.sdk.service.internal.Preconditions.checkNotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class AuthService { - private final AuthStrategy mPolicy; - - AuthService(AuthStrategy policy) { - mPolicy = policy; - } - - @NotNull - public Cookies authenticate(@NotNull Credentials credentials) throws HttpException, IOException { - checkNotNull(credentials, "Credentials should not be null"); - return credentials.apply(mPolicy); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 8e4b60c5..c2e2ba56 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -29,13 +29,13 @@ import com.squareup.okhttp.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import retrofit.Response; import retrofit.Retrofit; import retrofit.http.GET; -import retrofit.http.Header; import retrofit.http.Headers; import java.io.IOException; +import java.net.CookieManager; +import java.net.CookiePolicy; import java.util.Map; import java.util.Set; @@ -49,33 +49,30 @@ class AuthenticationRestApi { @NotNull private final Client mClient; - @Nullable - private OkHttpClient mOkHttpClient; - @Nullable - private Retrofit mRetrofit; - AuthenticationRestApi(@NotNull Client client) { mClient = client; } @NotNull - public Cookies springAuth(@NotNull final String username, - @NotNull final String password, - final String organization, - final Map params) throws HttpException, IOException { + public void springAuth(@NotNull final String username, + @NotNull final String password, + final String organization, + final Map params) throws HttpException, IOException { + HttpClientFactory clientFactory = mClient.getClientFactory(); + OkHttpClient okHttpClient = clientFactory.newHttpClient(); + okHttpClient.setFollowRedirects(false); + Request request = createAuthRequest(username, password, organization, params); - Call call = getHttpClient().newCall(request); + Call call = okHttpClient.newCall(request); + com.squareup.okhttp.Response response = call.execute(); + int statusCode = response.code(); - if (statusCode >= 200 && statusCode < 300) { // 2XX == successful request - return CookieExtractor.extract(response); - } else if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request + if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request String location = response.headers().get("Location"); HttpUrl url = HttpUrl.parse(location); String errorQueryParameter = url.queryParameter("error"); - if (errorQueryParameter == null) { - return CookieExtractor.extract(response); - } else { + if (errorQueryParameter != null) { com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() .protocol(response.protocol()) .request(response.request()) @@ -92,14 +89,19 @@ public Cookies springAuth(@NotNull final String username, @NotNull public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { - RestApi api = getRetrofit().create(RestApi.class); - Response response = CallWrapper.wrap(api.requestAnonymousCookie()).response(); - Cookies anonymousCookies = CookieExtractor.extract(response.raw()); + RetrofitFactory retrofitFactory = mClient.getRetrofitFactory(); + HttpClientFactory clientFactory = mClient.getClientFactory(); + OkHttpClient client = clientFactory.newHttpClient(); + client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); + Retrofit retrofit = retrofitFactory.newRetrofit() + .client(client) + .build(); - RestApi modifiedApi = getRetrofit().create(RestApi.class); + RestApi api = retrofit.create(RestApi.class); + CallWrapper.wrap(api.requestAnonymousCookie()); try { - return CallWrapper.wrap(modifiedApi.requestEncryptionMetadata(anonymousCookies.toString())).body(); + return CallWrapper.wrap(api.requestEncryptionMetadata()).body(); } catch (JsonSyntaxException ex) { /** * This possible when security option is disabled on JRS side. @@ -110,26 +112,6 @@ public EncryptionKey requestEncryptionMetadata() throws IOException, HttpExcepti } } - private OkHttpClient getHttpClient() { - if (mOkHttpClient == null) { - HttpClientFactory clientFactory = mClient.getClientFactory(); - OkHttpClient okHttpClient = clientFactory.newHttpClient(); - okHttpClient.setFollowRedirects(false); - mOkHttpClient = okHttpClient; - } - return mOkHttpClient; - } - - private Retrofit getRetrofit() { - if (mRetrofit == null) { - RetrofitFactory retrofitFactory = mClient.getRetrofitFactory(); - Retrofit retrofit = retrofitFactory.newRetrofit().build(); - mRetrofit = retrofit; - } - - return mRetrofit; - } - private Request createAuthRequest( @NotNull final String username, @NotNull final String password, @@ -170,6 +152,6 @@ private interface RestApi { @NotNull @GET("GetEncryptionKey") - retrofit.Call requestEncryptionMetadata(@NotNull @Header("Cookie") String cookie); + retrofit.Call requestEncryptionMetadata(); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java deleted file mode 100644 index 2e03e62e..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.OkHttpClient; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class AuthorizedClientImpl extends AuthorizedClient { - private final AuthPolicy mAuthPolicy; - private final Credentials mCredentials; - - AuthorizedClientImpl(String baseUrl, OkHttpClient client, AuthPolicy authPolicy, Credentials credentials) { - super(baseUrl, client); - mAuthPolicy = authPolicy; - mCredentials = credentials; - } - - public void authorize() throws IOException, HttpException { - throw new UnsupportedOperationException("Not yet implemented"); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index ba85716b..a31cb189 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -24,18 +24,24 @@ package com.jaspersoft.android.sdk.network; +import java.util.concurrent.TimeUnit; + /** * @author Tom Koptel * @since 2.0 */ public final class Client { private final String mBaseUrl; + private final long mConnectTimeout; + private final long mReadTimeout; private RetrofitFactory mRetrofitFactory; private HttpClientFactory mHttpClientFactory; - public Client(String baseUrl) { + private Client(String baseUrl, long connectTimeout, long readTimeout) { mBaseUrl = baseUrl; + mConnectTimeout = connectTimeout; + mReadTimeout = readTimeout; } public ServerRestApi infoApi() { @@ -54,6 +60,14 @@ public String getBaseUrl() { return mBaseUrl; } + public long getConnectTimeout() { + return mConnectTimeout; + } + + public long getReadTimeout() { + return mReadTimeout; + } + RetrofitFactory getRetrofitFactory() { if (mRetrofitFactory == null) { mRetrofitFactory = new RetrofitFactory(this); @@ -77,12 +91,25 @@ public OptionalBuilder withBaseUrl(String baseUrl) { public static class OptionalBuilder { private final String mBaseUrl; + private long connectTimeout = 10000; + private long readTimeout = 10000; + private OptionalBuilder(String baseUrl) { mBaseUrl = baseUrl; } + public OptionalBuilder withConnectionTimeOut(long timeout, TimeUnit unit) { + connectTimeout = unit.toMillis(timeout); + return this; + } + + public OptionalBuilder withReadTimeout(long timeout, TimeUnit unit) { + readTimeout = unit.toMillis(timeout); + return this; + } + public Client create() { - return new Client(mBaseUrl); + return new Client(mBaseUrl, connectTimeout, readTimeout); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java deleted file mode 100644 index 9c4629ef..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.OkHttpClient; - -import java.util.concurrent.TimeUnit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ClientBuilder { - private final OkHttpClient mOkHttpClient; - private RestApiLog mLog = RestApiLog.NONE; - private long connectTimeout = 10000; - private long readTimeout = 10000; - - public ClientBuilder() { - mOkHttpClient = new OkHttpClient(); - } - - public ClientBuilder setLog(RestApiLog logger) { - mLog = logger; - return this; - } - - public ClientBuilder connectionTimeOut(long timeout, TimeUnit unit) { - connectTimeout = unit.toMillis(timeout); - return this; - } - - public ClientBuilder readTimeout(long timeout, TimeUnit unit) { - readTimeout = unit.toMillis(timeout); - return this; - } - - public OkHttpClient build() { - mOkHttpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS); - mOkHttpClient.setConnectTimeout(connectTimeout, TimeUnit.MILLISECONDS); - mOkHttpClient.interceptors().add(new LoggingInterceptor(mLog)); - return mOkHttpClient; - } - - OkHttpClient getClient() { - return mOkHttpClient; - } - - void ensureDefaults() { - if (mLog == null) { - mLog = RestApiLog.NONE; - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java deleted file mode 100644 index 381e4616..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ClientFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.OkHttpClient; -import org.jetbrains.annotations.TestOnly; - -import java.util.concurrent.TimeUnit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public abstract class ClientFactory { - final String mBaseUrl; - final OkHttpClient mOkHttpClient; - AuthPolicy mAuthPolicy; - - @TestOnly - ClientFactory(String baseUrl, OkHttpClient okHttpClient) { - mBaseUrl = baseUrl; - mOkHttpClient = okHttpClient; - mAuthPolicy = AuthPolicy.RETRY; - } - - public ClientFactory withConnectionTimeOut(long timeout, TimeUnit unit) { - mOkHttpClient.setConnectTimeout(timeout, unit); - return this; - } - - public ClientFactory withReadTimeout(long timeout, TimeUnit unit) { - mOkHttpClient.setReadTimeout(timeout, unit); - return this; - } - - public ClientFactory withRetryPolicy(final AuthPolicy authPolicy) { - mAuthPolicy = authPolicy; - return this; - } - - public abstract Client create(); -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java deleted file mode 100644 index e65b52c5..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/CookieExtractor.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.Response; - -import java.net.HttpCookie; -import java.util.ArrayList; -import java.util.List; - - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class CookieExtractor { - private CookieExtractor() { - } - - public static Cookies extract(Response response) { - List headers = response.headers().values("Set-Cookie"); - List cookies = joinCookieHeaders(headers); - return new Cookies(cookies); - } - - private static List joinCookieHeaders(List headers) { - List cookies; - List result = new ArrayList<>(headers.size()); - for (String header : headers) { - cookies = HttpCookie.parse(header); - if (!cookies.isEmpty()) { - result.add(cookies.get(0).toString()); - } - } - return result; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java deleted file mode 100644 index 46074ffa..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Cookies.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; - -import java.util.*; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class Cookies { - - private final List mCookies = new ArrayList<>(3); - - @TestOnly - Cookies(List cookies) { - mCookies.addAll(cookies); - } - - @NotNull - public List get() { - return mCookies; - } - - public static Cookies parse(String cookiesString) { - Utils.checkNotNull(cookiesString, "Cookies should not be null"); - Utils.checkNotNull(cookiesString.length() > 0, "Cookies should not be empty String"); - if (cookiesString.contains(";")) { - String[] cookies = cookiesString.split(";"); - if (cookies.length == 0) { - return new Cookies(Collections.emptyList()); - } - return new Cookies(Arrays.asList(cookies)); - } - return new Cookies(Collections.singletonList(cookiesString)); - } - - @Override - public String toString() { - Iterator iterator = mCookies.iterator(); - StringBuilder result = new StringBuilder(); - while (iterator.hasNext()) { - result.append(iterator.next()); - if (iterator.hasNext()) { - result.append(";"); - } - } - return result.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Cookies cookies = (Cookies) o; - - if (mCookies != null ? !mCookies.equals(cookies.mCookies) : cookies.mCookies != null) return false; - - return true; - } - - @Override - public int hashCode() { - return mCookies != null ? mCookies.hashCode() : 0; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java index b436e81f..7b7e907f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Credentials.java @@ -7,5 +7,5 @@ * @since 2.0 */ public abstract class Credentials { - protected abstract Cookies apply(AuthStrategy authStrategy) throws IOException, HttpException; + protected abstract void apply(AuthStrategy authStrategy) throws IOException, HttpException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java b/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java deleted file mode 100644 index db03c293..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/GenericBuilder.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import retrofit.Retrofit; - -import java.util.concurrent.TimeUnit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -abstract class GenericBuilder { - protected final ClientBuilder clientBuilder; - protected final AdapterBuilder adapterBuilder; - - public GenericBuilder() { - clientBuilder = new ClientBuilder(); - adapterBuilder = new AdapterBuilder(clientBuilder); - } - - @SuppressWarnings("unchecked") - public TargetBuilder baseUrl(String baseUrl) { - adapterBuilder.baseUrl(baseUrl); - return (TargetBuilder) this; - } - - @SuppressWarnings("unchecked") - public TargetBuilder logger(RestApiLog log) { - clientBuilder.setLog(log); - return (TargetBuilder) this; - } - - @SuppressWarnings("unchecked") - public TargetBuilder connectionTimeOut(long timeout, TimeUnit unit) { - clientBuilder.connectionTimeOut(timeout, unit); - return (TargetBuilder) this; - } - - @SuppressWarnings("unchecked") - public TargetBuilder readTimeout(long timeout, TimeUnit unit) { - clientBuilder.readTimeout(timeout, unit); - return (TargetBuilder) this; - } - - void ensureDefaults() { - clientBuilder.ensureDefaults(); - adapterBuilder.ensureDefaults(); - } - - Retrofit.Builder getAdapter() { - return adapterBuilder.getAdapter(); - } - - abstract Api createApi(); - - public Api build() { - ensureDefaults(); - return createApi(); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java index 27a7ac5c..b4fe7b2c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java @@ -65,8 +65,8 @@ public Locale getLocale() { } @Override - protected Cookies apply(AuthStrategy policy) throws IOException, HttpException { - return policy.authorize(this); + protected void apply(AuthStrategy policy) throws IOException, HttpException { + policy.apply(this); } @Override From 040deea904eff1a8ff84043d769972b962238043 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 13:08:24 +0200 Subject: [PATCH 365/457] Reduce logging API --- .../sdk/network/LoggingInterceptor.java | 83 ------------------- .../android/sdk/network/RestApiLog.java | 38 --------- 2 files changed, 121 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java deleted file mode 100644 index ad4719a3..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/LoggingInterceptor.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.Interceptor; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; -import com.squareup.okhttp.ResponseBody; - -import java.io.IOException; - -import okio.Buffer; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class LoggingInterceptor implements Interceptor { - private final RestApiLog logger; - - public LoggingInterceptor(RestApiLog logger) { - this.logger = logger; - } - - @Override - public Response intercept(Interceptor.Chain chain) throws IOException { - Request request = chain.request(); - - long t1 = System.nanoTime(); - logger.log(String.format("Sending request------------------------------------------------------>" + - "%nMethod: %s%nUrl: %s%nConnection: %s%n%sWith body: \n%s", - request.method(), request.url(), chain.connection(), request.headers(), bodyToString(request))); - - Response response = chain.proceed(request); - - long t2 = System.nanoTime(); - String bodyString = response.body().string(); - logger.log(String.format("<-----------------------------------------------------Received response" + - "%nUrl: %s%nCode: %d%nTime spent: %.1fms%n%s%nBody: %s", - response.request().url(), response.code(), (t2 - t1) / 1e6d, response.headers(), bodyString)); - - return response.newBuilder() - .body(ResponseBody.create(response.body().contentType(), bodyString)) - .build(); - } - - private static String bodyToString(final Request request) { - try { - final Request copy = request.newBuilder().build(); - final Buffer buffer = new Buffer(); - if (copy.body() != null) { - copy.body().writeTo(buffer); - return buffer.readUtf8(); - } else { - return "No Body"; - } - } catch (final IOException e) { - return String.format("", e.getMessage()); - } - } -} \ No newline at end of file diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java deleted file mode 100644 index ae7f01ca..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RestApiLog.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface RestApiLog { - void log(String message); - - RestApiLog NONE = new RestApiLog() { - @Override public void log(String message) { - } - }; -} From 3e307f22d26edfe0f4af0141f12c2d1f8a5fb908 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 13:32:11 +0200 Subject: [PATCH 366/457] Update network layer tests according to client centered API --- .../android/sdk/network/Client.java | 13 +++- .../sdk/network/ServerRestApiImpl.java | 37 ++++----- .../android/sdk/network/AuthServiceTest.java | 44 ----------- .../network/AuthenticationRestApiTest.java | 20 ++--- .../sdk/network/CookieExtractorTest.java | 64 ---------------- .../InputControlRestApiBuilderTest.java | 75 ------------------- .../sdk/network/InputControlRestApiTest.java | 42 ++++------- .../ReportExecutionRestApiBuilderTest.java | 67 ----------------- .../network/ReportExecutionRestApiTest.java | 73 ++++++------------ .../ReportExportRestApiBuilderTest.java | 67 ----------------- .../sdk/network/ReportExportRestApiTest.java | 66 ++++++---------- .../ReportOptionRestApiBuilderTest.java | 69 ----------------- .../sdk/network/ReportOptionRestApiTest.java | 66 +++++----------- .../network/RepositoryRestApiBuilderTest.java | 68 ----------------- .../sdk/network/RepositoryRestApiTest.java | 58 +++++--------- .../sdk/network/ServerRestApiBuilderTest.java | 75 ------------------- .../sdk/network/ServerRestApiTest.java | 5 +- .../sdk/network/SpringAuthServiceTest.java | 2 - .../api/InputControlRestApiTest.java | 42 ++++------- .../api/{utils => }/JrsMetadata.java | 27 ++++--- .../sdk/test/integration/api/LazyClient.java | 60 +++++++++++++++ .../api/ReportExecutionRestApiTest.java | 37 +++++---- .../api/ReportExportRestApiTest.java | 35 +++------ .../api/ReportOptionRestApiTest.java | 25 +++---- .../api/RepositoryRestApiTest.java | 24 +++--- .../test/integration/api/ServerRestTest.java | 13 ++-- .../api/utils/DummyTokenProvider.java | 56 -------------- 27 files changed, 280 insertions(+), 950 deletions(-) delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java rename core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/{utils => }/JrsMetadata.java (91%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index a31cb189..f2f81057 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.network; +import retrofit.Retrofit; + import java.util.concurrent.TimeUnit; /** @@ -38,6 +40,8 @@ public final class Client { private RetrofitFactory mRetrofitFactory; private HttpClientFactory mHttpClientFactory; + private ServerRestApi mServerRestApi; + private Client(String baseUrl, long connectTimeout, long readTimeout) { mBaseUrl = baseUrl; mConnectTimeout = connectTimeout; @@ -45,7 +49,14 @@ private Client(String baseUrl, long connectTimeout, long readTimeout) { } public ServerRestApi infoApi() { - return new ServerRestApiImpl(this); + if (mServerRestApi == null) { + Retrofit retrofit = getRetrofitFactory() + .newRetrofit() + .build(); + + mServerRestApi = new ServerRestApiImpl(retrofit); + } + return mServerRestApi; } public AuthorizedClient.Builder makeAuthorizedClient(Credentials credentials) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java index a5b27464..6d29403e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java @@ -39,82 +39,71 @@ */ final class ServerRestApiImpl implements ServerRestApi { - private final Client mClient; + private final RestApi mApi; - private RestApi mApi; - - public ServerRestApiImpl(Client client) { - mClient = client; + public ServerRestApiImpl(Retrofit retrofit) { + mApi = retrofit.create(RestApi.class); } @NotNull @Override public ServerInfoData requestServerInfo() throws IOException, HttpException { - Call call = getApi().requestServerInfo(); + Call call = mApi.requestServerInfo(); return CallWrapper.wrap(call).body(); } @NotNull @Override public String requestEdition() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestEdition()).body(); + return CallWrapper.wrap(mApi.requestEdition()).body(); } @NotNull @Override public String requestVersion() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestVersion()).body(); + return CallWrapper.wrap(mApi.requestVersion()).body(); } @NotNull @Override public String requestBuild() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestBuild()).body(); + return CallWrapper.wrap(mApi.requestBuild()).body(); } @NotNull @Override public String requestFeatures() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestFeatures()).body(); + return CallWrapper.wrap(mApi.requestFeatures()).body(); } @NotNull @Override public String requestEditionName() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestEditionName()).body(); + return CallWrapper.wrap(mApi.requestEditionName()).body(); } @NotNull @Override public String requestLicenseType() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestLicenseType()).body(); + return CallWrapper.wrap(mApi.requestLicenseType()).body(); } @NotNull @Override public String requestExpiration() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestExpiration()).body(); + return CallWrapper.wrap(mApi.requestExpiration()).body(); } @NotNull @Override public String requestDateFormatPattern() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestDateFormatPattern()).body(); + return CallWrapper.wrap(mApi.requestDateFormatPattern()).body(); } @NotNull @Override public String requestDateTimeFormatPattern() throws IOException, HttpException { - return CallWrapper.wrap(getApi().requestDateTimeFormatPattern()).body(); - } - - private RestApi getApi() { - if (mApi == null) { - RetrofitFactory retrofitFactory = mClient.getRetrofitFactory(); - Retrofit retrofit = retrofitFactory.newRetrofit().build(); - return retrofit.create(RestApi.class); - } - return mApi; + return CallWrapper.wrap(mApi.requestDateTimeFormatPattern()).body(); } private interface RestApi { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java deleted file mode 100644 index e2e545ad..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthServiceTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.jaspersoft.android.sdk.network; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - -/** - * @author Tom Koptel - */ -public class AuthServiceTest { - - @Mock - AuthStrategy mAuthStrategy; - @Mock - Credentials mCredentials; - - private AuthService mAuthServiceUnderTest; - - @Rule - public ExpectedException mExpectedException = ExpectedException.none(); - private final Cookies fakeCookies = Cookies.parse("key=value"); - - @Before - public void setupMocks() throws Exception { - MockitoAnnotations.initMocks(this); - when(mCredentials.apply(any(AuthStrategy.class))).thenReturn(fakeCookies); - mAuthServiceUnderTest = new AuthService(mAuthStrategy); - } - - @Test - public void testAuthenticate() throws Exception { - mAuthServiceUnderTest.authenticate(mCredentials); - - verify(mCredentials).apply(mAuthStrategy); - verifyNoMoreInteractions(mCredentials); - verifyNoMoreInteractions(mAuthStrategy); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index 8b72deca..b67f0f18 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -53,7 +53,7 @@ public class AuthenticationRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); - private AuthenticationRestApi mRestApi; + private AuthenticationRestApi apiUnderTest; @ResourceFile("json/encryption_key.json") TestResource mKey; @@ -61,9 +61,10 @@ public class AuthenticationRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Client server = Client.create(mWebMockRule.getRootUrl()); - AnonymousClient client = server.newClient().create(); - mRestApi = new AuthenticationRestApi(client); + Client client = Client.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) + .create(); + apiUnderTest = new AuthenticationRestApi(client); } @Test @@ -73,8 +74,7 @@ public void shouldReturnResponseForSuccessRedirect() throws Exception { .addHeader("Location", mWebMockRule.getRootUrl() + LOCATION_SUCCESS); mWebMockRule.enqueue(mockResponse); - Cookies response = mRestApi.springAuth("joeuser", "joeuser", null, null); - assertThat(response, is(notNullValue())); + apiUnderTest.springAuth("joeuser", "joeuser", null, null); } @Test @@ -86,7 +86,7 @@ public void shouldRiseErrorForErrorRedirect() throws Exception { .addHeader("Set-Cookie", "cookie1"); mWebMockRule.enqueue(mockResponse); - mRestApi.springAuth("joeuser", "joeuser", "null", null); + apiUnderTest.springAuth("joeuser", "joeuser", "null", null); } @Test @@ -95,7 +95,7 @@ public void shouldRiseErrorForHttpException() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - mRestApi.springAuth("joeuser", "joeuser", "null", null); + apiUnderTest.springAuth("joeuser", "joeuser", "null", null); } @Test @@ -108,7 +108,7 @@ public void shouldReturnEncryptionKeyIfApiAvailable() throws Exception { mWebMockRule.enqueue(anonymousCookie); mWebMockRule.enqueue(encryptionKey); - EncryptionKey keyResponse = mRestApi.requestEncryptionMetadata(); + EncryptionKey keyResponse = apiUnderTest.requestEncryptionMetadata(); assertThat(keyResponse, is(notNullValue())); } @@ -125,7 +125,7 @@ public void shouldReturnEmptyEncryptionKeyIfApiNotAvailable() throws Exception { mWebMockRule.enqueue(anonymousCookie); mWebMockRule.enqueue(encryptionKey); - EncryptionKey keyResponse = mRestApi.requestEncryptionMetadata(); + EncryptionKey keyResponse = apiUnderTest.requestEncryptionMetadata(); assertThat(keyResponse.isAvailable(), is(false)); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java deleted file mode 100644 index 0b9e4ff5..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/CookieExtractorTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.Protocol; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class CookieExtractorTest { - - private Request mRequest; - - @Before - public void setup() { - mRequest = new Request.Builder() - .url("http://localhost") - .build(); - } - - @Test - public void shouldExtractTokenFromNetworkResponse() { - Response mockResponse = new Response.Builder() - .addHeader("Set-Cookie", "cookie1=12") - .addHeader("Set-Cookie", "cookie2=34") - .code(200) - .protocol(Protocol.HTTP_1_1) - .request(mRequest) - .build(); - - Cookies cookies = CookieExtractor.extract(mockResponse); - assertThat(cookies.toString(), is("cookie1=12;cookie2=34")); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java deleted file mode 100644 index ba2cf4b9..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiBuilderTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.InputControlRestApi; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class InputControlRestApiBuilderTest { - private InputControlRestApi.Builder builderUnderTest; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setup() { - builderUnderTest = new InputControlRestApi.Builder(); - } - - @Test - public void builderShouldNotAllowNullBaseUrl() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("baseUrl == null"); - - builderUnderTest.baseUrl(null); - } - - @Test - public void builderShouldNotAllowEmptyUrl() { - expectedException.expect(IllegalArgumentException.class); - builderUnderTest.baseUrl(""); - } - - @Test - public void builderShouldAllowNullLogLevel() { - builderUnderTest.logger(null); - } - - @Test - public void builderShouldEnsureBaseUrlNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Base url should be supplied to work with JRS API"); - - builderUnderTest.build(); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index f7c6be06..c60ee006 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -24,8 +24,10 @@ package com.jaspersoft.android.sdk.network; +import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -38,6 +40,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import retrofit.Retrofit; import java.util.*; @@ -60,7 +63,6 @@ public class InputControlRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private InputControlRestApi restApiUnderTest; - private final Cookies fakeCookies = Cookies.parse("key=value"); @ResourceFile("json/input_controls_states_list.json") TestResource icsStates; @@ -72,65 +74,53 @@ public class InputControlRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - restApiUnderTest = new InputControlRestApi.Builder() + Retrofit retrofit = new Retrofit.Builder() .baseUrl(mWebMockRule.getRootUrl()) + .addConverterFactory(GsonConverterFactory.create()) .build(); + restApiUnderTest = new InputControlRestApiImpl(retrofit); } @Test public void requestInputControlsShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControls(fakeCookies, null, false); - } - - @Test - public void requestInputControlsInitialStatesShouldNotAllowNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - restApiUnderTest.requestInputControlsInitialStates(null, "/uri", false); + restApiUnderTest.requestInputControls(null, false); } @Test public void requestInputControlsStatesShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsStates(fakeCookies, null, Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP, true); } @Test public void requestInputControlsStatesShouldNotAllowNullControlParams() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.requestInputControlsStates(fakeCookies, "any_id", null, true); - } - - @Test - public void requestInputControlsStatesShouldNotAllowNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - restApiUnderTest.requestInputControlsStates(null, "any_id", Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates("any_id", null, true); } @Test public void requestInputControlsShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControls(fakeCookies, "any_id", true); + restApiUnderTest.requestInputControls("any_id", true); } @Test public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsInitialStates(fakeCookies, "any_id", true); + restApiUnderTest.requestInputControlsInitialStates("any_id", true); } @Test public void requestInputControlsStatesShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsStates(fakeCookies, "any_id", Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true); } @Test @@ -139,7 +129,7 @@ public void apiShouldProvideListOfInputControlsInitialStatesWithFreshData() thro .setBody(icsStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection states = restApiUnderTest.requestInputControlsInitialStates(fakeCookies, "/my/uri", true); + Collection states = restApiUnderTest.requestInputControlsInitialStates("/my/uri", true); assertThat(states, is(not(empty()))); RecordedRequest response = mWebMockRule.get().takeRequest(); @@ -158,7 +148,7 @@ public void apiShouldProvideFreshStatesForInputControls() throws Exception { .setBody(icsStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection states = restApiUnderTest.requestInputControlsStates(fakeCookies, "/my/uri", parameters, true); + Collection states = restApiUnderTest.requestInputControlsStates("/my/uri", parameters, true); assertThat(states, Matchers.is(not(Matchers.empty()))); RecordedRequest response = mWebMockRule.get().takeRequest(); @@ -172,7 +162,7 @@ public void apiShouldProvideInputControlsListIfStateExcluded() throws Exception .setBody(icsWithoutStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection controls = restApiUnderTest.requestInputControls(fakeCookies, "/my/uri", true); + Collection controls = restApiUnderTest.requestInputControls("/my/uri", true); assertThat(controls, Matchers.is(not(Matchers.empty()))); assertThat(new ArrayList<>(controls).get(0).getState(), is(nullValue())); @@ -187,7 +177,7 @@ public void apiShouldProvideInputControlsWithStates() throws Exception { .setBody(icsWithStates.asString()); mWebMockRule.enqueue(mockResponse); - Collection controls = restApiUnderTest.requestInputControls(fakeCookies, "/my/uri", false); + Collection controls = restApiUnderTest.requestInputControls("/my/uri", false); assertThat(controls, Matchers.is(not(Matchers.empty()))); assertThat(new ArrayList<>(controls).get(0).getState(), is(not(nullValue()))); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java deleted file mode 100644 index 4c19e895..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiBuilderTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ReportExecutionRestApiBuilderTest { - private ReportExecutionRestApi.Builder builderUnderTest; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setup() { - builderUnderTest = new ReportExecutionRestApi.Builder(); - } - - @Test - public void builderShouldNotAllowNullBaseUrl() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("baseUrl == null"); - - builderUnderTest.baseUrl(null); - } - - @Test - public void builderShouldNotAllowEmptyUrl() { - expectedException.expect(IllegalArgumentException.class); - builderUnderTest.baseUrl(""); - } - - @Test - public void builderShouldAllowNullLogLevel() { - builderUnderTest.logger(null); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index bca752f8..09c2ffeb 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -40,6 +40,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import retrofit.Retrofit; import java.util.*; @@ -78,14 +79,15 @@ public class ReportExecutionRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); private ReportExecutionRestApi restApiUnderTest; - private final Cookies fakeCookies = Cookies.parse("key=value"); @Before public void setup() { TestResourceInjector.inject(this); - restApiUnderTest = new ReportExecutionRestApi.Builder() + Retrofit retrofit = new Retrofit.Builder() .baseUrl(mWebMockRule.getRootUrl()) + .addConverterFactory(GsonConverterFactory.create()) .build(); + restApiUnderTest = new ReportExecutionRestApiImpl(retrofit); } @Test @@ -94,7 +96,7 @@ public void shouldThroughRestErrorOnSearchRequestIfHttpError() throws Exception mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runReportExecution(fakeCookies, ReportExecutionRequestOptions.newRequest("/any/uri")); + restApiUnderTest.runReportExecution(ReportExecutionRequestOptions.newRequest("/any/uri")); } @Test @@ -102,16 +104,7 @@ public void bodyParameterShouldNotBeNullForRunReportExecution() throws Exception mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runReportExecution(fakeCookies, null); - } - - @Test - public void cookiesShouldNotBeNullForRunReportExecution() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/uri"); - restApiUnderTest.runReportExecution(null, options); + restApiUnderTest.runReportExecution(null); } @Test @@ -119,15 +112,7 @@ public void executionIdShouldNotBeNullForRequestExecutionDetails() throws Except mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionDetails(fakeCookies, null); - } - - @Test - public void cookiesShouldNotBeNullForRequestExecutionDetails() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.requestReportExecutionDetails(null, "exec_id"); + restApiUnderTest.requestReportExecutionDetails(null); } @Test @@ -135,15 +120,7 @@ public void executionIdShouldNotBeNullForRequestExecutionStatus() throws Excepti mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestReportExecutionStatus(fakeCookies, null); - } - - @Test - public void cookiesShouldNotBeNullForRequestExecutionStatus() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.requestReportExecutionStatus(null, "exec_id"); + restApiUnderTest.requestReportExecutionStatus(null); } @Test @@ -151,15 +128,7 @@ public void executionIdShouldNotBeNullForCancelRequestExecution() throws Excepti mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.cancelReportExecution(fakeCookies, null); - } - - @Test - public void cookiesShouldNotBeNullForCancelRequestExecution() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.cancelReportExecution(null, "exec_id"); + restApiUnderTest.cancelReportExecution(null); } @Test @@ -167,7 +136,7 @@ public void bodyParameterShouldNotBeNullForExecutionUpdate() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution params should not be null"); - restApiUnderTest.updateReportExecution(fakeCookies, "any_id", null); + restApiUnderTest.updateReportExecution("any_id", null); } @Test @@ -175,7 +144,7 @@ public void bodyParameterShouldNotBeEmptyForExecutionUpdate() throws Exception { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Execution params should not be empty"); - restApiUnderTest.updateReportExecution(fakeCookies, "any_id", Collections.emptyList()); + restApiUnderTest.updateReportExecution("any_id", Collections.emptyList()); } @Test @@ -184,7 +153,7 @@ public void shouldStartReportExecution() throws Exception { mWebMockRule.enqueue(response); ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/my/uri"); - restApiUnderTest.runReportExecution(fakeCookies, options); + restApiUnderTest.runReportExecution(options); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions")); @@ -198,7 +167,7 @@ public void shouldRequestReportExecutionDetails() throws Exception { MockResponse response = MockResponseFactory.create200().setBody(reportExecutionDetailsResponse.asString()); mWebMockRule.enqueue(response); - ReportExecutionDescriptor details = restApiUnderTest.requestReportExecutionDetails(fakeCookies, "exec_id"); + ReportExecutionDescriptor details = restApiUnderTest.requestReportExecutionDetails("exec_id"); assertThat(details, is(notNullValue())); RecordedRequest request = mWebMockRule.get().takeRequest(); @@ -212,7 +181,7 @@ public void shouldRequestReportExecutionStatus() throws Exception { MockResponse response = MockResponseFactory.create200().setBody("{\"value\":\"execution\"}"); mWebMockRule.enqueue(response); - ExecutionStatus status = restApiUnderTest.requestReportExecutionStatus(fakeCookies, "exec_id"); + ExecutionStatus status = restApiUnderTest.requestReportExecutionStatus("exec_id"); assertThat(status, is(notNullValue())); RecordedRequest request = mWebMockRule.get().takeRequest(); @@ -226,7 +195,7 @@ public void shouldCancelReportExecution() throws Exception { MockResponse response = MockResponseFactory.create200(); mWebMockRule.enqueue(response); - restApiUnderTest.cancelReportExecution(fakeCookies, "exec_id"); + restApiUnderTest.cancelReportExecution("exec_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); @@ -240,7 +209,7 @@ public void shouldUpdateReportExecution() throws Exception { MockResponse response = MockResponseFactory.create204(); mWebMockRule.enqueue(response); - restApiUnderTest.updateReportExecution(fakeCookies, "exec_id", PARAMS); + restApiUnderTest.updateReportExecution("exec_id", PARAMS); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/parameters")); @@ -253,7 +222,7 @@ public void shouldUpdateReportExecution() throws Exception { public void responseShouldNotBeCancelledIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - boolean cancelled = restApiUnderTest.cancelReportExecution(fakeCookies, "any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); assertThat(cancelled, is(false)); } @@ -263,7 +232,7 @@ public void responseShouldBeCancelledIfResponseIs200() throws Exception { MockResponse response = MockResponseFactory.create200().setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); - boolean cancelled = restApiUnderTest.cancelReportExecution(fakeCookies, "any_id"); + boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); assertThat(cancelled, is(true)); } @@ -272,7 +241,7 @@ public void responseShouldBeCancelledIfResponseIs200() throws Exception { public void executionSearchResponseShouldBeEmptyIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(fakeCookies, SEARCH_PARAMS); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS); assertThat(response.getItems(), is(empty())); } @@ -282,14 +251,14 @@ public void executionSearchResponseShouldNotBeEmptyIfResponseIs200() throws Exce mockResponse.setBody(searchExecutionResponse.asString()); mWebMockRule.enqueue(mockResponse); - ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(fakeCookies, SEARCH_PARAMS); + ReportExecutionSearchResponse response = restApiUnderTest.searchReportExecution(SEARCH_PARAMS); assertThat(response.getItems(), is(not(empty()))); } @Test public void executionUpdateRequestShouldBeSuccessIfResponseIs204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - boolean response = restApiUnderTest.updateReportExecution(fakeCookies, "any_id", PARAMS); + boolean response = restApiUnderTest.updateReportExecution("any_id", PARAMS); assertThat(response, is(true)); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java deleted file mode 100644 index 04b23ecf..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiBuilderTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.ReportExportRestApi; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ReportExportRestApiBuilderTest { - private ReportExportRestApi.Builder builderUnderTest; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setup() { - builderUnderTest = new ReportExportRestApi.Builder(); - } - - @Test - public void builderShouldNotAllowNullBaseUrl() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("baseUrl == null"); - - builderUnderTest.baseUrl(null); - } - - @Test - public void builderShouldNotAllowEmptyUrl() { - expectedException.expect(IllegalArgumentException.class); - builderUnderTest.baseUrl(""); - } - - @Test - public void builderShouldAllowNullLogLevel() { - builderUnderTest.logger(null); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index 5fac4e1e..e7b4e564 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -39,6 +39,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import retrofit.Retrofit; import java.io.InputStream; @@ -58,7 +59,6 @@ public class ReportExportRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private ReportExportRestApi restApiUnderTest; - private final Cookies fakeCookies = Cookies.parse("key=value"); @ResourceFile("json/root_folder.json") TestResource mResource; @@ -66,9 +66,11 @@ public class ReportExportRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - restApiUnderTest = new ReportExportRestApi.Builder() + Retrofit retrofit = new Retrofit.Builder() .baseUrl(mWebMockRule.getRootUrl()) + .addConverterFactory(GsonConverterFactory.create()) .build(); + restApiUnderTest = new ReportExportRestApiImpl(retrofit); } @Test @@ -76,7 +78,7 @@ public void executionIdShouldNotBeNullForRunRequestExecution() throws Exception mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.runExportExecution(fakeCookies, null, ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.create()); } @Test @@ -84,15 +86,7 @@ public void bodyShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); - restApiUnderTest.runExportExecution(fakeCookies, "any_id", null); - } - - @Test - public void cookiesShouldNotBeNullForRunRequestExecution() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.runExportExecution(null, "any_id", ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution("any_id", null); } @Test @@ -100,7 +94,7 @@ public void executionIdShouldNotBeNullForCheckRequestExecutionStatus() throws Ex mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.checkExportExecutionStatus(fakeCookies, null, "any_id"); + restApiUnderTest.checkExportExecutionStatus(null, "any_id"); } @Test @@ -108,15 +102,7 @@ public void exportIdShouldNotBeNullForCheckRequestExecutionStatus() throws Excep mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.checkExportExecutionStatus(fakeCookies, "any_id", null); - } - - @Test - public void cookiesShouldNotBeNullForCheckRequestExecutionStatus() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.checkExportExecutionStatus(null, "any_id", "any_id"); + restApiUnderTest.checkExportExecutionStatus("any_id", null); } @Test @@ -124,7 +110,7 @@ public void executionIdParameterShouldNotBeNullForAttachmentRequest() throws Exc mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); - restApiUnderTest.requestExportAttachment(fakeCookies, null, "any_id", "any_id"); + restApiUnderTest.requestExportAttachment(null, "any_id", "any_id"); } @Test @@ -132,7 +118,7 @@ public void exportIdParameterShouldNotBeNullForAttachmentRequest() throws Except mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Export id should not be null"); - restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", null, "any_id"); + restApiUnderTest.requestExportAttachment("any_id", null, "any_id"); } @Test @@ -140,15 +126,7 @@ public void attachmentIdParameterShouldNotBeNullForAttachmentRequest() throws Ex mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Attachment id should not be null"); - restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", "any_id", null); - } - - @Test - public void cookiesIdParameterShouldNotBeNullForAttachmentRequest() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.requestExportAttachment(null, "any_id", "any_id", "any_id"); + restApiUnderTest.requestExportAttachment("any_id", "any_id", null); } @Test @@ -158,7 +136,7 @@ public void requestForOutputShouldParsePagesFromHeader() throws Exception { .addHeader("report-pages", "1-10"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput(fakeCookies, "any_id", "any_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("any_id", "any_id"); assertThat(resource.getPages(), is("1-10")); } @@ -169,7 +147,7 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); - ExportOutputResource resource = restApiUnderTest.requestExportOutput(fakeCookies, "execution_id", "export_id"); + ExportOutputResource resource = restApiUnderTest.requestExportOutput("execution_id", "export_id"); assertThat(resource.isFinal(), is(true)); } @@ -177,7 +155,7 @@ public void requestForOutputShouldParseIsFinalHeader() throws Exception { public void shouldRequestExportOutput() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportOutput(fakeCookies, "execution_id", "html;pages=1"); + restApiUnderTest.requestExportOutput("execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/outputResource?suppressContentDisposition=true")); @@ -190,7 +168,7 @@ public void requestForAttachmentShouldBeWrappedInsideInput() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - OutputResource resource = restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", "any_id", "any_id"); + OutputResource resource = restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); InputStream stream = resource.getStream(); assertThat(stream, is(notNullValue())); stream.close(); @@ -202,7 +180,7 @@ public void shouldRequestExportAttachment() throws Exception { .setBody(mResource.asString()); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.requestExportAttachment(fakeCookies, "execution_id", "html;pages=1", "attachment_id"); + restApiUnderTest.requestExportAttachment("execution_id", "html;pages=1", "attachment_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/attachments/attachment_id")); @@ -214,7 +192,7 @@ public void shouldRunExportExecution() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.runExportExecution(fakeCookies, "execution_id", ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution("execution_id", ExecutionRequestOptions.create()); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports")); @@ -226,7 +204,7 @@ public void shouldCheckExportExecutionStatus() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); - restApiUnderTest.checkExportExecutionStatus(fakeCookies, "execution_id", "html;pages=1"); + restApiUnderTest.checkExportExecutionStatus("execution_id", "html;pages=1"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/status")); @@ -239,7 +217,7 @@ public void runExportExecutionShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.runExportExecution(fakeCookies, "any_id", ExecutionRequestOptions.create()); + restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create()); } @Test @@ -248,7 +226,7 @@ public void checkExportExecutionStatusShouldThrowRestErrorOn500() throws Excepti mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.checkExportExecutionStatus(fakeCookies, "any_id", "any_id"); + restApiUnderTest.checkExportExecutionStatus("any_id", "any_id"); } @Test @@ -257,7 +235,7 @@ public void requestExportOutputShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportOutput(fakeCookies, "any_id", "any_id"); + restApiUnderTest.requestExportOutput("any_id", "any_id"); } @Test @@ -266,6 +244,6 @@ public void requestExportAttachmentShouldThrowRestErrorOn500() throws Exception mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestExportAttachment(fakeCookies, "any_id", "any_id", "any_id"); + restApiUnderTest.requestExportAttachment("any_id", "any_id", "any_id"); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java deleted file mode 100644 index 06d27569..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiBuilderTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.ReportOptionRestApi; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.MockitoAnnotations; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ReportOptionRestApiBuilderTest { - private ReportOptionRestApi.Builder builderUnderTest; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - builderUnderTest = new ReportOptionRestApi.Builder(); - } - - @Test - public void builderShouldNotAllowNullBaseUrl() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("baseUrl == null"); - - builderUnderTest.baseUrl(null); - } - - @Test - public void builderShouldNotAllowEmptyUrl() { - expectedException.expect(IllegalArgumentException.class); - builderUnderTest.baseUrl(""); - } - - @Test - public void builderShouldAllowNullLogLevel() { - builderUnderTest.logger(null); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 20e18dd1..6d6481aa 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -37,6 +37,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import retrofit.Retrofit; import java.util.Collections; import java.util.HashMap; @@ -60,7 +61,6 @@ public class ReportOptionRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private ReportOptionRestApi restApiUnderTest; - private final Cookies fakeCookies = Cookies.parse("key=value"); @ResourceFile("json/report_option.json") TestResource reportOption; @@ -70,100 +70,74 @@ public class ReportOptionRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - restApiUnderTest = new ReportOptionRestApi.Builder() + Retrofit retrofit = new Retrofit.Builder() .baseUrl(mWebMockRule.getRootUrl()) + .addConverterFactory(GsonConverterFactory.create()) .build(); + restApiUnderTest = new ReportOptionRestApiImpl(retrofit); } @Test public void requestReportOptionsListShouldNotAllowNullReportUnitUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportOptionsList(fakeCookies, null); - } - - @Test - public void requestReportOptionsListShouldNotAllowNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - restApiUnderTest.requestReportOptionsList(null, "/my/uri"); + restApiUnderTest.requestReportOptionsList(null); } @Test public void createReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.createReportOption(fakeCookies, null, "label", Collections.EMPTY_MAP, false); - } - - @Test - public void createReportOptionShouldNotAllowNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - restApiUnderTest.createReportOption(null, "/my/uri", "label", Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption(null, "label", Collections.EMPTY_MAP, false); } @Test public void createReportOptionShouldNotAllowNullOptionLabel() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option label should not be null"); - restApiUnderTest.createReportOption(fakeCookies, "any_id", null, Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption("any_id", null, Collections.EMPTY_MAP, false); } @Test public void createReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.createReportOption(fakeCookies, "any_id", "label", null, false); + restApiUnderTest.createReportOption("any_id", "label", null, false); } @Test public void updateReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.updateReportOption(fakeCookies, null, "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption(null, "option_id", Collections.EMPTY_MAP); } @Test public void updateReportOptionShouldNotAllowNullOptionId() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.updateReportOption(fakeCookies, "any_id", null, Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption("any_id", null, Collections.EMPTY_MAP); } @Test public void updateReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Controls values should not be null"); - restApiUnderTest.updateReportOption(fakeCookies, "any_id", "option_id", null); - } - - @Test - public void updateReportOptionShouldNotAllowNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - restApiUnderTest.updateReportOption(null, "any_id", "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption("any_id", "option_id", null); } @Test public void deleteReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.deleteReportOption(fakeCookies, null, "option_id"); + restApiUnderTest.deleteReportOption(null, "option_id"); } @Test public void deleteReportOptionShouldNotAllowNullOptionId() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.deleteReportOption(fakeCookies, "any_id", null); - } - - @Test - public void deleteReportOptionShouldNotAllowNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - restApiUnderTest.deleteReportOption(null, "any_id", "option_id"); + restApiUnderTest.deleteReportOption("any_id", null); } @Test @@ -171,7 +145,7 @@ public void apiShouldListReportOptions() throws Exception { MockResponse mockResponse = MockResponseFactory.create200().setBody(reportOptionsList.asString()); mWebMockRule.enqueue(mockResponse); - Set response = restApiUnderTest.requestReportOptionsList(fakeCookies, "/any/uri"); + Set response = restApiUnderTest.requestReportOptionsList("/any/uri"); assertThat(response, is(not(empty()))); RecordedRequest request = mWebMockRule.get().takeRequest(); @@ -187,7 +161,7 @@ public void apiShouldCreateReportOption() throws Exception { Map> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19")); - ReportOption reportOption = restApiUnderTest.createReportOption(fakeCookies, "/any/uri", "my label", params, true); + ReportOption reportOption = restApiUnderTest.createReportOption("/any/uri", "my label", params, true); assertThat(reportOption.getId(), is("my_label")); assertThat(reportOption.getLabel(), is("my label")); assertThat(reportOption.getUri(), is("/public/Samples/Reports/my_label")); @@ -205,7 +179,7 @@ public void apiShouldUpdateReportOption() throws Exception { Map> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("22")); - restApiUnderTest.updateReportOption(fakeCookies, "/any/uri", "option_id", params); + restApiUnderTest.updateReportOption("/any/uri", "option_id", params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); @@ -217,7 +191,7 @@ public void apiShouldUpdateReportOption() throws Exception { public void apiShouldDeleteReportOption() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.deleteReportOption(fakeCookies, "/any/uri", "option_id"); + restApiUnderTest.deleteReportOption("/any/uri", "option_id"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); @@ -231,7 +205,7 @@ public void requestReportOptionsListShouldThrow500Error() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestReportOptionsList(fakeCookies, "any_id"); + restApiUnderTest.requestReportOptionsList("any_id"); } @Test @@ -240,7 +214,7 @@ public void updateReportOptionShouldThrowRestErrorFor500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.updateReportOption(fakeCookies, "any_id", "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP); } @Test @@ -249,6 +223,6 @@ public void deleteReportOptionShouldThrowRestErrorFor500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.deleteReportOption(fakeCookies, "any_id", "option_id"); + restApiUnderTest.deleteReportOption("any_id", "option_id"); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java deleted file mode 100644 index 06a9bd1b..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiBuilderTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.RepositoryRestApi; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class RepositoryRestApiBuilderTest { - private RepositoryRestApi.Builder builderUnderTest; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setup() { - builderUnderTest = new RepositoryRestApi.Builder(); - } - - @Test - public void builderShouldNotAllowNullBaseUrl() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("baseUrl == null"); - - builderUnderTest.baseUrl(null); - } - - @Test - public void builderShouldNotAllowEmptyUrl() { - expectedException.expect(IllegalArgumentException.class); - builderUnderTest.baseUrl(""); - } - - @Test - public void builderShouldAllowNullLogLevel() { - builderUnderTest.logger(null); - } - -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index b71a445e..4a69c81b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -38,6 +38,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.MockitoAnnotations; +import retrofit.Retrofit; import java.util.HashMap; import java.util.HashSet; @@ -64,22 +65,23 @@ public class RepositoryRestApiTest { public final ExpectedException mExpectedException = ExpectedException.none(); private RepositoryRestApi restApiUnderTest; - private final Cookies fakeCookies = Cookies.parse("key=value"); @Before public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); - restApiUnderTest = new RepositoryRestApi.Builder() + Retrofit retrofit = new Retrofit.Builder() .baseUrl(mWebMockRule.getRootUrl()) + .addConverterFactory(GsonConverterFactory.create()) .build(); + restApiUnderTest = new RepositoryRestApiImpl(retrofit); } @Test public void shouldReturnEmptyResponseForNoContentResponse() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); - ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getResources(), is(empty())); } @@ -90,7 +92,7 @@ public void requestForSearchShouldParseHeaderResultCount() throws Exception { .addHeader("Result-Count", "100"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getResultCount(), is(100)); } @@ -101,7 +103,7 @@ public void requestForSearchShouldParseHeaderTotalCount() throws Exception { .addHeader("Total-Count", "1000"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getTotalCount(), is(1000)); } @@ -112,7 +114,7 @@ public void requestForSearchShouldParseHeaderStartIndex() throws Exception { .addHeader("Start-Index", "5"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getStartIndex(), is(5)); } @@ -123,32 +125,16 @@ public void requestForSearchShouldParseHeaderNextOffset() throws Exception { .addHeader("Next-Offset", "10"); mWebMockRule.enqueue(mockResponse); - ResourceSearchResult response = restApiUnderTest.searchResources(fakeCookies, null); + ResourceSearchResult response = restApiUnderTest.searchResources(null); assertThat(response.getNextOffset(), is(10)); } - @Test - public void searchResourcesShouldNotAcceptNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.searchResources(null, null); - } - @Test public void requestForReportResourceShouldNotAcceptNullUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.requestReportResource(fakeCookies, null); - } - - @Test - public void requestForReportResourceShouldNotAcceptNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.requestReportResource(null, "/uri"); + restApiUnderTest.requestReportResource(null); } @Test @@ -156,15 +142,7 @@ public void requestForFolderResourceShouldNotAcceptNullUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Folder uri should not be null"); - restApiUnderTest.requestFolderResource(fakeCookies, null); - } - - @Test - public void requestForFolderResourceShouldNotAcceptNullCookies() throws Exception { - mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Request cookies should not be null"); - - restApiUnderTest.requestFolderResource(null, "/my/uri"); + restApiUnderTest.requestFolderResource(null); } @Test @@ -173,7 +151,7 @@ public void searchResourcesShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.searchResources(fakeCookies, null); + restApiUnderTest.searchResources(null); } @Test @@ -182,7 +160,7 @@ public void requestReportResourceShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestReportResource(fakeCookies, "any_id"); + restApiUnderTest.requestReportResource("any_id"); } @Test @@ -191,7 +169,7 @@ public void requestFolderResourceShouldThrowRestErrorOn500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestFolderResource(fakeCookies, "any_id"); + restApiUnderTest.requestFolderResource("any_id"); } @Test @@ -208,7 +186,7 @@ public void searchEndpointShouldHandleMultipleResourceTypes() throws Exception { types.add("dashboard"); params.put("type", types); - restApiUnderTest.searchResources(fakeCookies, params); + restApiUnderTest.searchResources(params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?folderUri=/&type=reportUnit&type=dashboard")); @@ -221,7 +199,7 @@ public void shouldSearchResources() throws Exception { Map params = new LinkedHashMap<>(); params.put("limit", 100); params.put("offset", 100); - restApiUnderTest.searchResources(fakeCookies, params); + restApiUnderTest.searchResources(params); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?limit=100&offset=100")); @@ -232,7 +210,7 @@ public void shouldSearchResources() throws Exception { public void shouldRequestReportResources() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.requestReportResource(fakeCookies, "/my/uri"); + restApiUnderTest.requestReportResource("/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); @@ -244,7 +222,7 @@ public void shouldRequestReportResources() throws Exception { public void shouldRequestFolderResource() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create200()); - restApiUnderTest.requestFolderResource(fakeCookies, "/my/uri"); + restApiUnderTest.requestFolderResource("/my/uri"); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java deleted file mode 100644 index 9f704863..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiBuilderTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.ServerRestApi; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ServerRestApiBuilderTest { - private ServerRestApi.Builder builderUnderTest; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setup() { - builderUnderTest = new ServerRestApi.Builder(); - } - - @Test - public void builderShouldNotAllowNullBaseUrl() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("baseUrl == null"); - - builderUnderTest.baseUrl(null); - } - - @Test - public void builderShouldNotAllowEmptyUrl() { - expectedException.expect(IllegalArgumentException.class); - builderUnderTest.baseUrl(""); - } - - @Test - public void builderShouldAllowNullLogLevel() { - builderUnderTest.logger(null); - } - - @Test - public void builderShouldEnsureBaseUrlNotNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Base url should be supplied to work with JRS API"); - - builderUnderTest.build(); - } -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java index 1f41f6af..e4c49a58 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java @@ -31,6 +31,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import retrofit.Retrofit; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -50,9 +51,11 @@ public class ServerRestApiTest { @Before public void setup() { - objectUnderTest = new ServerRestApi.Builder() + Retrofit retrofit = new Retrofit.Builder() .baseUrl(mWebMockRule.getRootUrl()) + .addConverterFactory(GsonConverterFactory.create()) .build(); + objectUnderTest = new ServerRestApiImpl(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java index 1078db85..d278d677 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java @@ -65,7 +65,6 @@ public class SpringAuthServiceTest { private SpringAuthService objectUnderTest; private SpringCredentials credentials; - private final Cookies fakeCookies = Cookies.parse("key=value"); private static final Map sOptionals = new HashMap<>(); static { @@ -91,7 +90,6 @@ public void setup() throws Exception { when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); when(mTimeZone.getID()).thenReturn("Europe/Helsinki"); - when(mRestApi.springAuth(anyString(), anyString(), anyString(), anyMap())).thenReturn(fakeCookies); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 54e9f741..8435c298 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -24,28 +24,17 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; - import org.junit.Before; import org.junit.Test; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.Matchers.*; import static org.hamcrest.core.IsNot.not; /** @@ -54,9 +43,7 @@ */ public class InputControlRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); - private InputControlRestApi mRestApi; + public static final Map> CONTROL_PARAMETERS = new HashMap<>(); static { @@ -65,17 +52,20 @@ public class InputControlRestApiTest { CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); } + private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private InputControlRestApi apiUnderTest; + @Before - public void setup() { - mRestApi = new InputControlRestApi.Builder() - .baseUrl(mMetadata.getServerUrl()) - .logger(TestLogger.get(this)) - .build(); + public void setUp() throws Exception { + if (apiUnderTest == null) { + AuthorizedClient client = mLazyClient.get(); + apiUnderTest = client.inputControlApi(); + } } @Test public void shouldProvideInputControlsList() throws Exception { - Collection controls = mRestApi.requestInputControls(mAuthenticator.token(), REPORT_URI, false); + Collection controls = apiUnderTest.requestInputControls(REPORT_URI, false); assertThat(controls, is(not(empty()))); InputControl control = new ArrayList<>(controls).get(0); @@ -87,7 +77,7 @@ public void shouldProvideInputControlsList() throws Exception { */ @Test public void shouldProvideInputControlsListIfStateExcluded() throws Exception { - Collection controls = mRestApi.requestInputControls(mAuthenticator.token(), REPORT_URI, true); + Collection controls = apiUnderTest.requestInputControls(REPORT_URI, true); assertThat(controls, is(not(empty()))); InputControl control = new ArrayList<>(controls).get(0); @@ -96,13 +86,13 @@ public void shouldProvideInputControlsListIfStateExcluded() throws Exception { @Test public void shouldProvideFreshInitialInputControlsValues() throws Exception { - Collection states = mRestApi.requestInputControlsInitialStates(mAuthenticator.token(), REPORT_URI, true); + Collection states = apiUnderTest.requestInputControlsInitialStates(REPORT_URI, true); assertThat(states, is(not(empty()))); } @Test public void shouldProvideFreshStatesForInputControls() throws Exception { - Collection states = mRestApi.requestInputControlsStates(mAuthenticator.token(), REPORT_URI, CONTROL_PARAMETERS, true); + Collection states = apiUnderTest.requestInputControlsStates(REPORT_URI, CONTROL_PARAMETERS, true); assertThat(states, is(not(empty()))); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java similarity index 91% rename from core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java rename to core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java index 33d1faa9..dc8cb5b2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/JrsMetadata.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java @@ -22,7 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.test.integration.api.utils; +package com.jaspersoft.android.sdk.test.integration.api; + +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.network.SpringCredentials; import java.net.MalformedURLException; import java.net.URL; @@ -31,7 +34,7 @@ * @author Tom Koptel * @since 2.0 */ -public final class JrsMetadata { +final class JrsMetadata { private final String organization; private final String serverUrl; @@ -67,22 +70,10 @@ public static Builder builder() { return new Builder(); } - public String getOrganization() { - return organization; - } - public String getServerUrl() { return serverUrl; } - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - @Override public String toString() { return "JrsMetadata{" + @@ -93,6 +84,14 @@ public String toString() { '}'; } + public Credentials getCredentials() { + return SpringCredentials.builder() + .password(password) + .username(username) + .organization(organization) + .build(); + } + public static class Builder { private String organization; private String serverUrl; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java new file mode 100644 index 00000000..aa65936f --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.HttpException; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class LazyClient { + private final JrsMetadata mJrsMetadata; + private AuthorizedClient authorizedClient; + + public LazyClient(JrsMetadata jrsMetadata) { + mJrsMetadata = jrsMetadata; + } + + public AuthorizedClient get() { + if (authorizedClient == null) { + Client client = Client.newBuilder() + .withBaseUrl(mJrsMetadata.getServerUrl()) + .create(); + authorizedClient = client.makeAuthorizedClient(mJrsMetadata.getCredentials()) + .create(); + try { + authorizedClient.connect(); + } catch (IOException | HttpException e) { + throw new RuntimeException(e); + } + } + return authorizedClient; + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index bfb05be1..5f2c5fd3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -24,21 +24,22 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import org.jetbrains.annotations.NotNull; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.Is.is; @@ -55,18 +56,14 @@ public class ReportExecutionRestApiTest { private final String REPORT_URI = "/public/Samples/Reports/ProfitDetailReport"; private final ReportParameter PRODUCT_FAMILY = new ReportParameter("ProductFamily", new HashSet(Collections.singletonList("Drink"))); - ReportExecutionRestApi apiUnderTest; - - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); + private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private ReportExecutionRestApi apiUnderTest; @Before - public void setup() { + public void setUp() throws Exception { if (apiUnderTest == null) { - apiUnderTest = new ReportExecutionRestApi.Builder() - .baseUrl(mMetadata.getServerUrl()) - .logger(TestLogger.get(this)) - .build(); + AuthorizedClient client = mLazyClient.get(); + apiUnderTest = client.reportExecutionApi(); } } @@ -83,7 +80,7 @@ public void shouldStartReportExecution() throws Exception { @Ignore public void shouldCancelReportExecution() throws Exception { ReportExecutionDescriptor response = startExecution(); - boolean cancelled = apiUnderTest.cancelReportExecution(mAuthenticator.token(), response.getExecutionId()); + boolean cancelled = apiUnderTest.cancelReportExecution(response.getExecutionId()); assertThat(cancelled, is(true)); } @@ -92,7 +89,7 @@ public void shouldReturnReportExecutionDetails() throws Exception { ReportExecutionDescriptor executionResponse = startExecution(); String executionId = executionResponse.getExecutionId(); - ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(mAuthenticator.token(), executionResponse.getExecutionId()); + ReportExecutionDescriptor response = apiUnderTest.requestReportExecutionDetails(executionResponse.getExecutionId()); assertThat(response.getExecutionId(), is(executionId)); } @@ -100,7 +97,7 @@ public void shouldReturnReportExecutionDetails() throws Exception { public void shouldCheckReportExecutionStatus() throws Exception { ReportExecutionDescriptor executionResponse = startExecution(); - ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(mAuthenticator.token(), executionResponse.getExecutionId()); + ExecutionStatus response = apiUnderTest.requestReportExecutionStatus(executionResponse.getExecutionId()); assertThat(response.getStatus(), is(notNullValue())); } @@ -114,14 +111,14 @@ public void searchForExecutionShouldReturnResult() throws Exception { Map params = new HashMap<>(); params.put("reportURI", executionResponse.getReportURI()); - ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(mAuthenticator.token(), params); + ReportExecutionSearchResponse response = apiUnderTest.searchReportExecution(params); assertThat(response.getItems(), is(not(empty()))); } @Test public void updateOfParametersForExecutionShouldReturnResult() throws Exception { ReportExecutionDescriptor executionResponse = startExecution(); - boolean success = apiUnderTest.updateReportExecution(mAuthenticator.token(), executionResponse.getExecutionId(), + boolean success = apiUnderTest.updateReportExecution(executionResponse.getExecutionId(), Collections.singletonList(PRODUCT_FAMILY)); assertThat(success, is(true)); } @@ -130,7 +127,7 @@ public void updateOfParametersForExecutionShouldReturnResult() throws Exception * Helper methods */ @NotNull - private ReportExecutionDescriptor startExecution() throws Exception { + private ReportExecutionDescriptor startExecution() throws Exception { return startExecution(REPORT_URI); } @@ -139,6 +136,6 @@ private ReportExecutionDescriptor startExecution(String uri) throws Exception { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(uri); executionRequestOptions.withParameters(Collections.singletonList(PRODUCT_FAMILY)); - return apiUnderTest.runReportExecution(mAuthenticator.token(), executionRequestOptions); + return apiUnderTest.runReportExecution(executionRequestOptions); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 0158f0c4..ab354335 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; @@ -32,10 +33,6 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; - import org.jetbrains.annotations.NotNull; import org.junit.Before; import org.junit.Test; @@ -51,26 +48,16 @@ public class ReportExportRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/AllAccounts"; - ReportExecutionRestApi mExecApi; - ReportExportRestApi apiUnderTest; - - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); + private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private ReportExecutionRestApi mExecApi; + private ReportExportRestApi apiUnderTest; @Before public void setup() { - if (mExecApi == null) { - mExecApi = new ReportExecutionRestApi.Builder() - .baseUrl(mMetadata.getServerUrl()) - .logger(TestLogger.get(this)) - .build(); - } - if (apiUnderTest == null) { - apiUnderTest = new ReportExportRestApi.Builder() - .baseUrl(mMetadata.getServerUrl()) - .logger(TestLogger.get(this)) - .build(); + AuthorizedClient client = mLazyClient.get(); + mExecApi = client.reportExecutionApi(); + apiUnderTest = client.reportExportApi(); } } @@ -85,7 +72,7 @@ public void runExportRequestShouldReturnResult() throws Exception { public void checkExportRequestStatusShouldReturnResult() throws Exception { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); - ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(mAuthenticator.token(), exec.getExecutionId(), execDetails.getExportId()); + ExecutionStatus response = apiUnderTest.checkExportExecutionStatus(exec.getExecutionId(), execDetails.getExportId()); assertThat(response, is(notNullValue())); } @@ -93,7 +80,7 @@ public void checkExportRequestStatusShouldReturnResult() throws Exception { public void requestExportOutputShouldReturnResult() throws Exception { ReportExecutionDescriptor exec = startExecution(); ExportExecutionDescriptor execDetails = startExportExecution(exec); - ExportOutputResource output = apiUnderTest.requestExportOutput(mAuthenticator.token(), exec.getExecutionId(), execDetails.getExportId()); + ExportOutputResource output = apiUnderTest.requestExportOutput(exec.getExecutionId(), execDetails.getExportId()); assertThat(output.getOutputResource(), is(notNullValue())); assertThat(output.getPages(), is("1-2")); @@ -108,12 +95,12 @@ private ExportExecutionDescriptor startExportExecution(ReportExecutionDescriptor ExecutionRequestOptions options = ExecutionRequestOptions.create() .withPages("1-2") .withOutputFormat("PDF"); - return apiUnderTest.runExportExecution(mAuthenticator.token(), exec.getExecutionId(), options); + return apiUnderTest.runExportExecution(exec.getExecutionId(), options); } @NotNull private ReportExecutionDescriptor startExecution() throws Exception { ReportExecutionRequestOptions executionRequestOptions = ReportExecutionRequestOptions.newRequest(REPORT_URI); - return mExecApi.runReportExecution(mAuthenticator.token(), executionRequestOptions); + return mExecApi.runReportExecution(executionRequestOptions); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index ed3ba71a..38647b36 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -24,11 +24,9 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; import org.junit.Before; import org.junit.Ignore; @@ -48,10 +46,6 @@ */ public class ReportOptionRestApiTest { - private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); - private ReportOptionRestApi apiUnderTest; - private static final String REPORT_URI = "/public/Samples/Reports/1._Geographic_Results_by_Segment_Report"; public static final Map> CONTROL_PARAMETERS = new HashMap<>(); @@ -61,31 +55,32 @@ public class ReportOptionRestApiTest { CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); } + private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private ReportOptionRestApi apiUnderTest; + @Before public void setup() { if (apiUnderTest == null) { - apiUnderTest = new ReportOptionRestApi.Builder() - .logger(TestLogger.get(this)) - .baseUrl(mMetadata.getServerUrl()) - .build(); + AuthorizedClient client = mLazyClient.get(); + apiUnderTest = client.reportOptionsApi(); } } // TODO: fix this by providing proper integration tests @Ignore public void shouldRequestReportOptionsList() throws Exception { - Set response = apiUnderTest.requestReportOptionsList(mAuthenticator.token(), REPORT_URI); + Set response = apiUnderTest.requestReportOptionsList(REPORT_URI); assertThat(response, is(not(nullValue()))); } // TODO: fix this by providing proper integration tests @Ignore public void apiSupportsCrudForReportOption() throws Exception { - ReportOption response = apiUnderTest.createReportOption(mAuthenticator.token(), REPORT_URI, "label", CONTROL_PARAMETERS, true); + ReportOption response = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true); assertThat(response.getLabel(), is("label")); - apiUnderTest.updateReportOption(mAuthenticator.token(), REPORT_URI, response.getId(), CONTROL_PARAMETERS); + apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS); - apiUnderTest.deleteReportOption(mAuthenticator.token(), REPORT_URI, response.getId()); + apiUnderTest.deleteReportOption(REPORT_URI, response.getId()); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 25191fe7..88fe05ee 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,14 +24,11 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.test.TestLogger; -import com.jaspersoft.android.sdk.test.integration.api.utils.DummyTokenProvider; -import com.jaspersoft.android.sdk.test.integration.api.utils.JrsMetadata; - import org.junit.Before; import org.junit.Test; @@ -48,36 +45,35 @@ public class RepositoryRestApiTest { private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final DummyTokenProvider mAuthenticator = DummyTokenProvider.create(mMetadata); - private RepositoryRestApi api; + + private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private RepositoryRestApi apiUnderTest; @Before public void setup() { - if (api == null) { - api = new RepositoryRestApi.Builder() - .baseUrl(mMetadata.getServerUrl()) - .logger(TestLogger.get(this)) - .build(); + if (apiUnderTest == null) { + AuthorizedClient client = mLazyClient.get(); + apiUnderTest = client.repositoryApi(); } } @Test public void shouldRequestListOfResources() throws Exception { - ResourceSearchResult resourceSearchResult = api.searchResources(mAuthenticator.token(), null); + ResourceSearchResult resourceSearchResult = apiUnderTest.searchResources(null); assertThat(resourceSearchResult, is(notNullValue())); assertThat(resourceSearchResult.getResources(), is(not(empty()))); } @Test public void shouldRequestReport() throws Exception { - ReportLookup report = api.requestReportResource(mAuthenticator.token(), "/public/Samples/Reports/AllAccounts"); + ReportLookup report = apiUnderTest.requestReportResource("/public/Samples/Reports/AllAccounts"); assertThat(report, is(notNullValue())); assertThat(report.getUri(), is("/public/Samples/Reports/AllAccounts")); } @Test public void shouldRequestRootFolder() throws Exception { - FolderLookup folder = api.requestFolderResource(mAuthenticator.token(), "/"); + FolderLookup folder = apiUnderTest.requestFolderResource("/"); assertThat(folder, is(notNullValue())); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 984287fa..66e5cb25 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -25,10 +25,9 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import com.jaspersoft.android.sdk.test.TestLogger; - import org.junit.Before; import org.junit.Test; @@ -47,10 +46,12 @@ public class ServerRestTest { @Before public void setup() { - apiUnderTest = new ServerRestApi.Builder() - .logger(TestLogger.get(this)) - .baseUrl(mobileDemo2) - .build(); + if (apiUnderTest == null) { + Client client = Client.newBuilder() + .withBaseUrl(mobileDemo2) + .create(); + apiUnderTest = client.infoApi(); + } } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java deleted file mode 100644 index 09c70876..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/utils/DummyTokenProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.test.integration.api.utils; - - -import com.jaspersoft.android.sdk.network.Cookies; -import org.jetbrains.annotations.NotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class DummyTokenProvider { - - private final JrsMetadata mJrsMetadata; - private Cookies mToken; - - public DummyTokenProvider(JrsMetadata jrsMetadata) { - mJrsMetadata = jrsMetadata; - } - - public static DummyTokenProvider create(JrsMetadata metadata) { - return new DummyTokenProvider(metadata); - } - - @NotNull - public Cookies provideCookies() throws Exception { - throw new UnsupportedOperationException("Not yet implemented"); - } - - public Cookies token() throws Exception { - return provideCookies(); - } -} From 04c3361d14b1b4fa1bd92b5914f3683298e4ae07 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 13:55:28 +0200 Subject: [PATCH 367/457] Refactor basic entities/introducing Server/RestClient --- .../android/sdk/network/AuthClientState.java | 2 +- .../android/sdk/network/AuthStrategy.java | 8 +- .../sdk/network/AuthenticationRestApi.java | 15 +-- .../network/AuthorizedAuthClientState.java | 16 +-- .../android/sdk/network/AuthorizedClient.java | 105 --------------- .../android/sdk/network/Client.java | 103 ++++++-------- .../sdk/network/HttpClientFactory.java | 6 +- .../sdk/network/InitialAuthClientState.java | 2 +- .../android/sdk/network/RetrofitFactory.java | 8 +- .../android/sdk/network/Server.java | 126 ++++++++++++++++++ .../network/AuthenticationRestApiTest.java | 4 +- .../api/InputControlRestApiTest.java | 4 +- .../sdk/test/integration/api/LazyClient.java | 16 +-- .../api/ReportExecutionRestApiTest.java | 4 +- .../api/ReportExportRestApiTest.java | 4 +- .../api/ReportOptionRestApiTest.java | 4 +- .../api/RepositoryRestApiTest.java | 4 +- .../test/integration/api/ServerRestTest.java | 6 +- 18 files changed, 218 insertions(+), 219 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/Server.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java index 8442400d..e65bdb3d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java @@ -31,7 +31,7 @@ * @since 2.0 */ interface AuthClientState { - void connect(AuthorizedClient context) throws IOException, HttpException; + void connect(Client context) throws IOException, HttpException; ReportExecutionRestApi makeReportExecutionApi(); ReportExportRestApi makeReportExportRestApi(); ReportOptionRestApi makeReportOptionRestApi(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java index 0314a3e4..6f7db8ac 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java @@ -35,13 +35,13 @@ */ class AuthStrategy { @NotNull - private final Client mClient; + private final Server mServer; @Nullable private SpringAuthService springAuthService; - AuthStrategy(@NotNull Client client) { - mClient = client; + AuthStrategy(@NotNull Server server) { + mServer = server; } void apply(SpringCredentials credentials) throws IOException, HttpException { @@ -52,7 +52,7 @@ void apply(SpringCredentials credentials) throws IOException, HttpException { } private SpringAuthService createSpringAuthService() { - AuthenticationRestApi restApi = new AuthenticationRestApi(mClient); + AuthenticationRestApi restApi = new AuthenticationRestApi(mServer); JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); return new SpringAuthService(restApi, encryptionAlgorithm); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index c2e2ba56..181b0e20 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; import com.squareup.okhttp.*; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import retrofit.Retrofit; import retrofit.http.GET; import retrofit.http.Headers; @@ -47,10 +46,10 @@ */ class AuthenticationRestApi { @NotNull - private final Client mClient; + private final Server mServer; - AuthenticationRestApi(@NotNull Client client) { - mClient = client; + AuthenticationRestApi(@NotNull Server server) { + mServer = server; } @NotNull @@ -58,7 +57,7 @@ public void springAuth(@NotNull final String username, @NotNull final String password, final String organization, final Map params) throws HttpException, IOException { - HttpClientFactory clientFactory = mClient.getClientFactory(); + HttpClientFactory clientFactory = mServer.getClientFactory(); OkHttpClient okHttpClient = clientFactory.newHttpClient(); okHttpClient.setFollowRedirects(false); @@ -89,8 +88,8 @@ public void springAuth(@NotNull final String username, @NotNull public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { - RetrofitFactory retrofitFactory = mClient.getRetrofitFactory(); - HttpClientFactory clientFactory = mClient.getClientFactory(); + RetrofitFactory retrofitFactory = mServer.getRetrofitFactory(); + HttpClientFactory clientFactory = mServer.getClientFactory(); OkHttpClient client = clientFactory.newHttpClient(); client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); Retrofit retrofit = retrofitFactory.newRetrofit() @@ -139,7 +138,7 @@ private Request createAuthRequest( * Constructs url http[s]://some.jrs/j_spring_security_check */ return new Request.Builder() - .url(mClient.getBaseUrl() + "j_spring_security_check") + .url(mServer.getBaseUrl() + "j_spring_security_check") .post(formBody.build()) .build(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index cbd59d5c..8183b9e9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -40,7 +40,7 @@ final class AuthorizedAuthClientState implements AuthClientState { private Retrofit mRetrofit; - private AuthorizedClient mAuthorizedClient; + private Client mClient; private ReportExecutionRestApi mReportExecutionRestApi; private ReportExportRestApi mReportExportRestApi; @@ -49,15 +49,15 @@ final class AuthorizedAuthClientState implements AuthClientState { private RepositoryRestApi mRepositoryRestApi; @Override - public void connect(AuthorizedClient context) throws IOException, HttpException { - mAuthorizedClient = context; + public void connect(Client context) throws IOException, HttpException { + mClient = context; makeAuthCall(); } private void makeAuthCall() throws IOException, HttpException { - Client client = mAuthorizedClient.anonymousClient; - Credentials credentials = mAuthorizedClient.credentials; - AuthStrategy authStrategy = new AuthStrategy(client); + Server server = mClient.mAnonymousServer; + Credentials credentials = mClient.credentials; + AuthStrategy authStrategy = new AuthStrategy(server); credentials.apply(authStrategy); } @@ -103,7 +103,7 @@ public RepositoryRestApi makeRepositoryRestApi() { Retrofit getRetrofit() { if (mRetrofit == null) { - RetrofitFactory retrofitFactory = new RetrofitFactory(mAuthorizedClient.anonymousClient); + RetrofitFactory retrofitFactory = new RetrofitFactory(mClient.mAnonymousServer); Retrofit.Builder builder = retrofitFactory.newRetrofit(); OkHttpClient okHttpClient = configureOkHttp(); @@ -117,7 +117,7 @@ Retrofit getRetrofit() { private OkHttpClient configureOkHttp() { OkHttpClient okHttpClient = new OkHttpClient(); - if (mAuthorizedClient.authenticationPolicy == AuthPolicy.RETRY) { + if (mClient.authenticationPolicy == AuthPolicy.RETRY) { okHttpClient.setAuthenticator(new Authenticator() { @Override public Request authenticate(Proxy proxy, Response response) throws IOException { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java deleted file mode 100644 index 74dec4a1..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import org.jetbrains.annotations.TestOnly; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class AuthorizedClient { - final Client anonymousClient; - final Credentials credentials; - final AuthPolicy authenticationPolicy; - - private AuthClientState mAuthClientState; - - @TestOnly - AuthorizedClient(Client client, Credentials credentials, AuthPolicy authenticationPolicy, AuthClientState authClientState) { - anonymousClient = client; - this.credentials = credentials; - this.authenticationPolicy = authenticationPolicy; - - mAuthClientState = authClientState; - } - - public void connect() throws IOException, HttpException { - mAuthClientState.connect(this); - } - - public ReportExecutionRestApi reportExecutionApi() { - return mAuthClientState.makeReportExecutionApi(); - } - - public ReportExportRestApi reportExportApi() { - return mAuthClientState.makeReportExportRestApi(); - } - - public ReportOptionRestApi reportOptionsApi() { - return mAuthClientState.makeReportOptionRestApi(); - } - - public InputControlRestApi inputControlApi() { - return mAuthClientState.makeInputControlRestApi(); - } - - public RepositoryRestApi repositoryApi() { - return mAuthClientState.makeRepositoryRestApi(); - } - - void setAuthClientState(AuthClientState authClientState) { - mAuthClientState = authClientState; - } - - public static class Builder { - private final Client mClient; - private final Credentials mCredentials; - - private AuthPolicy mAuthenticationPolicy; - - Builder(Client client, Credentials credentials) { - mClient = client; - mCredentials = credentials; - } - - public Builder withAuthenticationPolicy(AuthPolicy authenticationPolicy) { - mAuthenticationPolicy = authenticationPolicy; - return this; - } - - public AuthorizedClient create() { - ensureSaneDefaults(); - AuthClientState state = new InitialAuthClientState(); - return new AuthorizedClient(mClient, mCredentials, mAuthenticationPolicy, state); - } - - private void ensureSaneDefaults() { - mAuthenticationPolicy = AuthPolicy.RETRY; - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index f2f81057..348ea968 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -24,103 +24,82 @@ package com.jaspersoft.android.sdk.network; -import retrofit.Retrofit; +import org.jetbrains.annotations.TestOnly; -import java.util.concurrent.TimeUnit; +import java.io.IOException; /** * @author Tom Koptel * @since 2.0 */ public final class Client { - private final String mBaseUrl; - private final long mConnectTimeout; - private final long mReadTimeout; + final Server mAnonymousServer; + final Credentials credentials; + final AuthPolicy authenticationPolicy; - private RetrofitFactory mRetrofitFactory; - private HttpClientFactory mHttpClientFactory; + private AuthClientState mAuthClientState; - private ServerRestApi mServerRestApi; + @TestOnly + Client(Server server, Credentials credentials, AuthPolicy authenticationPolicy, AuthClientState authClientState) { + mAnonymousServer = server; + this.credentials = credentials; + this.authenticationPolicy = authenticationPolicy; - private Client(String baseUrl, long connectTimeout, long readTimeout) { - mBaseUrl = baseUrl; - mConnectTimeout = connectTimeout; - mReadTimeout = readTimeout; + mAuthClientState = authClientState; } - public ServerRestApi infoApi() { - if (mServerRestApi == null) { - Retrofit retrofit = getRetrofitFactory() - .newRetrofit() - .build(); - - mServerRestApi = new ServerRestApiImpl(retrofit); - } - return mServerRestApi; - } - - public AuthorizedClient.Builder makeAuthorizedClient(Credentials credentials) { - return new AuthorizedClient.Builder(this, credentials); - } - - public static GenericBuilder newBuilder() { - return new GenericBuilder(); + public void connect() throws IOException, HttpException { + mAuthClientState.connect(this); } - public String getBaseUrl() { - return mBaseUrl; + public ReportExecutionRestApi reportExecutionApi() { + return mAuthClientState.makeReportExecutionApi(); } - public long getConnectTimeout() { - return mConnectTimeout; + public ReportExportRestApi reportExportApi() { + return mAuthClientState.makeReportExportRestApi(); } - public long getReadTimeout() { - return mReadTimeout; + public ReportOptionRestApi reportOptionsApi() { + return mAuthClientState.makeReportOptionRestApi(); } - RetrofitFactory getRetrofitFactory() { - if (mRetrofitFactory == null) { - mRetrofitFactory = new RetrofitFactory(this); - } - return mRetrofitFactory; + public InputControlRestApi inputControlApi() { + return mAuthClientState.makeInputControlRestApi(); } - HttpClientFactory getClientFactory() { - if (mHttpClientFactory == null) { - mHttpClientFactory = new HttpClientFactory(this); - } - return mHttpClientFactory; + public RepositoryRestApi repositoryApi() { + return mAuthClientState.makeRepositoryRestApi(); } - public static class GenericBuilder { - public OptionalBuilder withBaseUrl(String baseUrl) { - return new OptionalBuilder(baseUrl); - } + void setAuthClientState(AuthClientState authClientState) { + mAuthClientState = authClientState; } - public static class OptionalBuilder { - private final String mBaseUrl; + public static class Builder { + private final Server mServer; + private final Credentials mCredentials; - private long connectTimeout = 10000; - private long readTimeout = 10000; + private AuthPolicy mAuthenticationPolicy; - private OptionalBuilder(String baseUrl) { - mBaseUrl = baseUrl; + Builder(Server server, Credentials credentials) { + mServer = server; + mCredentials = credentials; } - public OptionalBuilder withConnectionTimeOut(long timeout, TimeUnit unit) { - connectTimeout = unit.toMillis(timeout); + public Builder withAuthenticationPolicy(AuthPolicy authenticationPolicy) { + mAuthenticationPolicy = authenticationPolicy; return this; } - public OptionalBuilder withReadTimeout(long timeout, TimeUnit unit) { - readTimeout = unit.toMillis(timeout); - return this; + public Client create() { + ensureSaneDefaults(); + AuthClientState state = new InitialAuthClientState(); + return new Client(mServer, mCredentials, mAuthenticationPolicy, state); } - public Client create() { - return new Client(mBaseUrl, connectTimeout, readTimeout); + private void ensureSaneDefaults() { + mAuthenticationPolicy = AuthPolicy.RETRY; } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java index 4f67efdc..bf462d26 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java @@ -31,10 +31,10 @@ * @since 2.0 */ final class HttpClientFactory { - private final Client mClient; + private final Server mServer; - HttpClientFactory(Client client) { - mClient = client; + HttpClientFactory(Server server) { + mServer = server; } public OkHttpClient newHttpClient() { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java index 2b22ef26..a3ec08e8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java @@ -34,7 +34,7 @@ final class InitialAuthClientState implements AuthClientState { private static final String MESSAGE = "Unauthorized state. Please, connect client before usage"; @Override - public void connect(AuthorizedClient context) throws IOException, HttpException { + public void connect(Client context) throws IOException, HttpException { AuthClientState state = new AuthorizedAuthClientState(); state.connect(context); context.setAuthClientState(state); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java index 764ddef8..4bd503c0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java @@ -34,11 +34,11 @@ * @since 2.0 */ final class RetrofitFactory { - private final Client mClient; + private final Server mServer; @TestOnly - RetrofitFactory(Client client) { - mClient = client; + RetrofitFactory(Server server) { + mServer = server; } public Retrofit.Builder newRetrofit() { @@ -47,7 +47,7 @@ public Retrofit.Builder newRetrofit() { StringConverterFactory stringConverterFactory = StringConverterFactory.create(); return new Retrofit.Builder() - .baseUrl(mClient.getBaseUrl()) + .baseUrl(mServer.getBaseUrl()) .addConverterFactory(gsonConverterFactory) .addConverterFactory(stringConverterFactory); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java new file mode 100644 index 00000000..f8975cd7 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -0,0 +1,126 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import retrofit.Retrofit; + +import java.util.concurrent.TimeUnit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class Server { + private final String mBaseUrl; + private final long mConnectTimeout; + private final long mReadTimeout; + + private RetrofitFactory mRetrofitFactory; + private HttpClientFactory mHttpClientFactory; + + private ServerRestApi mServerRestApi; + + private Server(String baseUrl, long connectTimeout, long readTimeout) { + mBaseUrl = baseUrl; + mConnectTimeout = connectTimeout; + mReadTimeout = readTimeout; + } + + public ServerRestApi infoApi() { + if (mServerRestApi == null) { + Retrofit retrofit = getRetrofitFactory() + .newRetrofit() + .build(); + + mServerRestApi = new ServerRestApiImpl(retrofit); + } + return mServerRestApi; + } + + public Client.Builder makeAuthorizedClient(Credentials credentials) { + return new Client.Builder(this, credentials); + } + + public static GenericBuilder newBuilder() { + return new GenericBuilder(); + } + + public String getBaseUrl() { + return mBaseUrl; + } + + public long getConnectTimeout() { + return mConnectTimeout; + } + + public long getReadTimeout() { + return mReadTimeout; + } + + RetrofitFactory getRetrofitFactory() { + if (mRetrofitFactory == null) { + mRetrofitFactory = new RetrofitFactory(this); + } + return mRetrofitFactory; + } + + HttpClientFactory getClientFactory() { + if (mHttpClientFactory == null) { + mHttpClientFactory = new HttpClientFactory(this); + } + return mHttpClientFactory; + } + + public static class GenericBuilder { + public OptionalBuilder withBaseUrl(String baseUrl) { + return new OptionalBuilder(baseUrl); + } + } + + public static class OptionalBuilder { + private final String mBaseUrl; + + private long connectTimeout = 10000; + private long readTimeout = 10000; + + private OptionalBuilder(String baseUrl) { + mBaseUrl = baseUrl; + } + + public OptionalBuilder withConnectionTimeOut(long timeout, TimeUnit unit) { + connectTimeout = unit.toMillis(timeout); + return this; + } + + public OptionalBuilder withReadTimeout(long timeout, TimeUnit unit) { + readTimeout = unit.toMillis(timeout); + return this; + } + + public Server create() { + return new Server(mBaseUrl, connectTimeout, readTimeout); + } + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index b67f0f18..b983ae63 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -61,10 +61,10 @@ public class AuthenticationRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Client client = Client.newBuilder() + Server server = Server.newBuilder() .withBaseUrl(mWebMockRule.getRootUrl()) .create(); - apiUnderTest = new AuthenticationRestApi(client); + apiUnderTest = new AuthenticationRestApi(server); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 8435c298..92bb76d8 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; @@ -58,7 +58,7 @@ public class InputControlRestApiTest { @Before public void setUp() throws Exception { if (apiUnderTest == null) { - AuthorizedClient client = mLazyClient.get(); + Client client = mLazyClient.get(); apiUnderTest = client.inputControlApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java index aa65936f..77ceec68 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java @@ -24,8 +24,8 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.HttpException; import java.io.IOException; @@ -36,25 +36,25 @@ */ final class LazyClient { private final JrsMetadata mJrsMetadata; - private AuthorizedClient authorizedClient; + private Client mClient; public LazyClient(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; } - public AuthorizedClient get() { - if (authorizedClient == null) { - Client client = Client.newBuilder() + public Client get() { + if (mClient == null) { + Server server = Server.newBuilder() .withBaseUrl(mJrsMetadata.getServerUrl()) .create(); - authorizedClient = client.makeAuthorizedClient(mJrsMetadata.getCredentials()) + mClient = server.makeAuthorizedClient(mJrsMetadata.getCredentials()) .create(); try { - authorizedClient.connect(); + mClient.connect(); } catch (IOException | HttpException e) { throw new RuntimeException(e); } } - return authorizedClient; + return mClient; } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index 5f2c5fd3..b55c8289 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; @@ -62,7 +62,7 @@ public class ReportExecutionRestApiTest { @Before public void setUp() throws Exception { if (apiUnderTest == null) { - AuthorizedClient client = mLazyClient.get(); + Client client = mLazyClient.get(); apiUnderTest = client.reportExecutionApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index ab354335..bed476c1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; @@ -55,7 +55,7 @@ public class ReportExportRestApiTest { @Before public void setup() { if (apiUnderTest == null) { - AuthorizedClient client = mLazyClient.get(); + Client client = mLazyClient.get(); mExecApi = client.reportExecutionApi(); apiUnderTest = client.reportExportApi(); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 38647b36..25c083db 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import org.junit.Before; @@ -61,7 +61,7 @@ public class ReportOptionRestApiTest { @Before public void setup() { if (apiUnderTest == null) { - AuthorizedClient client = mLazyClient.get(); + Client client = mLazyClient.get(); apiUnderTest = client.reportOptionsApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 88fe05ee..eebc8896 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; @@ -52,7 +52,7 @@ public class RepositoryRestApiTest { @Before public void setup() { if (apiUnderTest == null) { - AuthorizedClient client = mLazyClient.get(); + Client client = mLazyClient.get(); apiUnderTest = client.repositoryApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 66e5cb25..c55a56c4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -25,7 +25,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import org.junit.Before; @@ -47,10 +47,10 @@ public class ServerRestTest { @Before public void setup() { if (apiUnderTest == null) { - Client client = Client.newBuilder() + Server server = Server.newBuilder() .withBaseUrl(mobileDemo2) .create(); - apiUnderTest = client.infoApi(); + apiUnderTest = server.infoApi(); } } From 10b65e9dfb7f7f26d427c9518003492e2513d856 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 14:17:57 +0200 Subject: [PATCH 368/457] Drop token dependent code from service layer --- .../network/AuthorizedAuthClientState.java | 4 +- .../android/sdk/network/Client.java | 8 ++- .../android/sdk/service/AnonymousSession.java | 11 +-- .../android/sdk/service/RestClient.java | 68 +++++++++---------- .../android/sdk/service/Session.java | 49 ++----------- .../service/auth/AuthenticationService.java | 32 --------- .../android/sdk/service/internal/Call.java | 3 +- .../service/internal/DefaultCallExecutor.java | 16 +++-- .../service/internal/InfoCacheManager.java | 10 +-- .../service/internal/TokenCacheManager.java | 51 -------------- .../report/ExecutionOptionsDataMapper.java | 6 -- .../report/ReportExecutionUseCase.java | 17 +++-- .../service/report/ReportExportUseCase.java | 17 +++-- .../sdk/service/report/ReportService.java | 30 ++++---- .../service/repository/RepositoryService.java | 20 ++---- .../sdk/service/repository/SearchUseCase.java | 5 +- .../sdk/service/server/ServerInfoService.java | 19 +----- .../sdk/service/token/InMemoryTokenCache.java | 56 --------------- .../android/sdk/service/token/TokenCache.java | 42 ------------ .../android/sdk/service/FakeCallExecutor.java | 9 +-- .../sdk/service/InMemoryTokenCacheTest.java | 53 --------------- .../report/ReportExecutionUseCaseTest.java | 13 ++-- .../report/ReportExportUseCaseTest.java | 21 +++--- .../service/repository/SearchUseCaseTest.java | 8 +-- .../android/sdk/test/TestLogger.java | 52 -------------- 25 files changed, 128 insertions(+), 492 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index 8183b9e9..60a9847a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -55,7 +55,7 @@ public void connect(Client context) throws IOException, HttpException { } private void makeAuthCall() throws IOException, HttpException { - Server server = mClient.mAnonymousServer; + Server server = mClient.mServer; Credentials credentials = mClient.credentials; AuthStrategy authStrategy = new AuthStrategy(server); credentials.apply(authStrategy); @@ -103,7 +103,7 @@ public RepositoryRestApi makeRepositoryRestApi() { Retrofit getRetrofit() { if (mRetrofit == null) { - RetrofitFactory retrofitFactory = new RetrofitFactory(mClient.mAnonymousServer); + RetrofitFactory retrofitFactory = new RetrofitFactory(mClient.mServer); Retrofit.Builder builder = retrofitFactory.newRetrofit(); OkHttpClient okHttpClient = configureOkHttp(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index 348ea968..87bc7be0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -33,7 +33,7 @@ * @since 2.0 */ public final class Client { - final Server mAnonymousServer; + final Server mServer; final Credentials credentials; final AuthPolicy authenticationPolicy; @@ -41,7 +41,7 @@ public final class Client { @TestOnly Client(Server server, Credentials credentials, AuthPolicy authenticationPolicy, AuthClientState authClientState) { - mAnonymousServer = server; + mServer = server; this.credentials = credentials; this.authenticationPolicy = authenticationPolicy; @@ -76,6 +76,10 @@ void setAuthClientState(AuthClientState authClientState) { mAuthClientState = authClientState; } + public Server getServer() { + return mServer; + } + public static class Builder { private final Server mServer; private final Credentials mCredentials; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java index cd1ce453..015e9eb8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.service.auth.AuthenticationService; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.service.server.ServerInfoService; import org.jetbrains.annotations.NotNull; @@ -33,17 +33,12 @@ * @since 2.0 */ public class AnonymousSession { - protected final RestClient mClient; + protected final Client mClient; - protected AnonymousSession(RestClient client) { + protected AnonymousSession(Client client) { mClient = client; } - @NotNull - public final AuthenticationService authApi() { - throw new UnsupportedOperationException("Not yet implemented"); - } - @NotNull public final ServerInfoService infoApi() { throw new UnsupportedOperationException("Not yet implemented"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java index b959b848..a4a2aac5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java @@ -24,10 +24,16 @@ package com.jaspersoft.android.sdk.service; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.Server; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; import com.jaspersoft.android.sdk.service.info.InfoCache; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; +import java.io.IOException; import java.util.concurrent.TimeUnit; /** @@ -35,42 +41,43 @@ * @since 2.0 */ public final class RestClient { - private final String mServerUrl; - private final long mReadTimeOut; - private final long mConnectionTimeOut; - private final long mPollTimeout; + private final Server mServer; private final InfoCache mInfoCache; - - private RestClient(String serverUrl, long readTimeOut, long connectionTimeOut, long pollTimeout, InfoCache infoCache) { - mServerUrl = serverUrl; - mReadTimeOut = readTimeOut; - mConnectionTimeOut = connectionTimeOut; - mPollTimeout = pollTimeout; + private RestClient(Server server, InfoCache infoCache) { + mServer = server; mInfoCache = infoCache; } - public String getServerUrl() { - return mServerUrl; + return mServer.getBaseUrl(); } public long getReadTimeOut() { - return mReadTimeOut; + return mServer.getReadTimeout(); } public long getConnectionTimeOut() { - return mConnectionTimeOut; - } - - public long getPollTimeout() { - return mPollTimeout; + return mServer.getConnectTimeout(); } public InfoCache getInfoCache() { return mInfoCache; } + public Session authorize(Credentials credentials) throws ServiceException { + DefaultExceptionMapper exceptionMapper = new DefaultExceptionMapper(); + Client client = mServer.makeAuthorizedClient(credentials).create(); + try { + client.connect(); + } catch (IOException e) { + throw exceptionMapper.transform(e); + } catch (HttpException e) { + throw exceptionMapper.transform(e); + } + return new Session(client, mInfoCache); + } + public static Builder builder() { return new Builder(); } @@ -85,32 +92,24 @@ public ConditionalBuilder serverUrl(String serverUrl) { } public static class ConditionalBuilder { - private final String mServerUrl; - private long mConnectionReadTimeOut = TimeUnit.SECONDS.toMillis(10); - private long mConnectionTimeOut = TimeUnit.SECONDS.toMillis(10); - private long mPollTimeOut = TimeUnit.SECONDS.toMillis(1); + private final Server.OptionalBuilder mServerBuilder; private InfoCache mInfoCache; private ConditionalBuilder(String serverUrl) { - mServerUrl = serverUrl; - } - - public ConditionalBuilder pollTimeOut(int timeOut, TimeUnit unit) { - mPollTimeOut = unit.toMillis(timeOut); - return this; + mServerBuilder = Server.newBuilder().withBaseUrl(serverUrl); } - public ConditionalBuilder readTimeOut(int timeOut, TimeUnit unit) { - mConnectionReadTimeOut = unit.toMillis(timeOut); + public ConditionalBuilder withReadTimeout(int timeOut, TimeUnit unit) { + mServerBuilder.withReadTimeout(timeOut, unit); return this; } - public ConditionalBuilder connectionTimeOut(int timeOut, TimeUnit unit) { - mConnectionTimeOut = unit.toMillis(timeOut); + public ConditionalBuilder withConnectionTimeOut(int timeOut, TimeUnit unit) { + mServerBuilder.withConnectionTimeOut(timeOut, unit); return this; } - public ConditionalBuilder infoCache(InfoCache infoCache) { + public ConditionalBuilder withInfoCache(InfoCache infoCache) { mInfoCache = infoCache; return this; } @@ -119,7 +118,8 @@ public RestClient create() { if (mInfoCache == null) { mInfoCache = new InMemoryInfoCache(); } - return new RestClient(mServerUrl, mConnectionReadTimeOut, mConnectionTimeOut, mPollTimeOut, mInfoCache); + Server server = mServerBuilder.create(); + return new RestClient(server, mInfoCache); } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java index 919b166d..c22af53b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java @@ -24,11 +24,10 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.service.info.InfoCache; import com.jaspersoft.android.sdk.service.report.ReportService; import com.jaspersoft.android.sdk.service.repository.RepositoryService; -import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; -import com.jaspersoft.android.sdk.service.token.TokenCache; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -38,31 +37,21 @@ */ public final class Session extends AnonymousSession { - private final Credentials mCredentials; - private final TokenCache mTokenCache; + private final InfoCache mInfoCache; private ReportService mReportService; private RepositoryService mRepositoryService; @TestOnly - Session(RestClient client, Credentials credentials, TokenCache tokenCache) { + Session(Client client, InfoCache infoCache) { super(client); - mCredentials = credentials; - mTokenCache = tokenCache; - } - - public TokenCache getTokenCache() { - return mTokenCache; - } - - public Credentials getCredentials() { - return mCredentials; + mInfoCache = infoCache; } @NotNull public ReportService reportApi() { if (mReportService == null) { - mReportService = ReportService.create(mClient, this); + mReportService = ReportService.create(mClient, mInfoCache); } return mReportService; } @@ -70,32 +59,8 @@ public ReportService reportApi() { @NotNull public RepositoryService repositoryApi() { if (mRepositoryService == null) { - mRepositoryService = RepositoryService.create(mClient, this); + mRepositoryService = RepositoryService.create(mClient, mInfoCache); } return mRepositoryService; } - - public static class Builder { - private final RestClient mClient; - private final Credentials mCredentials; - - private TokenCache mTokenCache; - - Builder(RestClient client, Credentials credentials) { - mClient = client; - mCredentials = credentials; - } - - public Builder tokenCache(TokenCache tokenCache) { - mTokenCache = tokenCache; - return this; - } - - public Session create() { - if (mTokenCache == null) { - mTokenCache = new InMemoryTokenCache(); - } - return new Session(mClient, mCredentials, mTokenCache); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java deleted file mode 100644 index 14b4dc7f..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthenticationService.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.auth; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface AuthenticationService { -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java index 093cb99c..3d365079 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/Call.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.internal; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import java.io.IOException; @@ -34,5 +33,5 @@ * @since 2.0 */ public interface Call { - T perform(Cookies cookies) throws IOException, HttpException; + T perform() throws IOException, HttpException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java index 662d38b8..a5c64b92 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultCallExecutor.java @@ -24,25 +24,31 @@ package com.jaspersoft.android.sdk.service.internal; +import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 */ public class DefaultCallExecutor implements CallExecutor { - - private final TokenCacheManager mTokenCacheManager; private final ServiceExceptionMapper mServiceExceptionMapper; - public DefaultCallExecutor(TokenCacheManager tokenCacheManager, ServiceExceptionMapper serviceExceptionMapper) { - mTokenCacheManager = tokenCacheManager; + public DefaultCallExecutor(ServiceExceptionMapper serviceExceptionMapper) { mServiceExceptionMapper = serviceExceptionMapper; } @NotNull public T execute(Call call) throws ServiceException { - throw new UnsupportedOperationException("Not yet implemented"); + try { + return call.perform(); + } catch (IOException e) { + throw mServiceExceptionMapper.transform(e); + } catch (HttpException e) { + throw mServiceExceptionMapper.transform(e); + } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java index c238ade3..7b60eaae 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.internal; -import com.jaspersoft.android.sdk.service.RestClient; +import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.info.InfoCache; @@ -47,10 +47,10 @@ public class InfoCacheManager { mInfoCache = infoCache; } - public static InfoCacheManager create(RestClient client) { - ServerInfoService serverInfoService = ServerInfoService.create(client); - String baseUrl = client.getServerUrl(); - return new InfoCacheManager(baseUrl, serverInfoService, client.getInfoCache()); + public static InfoCacheManager create(Server server, InfoCache cache) { + ServerInfoService serverInfoService = ServerInfoService.create(server); + String baseUrl = server.getBaseUrl(); + return new InfoCacheManager(baseUrl, serverInfoService, cache); } public ServerInfo getInfo() throws ServiceException { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java deleted file mode 100644 index ede25e81..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/TokenCacheManager.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.internal; - -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.Session; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class TokenCacheManager { - - - @NotNull - public static TokenCacheManager create(RestClient restClient, Session session) { - throw new UnsupportedOperationException("Not yet implemented"); - } - - @NotNull - public Cookies loadToken() throws IOException, HttpException { - throw new UnsupportedOperationException("Not yet implemented"); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java index b5b8d346..729808de 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.jetbrains.annotations.NotNull; @@ -90,11 +89,6 @@ private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, } } - public static ExecutionOptionsDataMapper create(RestClient client) { - String baseUrl = client.getServerUrl(); - return new ExecutionOptionsDataMapper(baseUrl); - } - static class Helper { static String adaptFormat(ExecutionCriteria.Format format) { if (format == null) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java index 743e25ee..7f3b6615 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -68,10 +67,10 @@ public ReportExecutionDescriptor runReportExecution(final String reportUri, fina final ServerVersion version = info.getVersion(); Call call = new Call() { @Override - public ReportExecutionDescriptor perform(Cookies cookies) throws IOException, HttpException { + public ReportExecutionDescriptor perform() throws IOException, HttpException { ReportExecutionRequestOptions options = mExecutionOptionsMapper.transformRunReportOptions(reportUri, version, criteria); - return mExecutionApi.runReportExecution(cookies, options); + return mExecutionApi.runReportExecution(options); } }; return mCallExecutor.execute(call); @@ -81,8 +80,8 @@ public ReportExecutionDescriptor perform(Cookies cookies) throws IOException, Ht public ExecutionStatus requestStatus(final String executionId) throws ServiceException { Call call = new Call() { @Override - public ExecutionStatus perform(Cookies cookies) throws IOException, HttpException { - return mExecutionApi.requestReportExecutionStatus(cookies, executionId); + public ExecutionStatus perform() throws IOException, HttpException { + return mExecutionApi.requestReportExecutionStatus(executionId); } }; return mCallExecutor.execute(call); @@ -92,8 +91,8 @@ public ExecutionStatus perform(Cookies cookies) throws IOException, HttpExceptio public ReportExecutionDescriptor requestExecutionDetails(final String executionId) throws ServiceException { Call call = new Call() { @Override - public ReportExecutionDescriptor perform(Cookies cookies) throws IOException, HttpException { - return mExecutionApi.requestReportExecutionDetails(cookies, executionId); + public ReportExecutionDescriptor perform() throws IOException, HttpException { + return mExecutionApi.requestReportExecutionDetails(executionId); } }; return mCallExecutor.execute(call); @@ -102,8 +101,8 @@ public ReportExecutionDescriptor perform(Cookies cookies) throws IOException, Ht public void updateExecution(final String executionId, final List newParameters) throws ServiceException { Call call = new Call() { @Override - public Void perform(Cookies cookies) throws IOException, HttpException { - mExecutionApi.updateReportExecution(cookies, executionId, newParameters); + public Void perform() throws IOException, HttpException { + mExecutionApi.updateReportExecution(executionId, newParameters); return null; } }; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java index 38261712..ff1ecaf2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; @@ -71,9 +70,9 @@ public ExportExecutionDescriptor runExport(final String executionId, final RunEx Call call = new Call() { @Override - public ExportExecutionDescriptor perform(Cookies cookies) throws IOException, HttpException { + public ExportExecutionDescriptor perform() throws IOException, HttpException { ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria, version); - return mExportApi.runExportExecution(cookies, executionId, options); + return mExportApi.runExportExecution(executionId, options); } }; return mCallExecutor.execute(call); @@ -90,8 +89,8 @@ public ExecutionStatus checkExportExecutionStatus(final String executionId, Call call = new Call() { @Override - public ExecutionStatus perform(Cookies cookies) throws IOException, HttpException { - return mExportApi.checkExportExecutionStatus(cookies, executionId, exportId); + public ExecutionStatus perform() throws IOException, HttpException { + return mExportApi.checkExportExecutionStatus(executionId, exportId); } }; return mCallExecutor.execute(call); @@ -106,8 +105,8 @@ public ReportOutput requestExportOutput(RunExportCriteria exportCriteria, Call call = new Call() { @Override - public ReportOutput perform(Cookies cookies) throws IOException, HttpException { - ExportOutputResource result = mExportApi.requestExportOutput(cookies, executionId, resultId); + public ReportOutput perform() throws IOException, HttpException { + ExportOutputResource result = mExportApi.requestExportOutput(executionId, resultId); return OutputDataMapper.transform(result); } }; @@ -124,9 +123,9 @@ public ResourceOutput requestExportAttachmentOutput(RunExportCriteria exportCrit Call call = new Call() { @Override - public ResourceOutput perform(Cookies cookies) throws IOException, HttpException { + public ResourceOutput perform() throws IOException, HttpException { OutputResource result = mExportApi.requestExportAttachment( - cookies, executionId, resultId, fileName); + executionId, resultId, fileName); return OutputDataMapper.transform(result); } }; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 85c2d912..0a4607f5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -24,15 +24,16 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.Session; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.info.InfoCache; import com.jaspersoft.android.sdk.service.internal.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -62,32 +63,25 @@ public final class ReportService { mExportUseCase = exportUseCase; } - public static ReportService create(RestClient client, Session session) { - ReportExecutionRestApi executionApi = new ReportExecutionRestApi.Builder() - .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) - .baseUrl(client.getServerUrl()) - .build(); - ReportExportRestApi exportApi = new ReportExportRestApi.Builder() - .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) - .baseUrl(client.getServerUrl()) - .build(); + public static ReportService create(Client client, InfoCache infoCache) { + ReportExecutionRestApi executionApi = client.reportExecutionApi(); + ReportExportRestApi exportApi = client.reportExportApi(); ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); ServiceExceptionMapper reportExMapper = new ReportExceptionMapper(defaultExMapper); - TokenCacheManager tokenCacheManager = TokenCacheManager.create(client, session); - CallExecutor callExecutor = new DefaultCallExecutor(tokenCacheManager, reportExMapper); - ExecutionOptionsDataMapper executionOptionsMapper = ExecutionOptionsDataMapper.create(client); + CallExecutor callExecutor = new DefaultCallExecutor(reportExMapper); - InfoCacheManager cacheManager = InfoCacheManager.create(client); + Server server = client.getServer(); + ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(server.getBaseUrl()); + + InfoCacheManager cacheManager = InfoCacheManager.create(server, infoCache); ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, callExecutor, cacheManager, executionOptionsMapper); ReportExportUseCase reportExportUseCase = new ReportExportUseCase(exportApi, callExecutor, cacheManager, executionOptionsMapper); return new ReportService( - client.getPollTimeout(), + TimeUnit.SECONDS.toMillis(1), cacheManager, reportExecutionUseCase, reportExportUseCase); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 043a01e4..bc43629b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -24,14 +24,12 @@ package com.jaspersoft.android.sdk.service.repository; +import com.jaspersoft.android.sdk.network.Client; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.RestClient; -import com.jaspersoft.android.sdk.service.Session; +import com.jaspersoft.android.sdk.service.info.InfoCache; import com.jaspersoft.android.sdk.service.internal.*; import org.jetbrains.annotations.TestOnly; -import java.util.concurrent.TimeUnit; - /** * @author Tom Koptel * @since 2.0 @@ -46,17 +44,11 @@ public class RepositoryService { mInfoCacheManager = infoCacheManager; } - public static RepositoryService create(RestClient client, Session session) { - RepositoryRestApi repositoryRestApi = new RepositoryRestApi.Builder() - .baseUrl(client.getServerUrl()) - .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) - .build(); + public static RepositoryService create(Client client, InfoCache cache) { + RepositoryRestApi repositoryRestApi = client.repositoryApi(); ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); - TokenCacheManager tokenCacheManager = TokenCacheManager.create(client, session); - CallExecutor callExecutor = new DefaultCallExecutor(tokenCacheManager, defaultExMapper); - - InfoCacheManager cacheManager = InfoCacheManager.create(client); + CallExecutor callExecutor = new DefaultCallExecutor(defaultExMapper); + InfoCacheManager cacheManager = InfoCacheManager.create(client.getServer(), cache); ResourceMapper resourceMapper = new ResourceMapper(); SearchUseCase searchUseCase = new SearchUseCase( diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 849f0160..62f08b7b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; @@ -66,9 +65,9 @@ public SearchResult performSearch(@NotNull final InternalCriteria internalCriter final SimpleDateFormat dateTimeFormat = mInfoCacheManager.getInfo().getDatetimeFormatPattern(); Call call = new Call() { @Override - public SearchResult perform(Cookies cookies) throws IOException, HttpException { + public SearchResult perform() throws IOException, HttpException { Map criteria = CriteriaMapper.map(internalCriteria); - ResourceSearchResult response = mRestApi.searchResources(cookies, criteria); + ResourceSearchResult response = mRestApi.searchResources(criteria); SearchResult searchResult = new SearchResult(); searchResult.setNextOffset(response.getNextOffset()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index cf813b91..6b8deb97 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -25,20 +25,18 @@ package com.jaspersoft.android.sdk.service.server; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import com.jaspersoft.android.sdk.service.RestClient; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; - import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.TestOnly; import java.io.IOException; import java.text.SimpleDateFormat; -import java.util.concurrent.TimeUnit; /** * @author Tom Koptel @@ -56,20 +54,9 @@ public class ServerInfoService { mServiceExceptionMapper = serviceExceptionMapper; } - public static ServerInfoService create(RestClient client) { - ServerRestApi restApi = new ServerRestApi.Builder() - .baseUrl(client.getServerUrl()) - .connectionTimeOut(client.getConnectionTimeOut(), TimeUnit.MILLISECONDS) - .readTimeout(client.getReadTimeOut(), TimeUnit.MILLISECONDS) - .build(); - ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - - return new ServerInfoService(restApi, ServerInfoTransformer.get(), serviceExceptionMapper); - } - - public static ServerInfoService create(ServerRestApi restApi) { + public static ServerInfoService create(Server server) { ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - return new ServerInfoService(restApi, ServerInfoTransformer.get(), serviceExceptionMapper); + return new ServerInfoService(server.infoApi(), ServerInfoTransformer.get(), serviceExceptionMapper); } public ServerInfo requestServerInfo() throws ServiceException { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java deleted file mode 100644 index e117fdd6..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/InMemoryTokenCache.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.token; - -import com.jaspersoft.android.sdk.network.Cookies; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; -import java.util.WeakHashMap; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class InMemoryTokenCache implements TokenCache { - private final Map mCache = new WeakHashMap(); - - @Nullable - @Override - public Cookies get(@NotNull String host) { - return mCache.get(host); - } - - @Override - public void put(@NotNull String host, @NotNull Cookies cookies) { - mCache.put(host, cookies); - } - - @Override - public void remove(@NotNull String host) { - mCache.remove(host); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java deleted file mode 100644 index d78681ea..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/token/TokenCache.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.token; - -import com.jaspersoft.android.sdk.network.Cookies; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface TokenCache { - @Nullable - Cookies get(@NotNull String host); - - void put(@NotNull String host, @NotNull Cookies cookies); - - void remove(@NotNull String host); -} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java index 652f3ab2..e809d714 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java @@ -24,11 +24,10 @@ package com.jaspersoft.android.sdk.service; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import java.io.IOException; @@ -38,18 +37,16 @@ * @since 2.0 */ public final class FakeCallExecutor implements CallExecutor { - private final Cookies mCookies; private final DefaultExceptionMapper mExMapper; - public FakeCallExecutor(Cookies cookies) { - mCookies = cookies; + public FakeCallExecutor() { mExMapper = new DefaultExceptionMapper(); } @Override public T execute(Call call) throws ServiceException { try { - return call.perform(mCookies); + return call.perform(); } catch (IOException e) { throw mExMapper.transform(e); } catch (HttpException e) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java deleted file mode 100644 index 723c9ed5..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryTokenCacheTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.network.Cookies; -import com.jaspersoft.android.sdk.service.token.InMemoryTokenCache; -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.nullValue; -import static org.junit.Assert.assertThat; - -public class InMemoryTokenCacheTest { - - private InMemoryTokenCache cache; - - @Before - public void setUp() throws Exception { - cache = new InMemoryTokenCache(); - } - - @Test - public void testCache() throws Exception { - Cookies cookies = Cookies.parse("key;name"); - cache.put("http://localhost", cookies); - assertThat(cache.get("http://localhost"), is(cookies)); - cache.remove("http://localhost"); - assertThat(cache.get("http://localhost"), is(nullValue())); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java index bd9facb0..34f4bad9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; @@ -44,7 +43,6 @@ import java.util.List; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -65,8 +63,7 @@ public class ReportExecutionUseCaseTest { ServerInfo mServerInfo; private ReportExecutionUseCase executionUseCase; - private final Cookies fakeCookies = Cookies.parse("key=value"); - private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor(fakeCookies); + private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor(); @Before public void setUp() throws Exception { @@ -82,25 +79,25 @@ public void testRunReportExecution() throws Exception { RunReportCriteria criteria = RunReportCriteria.builder().create(); executionUseCase.runReportExecution("/my/uri", criteria); verify(mDataMapper).transformRunReportOptions("/my/uri", ServerVersion.v6, criteria); - verify(mExecutionRestApi).runReportExecution(eq(fakeCookies), any(ReportExecutionRequestOptions.class)); + verify(mExecutionRestApi).runReportExecution(any(ReportExecutionRequestOptions.class)); } @Test public void testRequestStatus() throws Exception { executionUseCase.requestStatus(EXECUTION_ID); - verify(mExecutionRestApi).requestReportExecutionStatus(fakeCookies, EXECUTION_ID); + verify(mExecutionRestApi).requestReportExecutionStatus(EXECUTION_ID); } @Test public void testRequestExecutionDetails() throws Exception { executionUseCase.requestExecutionDetails(EXECUTION_ID); - verify(mExecutionRestApi).requestReportExecutionDetails(fakeCookies, EXECUTION_ID); + verify(mExecutionRestApi).requestReportExecutionDetails(EXECUTION_ID); } @Test public void testUpdateExecution() throws Exception { List params = Collections.emptyList(); executionUseCase.updateExecution(EXECUTION_ID, params); - verify(mExecutionRestApi).updateReportExecution(fakeCookies, EXECUTION_ID, params); + verify(mExecutionRestApi).updateReportExecution(EXECUTION_ID, params); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java index 0be159d4..235a922e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; @@ -59,8 +58,6 @@ public class ReportExportUseCaseTest { InfoCacheManager mCacheManager; @Mock ServerInfo mServerInfo; - - private final Cookies fakeCookies = Cookies.parse("key=value"); private static final RunExportCriteria EXPORT_HTML_PAGE_1 = RunExportCriteria.builder() .format(ExecutionCriteria.Format.HTML) @@ -76,7 +73,7 @@ public void setUp() throws Exception { when(mCacheManager.getInfo()).thenReturn(mServerInfo); when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); - FakeCallExecutor callExecutor = new FakeCallExecutor(fakeCookies); + FakeCallExecutor callExecutor = new FakeCallExecutor(); useCase = new ReportExportUseCase(mExportApi, callExecutor, mCacheManager, mExecutionOptionsMapper); } @@ -84,7 +81,7 @@ public void setUp() throws Exception { public void testRequestExportOutputOnServer5_5() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); - verify(mExportApi).requestExportOutput(eq(fakeCookies), eq(EXEC_ID), eq(LEGACY_EXPORT_ID)); + verify(mExportApi).requestExportOutput(eq(EXEC_ID), eq(LEGACY_EXPORT_ID)); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); } @@ -93,7 +90,7 @@ public void testRequestExportOutputOnServer5_5() throws Exception { public void testRequestExportOutputOnServer5_6() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); - verify(mExportApi).requestExportOutput(eq(fakeCookies), eq(EXEC_ID), eq(EXPORT_ID)); + verify(mExportApi).requestExportOutput(eq(EXEC_ID), eq(EXPORT_ID)); verify(mCacheManager).getInfo(); } @@ -103,12 +100,12 @@ public void testRunExport() throws Exception { verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); verify(mExecutionOptionsMapper).transformExportOptions(EXPORT_HTML_PAGE_1, ServerVersion.v6); - verify(mExportApi).runExportExecution(eq(fakeCookies), eq(EXEC_ID), any(ExecutionRequestOptions.class)); + verify(mExportApi).runExportExecution(eq(EXEC_ID), any(ExecutionRequestOptions.class)); } @Test public void testCheckExportExecutionStatusOnServer5_5() throws Exception { - when(mExportApi.checkExportExecutionStatus(any(Cookies.class), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mExportApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(cancelledStatus()); when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); ExecutionStatus execStatus = useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); @@ -120,13 +117,13 @@ public void testCheckExportExecutionStatusOnServer5_5() throws Exception { @Test public void testCheckExportExecutionStatusOnServer5_6() throws Exception { - when(mExportApi.checkExportExecutionStatus(any(Cookies.class), anyString(), anyString())).thenReturn(cancelledStatus()); + when(mExportApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(cancelledStatus()); when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); - verify(mExportApi).checkExportExecutionStatus(eq(fakeCookies), eq(EXEC_ID), eq(EXPORT_ID)); + verify(mExportApi).checkExportExecutionStatus(eq(EXEC_ID), eq(EXPORT_ID)); } @Test @@ -134,7 +131,7 @@ public void testRequestExportAttachmentOutputOnServer5_5() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); - verify(mExportApi).requestExportAttachment(eq(fakeCookies), eq(EXEC_ID), eq(LEGACY_EXPORT_ID), eq("nay")); + verify(mExportApi).requestExportAttachment(eq(EXEC_ID), eq(LEGACY_EXPORT_ID), eq("nay")); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); } @@ -144,7 +141,7 @@ public void testRequestExportAttachmentOutputOnServer5_6() throws Exception { when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); - verify(mExportApi).requestExportAttachment(eq(fakeCookies), eq(EXEC_ID), eq(EXPORT_ID), eq("nay")); + verify(mExportApi).requestExportAttachment(eq(EXEC_ID), eq(EXPORT_ID), eq("nay")); verify(mCacheManager).getInfo(); verify(mServerInfo).getVersion(); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index 9240df20..e14dd947 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.Cookies; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; @@ -76,7 +75,6 @@ public class SearchUseCaseTest { ResourceSearchResult mResult; private SearchUseCase objectUnderTest; - private final Cookies fakeCookies = Cookies.parse("key=value"); @Before public void setup() throws Exception { @@ -89,14 +87,14 @@ public void setup() throws Exception { mDataMapper, mRepositoryRestApi, mInfoCacheManager, - new FakeCallExecutor(fakeCookies) + new FakeCallExecutor() ); } @Test public void shouldProvideAndAdaptSearchResult() throws Exception { when(mResult.getNextOffset()).thenReturn(100); - when(mRepositoryRestApi.searchResources(any(Cookies.class), anyMap())).thenReturn(mResult); + when(mRepositoryRestApi.searchResources(anyMap())).thenReturn(mResult); Collection resources = new ArrayList(); when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); @@ -106,6 +104,6 @@ public void shouldProvideAndAdaptSearchResult() throws Exception { assertThat(result.getNextOffset(), is(100)); assertThat(result.getResources(), is(resources)); - verify(mRepositoryRestApi).searchResources(any(Cookies.class), anyMap()); + verify(mRepositoryRestApi).searchResources(anyMap()); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java b/core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java deleted file mode 100644 index b7074e95..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/TestLogger.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.test; - -import com.jaspersoft.android.sdk.network.RestApiLog; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class TestLogger implements RestApiLog { - - private final Logger logger; - - private TestLogger(String logTarget) { - logger = Logger.getLogger(logTarget); - } - - public static TestLogger get(Object target) { - return new TestLogger(target.getClass().getSimpleName()); - } - - @Override - public void log(String message) { - logger.log(Level.INFO, message); - } -} From da4e2874139cf3a14f9c835edc9479fb95316436 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 14:50:25 +0200 Subject: [PATCH 369/457] Extend clien/server configuration API --- ...actory.java => AuthenticationHandler.java} | 46 +++++++++----- .../sdk/network/AuthenticationRestApi.java | 15 ++--- .../network/AuthorizedAuthClientState.java | 58 +++++++---------- .../android/sdk/network/Client.java | 57 +++++++++++++---- .../sdk/network/HttpClientFactory.java | 43 ------------- .../android/sdk/network/Server.java | 62 +++++++++++++------ 6 files changed, 143 insertions(+), 138 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/network/{RetrofitFactory.java => AuthenticationHandler.java} (53%) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationHandler.java similarity index 53% rename from core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationHandler.java index 4bd503c0..618291c9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RetrofitFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationHandler.java @@ -24,31 +24,43 @@ package com.jaspersoft.android.sdk.network; -import com.google.gson.Gson; -import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; -import org.jetbrains.annotations.TestOnly; -import retrofit.Retrofit; +import com.squareup.okhttp.Authenticator; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + +import java.io.IOException; +import java.net.Proxy; /** * @author Tom Koptel * @since 2.0 */ -final class RetrofitFactory { - private final Server mServer; +final class AuthenticationHandler implements Authenticator { + private final Client mClient; + + AuthenticationHandler(Client client) { + mClient = client; + } - @TestOnly - RetrofitFactory(Server server) { - mServer = server; + public void authenticate() throws IOException, HttpException { + Server server = mClient.getServer(); + Credentials credentials = mClient.getCredentials(); + AuthStrategy authStrategy = new AuthStrategy(server); + credentials.apply(authStrategy); } - public Retrofit.Builder newRetrofit() { - Gson configuredGson = GsonFactory.create(); - GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); - StringConverterFactory stringConverterFactory = StringConverterFactory.create(); + @Override + public Request authenticate(Proxy proxy, Response response) throws IOException { + try { + authenticate(); + return response.request(); + } catch (HttpException code) { + return null; + } + } - return new Retrofit.Builder() - .baseUrl(mServer.getBaseUrl()) - .addConverterFactory(gsonConverterFactory) - .addConverterFactory(stringConverterFactory); + @Override + public Request authenticateProxy(Proxy proxy, Response response) throws IOException { + return null; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 181b0e20..2fce0d81 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -52,17 +52,15 @@ class AuthenticationRestApi { mServer = server; } - @NotNull public void springAuth(@NotNull final String username, @NotNull final String password, final String organization, final Map params) throws HttpException, IOException { - HttpClientFactory clientFactory = mServer.getClientFactory(); - OkHttpClient okHttpClient = clientFactory.newHttpClient(); - okHttpClient.setFollowRedirects(false); + OkHttpClient client = new OkHttpClient(); + client.setFollowRedirects(false); Request request = createAuthRequest(username, password, organization, params); - Call call = okHttpClient.newCall(request); + Call call = client.newCall(request); com.squareup.okhttp.Response response = call.execute(); @@ -88,11 +86,10 @@ public void springAuth(@NotNull final String username, @NotNull public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { - RetrofitFactory retrofitFactory = mServer.getRetrofitFactory(); - HttpClientFactory clientFactory = mServer.getClientFactory(); - OkHttpClient client = clientFactory.newHttpClient(); + OkHttpClient client = new OkHttpClient(); client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); - Retrofit retrofit = retrofitFactory.newRetrofit() + + Retrofit retrofit = mServer.newRetrofit() .client(client) .build(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index 60a9847a..f3c0c63a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -24,14 +24,11 @@ package com.jaspersoft.android.sdk.network; -import com.squareup.okhttp.Authenticator; import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.Response; import retrofit.Retrofit; import java.io.IOException; -import java.net.Proxy; +import java.util.concurrent.TimeUnit; /** * @author Tom Koptel @@ -41,6 +38,7 @@ final class AuthorizedAuthClientState implements AuthClientState { private Retrofit mRetrofit; private Client mClient; + private AuthenticationHandler mAuthenticationHandler; private ReportExecutionRestApi mReportExecutionRestApi; private ReportExportRestApi mReportExportRestApi; @@ -51,14 +49,8 @@ final class AuthorizedAuthClientState implements AuthClientState { @Override public void connect(Client context) throws IOException, HttpException { mClient = context; - makeAuthCall(); - } - - private void makeAuthCall() throws IOException, HttpException { - Server server = mClient.mServer; - Credentials credentials = mClient.credentials; - AuthStrategy authStrategy = new AuthStrategy(server); - credentials.apply(authStrategy); + mAuthenticationHandler = new AuthenticationHandler(context); + mAuthenticationHandler.authenticate(); } @Override @@ -101,15 +93,13 @@ public RepositoryRestApi makeRepositoryRestApi() { return mRepositoryRestApi; } - Retrofit getRetrofit() { + private Retrofit getRetrofit() { if (mRetrofit == null) { - RetrofitFactory retrofitFactory = new RetrofitFactory(mClient.mServer); - Retrofit.Builder builder = retrofitFactory.newRetrofit(); - OkHttpClient okHttpClient = configureOkHttp(); - builder.client(okHttpClient); - - mRetrofit = builder.build(); + Server server = mClient.getServer(); + mRetrofit = server.newRetrofit() + .client(okHttpClient) + .build(); } return mRetrofit; @@ -117,24 +107,20 @@ Retrofit getRetrofit() { private OkHttpClient configureOkHttp() { OkHttpClient okHttpClient = new OkHttpClient(); - if (mClient.authenticationPolicy == AuthPolicy.RETRY) { - okHttpClient.setAuthenticator(new Authenticator() { - @Override - public Request authenticate(Proxy proxy, Response response) throws IOException { - try { - makeAuthCall(); - } catch (HttpException code) { - return null; - } - return null; - } - - @Override - public Request authenticateProxy(Proxy proxy, Response response) throws IOException { - return null; - } - }); + if (mClient.getAuthPolicy() == AuthPolicy.RETRY) { + okHttpClient.setAuthenticator(mAuthenticationHandler); } + okHttpClient.setCookieHandler(mClient.getCookieHandler()); + + Server server = mClient.getServer(); + okHttpClient.setConnectTimeout(server.getConnectTimeout(), TimeUnit.MILLISECONDS); + okHttpClient.setReadTimeout(server.getReadTimeout(), TimeUnit.MILLISECONDS); + okHttpClient.setWriteTimeout(server.getWriteTimeout(), TimeUnit.MILLISECONDS); + + if (server.getProxy() != null) { + okHttpClient.setProxy(server.getProxy()); + } + return okHttpClient; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index 87bc7be0..514ba6f6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -27,24 +27,32 @@ import org.jetbrains.annotations.TestOnly; import java.io.IOException; +import java.net.CookieHandler; +import java.net.CookieManager; +import java.net.CookiePolicy; /** * @author Tom Koptel * @since 2.0 */ public final class Client { - final Server mServer; - final Credentials credentials; - final AuthPolicy authenticationPolicy; + private final Server mServer; + private final Credentials mCredentials; + private final AuthPolicy mAuthPolicy; + private final CookieHandler mCookieHandler; private AuthClientState mAuthClientState; @TestOnly - Client(Server server, Credentials credentials, AuthPolicy authenticationPolicy, AuthClientState authClientState) { + Client(Server server, + Credentials credentials, + AuthPolicy authPolicy, + CookieHandler cookieHandler, + AuthClientState authClientState) { mServer = server; - this.credentials = credentials; - this.authenticationPolicy = authenticationPolicy; - + mCredentials = credentials; + mAuthPolicy = authPolicy; + mCookieHandler = cookieHandler; mAuthClientState = authClientState; } @@ -72,19 +80,32 @@ public RepositoryRestApi repositoryApi() { return mAuthClientState.makeRepositoryRestApi(); } - void setAuthClientState(AuthClientState authClientState) { - mAuthClientState = authClientState; - } - public Server getServer() { return mServer; } + public Credentials getCredentials() { + return mCredentials; + } + + public AuthPolicy getAuthPolicy() { + return mAuthPolicy; + } + + public CookieHandler getCookieHandler() { + return mCookieHandler; + } + + void setAuthClientState(AuthClientState authClientState) { + mAuthClientState = authClientState; + } + public static class Builder { private final Server mServer; private final Credentials mCredentials; private AuthPolicy mAuthenticationPolicy; + private CookieHandler mCookieHandler; Builder(Server server, Credentials credentials) { mServer = server; @@ -96,14 +117,24 @@ public Builder withAuthenticationPolicy(AuthPolicy authenticationPolicy) { return this; } + public Builder withCookieHandler(CookieHandler cookieHandler) { + mCookieHandler = cookieHandler; + return this; + } + public Client create() { ensureSaneDefaults(); AuthClientState state = new InitialAuthClientState(); - return new Client(mServer, mCredentials, mAuthenticationPolicy, state); + return new Client(mServer, mCredentials, mAuthenticationPolicy, mCookieHandler, state); } private void ensureSaneDefaults() { - mAuthenticationPolicy = AuthPolicy.RETRY; + if (mAuthenticationPolicy == null) { + mAuthenticationPolicy = AuthPolicy.RETRY; + } + if (mCookieHandler == null) { + mCookieHandler = new CookieManager(null, CookiePolicy.ACCEPT_ALL); + } } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java deleted file mode 100644 index bf462d26..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/HttpClientFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.squareup.okhttp.OkHttpClient; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class HttpClientFactory { - private final Server mServer; - - HttpClientFactory(Server server) { - mServer = server; - } - - public OkHttpClient newHttpClient() { - return new OkHttpClient(); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index f8975cd7..9e6abba1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -24,8 +24,11 @@ package com.jaspersoft.android.sdk.network; +import com.google.gson.Gson; +import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import retrofit.Retrofit; +import java.net.Proxy; import java.util.concurrent.TimeUnit; /** @@ -34,27 +37,28 @@ */ public final class Server { private final String mBaseUrl; + private final Proxy mProxy; private final long mConnectTimeout; private final long mReadTimeout; - - private RetrofitFactory mRetrofitFactory; - private HttpClientFactory mHttpClientFactory; + private final long mWriteTimeout; private ServerRestApi mServerRestApi; - private Server(String baseUrl, long connectTimeout, long readTimeout) { + private Server(String baseUrl, + Proxy proxy, + long connectTimeout, + long readTimeout, + long writeTimeout) { mBaseUrl = baseUrl; + mProxy = proxy; mConnectTimeout = connectTimeout; mReadTimeout = readTimeout; + mWriteTimeout = writeTimeout; } public ServerRestApi infoApi() { if (mServerRestApi == null) { - Retrofit retrofit = getRetrofitFactory() - .newRetrofit() - .build(); - - mServerRestApi = new ServerRestApiImpl(retrofit); + mServerRestApi = new ServerRestApiImpl(newRetrofit().build()); } return mServerRestApi; } @@ -79,18 +83,23 @@ public long getReadTimeout() { return mReadTimeout; } - RetrofitFactory getRetrofitFactory() { - if (mRetrofitFactory == null) { - mRetrofitFactory = new RetrofitFactory(this); - } - return mRetrofitFactory; + public long getWriteTimeout() { + return mWriteTimeout; } - HttpClientFactory getClientFactory() { - if (mHttpClientFactory == null) { - mHttpClientFactory = new HttpClientFactory(this); - } - return mHttpClientFactory; + public Proxy getProxy() { + return mProxy; + } + + Retrofit.Builder newRetrofit() { + Gson configuredGson = GsonFactory.create(); + GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); + StringConverterFactory stringConverterFactory = StringConverterFactory.create(); + + return new Retrofit.Builder() + .baseUrl(mBaseUrl) + .addConverterFactory(gsonConverterFactory) + .addConverterFactory(stringConverterFactory); } public static class GenericBuilder { @@ -102,8 +111,11 @@ public OptionalBuilder withBaseUrl(String baseUrl) { public static class OptionalBuilder { private final String mBaseUrl; + private Proxy mProxy; + private long connectTimeout = 10000; private long readTimeout = 10000; + private long writeTimeout = 10000; private OptionalBuilder(String baseUrl) { mBaseUrl = baseUrl; @@ -119,8 +131,18 @@ public OptionalBuilder withReadTimeout(long timeout, TimeUnit unit) { return this; } + public OptionalBuilder withWriteTimeout(long timeout, TimeUnit unit) { + writeTimeout = unit.toMillis(timeout); + return this; + } + + public OptionalBuilder withProxy(Proxy proxy) { + mProxy = proxy; + return this; + } + public Server create() { - return new Server(mBaseUrl, connectTimeout, readTimeout); + return new Server(mBaseUrl, mProxy, connectTimeout, readTimeout, writeTimeout); } } } From ec1f9d0fc945d3297377f2c94ab725be0f70d313 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 21 Dec 2015 15:00:57 +0200 Subject: [PATCH 370/457] Fix broken ServerRestApi --- .../network/AuthorizedAuthClientState.java | 14 ++----------- .../android/sdk/network/Server.java | 21 ++++++++++++++++--- .../sdk/test/integration/api/LazyClient.java | 17 ++++++++++----- .../test/integration/api/ServerRestTest.java | 6 +----- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java index f3c0c63a..083f897f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java @@ -28,7 +28,6 @@ import retrofit.Retrofit; import java.io.IOException; -import java.util.concurrent.TimeUnit; /** * @author Tom Koptel @@ -106,21 +105,12 @@ private Retrofit getRetrofit() { } private OkHttpClient configureOkHttp() { - OkHttpClient okHttpClient = new OkHttpClient(); + Server server = mClient.getServer(); + OkHttpClient okHttpClient = server.newOkHttp(); if (mClient.getAuthPolicy() == AuthPolicy.RETRY) { okHttpClient.setAuthenticator(mAuthenticationHandler); } okHttpClient.setCookieHandler(mClient.getCookieHandler()); - - Server server = mClient.getServer(); - okHttpClient.setConnectTimeout(server.getConnectTimeout(), TimeUnit.MILLISECONDS); - okHttpClient.setReadTimeout(server.getReadTimeout(), TimeUnit.MILLISECONDS); - okHttpClient.setWriteTimeout(server.getWriteTimeout(), TimeUnit.MILLISECONDS); - - if (server.getProxy() != null) { - okHttpClient.setProxy(server.getProxy()); - } - return okHttpClient; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index 9e6abba1..e14c5099 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -26,6 +26,7 @@ import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; +import com.squareup.okhttp.OkHttpClient; import retrofit.Retrofit; import java.net.Proxy; @@ -58,7 +59,10 @@ private Server(String baseUrl, public ServerRestApi infoApi() { if (mServerRestApi == null) { - mServerRestApi = new ServerRestApiImpl(newRetrofit().build()); + Retrofit retrofit = newRetrofit() + .client(newOkHttp()) + .build(); + mServerRestApi = new ServerRestApiImpl(retrofit); } return mServerRestApi; } @@ -98,8 +102,19 @@ Retrofit.Builder newRetrofit() { return new Retrofit.Builder() .baseUrl(mBaseUrl) - .addConverterFactory(gsonConverterFactory) - .addConverterFactory(stringConverterFactory); + .addConverterFactory(stringConverterFactory) + .addConverterFactory(gsonConverterFactory); + } + + OkHttpClient newOkHttp() { + OkHttpClient okHttpClient = new OkHttpClient(); + okHttpClient.setConnectTimeout(mConnectTimeout, TimeUnit.MILLISECONDS); + okHttpClient.setReadTimeout(mReadTimeout, TimeUnit.MILLISECONDS); + okHttpClient.setWriteTimeout(mWriteTimeout, TimeUnit.MILLISECONDS); + if (mProxy != null) { + okHttpClient.setProxy(mProxy); + } + return okHttpClient; } public static class GenericBuilder { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java index 77ceec68..c7b2cbee 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java @@ -25,10 +25,12 @@ package com.jaspersoft.android.sdk.test.integration.api; import com.jaspersoft.android.sdk.network.Client; -import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.Server; import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Proxy; /** * @author Tom Koptel @@ -42,12 +44,17 @@ public LazyClient(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; } + public static Server getServer(String serverUrl) { + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("0.0.0.0", 8888)); + return Server.newBuilder() + .withBaseUrl(serverUrl) + .withProxy(proxy) + .create(); + } + public Client get() { if (mClient == null) { - Server server = Server.newBuilder() - .withBaseUrl(mJrsMetadata.getServerUrl()) - .create(); - mClient = server.makeAuthorizedClient(mJrsMetadata.getCredentials()) + mClient = getServer(mJrsMetadata.getServerUrl()).makeAuthorizedClient(mJrsMetadata.getCredentials()) .create(); try { mClient.connect(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index c55a56c4..f70a1d40 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import org.junit.Before; @@ -47,10 +46,7 @@ public class ServerRestTest { @Before public void setup() { if (apiUnderTest == null) { - Server server = Server.newBuilder() - .withBaseUrl(mobileDemo2) - .create(); - apiUnderTest = server.infoApi(); + apiUnderTest = LazyClient.getServer(mobileDemo2).infoApi(); } } From 1b1c30c978c3555802e44c3ff944acb2faca1646 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Dec 2015 12:28:41 +0100 Subject: [PATCH 371/457] Revise server abstarction/reintroduce specific clients --- ...thClientState.java => AbstractClient.java} | 20 +- .../android/sdk/network/AnonymousClient.java | 33 +++ .../AnonymousClientImpl.java} | 22 +- .../sdk/network/AuthenticationRestApi.java | 2 +- .../android/sdk/network/AuthorizedClient.java | 42 ++++ ...ntState.java => AuthorizedClientImpl.java} | 64 ++---- .../android/sdk/network/Client.java | 111 +---------- ...ler.java => RecoverableAuthenticator.java} | 22 +- .../android/sdk/network/Server.java | 188 +++++++++++------- ...tate.java => SingleTimeAuthenticator.java} | 44 ++-- .../android/sdk/service/RestClient.java | 125 ------------ .../android/sdk/service/Session.java | 66 ------ .../service/internal/InfoCacheManager.java | 8 +- .../sdk/service/report/ReportService.java | 10 +- .../service/repository/RepositoryService.java | 6 +- .../sdk/service/server/ServerInfoService.java | 6 +- .../network/AuthenticationRestApiTest.java | 2 +- .../api/InputControlRestApiTest.java | 4 +- .../sdk/test/integration/api/LazyClient.java | 18 +- .../api/ReportExecutionRestApiTest.java | 4 +- .../api/ReportExportRestApiTest.java | 4 +- .../api/ReportOptionRestApiTest.java | 4 +- .../api/RepositoryRestApiTest.java | 4 +- .../test/integration/api/ServerRestTest.java | 6 +- 24 files changed, 298 insertions(+), 517 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/network/{AuthClientState.java => AbstractClient.java} (75%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java rename core/src/main/java/com/jaspersoft/android/sdk/{service/AnonymousSession.java => network/AnonymousClientImpl.java} (69%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java rename core/src/main/java/com/jaspersoft/android/sdk/network/{AuthorizedAuthClientState.java => AuthorizedClientImpl.java} (51%) rename core/src/main/java/com/jaspersoft/android/sdk/network/{AuthenticationHandler.java => RecoverableAuthenticator.java} (79%) rename core/src/main/java/com/jaspersoft/android/sdk/network/{InitialAuthClientState.java => SingleTimeAuthenticator.java} (54%) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/Session.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AbstractClient.java similarity index 75% rename from core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AbstractClient.java index e65bdb3d..a6ac7f5d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AbstractClient.java @@ -24,17 +24,21 @@ package com.jaspersoft.android.sdk.network; -import java.io.IOException; +import retrofit.Retrofit; /** * @author Tom Koptel * @since 2.0 */ -interface AuthClientState { - void connect(Client context) throws IOException, HttpException; - ReportExecutionRestApi makeReportExecutionApi(); - ReportExportRestApi makeReportExportRestApi(); - ReportOptionRestApi makeReportOptionRestApi(); - InputControlRestApi makeInputControlRestApi(); - RepositoryRestApi makeRepositoryRestApi(); +abstract class AbstractClient implements Client { + protected final Retrofit mRetrofit; + + protected AbstractClient(Retrofit retrofit) { + mRetrofit = retrofit; + } + + @Override + public String getBaseUrl() { + return mRetrofit.baseUrl().url().toString(); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java new file mode 100644 index 00000000..9abdadd8 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface AnonymousClient extends Client { + ServerRestApi infoApi(); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java similarity index 69% rename from core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java index 015e9eb8..15ee2fa8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/AnonymousSession.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java @@ -22,25 +22,25 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.Client; -import com.jaspersoft.android.sdk.service.server.ServerInfoService; -import org.jetbrains.annotations.NotNull; +import retrofit.Retrofit; /** * @author Tom Koptel * @since 2.0 */ -public class AnonymousSession { - protected final Client mClient; +final class AnonymousClientImpl extends AbstractClient implements AnonymousClient { + private ServerRestApiImpl mServerRestApi; - protected AnonymousSession(Client client) { - mClient = client; + AnonymousClientImpl(Retrofit retrofit) { + super(retrofit); } - @NotNull - public final ServerInfoService infoApi() { - throw new UnsupportedOperationException("Not yet implemented"); + public ServerRestApi infoApi() { + if (mServerRestApi == null) { + mServerRestApi = new ServerRestApiImpl(mRetrofit); + } + return mServerRestApi; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 2fce0d81..cb7210ae 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -56,7 +56,7 @@ public void springAuth(@NotNull final String username, @NotNull final String password, final String organization, final Map params) throws HttpException, IOException { - OkHttpClient client = new OkHttpClient(); + OkHttpClient client = mServer.getClient(); client.setFollowRedirects(false); Request request = createAuthRequest(username, password, organization, params); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java new file mode 100644 index 00000000..16f415c8 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -0,0 +1,42 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface AuthorizedClient extends AnonymousClient { + + ReportExecutionRestApi reportExecutionApi(); + + ReportExportRestApi reportExportApi(); + + ReportOptionRestApi reportOptionsApi(); + + InputControlRestApi inputControlApi(); + + RepositoryRestApi repositoryApi(); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java similarity index 51% rename from core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java index 083f897f..63c7c926 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java @@ -24,20 +24,15 @@ package com.jaspersoft.android.sdk.network; -import com.squareup.okhttp.OkHttpClient; import retrofit.Retrofit; -import java.io.IOException; - /** * @author Tom Koptel * @since 2.0 */ -final class AuthorizedAuthClientState implements AuthClientState { +final class AuthorizedClientImpl extends AbstractClient implements AuthorizedClient { - private Retrofit mRetrofit; - private Client mClient; - private AuthenticationHandler mAuthenticationHandler; + private final AnonymousClient mAnonymousClient; private ReportExecutionRestApi mReportExecutionRestApi; private ReportExportRestApi mReportExportRestApi; @@ -45,72 +40,47 @@ final class AuthorizedAuthClientState implements AuthClientState { private InputControlRestApi mInputControlRestApi; private RepositoryRestApi mRepositoryRestApi; - @Override - public void connect(Client context) throws IOException, HttpException { - mClient = context; - mAuthenticationHandler = new AuthenticationHandler(context); - mAuthenticationHandler.authenticate(); + AuthorizedClientImpl(Retrofit retrofit, AnonymousClient anonymousClient) { + super(retrofit); + mAnonymousClient = anonymousClient; } - @Override - public ReportExecutionRestApi makeReportExecutionApi() { + public ReportExecutionRestApi reportExecutionApi() { if (mReportExecutionRestApi == null) { - mReportExecutionRestApi = new ReportExecutionRestApiImpl(getRetrofit()); + mReportExecutionRestApi = new ReportExecutionRestApiImpl(mRetrofit); } return mReportExecutionRestApi; } - @Override - public ReportExportRestApi makeReportExportRestApi() { + public ReportExportRestApi reportExportApi() { if (mReportExportRestApi == null) { - mReportExportRestApi = new ReportExportRestApiImpl(getRetrofit()); + mReportExportRestApi = new ReportExportRestApiImpl(mRetrofit); } return mReportExportRestApi; } - @Override - public ReportOptionRestApi makeReportOptionRestApi() { + public ReportOptionRestApi reportOptionsApi() { if (mReportOptionRestApi == null) { - mReportOptionRestApi = new ReportOptionRestApiImpl(getRetrofit()); + mReportOptionRestApi = new ReportOptionRestApiImpl(mRetrofit); } return mReportOptionRestApi; } - @Override - public InputControlRestApi makeInputControlRestApi() { + public InputControlRestApi inputControlApi() { if (mInputControlRestApi == null) { - mInputControlRestApi = new InputControlRestApiImpl(getRetrofit()); + mInputControlRestApi = new InputControlRestApiImpl(mRetrofit); } return mInputControlRestApi; } - @Override - public RepositoryRestApi makeRepositoryRestApi() { + public RepositoryRestApi repositoryApi() { if (mRepositoryRestApi == null) { - mRepositoryRestApi = new RepositoryRestApiImpl(getRetrofit()); + mRepositoryRestApi = new RepositoryRestApiImpl(mRetrofit); } return mRepositoryRestApi; } - private Retrofit getRetrofit() { - if (mRetrofit == null) { - OkHttpClient okHttpClient = configureOkHttp(); - Server server = mClient.getServer(); - mRetrofit = server.newRetrofit() - .client(okHttpClient) - .build(); - } - - return mRetrofit; - } - - private OkHttpClient configureOkHttp() { - Server server = mClient.getServer(); - OkHttpClient okHttpClient = server.newOkHttp(); - if (mClient.getAuthPolicy() == AuthPolicy.RETRY) { - okHttpClient.setAuthenticator(mAuthenticationHandler); - } - okHttpClient.setCookieHandler(mClient.getCookieHandler()); - return okHttpClient; + public ServerRestApi infoApi() { + return mAnonymousClient.infoApi(); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index 514ba6f6..3e950d1d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -24,117 +24,10 @@ package com.jaspersoft.android.sdk.network; -import org.jetbrains.annotations.TestOnly; - -import java.io.IOException; -import java.net.CookieHandler; -import java.net.CookieManager; -import java.net.CookiePolicy; - /** * @author Tom Koptel * @since 2.0 */ -public final class Client { - private final Server mServer; - private final Credentials mCredentials; - private final AuthPolicy mAuthPolicy; - private final CookieHandler mCookieHandler; - - private AuthClientState mAuthClientState; - - @TestOnly - Client(Server server, - Credentials credentials, - AuthPolicy authPolicy, - CookieHandler cookieHandler, - AuthClientState authClientState) { - mServer = server; - mCredentials = credentials; - mAuthPolicy = authPolicy; - mCookieHandler = cookieHandler; - mAuthClientState = authClientState; - } - - public void connect() throws IOException, HttpException { - mAuthClientState.connect(this); - } - - public ReportExecutionRestApi reportExecutionApi() { - return mAuthClientState.makeReportExecutionApi(); - } - - public ReportExportRestApi reportExportApi() { - return mAuthClientState.makeReportExportRestApi(); - } - - public ReportOptionRestApi reportOptionsApi() { - return mAuthClientState.makeReportOptionRestApi(); - } - - public InputControlRestApi inputControlApi() { - return mAuthClientState.makeInputControlRestApi(); - } - - public RepositoryRestApi repositoryApi() { - return mAuthClientState.makeRepositoryRestApi(); - } - - public Server getServer() { - return mServer; - } - - public Credentials getCredentials() { - return mCredentials; - } - - public AuthPolicy getAuthPolicy() { - return mAuthPolicy; - } - - public CookieHandler getCookieHandler() { - return mCookieHandler; - } - - void setAuthClientState(AuthClientState authClientState) { - mAuthClientState = authClientState; - } - - public static class Builder { - private final Server mServer; - private final Credentials mCredentials; - - private AuthPolicy mAuthenticationPolicy; - private CookieHandler mCookieHandler; - - Builder(Server server, Credentials credentials) { - mServer = server; - mCredentials = credentials; - } - - public Builder withAuthenticationPolicy(AuthPolicy authenticationPolicy) { - mAuthenticationPolicy = authenticationPolicy; - return this; - } - - public Builder withCookieHandler(CookieHandler cookieHandler) { - mCookieHandler = cookieHandler; - return this; - } - - public Client create() { - ensureSaneDefaults(); - AuthClientState state = new InitialAuthClientState(); - return new Client(mServer, mCredentials, mAuthenticationPolicy, mCookieHandler, state); - } - - private void ensureSaneDefaults() { - if (mAuthenticationPolicy == null) { - mAuthenticationPolicy = AuthPolicy.RETRY; - } - if (mCookieHandler == null) { - mCookieHandler = new CookieManager(null, CookiePolicy.ACCEPT_ALL); - } - } - } +public interface Client { + String getBaseUrl(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationHandler.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java similarity index 79% rename from core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationHandler.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java index 618291c9..c7af8aa9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationHandler.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java @@ -35,18 +35,13 @@ * @author Tom Koptel * @since 2.0 */ -final class AuthenticationHandler implements Authenticator { - private final Client mClient; +final class RecoverableAuthenticator implements Authenticator { + private final Server mServer; + private final Credentials mCredentials; - AuthenticationHandler(Client client) { - mClient = client; - } - - public void authenticate() throws IOException, HttpException { - Server server = mClient.getServer(); - Credentials credentials = mClient.getCredentials(); - AuthStrategy authStrategy = new AuthStrategy(server); - credentials.apply(authStrategy); + RecoverableAuthenticator(Server server, Credentials credentials) { + mServer = server; + mCredentials = credentials; } @Override @@ -63,4 +58,9 @@ public Request authenticate(Proxy proxy, Response response) throws IOException { public Request authenticateProxy(Proxy proxy, Response response) throws IOException { return null; } + + private void authenticate() throws IOException, HttpException { + AuthStrategy authStrategy = new AuthStrategy(mServer); + mCredentials.apply(authStrategy); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index e14c5099..f5943ec2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -26,9 +26,13 @@ import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; -import com.squareup.okhttp.OkHttpClient; +import com.squareup.okhttp.*; import retrofit.Retrofit; +import java.io.IOException; +import java.net.CookieHandler; +import java.net.CookieManager; +import java.net.CookiePolicy; import java.net.Proxy; import java.util.concurrent.TimeUnit; @@ -38,63 +42,29 @@ */ public final class Server { private final String mBaseUrl; - private final Proxy mProxy; - private final long mConnectTimeout; - private final long mReadTimeout; - private final long mWriteTimeout; - - private ServerRestApi mServerRestApi; - - private Server(String baseUrl, - Proxy proxy, - long connectTimeout, - long readTimeout, - long writeTimeout) { - mBaseUrl = baseUrl; - mProxy = proxy; - mConnectTimeout = connectTimeout; - mReadTimeout = readTimeout; - mWriteTimeout = writeTimeout; - } + private final OkHttpClient mOkHttpClient; - public ServerRestApi infoApi() { - if (mServerRestApi == null) { - Retrofit retrofit = newRetrofit() - .client(newOkHttp()) - .build(); - mServerRestApi = new ServerRestApiImpl(retrofit); - } - return mServerRestApi; + private Server(String baseUrl, OkHttpClient okHttpClient) { + mBaseUrl = baseUrl; + mOkHttpClient = okHttpClient; } - public Client.Builder makeAuthorizedClient(Credentials credentials) { - return new Client.Builder(this, credentials); + public AnonymousClient newClient() { + return new AnonymousClientImpl( + newRetrofit() + .client(mOkHttpClient) + .build() + ); } - public static GenericBuilder newBuilder() { - return new GenericBuilder(); + public AuthorizedClientBuilder newClient(Credentials credentials) { + return new AuthorizedClientBuilder(this, credentials); } public String getBaseUrl() { return mBaseUrl; } - public long getConnectTimeout() { - return mConnectTimeout; - } - - public long getReadTimeout() { - return mReadTimeout; - } - - public long getWriteTimeout() { - return mWriteTimeout; - } - - public Proxy getProxy() { - return mProxy; - } - Retrofit.Builder newRetrofit() { Gson configuredGson = GsonFactory.create(); GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); @@ -106,18 +76,17 @@ Retrofit.Builder newRetrofit() { .addConverterFactory(gsonConverterFactory); } - OkHttpClient newOkHttp() { - OkHttpClient okHttpClient = new OkHttpClient(); - okHttpClient.setConnectTimeout(mConnectTimeout, TimeUnit.MILLISECONDS); - okHttpClient.setReadTimeout(mReadTimeout, TimeUnit.MILLISECONDS); - okHttpClient.setWriteTimeout(mWriteTimeout, TimeUnit.MILLISECONDS); - if (mProxy != null) { - okHttpClient.setProxy(mProxy); - } - return okHttpClient; + OkHttpClient getClient() { + return mOkHttpClient; + } + + public static Builder newBuilder() { + return new Builder(); } - public static class GenericBuilder { + public static class Builder { + private Builder() {} + public OptionalBuilder withBaseUrl(String baseUrl) { return new OptionalBuilder(baseUrl); } @@ -125,39 +94,116 @@ public OptionalBuilder withBaseUrl(String baseUrl) { public static class OptionalBuilder { private final String mBaseUrl; - - private Proxy mProxy; - - private long connectTimeout = 10000; - private long readTimeout = 10000; - private long writeTimeout = 10000; + private final OkHttpClient mOkHttpClient = new OkHttpClient(); private OptionalBuilder(String baseUrl) { mBaseUrl = baseUrl; } public OptionalBuilder withConnectionTimeOut(long timeout, TimeUnit unit) { - connectTimeout = unit.toMillis(timeout); + mOkHttpClient.setConnectTimeout(timeout, unit); return this; } public OptionalBuilder withReadTimeout(long timeout, TimeUnit unit) { - readTimeout = unit.toMillis(timeout); + mOkHttpClient.setReadTimeout(timeout, unit); return this; } - public OptionalBuilder withWriteTimeout(long timeout, TimeUnit unit) { - writeTimeout = unit.toMillis(timeout); + public OptionalBuilder withProxy(Proxy proxy) { + mOkHttpClient.setProxy(proxy); return this; } - public OptionalBuilder withProxy(Proxy proxy) { - mProxy = proxy; + public Server build() { + return new Server(mBaseUrl, mOkHttpClient); + } + } + + public static class AuthorizedClientBuilder { + private final Server mServer; + private final Credentials mCredentials; + + private AuthPolicy mAuthenticationPolicy; + private CookieHandler mCookieHandler; + + AuthorizedClientBuilder(Server server, Credentials credentials) { + mServer = server; + mCredentials = credentials; + } + + public AuthorizedClientBuilder withAuthenticationPolicy(AuthPolicy authenticationPolicy) { + mAuthenticationPolicy = authenticationPolicy; return this; } - public Server create() { - return new Server(mBaseUrl, mProxy, connectTimeout, readTimeout, writeTimeout); + public AuthorizedClientBuilder withCookieHandler(CookieHandler cookieHandler) { + mCookieHandler = cookieHandler; + return this; + } + + public AuthorizedClient create() { + ensureSaneDefaults(); + + OkHttpClient authClient = configureAuthClient(mServer.getClient().clone()); + OkHttpClient anonymClient = configureAnonymClient(mServer.getClient().clone()); + + Retrofit authRetrofit = mServer.newRetrofit() + .client(authClient) + .build(); + Retrofit anonymRetrofit = mServer.newRetrofit() + .client(anonymClient) + .build(); + + AnonymousClient anonymousClient = new AnonymousClientImpl(anonymRetrofit); + return new AuthorizedClientImpl(authRetrofit, anonymousClient); + } + + private OkHttpClient configureAnonymClient(OkHttpClient client) { + client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); + return client; + } + + private OkHttpClient configureAuthClient(OkHttpClient client) { + client.setCookieHandler(mCookieHandler); + + if (mAuthenticationPolicy == AuthPolicy.FAIL_FAST) { + client.interceptors().add(new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + Headers headers = chain.request().headers(); + boolean hasCookies = headers.names().contains("Cookie"); + if (!hasCookies) { + Response response401 = new Response.Builder() + .protocol(Protocol.HTTP_1_1) + .request(chain.request()) + .headers(chain.request().headers()) + .code(401) + .build(); + return response401; + } + return chain.proceed(chain.request()); + } + }); + + RecoverableAuthenticator recoverableAuthenticator = new RecoverableAuthenticator(mServer, mCredentials); + SingleTimeAuthenticator singleTimeAuthenticator = new SingleTimeAuthenticator(recoverableAuthenticator); + client.setAuthenticator(singleTimeAuthenticator); + } else { + RecoverableAuthenticator recoverableAuthenticator = new RecoverableAuthenticator(mServer, mCredentials); + client.setAuthenticator(recoverableAuthenticator); + } + + return client; + } + + private void ensureSaneDefaults() { + if (mAuthenticationPolicy == null) { + mAuthenticationPolicy = AuthPolicy.RETRY; + } + if (mCookieHandler == null) { + mCookieHandler = new CookieManager(null, CookiePolicy.ACCEPT_ALL); + } } } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SingleTimeAuthenticator.java similarity index 54% rename from core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/SingleTimeAuthenticator.java index a3ec08e8..76ca678b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InitialAuthClientState.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SingleTimeAuthenticator.java @@ -24,44 +24,36 @@ package com.jaspersoft.android.sdk.network; +import com.squareup.okhttp.Authenticator; +import com.squareup.okhttp.Request; +import com.squareup.okhttp.Response; + import java.io.IOException; +import java.net.Proxy; /** * @author Tom Koptel * @since 2.0 */ -final class InitialAuthClientState implements AuthClientState { - private static final String MESSAGE = "Unauthorized state. Please, connect client before usage"; - - @Override - public void connect(Client context) throws IOException, HttpException { - AuthClientState state = new AuthorizedAuthClientState(); - state.connect(context); - context.setAuthClientState(state); - } +final class SingleTimeAuthenticator implements Authenticator { + private Authenticator mDelegate; - @Override - public ReportExecutionRestApi makeReportExecutionApi() { - throw new IllegalStateException(MESSAGE); - } - - @Override - public ReportExportRestApi makeReportExportRestApi() { - throw new IllegalStateException(MESSAGE); - } - - @Override - public ReportOptionRestApi makeReportOptionRestApi() { - throw new IllegalStateException(MESSAGE); + public SingleTimeAuthenticator(Authenticator delegate) { + mDelegate = delegate; } @Override - public InputControlRestApi makeInputControlRestApi() { - throw new IllegalStateException(MESSAGE); + public Request authenticate(Proxy proxy, Response response) throws IOException { + if (mDelegate != null) { + Request request = mDelegate.authenticate(proxy, response); + mDelegate = null; + return request; + } + return null; } @Override - public RepositoryRestApi makeRepositoryRestApi() { - throw new IllegalStateException(MESSAGE); + public Request authenticateProxy(Proxy proxy, Response response) throws IOException { + return null; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java b/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java deleted file mode 100644 index a4a2aac5..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/RestClient.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.network.Client; -import com.jaspersoft.android.sdk.network.Credentials; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.Server; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; -import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; - -import java.io.IOException; -import java.util.concurrent.TimeUnit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class RestClient { - private final Server mServer; - private final InfoCache mInfoCache; - - private RestClient(Server server, InfoCache infoCache) { - mServer = server; - mInfoCache = infoCache; - } - - public String getServerUrl() { - return mServer.getBaseUrl(); - } - - public long getReadTimeOut() { - return mServer.getReadTimeout(); - } - - public long getConnectionTimeOut() { - return mServer.getConnectTimeout(); - } - - public InfoCache getInfoCache() { - return mInfoCache; - } - - public Session authorize(Credentials credentials) throws ServiceException { - DefaultExceptionMapper exceptionMapper = new DefaultExceptionMapper(); - Client client = mServer.makeAuthorizedClient(credentials).create(); - try { - client.connect(); - } catch (IOException e) { - throw exceptionMapper.transform(e); - } catch (HttpException e) { - throw exceptionMapper.transform(e); - } - return new Session(client, mInfoCache); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Builder() { - } - - public ConditionalBuilder serverUrl(String serverUrl) { - return new ConditionalBuilder(serverUrl); - } - } - - public static class ConditionalBuilder { - private final Server.OptionalBuilder mServerBuilder; - private InfoCache mInfoCache; - - private ConditionalBuilder(String serverUrl) { - mServerBuilder = Server.newBuilder().withBaseUrl(serverUrl); - } - - public ConditionalBuilder withReadTimeout(int timeOut, TimeUnit unit) { - mServerBuilder.withReadTimeout(timeOut, unit); - return this; - } - - public ConditionalBuilder withConnectionTimeOut(int timeOut, TimeUnit unit) { - mServerBuilder.withConnectionTimeOut(timeOut, unit); - return this; - } - - public ConditionalBuilder withInfoCache(InfoCache infoCache) { - mInfoCache = infoCache; - return this; - } - - public RestClient create() { - if (mInfoCache == null) { - mInfoCache = new InMemoryInfoCache(); - } - Server server = mServerBuilder.create(); - return new RestClient(server, mInfoCache); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java b/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java deleted file mode 100644 index c22af53b..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/Session.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service; - -import com.jaspersoft.android.sdk.network.Client; -import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.report.ReportService; -import com.jaspersoft.android.sdk.service.repository.RepositoryService; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public final class Session extends AnonymousSession { - - private final InfoCache mInfoCache; - - private ReportService mReportService; - private RepositoryService mRepositoryService; - - @TestOnly - Session(Client client, InfoCache infoCache) { - super(client); - mInfoCache = infoCache; - } - - @NotNull - public ReportService reportApi() { - if (mReportService == null) { - mReportService = ReportService.create(mClient, mInfoCache); - } - return mReportService; - } - - @NotNull - public RepositoryService repositoryApi() { - if (mRepositoryService == null) { - mRepositoryService = RepositoryService.create(mClient, mInfoCache); - } - return mRepositoryService; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java index 7b60eaae..a806e4d6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.internal; -import com.jaspersoft.android.sdk.network.Server; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.info.InfoCache; @@ -47,9 +47,9 @@ public class InfoCacheManager { mInfoCache = infoCache; } - public static InfoCacheManager create(Server server, InfoCache cache) { - ServerInfoService serverInfoService = ServerInfoService.create(server); - String baseUrl = server.getBaseUrl(); + public static InfoCacheManager create(AuthorizedClient client, InfoCache cache) { + ServerInfoService serverInfoService = ServerInfoService.create(client); + String baseUrl = client.getBaseUrl(); return new InfoCacheManager(baseUrl, serverInfoService, cache); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 0a4607f5..2ef9a427 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -24,10 +24,9 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; @@ -63,7 +62,7 @@ public final class ReportService { mExportUseCase = exportUseCase; } - public static ReportService create(Client client, InfoCache infoCache) { + public static ReportService create(AuthorizedClient client, InfoCache infoCache) { ReportExecutionRestApi executionApi = client.reportExecutionApi(); ReportExportRestApi exportApi = client.reportExportApi(); @@ -71,10 +70,9 @@ public static ReportService create(Client client, InfoCache infoCache) { ServiceExceptionMapper reportExMapper = new ReportExceptionMapper(defaultExMapper); CallExecutor callExecutor = new DefaultCallExecutor(reportExMapper); - Server server = client.getServer(); - ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(server.getBaseUrl()); + ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getBaseUrl()); - InfoCacheManager cacheManager = InfoCacheManager.create(server, infoCache); + InfoCacheManager cacheManager = InfoCacheManager.create(client, infoCache); ReportExecutionUseCase reportExecutionUseCase = new ReportExecutionUseCase(executionApi, callExecutor, cacheManager, executionOptionsMapper); ReportExportUseCase reportExportUseCase = diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index bc43629b..edc4c75e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.info.InfoCache; import com.jaspersoft.android.sdk.service.internal.*; @@ -44,11 +44,11 @@ public class RepositoryService { mInfoCacheManager = infoCacheManager; } - public static RepositoryService create(Client client, InfoCache cache) { + public static RepositoryService create(AuthorizedClient client, InfoCache cache) { RepositoryRestApi repositoryRestApi = client.repositoryApi(); ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); CallExecutor callExecutor = new DefaultCallExecutor(defaultExMapper); - InfoCacheManager cacheManager = InfoCacheManager.create(client.getServer(), cache); + InfoCacheManager cacheManager = InfoCacheManager.create(client, cache); ResourceMapper resourceMapper = new ResourceMapper(); SearchUseCase searchUseCase = new SearchUseCase( diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java index 6b8deb97..beb0d545 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java @@ -24,8 +24,8 @@ package com.jaspersoft.android.sdk.service.server; +import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -54,9 +54,9 @@ public class ServerInfoService { mServiceExceptionMapper = serviceExceptionMapper; } - public static ServerInfoService create(Server server) { + public static ServerInfoService create(AnonymousClient client) { ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - return new ServerInfoService(server.infoApi(), ServerInfoTransformer.get(), serviceExceptionMapper); + return new ServerInfoService(client.infoApi(), ServerInfoTransformer.get(), serviceExceptionMapper); } public ServerInfo requestServerInfo() throws ServiceException { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index b983ae63..ebbd7c80 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -63,7 +63,7 @@ public void setup() { TestResourceInjector.inject(this); Server server = Server.newBuilder() .withBaseUrl(mWebMockRule.getRootUrl()) - .create(); + .build(); apiUnderTest = new AuthenticationRestApi(server); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 92bb76d8..a292a485 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; @@ -58,7 +58,7 @@ public class InputControlRestApiTest { @Before public void setUp() throws Exception { if (apiUnderTest == null) { - Client client = mLazyClient.get(); + AuthorizedClient client = mLazyClient.getAuthorizedClient(); apiUnderTest = client.inputControlApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java index c7b2cbee..5b066603 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java @@ -24,11 +24,9 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Client; -import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.Server; -import java.io.IOException; import java.net.InetSocketAddress; import java.net.Proxy; @@ -38,7 +36,7 @@ */ final class LazyClient { private final JrsMetadata mJrsMetadata; - private Client mClient; + private AuthorizedClient mClient; public LazyClient(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; @@ -49,18 +47,14 @@ public static Server getServer(String serverUrl) { return Server.newBuilder() .withBaseUrl(serverUrl) .withProxy(proxy) - .create(); + .build(); } - public Client get() { + public AuthorizedClient getAuthorizedClient() { if (mClient == null) { - mClient = getServer(mJrsMetadata.getServerUrl()).makeAuthorizedClient(mJrsMetadata.getCredentials()) + mClient = getServer(mJrsMetadata.getServerUrl()) + .newClient(mJrsMetadata.getCredentials()) .create(); - try { - mClient.connect(); - } catch (IOException | HttpException e) { - throw new RuntimeException(e); - } } return mClient; } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index b55c8289..c2155cb0 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; @@ -62,7 +62,7 @@ public class ReportExecutionRestApiTest { @Before public void setUp() throws Exception { if (apiUnderTest == null) { - Client client = mLazyClient.get(); + AuthorizedClient client = mLazyClient.getAuthorizedClient(); apiUnderTest = client.reportExecutionApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index bed476c1..9ea77072 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; @@ -55,7 +55,7 @@ public class ReportExportRestApiTest { @Before public void setup() { if (apiUnderTest == null) { - Client client = mLazyClient.get(); + AuthorizedClient client = mLazyClient.getAuthorizedClient(); mExecApi = client.reportExecutionApi(); apiUnderTest = client.reportExportApi(); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index 25c083db..da8220e4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import org.junit.Before; @@ -61,7 +61,7 @@ public class ReportOptionRestApiTest { @Before public void setup() { if (apiUnderTest == null) { - Client client = mLazyClient.get(); + AuthorizedClient client = mLazyClient.getAuthorizedClient(); apiUnderTest = client.reportOptionsApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index eebc8896..19e2b44a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.Client; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; @@ -52,7 +52,7 @@ public class RepositoryRestApiTest { @Before public void setup() { if (apiUnderTest == null) { - Client client = mLazyClient.get(); + AuthorizedClient client = mLazyClient.getAuthorizedClient(); apiUnderTest = client.repositoryApi(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index f70a1d40..bce43ae3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -39,14 +39,14 @@ * @since 2.0 */ public class ServerRestTest { - - private String mobileDemo2 = "http://mobiledemo2.jaspersoft.com/jasperserver-pro/"; private ServerRestApi apiUnderTest; + private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + @Before public void setup() { if (apiUnderTest == null) { - apiUnderTest = LazyClient.getServer(mobileDemo2).infoApi(); + apiUnderTest = mLazyClient.getAuthorizedClient().infoApi(); } } From 45c2fbc55499dcfbcdafbc7dbbc0b26d24ad94de Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Dec 2015 13:52:05 +0200 Subject: [PATCH 372/457] Configure anonymous client in single point --- .../android/sdk/network/Server.java | 28 ++++++++----------- .../sdk/test/integration/api/JrsMetadata.java | 4 +-- .../test/integration/api/ServerRestTest.java | 11 ++++---- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index f5943ec2..38944e2c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -50,11 +50,12 @@ private Server(String baseUrl, OkHttpClient okHttpClient) { } public AnonymousClient newClient() { - return new AnonymousClientImpl( - newRetrofit() - .client(mOkHttpClient) - .build() - ); + OkHttpClient anonymousClient = configureAnonymosClient(mOkHttpClient.clone()); + Retrofit anonymousRetrofit = newRetrofit() + .client(anonymousClient) + .build(); + + return new AnonymousClientImpl(anonymousRetrofit); } public AuthorizedClientBuilder newClient(Credentials credentials) { @@ -80,6 +81,11 @@ OkHttpClient getClient() { return mOkHttpClient; } + private OkHttpClient configureAnonymosClient(OkHttpClient client) { + client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); + return client; + } + public static Builder newBuilder() { return new Builder(); } @@ -144,26 +150,16 @@ public AuthorizedClientBuilder withCookieHandler(CookieHandler cookieHandler) { public AuthorizedClient create() { ensureSaneDefaults(); - OkHttpClient authClient = configureAuthClient(mServer.getClient().clone()); - OkHttpClient anonymClient = configureAnonymClient(mServer.getClient().clone()); Retrofit authRetrofit = mServer.newRetrofit() .client(authClient) .build(); - Retrofit anonymRetrofit = mServer.newRetrofit() - .client(anonymClient) - .build(); - AnonymousClient anonymousClient = new AnonymousClientImpl(anonymRetrofit); + AnonymousClient anonymousClient = mServer.newClient(); return new AuthorizedClientImpl(authRetrofit, anonymousClient); } - private OkHttpClient configureAnonymClient(OkHttpClient client) { - client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); - return client; - } - private OkHttpClient configureAuthClient(OkHttpClient client) { client.setCookieHandler(mCookieHandler); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java index dc8cb5b2..71d85719 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java @@ -51,7 +51,7 @@ private JrsMetadata(Builder builder) { public static JrsMetadata createMobileDemo() { return builder() .setOrganization("") - .setServerUrl("http://mobiledemo.jaspersoft.com/jasperserver-pro") + .setServerUrl("http://mobiledemo.jaspersoft.com/jasperserver-pro/") .setUsername("superuser") .setPassword("superuser") .build(); @@ -60,7 +60,7 @@ public static JrsMetadata createMobileDemo() { public static JrsMetadata createMobileDemo2() { return builder() .setOrganization("organization_1") - .setServerUrl("http://mobiledemo2.jaspersoft.com/jasperserver-pro") + .setServerUrl("http://mobiledemo2.jaspersoft.com/jasperserver-pro/") .setUsername("phoneuser") .setPassword("phoneuser") .build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index bce43ae3..0cb6234a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -27,7 +27,7 @@ import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import static org.hamcrest.core.Is.is; @@ -39,12 +39,11 @@ * @since 2.0 */ public class ServerRestTest { - private ServerRestApi apiUnderTest; + private static ServerRestApi apiUnderTest; + private final static LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); - private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); - - @Before - public void setup() { + @BeforeClass + public static void setup() { if (apiUnderTest == null) { apiUnderTest = mLazyClient.getAuthorizedClient().infoApi(); } From 8d19d8a11a9a2334c3845815d1105c1e396bc8e6 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Dec 2015 21:02:10 +0200 Subject: [PATCH 373/457] Fix auth chain for clients --- .../android/sdk/network/AuthStrategy.java | 10 +- .../sdk/network/AuthenticationRestApi.java | 25 +- .../sdk/network/InMemoryCookieStore.java | 390 ++++++++++++++++++ .../sdk/network/RecoverableAuthenticator.java | 18 +- .../android/sdk/network/Server.java | 98 ++--- .../network/AuthenticationRestApiTest.java | 9 +- .../sdk/network/TestCookieManager.java | 38 ++ .../api/InputControlRestApiTest.java | 10 +- .../sdk/test/integration/api/LazyClient.java | 2 + 9 files changed, 507 insertions(+), 93 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/TestCookieManager.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java index 6f7db8ac..49ac7cf8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java @@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import retrofit.Retrofit; import java.io.IOException; @@ -35,13 +36,12 @@ */ class AuthStrategy { @NotNull - private final Server mServer; - + private final Retrofit mRetrofit; @Nullable private SpringAuthService springAuthService; - AuthStrategy(@NotNull Server server) { - mServer = server; + AuthStrategy(@NotNull Retrofit retrofit) { + mRetrofit = retrofit; } void apply(SpringCredentials credentials) throws IOException, HttpException { @@ -52,7 +52,7 @@ void apply(SpringCredentials credentials) throws IOException, HttpException { } private SpringAuthService createSpringAuthService() { - AuthenticationRestApi restApi = new AuthenticationRestApi(mServer); + AuthenticationRestApi restApi = new AuthenticationRestApi(mRetrofit); JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); return new SpringAuthService(restApi, encryptionAlgorithm); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index cb7210ae..9646cfaf 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -33,8 +33,6 @@ import retrofit.http.Headers; import java.io.IOException; -import java.net.CookieManager; -import java.net.CookiePolicy; import java.util.Map; import java.util.Set; @@ -46,21 +44,18 @@ */ class AuthenticationRestApi { @NotNull - private final Server mServer; + private final Retrofit mRetrofit; - AuthenticationRestApi(@NotNull Server server) { - mServer = server; + AuthenticationRestApi(@NotNull Retrofit retrofit) { + mRetrofit = retrofit; } public void springAuth(@NotNull final String username, @NotNull final String password, final String organization, final Map params) throws HttpException, IOException { - OkHttpClient client = mServer.getClient(); - client.setFollowRedirects(false); - Request request = createAuthRequest(username, password, organization, params); - Call call = client.newCall(request); + Call call = mRetrofit.client().newCall(request); com.squareup.okhttp.Response response = call.execute(); @@ -86,14 +81,7 @@ public void springAuth(@NotNull final String username, @NotNull public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { - OkHttpClient client = new OkHttpClient(); - client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); - - Retrofit retrofit = mServer.newRetrofit() - .client(client) - .build(); - - RestApi api = retrofit.create(RestApi.class); + RestApi api = mRetrofit.create(RestApi.class); CallWrapper.wrap(api.requestAnonymousCookie()); try { @@ -134,8 +122,9 @@ private Request createAuthRequest( /** * Constructs url http[s]://some.jrs/j_spring_security_check */ + String baseUrl = mRetrofit.baseUrl().url().toString(); return new Request.Builder() - .url(mServer.getBaseUrl() + "j_spring_security_check") + .url(baseUrl + "j_spring_security_check") .post(formBody.build()) .build(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java new file mode 100644 index 00000000..417c5c51 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java @@ -0,0 +1,390 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import java.net.CookieStore; +import java.net.HttpCookie; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import java.util.concurrent.locks.ReentrantLock; + +/** + * Implementation cf {@link java.net.CookieStore} copied from internal sources. + * Used exclusively for anonymous session handling + */ +final class InMemoryCookieStore implements CookieStore { + // the in-memory representation of cookies + private List cookieJar = null; + + // the cookies are indexed by its domain and associated uri (if present) + // CAUTION: when a cookie removed from main data structure (i.e. cookieJar), + // it won't be cleared in domainIndex & uriIndex. Double-check the + // presence of cookie when retrieve one form index store. + private Map> domainIndex = null; + private Map> uriIndex = null; + + // use ReentrantLock instead of syncronized for scalability + private ReentrantLock lock = null; + + + /** + * The default ctor + */ + public InMemoryCookieStore() { + cookieJar = new ArrayList(); + domainIndex = new HashMap>(); + uriIndex = new HashMap>(); + + lock = new ReentrantLock(false); + } + + /** + * Add one cookie into cookie store. + */ + public void add(URI uri, HttpCookie cookie) { + // pre-condition : argument can't be null + if (cookie == null) { + throw new NullPointerException("cookie is null"); + } + + + lock.lock(); + try { + // remove the ole cookie if there has had one + cookieJar.remove(cookie); + + // add new cookie if it has a non-zero max-age + if (cookie.getMaxAge() != 0) { + cookieJar.add(cookie); + // and add it to domain index + if (cookie.getDomain() != null) { + addIndex(domainIndex, cookie.getDomain(), cookie); + } + if (uri != null) { + // add it to uri index, too + addIndex(uriIndex, getEffectiveURI(uri), cookie); + } + } + } finally { + lock.unlock(); + } + } + + + /** + * Get all cookies, which: + * 1) given uri domain-matches with, or, associated with + * given uri when added to the cookie store. + * 3) not expired. + * See RFC 2965 sec. 3.3.4 for more detail. + */ + public List get(URI uri) { + // argument can't be null + if (uri == null) { + throw new NullPointerException("uri is null"); + } + + List cookies = new ArrayList(); + boolean secureLink = "https".equalsIgnoreCase(uri.getScheme()); + lock.lock(); + try { + // check domainIndex first + getInternal1(cookies, domainIndex, uri.getHost(), secureLink); + // check uriIndex then + getInternal2(cookies, uriIndex, getEffectiveURI(uri), secureLink); + } finally { + lock.unlock(); + } + + return cookies; + } + + /** + * Get all cookies in cookie store, except those have expired + */ + public List getCookies() { + List rt; + + lock.lock(); + try { + Iterator it = cookieJar.iterator(); + while (it.hasNext()) { + if (it.next().hasExpired()) { + it.remove(); + } + } + } finally { + rt = Collections.unmodifiableList(cookieJar); + lock.unlock(); + } + + return rt; + } + + /** + * Get all URIs, which are associated with at least one cookie + * of this cookie store. + */ + public List getURIs() { + List uris = new ArrayList(); + + lock.lock(); + try { + Iterator it = uriIndex.keySet().iterator(); + while (it.hasNext()) { + URI uri = it.next(); + List cookies = uriIndex.get(uri); + if (cookies == null || cookies.size() == 0) { + // no cookies list or an empty list associated with + // this uri entry, delete it + it.remove(); + } + } + } finally { + uris.addAll(uriIndex.keySet()); + lock.unlock(); + } + + return uris; + } + + + /** + * Remove a cookie from store + */ + public boolean remove(URI uri, HttpCookie ck) { + // argument can't be null + if (ck == null) { + throw new NullPointerException("cookie is null"); + } + + boolean modified = false; + lock.lock(); + try { + modified = cookieJar.remove(ck); + } finally { + lock.unlock(); + } + + return modified; + } + + + /** + * Remove all cookies in this cookie store. + */ + public boolean removeAll() { + lock.lock(); + try { + if (cookieJar.isEmpty()) { + return false; + } + cookieJar.clear(); + domainIndex.clear(); + uriIndex.clear(); + } finally { + lock.unlock(); + } + + return true; + } + + + /* ---------------- Private operations -------------- */ + + + /* + * This is almost the same as HttpCookie.domainMatches except for + * one difference: It won't reject cookies when the 'H' part of the + * domain contains a dot ('.'). + * I.E.: RFC 2965 section 3.3.2 says that if host is x.y.domain.com + * and the cookie domain is .domain.com, then it should be rejected. + * However that's not how the real world works. Browsers don't reject and + * some sites, like yahoo.com do actually expect these cookies to be + * passed along. + * And should be used for 'old' style cookies (aka Netscape type of cookies) + */ + private boolean netscapeDomainMatches(String domain, String host) + { + if (domain == null || host == null) { + return false; + } + + // if there's no embedded dot in domain and domain is not .local + boolean isLocalDomain = ".local".equalsIgnoreCase(domain); + int embeddedDotInDomain = domain.indexOf('.'); + if (embeddedDotInDomain == 0) { + embeddedDotInDomain = domain.indexOf('.', 1); + } + if (!isLocalDomain && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length() - 1)) { + return false; + } + + // if the host name contains no dot and the domain name is .local + int firstDotInHost = host.indexOf('.'); + if (firstDotInHost == -1 && isLocalDomain) { + return true; + } + + int domainLength = domain.length(); + int lengthDiff = host.length() - domainLength; + if (lengthDiff == 0) { + // if the host name and the domain name are just string-compare euqal + return host.equalsIgnoreCase(domain); + } else if (lengthDiff > 0) { + // need to check H & D component + String H = host.substring(0, lengthDiff); + String D = host.substring(lengthDiff); + + return (D.equalsIgnoreCase(domain)); + } else if (lengthDiff == -1) { + // if domain is actually .host + return (domain.charAt(0) == '.' && + host.equalsIgnoreCase(domain.substring(1))); + } + + return false; + } + + private void getInternal1(List cookies, Map> cookieIndex, + String host, boolean secureLink) { + // Use a separate list to handle cookies that need to be removed so + // that there is no conflict with iterators. + ArrayList toRemove = new ArrayList(); + for (Map.Entry> entry : cookieIndex.entrySet()) { + String domain = entry.getKey(); + List lst = entry.getValue(); + for (HttpCookie c : lst) { + if ((c.getVersion() == 0 && netscapeDomainMatches(domain, host)) || + (c.getVersion() == 1 && HttpCookie.domainMatches(domain, host))) { + if ((cookieJar.indexOf(c) != -1)) { + // the cookie still in main cookie store + if (!c.hasExpired()) { + // don't add twice and make sure it's the proper + // security level + if ((secureLink || !c.getSecure()) && + !cookies.contains(c)) { + cookies.add(c); + } + } else { + toRemove.add(c); + } + } else { + // the cookie has beed removed from main store, + // so also remove it from domain indexed store + toRemove.add(c); + } + } + } + // Clear up the cookies that need to be removed + for (HttpCookie c : toRemove) { + lst.remove(c); + cookieJar.remove(c); + + } + toRemove.clear(); + } + } + + // @param cookies [OUT] contains the found cookies + // @param cookieIndex the index + // @param comparator the prediction to decide whether or not + // a cookie in index should be returned + private void getInternal2(List cookies, + Map> cookieIndex, + Comparable comparator, boolean secureLink) + { + for (T index : cookieIndex.keySet()) { + if (comparator.compareTo(index) == 0) { + List indexedCookies = cookieIndex.get(index); + // check the list of cookies associated with this domain + if (indexedCookies != null) { + Iterator it = indexedCookies.iterator(); + while (it.hasNext()) { + HttpCookie ck = it.next(); + if (cookieJar.indexOf(ck) != -1) { + // the cookie still in main cookie store + if (!ck.hasExpired()) { + // don't add twice + if ((secureLink || !ck.getSecure()) && + !cookies.contains(ck)) + cookies.add(ck); + } else { + it.remove(); + cookieJar.remove(ck); + } + } else { + // the cookie has beed removed from main store, + // so also remove it from domain indexed store + it.remove(); + } + } + } // end of indexedCookies != null + } // end of comparator.compareTo(index) == 0 + } // end of cookieIndex iteration + } + + // add 'cookie' indexed by 'index' into 'indexStore' + private void addIndex(Map> indexStore, + T index, + HttpCookie cookie) + { + if (index != null) { + List cookies = indexStore.get(index); + if (cookies != null) { + // there may already have the same cookie, so remove it first + cookies.remove(cookie); + + cookies.add(cookie); + } else { + cookies = new ArrayList(); + cookies.add(cookie); + indexStore.put(index, cookies); + } + } + } + + + // + // for cookie purpose, the effective uri should only be http://host + // the path will be taken into account when path-match algorithm applied + // + private URI getEffectiveURI(URI uri) { + URI effectiveURI = null; + try { + effectiveURI = new URI("http", + uri.getHost(), + null, // path component + null, // query component + null // fragment component + ); + } catch (URISyntaxException ignored) { + effectiveURI = uri; + } + + return effectiveURI; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java index c7af8aa9..dd61fd99 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java @@ -25,29 +25,34 @@ package com.jaspersoft.android.sdk.network; import com.squareup.okhttp.Authenticator; +import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; import java.io.IOException; +import java.net.CookieStore; +import java.net.HttpCookie; import java.net.Proxy; +import java.net.URI; +import java.util.List; /** * @author Tom Koptel * @since 2.0 */ final class RecoverableAuthenticator implements Authenticator { - private final Server mServer; + private final AuthStrategy mAuthStrategy; private final Credentials mCredentials; - RecoverableAuthenticator(Server server, Credentials credentials) { - mServer = server; + RecoverableAuthenticator(AuthStrategy authStrategy, Credentials credentials) { + mAuthStrategy = authStrategy; mCredentials = credentials; } @Override public Request authenticate(Proxy proxy, Response response) throws IOException { try { - authenticate(); + mCredentials.apply(mAuthStrategy); return response.request(); } catch (HttpException code) { return null; @@ -58,9 +63,4 @@ public Request authenticate(Proxy proxy, Response response) throws IOException { public Request authenticateProxy(Proxy proxy, Response response) throws IOException { return null; } - - private void authenticate() throws IOException, HttpException { - AuthStrategy authStrategy = new AuthStrategy(mServer); - mCredentials.apply(authStrategy); - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index 38944e2c..ce9fa708 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -26,10 +26,10 @@ import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; -import com.squareup.okhttp.*; +import com.squareup.okhttp.Authenticator; +import com.squareup.okhttp.OkHttpClient; import retrofit.Retrofit; -import java.io.IOException; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; @@ -43,14 +43,20 @@ public final class Server { private final String mBaseUrl; private final OkHttpClient mOkHttpClient; + private final Retrofit.Builder mRetrofitBuilder; - private Server(String baseUrl, OkHttpClient okHttpClient) { + private Server(String baseUrl, OkHttpClient okHttpClient, Retrofit.Builder retrofitBuilder) { mBaseUrl = baseUrl; mOkHttpClient = okHttpClient; + mRetrofitBuilder = retrofitBuilder; } public AnonymousClient newClient() { - OkHttpClient anonymousClient = configureAnonymosClient(mOkHttpClient.clone()); + OkHttpClient anonymousClient = mOkHttpClient.clone(); + CookieManager cookieHandler = new CookieManager( + new InMemoryCookieStore(), CookiePolicy.ACCEPT_ORIGINAL_SERVER); + anonymousClient.setCookieHandler(cookieHandler); + Retrofit anonymousRetrofit = newRetrofit() .client(anonymousClient) .build(); @@ -67,17 +73,10 @@ public String getBaseUrl() { } Retrofit.Builder newRetrofit() { - Gson configuredGson = GsonFactory.create(); - GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); - StringConverterFactory stringConverterFactory = StringConverterFactory.create(); - - return new Retrofit.Builder() - .baseUrl(mBaseUrl) - .addConverterFactory(stringConverterFactory) - .addConverterFactory(gsonConverterFactory); + return mRetrofitBuilder; } - OkHttpClient getClient() { + OkHttpClient client() { return mOkHttpClient; } @@ -91,7 +90,8 @@ public static Builder newBuilder() { } public static class Builder { - private Builder() {} + private Builder() { + } public OptionalBuilder withBaseUrl(String baseUrl) { return new OptionalBuilder(baseUrl); @@ -122,7 +122,16 @@ public OptionalBuilder withProxy(Proxy proxy) { } public Server build() { - return new Server(mBaseUrl, mOkHttpClient); + Gson configuredGson = GsonFactory.create(); + GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(configuredGson); + StringConverterFactory stringConverterFactory = StringConverterFactory.create(); + + Retrofit.Builder retrofitBuilder = new Retrofit.Builder() + .baseUrl(mBaseUrl) + .addConverterFactory(stringConverterFactory) + .addConverterFactory(gsonConverterFactory); + + return new Server(mBaseUrl, mOkHttpClient, retrofitBuilder); } } @@ -131,7 +140,7 @@ public static class AuthorizedClientBuilder { private final Credentials mCredentials; private AuthPolicy mAuthenticationPolicy; - private CookieHandler mCookieHandler; + private CookieHandler mCookieHandler = new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER); AuthorizedClientBuilder(Server server, Credentials credentials) { mServer = server; @@ -149,9 +158,7 @@ public AuthorizedClientBuilder withCookieHandler(CookieHandler cookieHandler) { } public AuthorizedClient create() { - ensureSaneDefaults(); - OkHttpClient authClient = configureAuthClient(mServer.getClient().clone()); - + OkHttpClient authClient = configureAuthClient(mServer.client().clone()); Retrofit authRetrofit = mServer.newRetrofit() .client(authClient) .build(); @@ -162,44 +169,29 @@ public AuthorizedClient create() { private OkHttpClient configureAuthClient(OkHttpClient client) { client.setCookieHandler(mCookieHandler); - - if (mAuthenticationPolicy == AuthPolicy.FAIL_FAST) { - client.interceptors().add(new Interceptor() { - @Override - public Response intercept(Chain chain) throws IOException { - Headers headers = chain.request().headers(); - boolean hasCookies = headers.names().contains("Cookie"); - if (!hasCookies) { - Response response401 = new Response.Builder() - .protocol(Protocol.HTTP_1_1) - .request(chain.request()) - .headers(chain.request().headers()) - .code(401) - .build(); - return response401; - } - return chain.proceed(chain.request()); - } - }); - - RecoverableAuthenticator recoverableAuthenticator = new RecoverableAuthenticator(mServer, mCredentials); - SingleTimeAuthenticator singleTimeAuthenticator = new SingleTimeAuthenticator(recoverableAuthenticator); - client.setAuthenticator(singleTimeAuthenticator); - } else { - RecoverableAuthenticator recoverableAuthenticator = new RecoverableAuthenticator(mServer, mCredentials); - client.setAuthenticator(recoverableAuthenticator); - } - + AuthStrategy authStrategy = configureAuthStrategy(client); + configureAuthenticator(client, authStrategy); return client; } - private void ensureSaneDefaults() { - if (mAuthenticationPolicy == null) { - mAuthenticationPolicy = AuthPolicy.RETRY; - } - if (mCookieHandler == null) { - mCookieHandler = new CookieManager(null, CookiePolicy.ACCEPT_ALL); + private AuthStrategy configureAuthStrategy(OkHttpClient client) { + OkHttpClient authClient = client.clone(); + authClient.setFollowRedirects(false); + Retrofit authRetrofit = mServer.newRetrofit() + .client(authClient) + .build(); + return new AuthStrategy(authRetrofit); + } + + private void configureAuthenticator(OkHttpClient client, AuthStrategy authStrategy) { + Authenticator recoverableAuthenticator = + new RecoverableAuthenticator(authStrategy, mCredentials); + + Authenticator authenticator = recoverableAuthenticator; + if (mAuthenticationPolicy == AuthPolicy.FAIL_FAST) { + authenticator = new SingleTimeAuthenticator(recoverableAuthenticator); } + client.setAuthenticator(authenticator); } } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index ebbd7c80..da49c981 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -30,11 +30,13 @@ import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; +import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.mockwebserver.MockResponse; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import retrofit.Retrofit; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; @@ -61,10 +63,11 @@ public class AuthenticationRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Server server = Server.newBuilder() - .withBaseUrl(mWebMockRule.getRootUrl()) + Retrofit retrofit = new Retrofit.Builder() + .baseUrl(mWebMockRule.getRootUrl()) + .client(new OkHttpClient()) .build(); - apiUnderTest = new AuthenticationRestApi(server); + apiUnderTest = new AuthenticationRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/TestCookieManager.java b/core/src/test/java/com/jaspersoft/android/sdk/network/TestCookieManager.java new file mode 100644 index 00000000..d1a8c63e --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/TestCookieManager.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import java.net.CookieManager; +import java.net.CookiePolicy; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class TestCookieManager extends CookieManager { + public TestCookieManager() { + super(new InMemoryCookieStore(), CookiePolicy.ACCEPT_ORIGINAL_SERVER); + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index a292a485..4778ed43 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -28,7 +28,7 @@ import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import java.util.*; @@ -52,11 +52,11 @@ public class InputControlRestApiTest { CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); } - private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); - private InputControlRestApi apiUnderTest; + private final static LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private static InputControlRestApi apiUnderTest; - @Before - public void setUp() throws Exception { + @BeforeClass + public static void setUp() throws Exception { if (apiUnderTest == null) { AuthorizedClient client = mLazyClient.getAuthorizedClient(); apiUnderTest = client.inputControlApi(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java index 5b066603..5d4d3bfa 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.Server; +import com.jaspersoft.android.sdk.network.TestCookieManager; import java.net.InetSocketAddress; import java.net.Proxy; @@ -54,6 +55,7 @@ public AuthorizedClient getAuthorizedClient() { if (mClient == null) { mClient = getServer(mJrsMetadata.getServerUrl()) .newClient(mJrsMetadata.getCredentials()) + .withCookieHandler(new TestCookieManager()) .create(); } return mClient; From 6e56db2c516f22bf974ca71dba088ac07496b075 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Dec 2015 21:20:24 +0200 Subject: [PATCH 374/457] Force @BeforeClass on integration tests --- .../integration/api/ReportExecutionRestApiTest.java | 10 +++++----- .../integration/api/ReportExportRestApiTest.java | 12 ++++++------ .../test/integration/api/RepositoryRestApiTest.java | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java index c2155cb0..7d8a6232 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExecutionRestApiTest.java @@ -32,7 +32,7 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -56,11 +56,11 @@ public class ReportExecutionRestApiTest { private final String REPORT_URI = "/public/Samples/Reports/ProfitDetailReport"; private final ReportParameter PRODUCT_FAMILY = new ReportParameter("ProductFamily", new HashSet(Collections.singletonList("Drink"))); - private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); - private ReportExecutionRestApi apiUnderTest; + private final static LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private static ReportExecutionRestApi apiUnderTest; - @Before - public void setUp() throws Exception { + @BeforeClass + public static void setUp() throws Exception { if (apiUnderTest == null) { AuthorizedClient client = mLazyClient.getAuthorizedClient(); apiUnderTest = client.reportExecutionApi(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java index 9ea77072..5fdcb243 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportExportRestApiTest.java @@ -34,7 +34,7 @@ import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import org.jetbrains.annotations.NotNull; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import static org.hamcrest.core.Is.is; @@ -48,12 +48,12 @@ public class ReportExportRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/AllAccounts"; - private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); - private ReportExecutionRestApi mExecApi; - private ReportExportRestApi apiUnderTest; + private final static LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private static ReportExecutionRestApi mExecApi; + private static ReportExportRestApi apiUnderTest; - @Before - public void setup() { + @BeforeClass + public static void setup() { if (apiUnderTest == null) { AuthorizedClient client = mLazyClient.getAuthorizedClient(); mExecApi = client.reportExecutionApi(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java index 19e2b44a..4c5d9f78 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/RepositoryRestApiTest.java @@ -29,7 +29,7 @@ import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import static org.hamcrest.collection.IsEmptyCollection.empty; @@ -46,11 +46,11 @@ public class RepositoryRestApiTest { private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); - private RepositoryRestApi apiUnderTest; + private final static LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); + private static RepositoryRestApi apiUnderTest; - @Before - public void setup() { + @BeforeClass + public static void setup() { if (apiUnderTest == null) { AuthorizedClient client = mLazyClient.getAuthorizedClient(); apiUnderTest = client.repositoryApi(); From b6f8cce08206fe000673170a35d92e91fc0328f3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Dec 2015 22:12:11 +0200 Subject: [PATCH 375/457] Make anonymous client creation homogeneous --- .../android/sdk/network/Server.java | 65 ++++++++++++------- .../sdk/test/integration/api/LazyClient.java | 48 ++++++++++---- .../test/integration/api/ServerRestTest.java | 2 +- 3 files changed, 78 insertions(+), 37 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index ce9fa708..4bc14488 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -28,12 +28,11 @@ import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import com.squareup.okhttp.Authenticator; import com.squareup.okhttp.OkHttpClient; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import retrofit.Retrofit; -import java.net.CookieHandler; -import java.net.CookieManager; -import java.net.CookiePolicy; -import java.net.Proxy; +import java.net.*; import java.util.concurrent.TimeUnit; /** @@ -51,23 +50,23 @@ private Server(String baseUrl, OkHttpClient okHttpClient, Retrofit.Builder retro mRetrofitBuilder = retrofitBuilder; } - public AnonymousClient newClient() { - OkHttpClient anonymousClient = mOkHttpClient.clone(); - CookieManager cookieHandler = new CookieManager( - new InMemoryCookieStore(), CookiePolicy.ACCEPT_ORIGINAL_SERVER); - anonymousClient.setCookieHandler(cookieHandler); - - Retrofit anonymousRetrofit = newRetrofit() - .client(anonymousClient) - .build(); + @NotNull + public static Builder newBuilder() { + return new Builder(); + } - return new AnonymousClientImpl(anonymousRetrofit); + @NotNull + public AnonymousClientBuilder newClient() { + return new AnonymousClientBuilder(this); } - public AuthorizedClientBuilder newClient(Credentials credentials) { + @NotNull + public AuthorizedClientBuilder newClient(@Nullable Credentials credentials) { + Utils.checkNotNull(credentials, "Credentials should not be null"); return new AuthorizedClientBuilder(this, credentials); } + @NotNull public String getBaseUrl() { return mBaseUrl; } @@ -80,15 +79,6 @@ OkHttpClient client() { return mOkHttpClient; } - private OkHttpClient configureAnonymosClient(OkHttpClient client) { - client.setCookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); - return client; - } - - public static Builder newBuilder() { - return new Builder(); - } - public static class Builder { private Builder() { } @@ -135,6 +125,31 @@ public Server build() { } } + public static class AnonymousClientBuilder { + private final Server mServer; + private CookieHandler mCookieHandler = + new CookieManager(new InMemoryCookieStore(), CookiePolicy.ACCEPT_ORIGINAL_SERVER); + + AnonymousClientBuilder(Server server) { + mServer = server; + } + + public AnonymousClientBuilder withCookieHandler(CookieHandler cookieHandler) { + mCookieHandler = cookieHandler; + return this; + } + + public AnonymousClient create() { + OkHttpClient anonymousClient = mServer.client().clone(); + anonymousClient.setCookieHandler(mCookieHandler); + + Retrofit anonymousRetrofit = mServer.newRetrofit() + .client(anonymousClient) + .build(); + return new AnonymousClientImpl(anonymousRetrofit); + } + } + public static class AuthorizedClientBuilder { private final Server mServer; private final Credentials mCredentials; @@ -163,7 +178,7 @@ public AuthorizedClient create() { .client(authClient) .build(); - AnonymousClient anonymousClient = mServer.newClient(); + AnonymousClient anonymousClient = mServer.newClient().create(); return new AuthorizedClientImpl(authRetrofit, anonymousClient); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java index 5d4d3bfa..f13741d3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java @@ -24,12 +24,13 @@ package com.jaspersoft.android.sdk.test.integration.api; +import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.Server; import com.jaspersoft.android.sdk.network.TestCookieManager; -import java.net.InetSocketAddress; -import java.net.Proxy; +import java.io.IOException; +import java.net.*; /** * @author Tom Koptel @@ -37,27 +38,52 @@ */ final class LazyClient { private final JrsMetadata mJrsMetadata; - private AuthorizedClient mClient; + private AuthorizedClient mAuthorizedClient; + private AnonymousClient mAnonymousClient; + public static final InetSocketAddress CHARLES_ADDRESS = new InetSocketAddress("0.0.0.0", 8888); public LazyClient(JrsMetadata jrsMetadata) { mJrsMetadata = jrsMetadata; } public static Server getServer(String serverUrl) { - Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("0.0.0.0", 8888)); - return Server.newBuilder() - .withBaseUrl(serverUrl) - .withProxy(proxy) - .build(); + Server.OptionalBuilder serverBuilder = Server.newBuilder() + .withBaseUrl(serverUrl); + if (isProxyReachable()) { + Proxy proxy = new Proxy(Proxy.Type.HTTP, CHARLES_ADDRESS); + serverBuilder.withProxy(proxy); + } + return serverBuilder.build(); + } + + private static boolean isProxyReachable() { + try { + Socket socket = new Socket(); + socket.connect(CHARLES_ADDRESS); + socket.close(); + return true; + } catch (IOException e) { + return false; + } + } + + public AnonymousClient getAnonymousClient() { + if (mAnonymousClient == null) { + mAnonymousClient = getServer(mJrsMetadata.getServerUrl()) + .newClient() + .withCookieHandler(new TestCookieManager()) + .create(); + } + return mAnonymousClient; } public AuthorizedClient getAuthorizedClient() { - if (mClient == null) { - mClient = getServer(mJrsMetadata.getServerUrl()) + if (mAuthorizedClient == null) { + mAuthorizedClient = getServer(mJrsMetadata.getServerUrl()) .newClient(mJrsMetadata.getCredentials()) .withCookieHandler(new TestCookieManager()) .create(); } - return mClient; + return mAuthorizedClient; } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java index 0cb6234a..fd6a0fa9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ServerRestTest.java @@ -45,7 +45,7 @@ public class ServerRestTest { @BeforeClass public static void setup() { if (apiUnderTest == null) { - apiUnderTest = mLazyClient.getAuthorizedClient().infoApi(); + apiUnderTest = mLazyClient.getAnonymousClient().infoApi(); } } From 6b872f45703ff19257205460f0643a8285200954 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 23 Dec 2015 22:46:28 +0200 Subject: [PATCH 376/457] Remove cookie assertions --- .../sdk/network/AuthenticationRestApiTest.java | 8 ++++---- .../android/sdk/network/InputControlRestApiTest.java | 12 +++--------- .../sdk/network/ReportExecutionRestApiTest.java | 11 +++-------- .../android/sdk/network/ReportExportRestApiTest.java | 10 +++------- .../android/sdk/network/ReportOptionRestApiTest.java | 10 +++------- .../android/sdk/network/RepositoryRestApiTest.java | 9 +++------ .../android/sdk/network/ServerRestApiTest.java | 6 +++--- 7 files changed, 22 insertions(+), 44 deletions(-) diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index da49c981..96260bdc 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -30,7 +30,6 @@ import com.jaspersoft.android.sdk.test.resource.ResourceFile; import com.jaspersoft.android.sdk.test.resource.TestResource; import com.jaspersoft.android.sdk.test.resource.inject.TestResourceInjector; -import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.mockwebserver.MockResponse; import org.junit.Before; import org.junit.Rule; @@ -63,10 +62,11 @@ public class AuthenticationRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Retrofit retrofit = new Retrofit.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .client(new OkHttpClient()) + Server server = Server.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) .build(); + Retrofit retrofit = server.newRetrofit().build(); + retrofit.client().setFollowRedirects(false); apiUnderTest = new AuthenticationRestApi(retrofit); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index c60ee006..c1b6014a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -24,10 +24,8 @@ package com.jaspersoft.android.sdk.network; -import com.google.gson.Gson; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.network.entity.type.GsonFactory; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -74,10 +72,10 @@ public class InputControlRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Retrofit retrofit = new Retrofit.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .addConverterFactory(GsonConverterFactory.create()) + Server server = Server.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) .build(); + Retrofit retrofit = server.newRetrofit().build(); restApiUnderTest = new InputControlRestApiImpl(retrofit); } @@ -134,7 +132,6 @@ public void apiShouldProvideListOfInputControlsInitialStatesWithFreshData() thro RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls/values?freshData=true")); - assertThat(response.getHeader("Cookie"), is("key=value")); } @Test @@ -153,7 +150,6 @@ public void apiShouldProvideFreshStatesForInputControls() throws Exception { RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls/sales_fact_ALL__store_sales_2013_1/values?freshData=true")); - assertThat(response.getHeader("Cookie"), is("key=value")); } @Test @@ -168,7 +164,6 @@ public void apiShouldProvideInputControlsListIfStateExcluded() throws Exception RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls?exclude=state")); - assertThat(response.getHeader("Cookie"), is("key=value")); } @Test @@ -183,6 +178,5 @@ public void apiShouldProvideInputControlsWithStates() throws Exception { RecordedRequest response = mWebMockRule.get().takeRequest(); assertThat(response.getPath(), is("/rest_v2/reports/my/uri/inputControls")); - assertThat(response.getHeader("Cookie"), is("key=value")); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index 09c2ffeb..d2370afb 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -83,10 +83,10 @@ public class ReportExecutionRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Retrofit retrofit = new Retrofit.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .addConverterFactory(GsonConverterFactory.create()) + Server server = Server.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) .build(); + Retrofit retrofit = server.newRetrofit().build(); restApiUnderTest = new ReportExecutionRestApiImpl(retrofit); } @@ -158,7 +158,6 @@ public void shouldStartReportExecution() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions")); assertThat(request.getBody().readUtf8(), is("{\"reportUnitUri\":\"/my/uri\"}")); - assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getMethod(), is("POST")); } @@ -172,7 +171,6 @@ public void shouldRequestReportExecutionDetails() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id")); - assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getMethod(), is("GET")); } @@ -186,7 +184,6 @@ public void shouldRequestReportExecutionStatus() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); - assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getMethod(), is("GET")); } @@ -199,7 +196,6 @@ public void shouldCancelReportExecution() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/status")); - assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getBody().readUtf8(), is("{\"value\":\"cancelled\"}")); assertThat(request.getMethod(), is("PUT")); } @@ -213,7 +209,6 @@ public void shouldUpdateReportExecution() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/exec_id/parameters")); - assertThat(request.getHeader("Cookie"), is("key=value")); assertThat(request.getBody().readUtf8(), is("[{\"name\":\"key\",\"value\":[\"value\"]}]")); assertThat(request.getMethod(), is("POST")); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index e7b4e564..54ec7d1a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -66,10 +66,10 @@ public class ReportExportRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Retrofit retrofit = new Retrofit.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .addConverterFactory(GsonConverterFactory.create()) + Server server = Server.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) .build(); + Retrofit retrofit = server.newRetrofit().build(); restApiUnderTest = new ReportExportRestApiImpl(retrofit); } @@ -159,7 +159,6 @@ public void shouldRequestExportOutput() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/outputResource?suppressContentDisposition=true")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -184,7 +183,6 @@ public void shouldRequestExportAttachment() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/attachments/attachment_id")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -196,7 +194,6 @@ public void shouldRunExportExecution() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -208,7 +205,6 @@ public void shouldCheckExportExecutionStatus() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reportExecutions/execution_id/exports/html;pages=1/status")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 6d6481aa..ac8d8962 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -70,10 +70,10 @@ public class ReportOptionRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Retrofit retrofit = new Retrofit.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .addConverterFactory(GsonConverterFactory.create()) + Server server = Server.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) .build(); + Retrofit retrofit = server.newRetrofit().build(); restApiUnderTest = new ReportOptionRestApiImpl(retrofit); } @@ -150,7 +150,6 @@ public void apiShouldListReportOptions() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -169,7 +168,6 @@ public void apiShouldCreateReportOption() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options?label=my%20label&overwrite=true")); assertThat(request.getBody().readUtf8(), is("{\"sales_fact_ALL__store_sales_2013_1\":[\"19\"]}")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -184,7 +182,6 @@ public void apiShouldUpdateReportOption() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); assertThat(request.getMethod(), is("PUT")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -196,7 +193,6 @@ public void apiShouldDeleteReportOption() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/reports/any/uri/options/option_id")); assertThat(request.getMethod(), is("DELETE")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index 4a69c81b..dee55417 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -70,10 +70,10 @@ public class RepositoryRestApiTest { public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); - Retrofit retrofit = new Retrofit.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .addConverterFactory(GsonConverterFactory.create()) + Server server = Server.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) .build(); + Retrofit retrofit = server.newRetrofit().build(); restApiUnderTest = new RepositoryRestApiImpl(retrofit); } @@ -203,7 +203,6 @@ public void shouldSearchResources() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources?limit=100&offset=100")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -215,7 +214,6 @@ public void shouldRequestReportResources() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); assertThat(request.getHeader("Accept"), is("application/repository.reportUnit+json")); - assertThat(request.getHeader("Cookie"), is("key=value")); } @Test @@ -227,6 +225,5 @@ public void shouldRequestFolderResource() throws Exception { RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request.getPath(), is("/rest_v2/resources/my/uri")); assertThat(request.getHeader("Accept"), is("application/repository.folder+json")); - assertThat(request.getHeader("Cookie"), is("key=value")); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java index e4c49a58..105faf9d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java @@ -51,10 +51,10 @@ public class ServerRestApiTest { @Before public void setup() { - Retrofit retrofit = new Retrofit.Builder() - .baseUrl(mWebMockRule.getRootUrl()) - .addConverterFactory(GsonConverterFactory.create()) + Server server = Server.newBuilder() + .withBaseUrl(mWebMockRule.getRootUrl()) .build(); + Retrofit retrofit = server.newRetrofit().build(); objectUnderTest = new ServerRestApiImpl(retrofit); } From fa04bacea56bf7589b46bba33ad6c6c7605d825a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Sat, 26 Dec 2015 00:03:31 +0200 Subject: [PATCH 377/457] Generify API around networks clients Incapsulate report package as internal one Implement proxy search task Incapsulating ServerInfoService Incapsulating ReportService api Add report execution API Add status observers Provide test for ExportStatusObserver Provide test for ReportStatusObserverTest Separate usecases on specific actions Implement report service retrofited run() Implement ReportExecution5_6Plus Implement ReportExecution5_6Plus Simplifying use cases for report api Connecting proxy report service impl Add tests for Export/Report execution API Update export options mapper return type Add tests for report service/execution Separating report factories/mappers Move repository package to service one Move info package to service one Move report package to service one Implement export criteria mappers Rename RunReportCriteria -> ReportExportOptions Implement report run options mappers across versions Escape attachment prefix Reduce execution fields anchor/markup for JRS 5.5 Encode attachment prefix for report export Fix compiler warnings Fix bytecode issues while executing all tests in suite Refactor name RunReportCriteria -> ReportExecutionOptions Unify builder patterns Generify public api for Report/Repository/Info services --- .../android/sdk/network/Server.java | 2 +- .../sdk/network/SpringCredentials.java | 10 +- .../execution/ExecutionRequestOptions.java | 11 + .../sdk/service/data/report/PageRange.java | 49 ++- ...ortOutput.java => ReportExportOutput.java} | 2 +- .../service/data/report/ReportMetadata.java | 8 + .../service/data/repository/SearchResult.java | 8 +- .../sdk/service/info/ServerInfoService.java | 49 +++ .../ServerInfoServiceImpl.java} | 40 +-- .../ServerInfoTransformer.java | 2 +- .../info/InMemoryInfoCache.java | 3 +- .../{ => internal}/info/InfoCache.java | 2 +- .../internal/{ => info}/InfoCacheManager.java | 7 +- .../report/AbstractReportExecution.java | 59 ++++ .../service/report/AbstractReportService.java | 61 ++++ .../report/AttachmentExportMapper.java | 46 +++ .../service/report/AttachmentsFactory.java | 61 ++++ .../sdk/service/report/ExecutionCriteria.java | 86 ----- .../report/ExecutionOptionsDataMapper.java | 111 ------ .../service/report/ExportExecutionApi.java | 45 +++ .../report/ExportExecutionApiImpl.java | 144 ++++++++ .../sdk/service/report/ExportFactory.java | 46 +-- .../service/report/ExportOptionsMapper.java | 82 +++++ .../report/ExportOptionsMapper5_5and6_1.java | 44 +++ .../report/ExportOptionsMapper6_2.java | 35 ++ .../service/report/ProxyReportService.java | 54 +++ .../sdk/service/report/ReportAttachment.java | 43 +-- .../ReportAttachmentImpl.java} | 44 ++- .../sdk/service/report/ReportExecution.java | 182 +--------- .../service/report/ReportExecution5_5.java | 87 +++++ .../report/ReportExecution5_6Plus.java | 74 ++++ .../service/report/ReportExecutionApi.java | 46 +++ .../report/ReportExecutionApiImpl.java | 137 ++++++++ .../report/ReportExecutionOptions.java | 328 ++++++++++++++++++ .../report/ReportExecutionUseCase.java | 111 ------ .../sdk/service/report/ReportExport.java | 42 +-- .../sdk/service/report/ReportExportImpl.java | 64 ++++ ...ataMapper.java => ReportExportMapper.java} | 33 +- .../service/report/ReportExportOptions.java | 197 +++++++++++ .../service/report/ReportExportUseCase.java | 145 -------- .../sdk/service/report/ReportFormat.java | 33 ++ .../sdk/service/report/ReportMarkup.java | 33 ++ .../service/report/ReportOptionsMapper.java | 97 ++++++ .../report/ReportOptionsMapper5_5.java | 51 +++ .../report/ReportOptionsMapper5_6.java | 44 +++ .../report/ReportOptionsMapper5_6Plus.java | 35 ++ .../sdk/service/report/ReportService.java | 129 ++----- .../sdk/service/report/ReportService5_5.java | 51 +++ .../service/report/ReportService5_6Plus.java | 50 +++ .../service/report/ReportServiceFactory.java | 93 +++++ .../service/report/RetryReportExecution.java | 77 ++++ .../sdk/service/report/RunExportCriteria.java | 99 ------ .../sdk/service/report/RunReportCriteria.java | 134 ------- .../android/sdk/service/report/Status.java | 8 + .../service/repository/CriteriaMapper.java | 2 +- .../service/repository/InternalCriteria.java | 9 +- ...kImpl.java => ProxyRepositoryService.java} | 51 +-- .../service/repository/RepositoryService.java | 40 +-- .../service/repository/ResourceMapper.java | 6 +- .../service/repository/SearchCriteria.java | 41 +-- .../sdk/service/repository/SearchTask.java | 5 +- .../service/repository/SearchTaskFactory.java | 55 +++ .../service/repository/SearchTaskProxy.java | 59 ++++ ...earchStrategy.java => SearchTaskV5_5.java} | 30 +- ...hStrategy.java => SearchTaskV5_6Plus.java} | 26 +- .../sdk/service/repository/SearchUseCase.java | 6 +- .../sdk/service/repository/SortType.java | 44 +++ .../network/AuthenticationRestApiTest.java | 2 +- .../sdk/network/InputControlRestApiTest.java | 2 +- .../network/JSEncryptionAlgorithmTest.java | 7 +- .../network/ReportExecutionRestApiTest.java | 2 +- .../sdk/network/ReportExportRestApiTest.java | 2 +- .../sdk/network/ReportOptionRestApiTest.java | 2 +- .../sdk/network/RepositoryRestApiTest.java | 2 +- .../sdk/network/ServerRestApiTest.java | 2 +- .../sdk/network/SpringAuthServiceTest.java | 11 +- .../sdk/network/SpringCredentialsTest.java | 11 +- .../data/{ => report}/PageRangeTest.java | 39 ++- .../ServerInfoServiceTest.java | 38 +- .../ServerInfoTransformerTest.java | 3 +- .../{ => internal}/FakeCallExecutor.java | 2 +- .../info}/InMemoryInfoCacheTest.java | 4 +- .../{ => info}/InfoCacheManagerTest.java | 6 +- .../report/AbstractReportExecutionTest.java | 92 +++++ .../report/AbstractReportServiceTest.java | 94 +++++ .../report/AttachmentExportMapperTest.java | 61 ++++ .../report/AttachmentsFactoryTest.java | 84 +++++ .../ExecutionOptionsDataMapperTest.java | 165 --------- .../report/ExportExecutionApiTest.java | 184 ++++++++++ .../sdk/service/report/ExportFactoryTest.java | 96 +++++ .../sdk/service/report/FakeOptions.java | 49 +++ .../service/report/ReportAttachmentTest.java | 25 +- .../report/ReportExecution5_5Test.java | 129 +++++++ .../report/ReportExecution5_6PlusTest.java | 112 ++++++ .../report/ReportExecutionOptionsTest.java | 87 +++++ .../service/report/ReportExecutionTest.java | 314 ----------------- .../report/ReportExecutionUseCaseTest.java | 103 ------ .../report/ReportExportMapperTest.java | 82 +++++ ...eportExportOptionsMapper5_5And6_1Test.java | 114 ++++++ .../ReportExportOptionsMapper6_2Test.java | 113 ++++++ .../report/ReportExportOptionsMapperTest.java | 62 ++++ .../report/ReportExportOptionsTest.java | 96 +++++ .../sdk/service/report/ReportExportTest.java | 19 +- .../report/ReportExportUseCaseTest.java | 148 -------- .../report/ReportOptionsMapper5_5Test.java | 188 ++++++++++ .../ReportOptionsMapper5_6PlusTest.java | 179 ++++++++++ .../report/ReportOptionsMapper5_6Test.java | 179 ++++++++++ .../sdk/service/report/ReportServiceTest.java | 158 ++------- .../report/RetryReportExecutionTest.java | 102 ++++++ .../repository/CriteriaMapperTest.java | 13 +- .../InternalSearchCriteriaTest.java | 20 +- ...t.java => ProxyRepositoryServiceTest.java} | 48 ++- .../repository/RepositoryServiceTest.java | 52 +-- .../repository/SearchCriteriaTest.java | 16 +- .../repository/SearchTaskFactoryTest.java | 75 ++++ .../repository/SearchTaskImplTest.java | 105 ------ .../repository/SearchTaskProxyTest.java | 74 ++++ ...ategyTest.java => SearchTaskV5_5Test.java} | 22 +- ...yTest.java => SearchTaskV5_6PlusTest.java} | 34 +- .../service/repository/SearchUseCaseTest.java | 18 +- .../sdk/service/repository/SortTypeTest.java | 47 +++ .../sdk/test/integration/api/JrsMetadata.java | 6 +- .../sdk/test/integration/api/LazyClient.java | 2 +- 123 files changed, 5160 insertions(+), 2450 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/service/data/report/{ReportOutput.java => ReportExportOutput.java} (95%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java rename core/src/main/java/com/jaspersoft/android/sdk/service/{server/ServerInfoService.java => info/ServerInfoServiceImpl.java} (59%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{server => info}/ServerInfoTransformer.java (98%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => internal}/info/InMemoryInfoCache.java (93%) rename core/src/main/java/com/jaspersoft/android/sdk/service/{ => internal}/info/InfoCache.java (96%) rename core/src/main/java/com/jaspersoft/android/sdk/service/internal/{ => info}/InfoCacheManager.java (92%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper5_5and6_1.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper6_2.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java rename core/src/main/java/com/jaspersoft/android/sdk/service/{repository/SearchStrategy.java => report/ReportAttachmentImpl.java} (54%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptions.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java rename core/src/main/java/com/jaspersoft/android/sdk/service/report/{OutputDataMapper.java => ReportExportMapper.java} (53%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportOptions.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportFormat.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportMarkup.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Plus.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java rename core/src/main/java/com/jaspersoft/android/sdk/service/repository/{SearchTaskImpl.java => ProxyRepositoryService.java} (50%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactory.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java rename core/src/main/java/com/jaspersoft/android/sdk/service/repository/{EmeraldMR2SearchStrategy.java => SearchTaskV5_5.java} (77%) rename core/src/main/java/com/jaspersoft/android/sdk/service/repository/{EmeraldMR3SearchStrategy.java => SearchTaskV5_6Plus.java} (78%) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/repository/SortType.java rename core/src/test/java/com/jaspersoft/android/sdk/service/data/{ => report}/PageRangeTest.java (69%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{server => info}/ServerInfoServiceTest.java (66%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{server => info}/ServerInfoTransformerTest.java (96%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{ => internal}/FakeCallExecutor.java (97%) rename core/src/test/java/com/jaspersoft/android/sdk/service/{ => internal/info}/InMemoryInfoCacheTest.java (91%) rename core/src/test/java/com/jaspersoft/android/sdk/service/internal/{ => info}/InfoCacheManagerTest.java (93%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapperTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactoryTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/FakeOptions.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5Test.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6PlusTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptionsTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportMapperTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper5_5And6_1Test.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper6_2Test.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapperTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5Test.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6PlusTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Test.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/RetryReportExecutionTest.java rename core/src/test/java/com/jaspersoft/android/sdk/service/repository/{SearchStrategyTest.java => ProxyRepositoryServiceTest.java} (53%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxyTest.java rename core/src/test/java/com/jaspersoft/android/sdk/service/repository/{EmeraldMR2SearchStrategyTest.java => SearchTaskV5_5Test.java} (87%) rename core/src/test/java/com/jaspersoft/android/sdk/service/repository/{EmeraldMR3SearchStrategyTest.java => SearchTaskV5_6PlusTest.java} (81%) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/repository/SortTypeTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index 4bc14488..621dec82 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -51,7 +51,7 @@ private Server(String baseUrl, OkHttpClient okHttpClient, Retrofit.Builder retro } @NotNull - public static Builder newBuilder() { + public static Builder builder() { return new Builder(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java index b4fe7b2c..37c51960 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringCredentials.java @@ -117,27 +117,27 @@ public static class Builder { private Builder() {} - public Builder username(@NotNull String username) { + public Builder withUsername(@NotNull String username) { mUsername = checkNotNull(username, "username == null"); return this; } - public Builder password(@NotNull String password) { + public Builder withPassword(@NotNull String password) { mPassword = checkNotNull(password, "password == null"); return this; } - public Builder organization(@Nullable String organization) { + public Builder withOrganization(@Nullable String organization) { mOrganization = organization; return this; } - public Builder timeZone(@NotNull TimeZone timeZone) { + public Builder withTimeZone(@NotNull TimeZone timeZone) { mTimeZone = checkNotNull(timeZone, "timeZone == null"); return this; } - public Builder locale(@NotNull Locale locale) { + public Builder withLocale(@NotNull Locale locale) { mLocale = checkNotNull(locale, "locale == null"); return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java index 55f4d8f0..203a6519 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/execution/ExecutionRequestOptions.java @@ -60,6 +60,8 @@ public class ExecutionRequestOptions { @Expose protected String attachmentsPrefix; @Expose + protected String markupType; + @Expose protected List parameters; protected ExecutionRequestOptions() {} @@ -103,6 +105,11 @@ public ExecutionRequestOptions withAttachmentsPrefix(String attachmentsPrefix) { return this; } + public ExecutionRequestOptions withMarkupType(String markupType) { + this.markupType = markupType; + return this; + } + public ExecutionRequestOptions withOutputFormat(String outputFormat) { this.outputFormat = outputFormat; return this; @@ -185,6 +192,10 @@ public String getTransformerKey() { return transformerKey; } + public String getMarkupType() { + return markupType; + } + @Override public String toString() { return "ExecutionRequestOptions{" + diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java index 6bb66aa6..1ca7c454 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/PageRange.java @@ -24,6 +24,9 @@ package com.jaspersoft.android.sdk.service.data.report; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; + /** * @author Tom Koptel * @since 2.0 @@ -32,9 +35,9 @@ public final class PageRange { private final int mLowerBound; private final int mUpperBound; - public PageRange(String rawRange) { - mLowerBound = parseLowerBound(rawRange); - mUpperBound = parseUpperBound(rawRange); + private PageRange(int lowerBound, int upperBound) { + mLowerBound = lowerBound; + mUpperBound = upperBound; } public int getLowerBound() { @@ -49,12 +52,20 @@ public boolean isRange() { return mUpperBound != Integer.MAX_VALUE; } - private int parseLowerBound(String rawRange) { + @NotNull + public static PageRange parse(@NotNull String pages) { + Preconditions.checkNotNull(pages, "Pages should not be null"); + int lowerBound = parseLowerBound(pages); + int upperBound = parseUpperBound(pages); + return new PageRange(lowerBound, upperBound); + } + + private static int parseLowerBound(String rawRange) { String[] split = rawRange.split("-"); return Integer.parseInt(split[0]); } - private int parseUpperBound(String rawRange) { + private static int parseUpperBound(String rawRange) { String[] split = rawRange.split("-"); if (split.length == 1) { return Integer.MAX_VALUE; @@ -62,4 +73,32 @@ private int parseUpperBound(String rawRange) { return Integer.parseInt(split[1]); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PageRange pageRange = (PageRange) o; + + if (mLowerBound != pageRange.mLowerBound) return false; + if (mUpperBound != pageRange.mUpperBound) return false; + + return true; + } + + @Override + public int hashCode() { + int result = mLowerBound; + result = 31 * result + mUpperBound; + return result; + } + + @Override + public String toString() { + if (isRange()) { + return String.format("%d-%d", mLowerBound, mUpperBound); + } + return String.valueOf(mLowerBound); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportExportOutput.java similarity index 95% rename from core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportExportOutput.java index 0a66007c..d1800595 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportOutput.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportExportOutput.java @@ -28,7 +28,7 @@ * @author Tom Koptel * @since 2.0 */ -public interface ReportOutput extends ResourceOutput { +public interface ReportExportOutput extends ResourceOutput { boolean isFinal(); PageRange getPages(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java index 076648cb..be3a0539 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java @@ -44,4 +44,12 @@ public String getUri() { public int getTotalPages() { return totalPages; } + + @Override + public String toString() { + return "ReportMetadata{" + + "uri='" + uri + '\'' + + ", totalPages=" + totalPages + + '}'; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java index 4e5abf48..27f01a9f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java @@ -24,21 +24,21 @@ package com.jaspersoft.android.sdk.service.data.repository; -import java.util.Collection; +import java.util.List; /** * @author Tom Koptel * @since 2.0 */ public class SearchResult { - private Collection mResources; + private List mResources; private int mNextOffset; - public Collection getResources() { + public List getResources() { return mResources; } - public void setResources(Collection resources) { + public void setResources(List resources) { mResources = resources; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java new file mode 100644 index 00000000..49b3dca1 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.info; + +import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class ServerInfoService { + @NotNull + public abstract ServerInfo requestServerInfo() throws ServiceException; + + @NotNull + public static ServerInfoService newService(@NotNull AnonymousClient client) { + Preconditions.checkNotNull(client, "Client should not be null"); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); + return new ServerInfoServiceImpl(client.infoApi(), ServerInfoTransformer.get(), serviceExceptionMapper); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceImpl.java similarity index 59% rename from core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceImpl.java index beb0d545..1278f2a1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceImpl.java @@ -22,43 +22,37 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service.info; -import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; import java.io.IOException; -import java.text.SimpleDateFormat; /** * @author Tom Koptel * @since 2.0 */ -public class ServerInfoService { +final class ServerInfoServiceImpl extends ServerInfoService { private final ServerRestApi mRestApi; private final ServerInfoTransformer mTransformer; private final ServiceExceptionMapper mServiceExceptionMapper; @TestOnly - ServerInfoService(ServerRestApi restApi, ServerInfoTransformer transformer, ServiceExceptionMapper serviceExceptionMapper) { + ServerInfoServiceImpl(ServerRestApi restApi, ServerInfoTransformer transformer, ServiceExceptionMapper serviceExceptionMapper) { mRestApi = restApi; mTransformer = transformer; mServiceExceptionMapper = serviceExceptionMapper; } - public static ServerInfoService create(AnonymousClient client) { - ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - return new ServerInfoService(client.infoApi(), ServerInfoTransformer.get(), serviceExceptionMapper); - } - + @NotNull + @Override public ServerInfo requestServerInfo() throws ServiceException { try { ServerInfoData response = mRestApi.requestServerInfo(); @@ -69,26 +63,4 @@ public ServerInfo requestServerInfo() throws ServiceException { throw mServiceExceptionMapper.transform(e); } } - - public ServerVersion requestServerVersion() throws ServiceException { - try { - String version = mRestApi.requestVersion(); - return ServerVersion.valueOf(version); - } catch (HttpException e) { - throw mServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw mServiceExceptionMapper.transform(e); - } - } - - public SimpleDateFormat requestServerDateTimeFormat() throws ServiceException { - try { - String dateTimeFormat = mRestApi.requestDateTimeFormatPattern(); - return new SimpleDateFormat(dateTimeFormat); - } catch (HttpException e) { - throw mServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw mServiceExceptionMapper.transform(e); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoTransformer.java similarity index 98% rename from core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoTransformer.java index f2725bd2..158c24e5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformer.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoTransformer.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCache.java similarity index 93% rename from core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCache.java index c4d1da71..9bb424c7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InMemoryInfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCache.java @@ -22,9 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.service.info; +package com.jaspersoft.android.sdk.service.internal.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.internal.info.InfoCache; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InfoCache.java similarity index 96% rename from core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InfoCache.java index ad539d8b..7979b0a6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/InfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InfoCache.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service.info; +package com.jaspersoft.android.sdk.service.internal.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import org.jetbrains.annotations.NotNull; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InfoCacheManager.java similarity index 92% rename from core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InfoCacheManager.java index a806e4d6..aa7bd09a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManager.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InfoCacheManager.java @@ -22,13 +22,12 @@ * . */ -package com.jaspersoft.android.sdk.service.internal; +package com.jaspersoft.android.sdk.service.internal.info; import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.server.ServerInfoService; +import com.jaspersoft.android.sdk.service.info.ServerInfoService; import org.jetbrains.annotations.TestOnly; /** @@ -48,7 +47,7 @@ public class InfoCacheManager { } public static InfoCacheManager create(AuthorizedClient client, InfoCache cache) { - ServerInfoService serverInfoService = ServerInfoService.create(client); + ServerInfoService serverInfoService = ServerInfoService.newService(client); String baseUrl = client.getBaseUrl(); return new InfoCacheManager(baseUrl, serverInfoService, cache); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java new file mode 100644 index 00000000..36357f73 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class AbstractReportExecution implements ReportExecution { + protected final ReportExecutionApi mReportExecutionApi; + protected final String mExecId; + protected final String mReportUri; + protected final long mDelay; + + protected AbstractReportExecution(ReportExecutionApi reportExecutionApi, + String execId, + String reportUri, + long delay) { + mReportExecutionApi = reportExecutionApi; + mExecId = execId; + mReportUri = reportUri; + mDelay = delay; + } + + @NotNull + @Override + public final ReportMetadata waitForReportCompletion() throws ServiceException { + mReportExecutionApi.awaitStatus(mExecId, mReportUri, mDelay, Status.ready()); + ReportExecutionDescriptor reportDescriptor = mReportExecutionApi.getDetails(mExecId); + return new ReportMetadata(mReportUri, reportDescriptor.getTotalPages()); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java new file mode 100644 index 00000000..b8c0dd8e --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class AbstractReportService extends ReportService { + protected final ExportExecutionApi mExportExecutionApi; + protected final ReportExecutionApi mReportExecutionApi; + protected final ExportFactory mExportFactory; + protected final long mDelay; + + protected AbstractReportService(ExportExecutionApi exportExecutionApi, + ReportExecutionApi reportExecutionApi, + ExportFactory exportFactory, long delay) { + mExportExecutionApi = exportExecutionApi; + mReportExecutionApi = reportExecutionApi; + mExportFactory = exportFactory; + mDelay = delay; + } + + @NotNull + @Override + public ReportExecution run(@NotNull String reportUri, @NotNull ReportExecutionOptions execOptions) throws ServiceException { + ReportExecutionDescriptor descriptor = mReportExecutionApi.start(reportUri, execOptions); + String executionId = descriptor.getExecutionId(); + mReportExecutionApi.awaitStatus(executionId, reportUri, mDelay, Status.execution(), Status.ready()); + + return buildExecution(reportUri, executionId, execOptions); + } + + protected abstract ReportExecution buildExecution(String reportUri, String executionId, ReportExecutionOptions criteria); +} \ No newline at end of file diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapper.java new file mode 100644 index 00000000..a0aa84b7 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapper.java @@ -0,0 +1,46 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class AttachmentExportMapper { + public ResourceOutput transform(final OutputResource resource) { + return new ResourceOutput() { + @Override + public InputStream getStream() throws IOException { + return resource.getStream(); + } + }; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java new file mode 100644 index 00000000..663b965a --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.AttachmentDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class AttachmentsFactory { + private final ExportExecutionApi mExportExecutionApi; + + AttachmentsFactory(ExportExecutionApi exportExecutionApi) { + mExportExecutionApi = exportExecutionApi; + } + + public List create(ExportDescriptor export, String execId) { + String exportId = export.getId(); + Set rawAttachments = export.getAttachments(); + List attachments = new ArrayList<>(rawAttachments.size()); + for (AttachmentDescriptor attachment : rawAttachments) { + String fileName = attachment.getFileName(); + ReportAttachment reportAttachment = new ReportAttachmentImpl( + mExportExecutionApi, + execId, + exportId, + fileName + ); + attachments.add(reportAttachment); + } + return attachments; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java deleted file mode 100644 index 2c983ca0..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionCriteria.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import org.jetbrains.annotations.Nullable; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public abstract class ExecutionCriteria { - - protected final boolean mFreshData; - protected final boolean mInteractive; - protected final boolean mSaveSnapshot; - protected final Format mFormat; - protected final String mPages; - protected final String mAttachmentPrefix; - - protected ExecutionCriteria(boolean freshData, - boolean interactive, - boolean saveSnapshot, - Format format, - String pages, - String attachmentPrefix) { - mFreshData = freshData; - mInteractive = interactive; - mSaveSnapshot = saveSnapshot; - mFormat = format; - mPages = pages; - mAttachmentPrefix = attachmentPrefix; - } - - public enum Format { - HTML, PDF, XLS - } - - public Format getFormat() { - return mFormat; - } - - public boolean isFreshData() { - return mFreshData; - } - - public boolean isInteractive() { - return mInteractive; - } - - public boolean isSaveSnapshot() { - return mSaveSnapshot; - } - - @Nullable - public String getPages() { - return mPages; - } - - @Nullable - public String getAttachmentPrefix() { - return mAttachmentPrefix; - } - -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java deleted file mode 100644 index 729808de..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapper.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import org.jetbrains.annotations.NotNull; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class ExecutionOptionsDataMapper { - private final String mBaseUrl; - - ExecutionOptionsDataMapper(String baseUrl) { - mBaseUrl = baseUrl; - } - - public ReportExecutionRequestOptions transformRunReportOptions(@NotNull String reportUri, - @NotNull ServerVersion serverVersion, - @NotNull RunReportCriteria criteria) { - ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); - mapCommonCriterion(criteria, serverVersion, options); - options.withAsync(true); - options.withParameters(criteria.getParams()); - return options; - } - - public ExecutionRequestOptions transformExportOptions(@NotNull RunExportCriteria configuration, - @NotNull ServerVersion serverVersion) { - ExecutionRequestOptions options = ExecutionRequestOptions.create(); - mapCommonCriterion(configuration, serverVersion, options); - if (serverVersion.lessThanOrEquals(ServerVersion.v5_5)) { - options.withSaveDataSnapshot(null); - options.withFreshData(null); - options.withInteractive(null); - } - return options; - } - - private void mapCommonCriterion(@NotNull ExecutionCriteria criteria, - @NotNull ServerVersion version, - @NotNull ExecutionRequestOptions options) { - options.withOutputFormat(Helper.adaptFormat(criteria.getFormat())); - options.withAttachmentsPrefix(Helper.adaptAttachmentPrefix(criteria.getAttachmentPrefix())); - - options.withFreshData(criteria.isFreshData()); - options.withSaveDataSnapshot(criteria.isSaveSnapshot()); - options.withInteractive(criteria.isInteractive()); - options.withPages(criteria.getPages()); - - if (version.lessThanOrEquals(ServerVersion.v5_5)) { - options.withBaseUrl(null); - options.withAllowInlineScripts(null); - if (options.getOutputFormat() == null) { - options.withOutputFormat("HTML"); - } - } else if (version.equals(ServerVersion.v5_6)) { - options.withInteractive(false); - } else { - options.withBaseUrl(mBaseUrl); - } - } - - static class Helper { - static String adaptFormat(ExecutionCriteria.Format format) { - if (format == null) { - return null; - } - return format.toString(); - } - - static String adaptAttachmentPrefix(String attachmentsPrefix) { - if (attachmentsPrefix == null) { - return null; - } - try { - return URLEncoder.encode(attachmentsPrefix, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("This should not be possible", e); - } - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java new file mode 100644 index 00000000..2ea54935 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +interface ExportExecutionApi { + ExportExecutionDescriptor start(String execId, ReportExportOptions options) throws ServiceException; + + ExecutionStatus awaitReadyStatus(String execId, String exportId, String reportUri, long delay) throws ServiceException; + + ReportExportOutput downloadExport(String execId, String exportId) throws ServiceException; + + ResourceOutput downloadAttachment(String execId, String exportId, String attachmentId) throws ServiceException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java new file mode 100644 index 00000000..ff515ca6 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java @@ -0,0 +1,144 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ExportExecutionApiImpl implements ExportExecutionApi { + private final ServiceExceptionMapper mExceptionMapper; + private final ReportExportRestApi mReportExportRestApi; + private final ExportOptionsMapper mExportOptionsMapper; + + private final ReportExportMapper mReportExportMapper; + private final AttachmentExportMapper mAttachmentExportMapper; + + ExportExecutionApiImpl(ServiceExceptionMapper exceptionMapper, + ReportExportRestApi reportExportRestApi, + ExportOptionsMapper exportOptionsMapper, + ReportExportMapper reportExportMapper, + AttachmentExportMapper attachmentExportMapper) { + mExceptionMapper = exceptionMapper; + mReportExportRestApi = reportExportRestApi; + mExportOptionsMapper = exportOptionsMapper; + mReportExportMapper = reportExportMapper; + mAttachmentExportMapper = attachmentExportMapper; + } + + @Override + public ExportExecutionDescriptor start(String execId, ReportExportOptions reportExportOptions) throws ServiceException { + ExecutionRequestOptions options = mExportOptionsMapper.transform(reportExportOptions); + try { + return mReportExportRestApi.runExportExecution(execId, options); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + @Override + public ExecutionStatus awaitReadyStatus(String execId, String exportId, String reportUri, long delay) throws ServiceException { + ExecutionStatus executionStatus; + ErrorDescriptor descriptor; + Status status; + + do { + executionStatus = getStatus(execId, exportId); + status = Status.wrap(executionStatus.getStatus()); + descriptor = executionStatus.getErrorDescriptor(); + if (status.isCancelled()) { + throw new ServiceException( + String.format("Export for report '%s' execution cancelled", reportUri), null, + StatusCodes.EXPORT_EXECUTION_CANCELLED); + } + if (status.isFailed()) { + String message = "Failed to perform report export"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.EXPORT_EXECUTION_FAILED); + } + try { + Thread.sleep(delay); + } catch (InterruptedException ex) { + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); + } + } while (!status.isReady()); + + return executionStatus; + } + + @Override + public ReportExportOutput downloadExport(String execId, String exportId) throws ServiceException { + try { + ExportOutputResource result = mReportExportRestApi.requestExportOutput(execId, exportId); + return mReportExportMapper.transform(result); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + @Override + public ResourceOutput downloadAttachment(String execId, String exportId, String attachmentId) throws ServiceException { + try { + OutputResource result = mReportExportRestApi.requestExportAttachment(execId, exportId, attachmentId); + return mAttachmentExportMapper.transform(result); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + private ExecutionStatus getStatus(String execId, String exportId) throws ServiceException { + try { + return mReportExportRestApi.checkExportExecutionStatus(execId, exportId); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index 2413571d..250e4416 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -24,62 +24,36 @@ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.entity.execution.AttachmentDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.exception.StatusCodes; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; import java.util.List; -import java.util.Set; /** * @author Tom Koptel * @since 2.0 */ -final class ExportFactory { - private final ReportExportUseCase mExportUseCase; +class ExportFactory { + private final ExportExecutionApi mExportExecutionApi; + private final AttachmentsFactory mAttachmentsFactory; - private final String mExecutionId; - - ExportFactory(ReportExportUseCase exportUseCase, String executionId) { - mExportUseCase = exportUseCase; - mExecutionId = executionId; + ExportFactory(ExportExecutionApi exportExecutionApi, AttachmentsFactory attachmentsFactory) { + mExportExecutionApi = exportExecutionApi; + mAttachmentsFactory = attachmentsFactory; } @NotNull - public ReportExport create( - RunExportCriteria criteria, - ReportExecutionDescriptor executionDetails, - ExportExecutionDescriptor exportExecutionDetails) throws ServiceException { - String exportId = exportExecutionDetails.getExportId(); - ExportDescriptor export = findExportDescriptor(executionDetails, exportId); + public ReportExport create(ReportExecutionDescriptor descriptor, String execId, String exportId) throws ServiceException { + ExportDescriptor export = findExportDescriptor(descriptor, exportId); if (export == null) { throw new ServiceException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); } - List attachments = adaptAttachments(criteria, export); - return new ReportExport(mExecutionId, exportId, attachments, criteria, mExportUseCase); - } - - @NotNull - private List adaptAttachments(RunExportCriteria criteria, ExportDescriptor export) { - String exportId = export.getId(); - Set rawAttachments = export.getAttachments(); - List attachments = new ArrayList<>(rawAttachments.size()); - for (AttachmentDescriptor attachment : rawAttachments) { - ReportAttachment reportAttachment = new ReportAttachment( - attachment.getFileName(), - mExecutionId, - exportId, - criteria, - mExportUseCase); - attachments.add(reportAttachment); - } - return attachments; + List attachments = mAttachmentsFactory.create(export, execId); + return new ReportExportImpl(mExportExecutionApi, attachments, execId, exportId); } @Nullable diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper.java new file mode 100644 index 00000000..68e3233e --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper.java @@ -0,0 +1,82 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class ExportOptionsMapper { + private final String mBaseUrl; + + protected ExportOptionsMapper(String baseUrl) { + mBaseUrl = baseUrl; + } + + public static ExportOptionsMapper create(ServerVersion serverVersion, String baseUrl) { + if (serverVersion.greaterThanOrEquals(ServerVersion.v6_2)) { + return new ExportOptionsMapper6_2(baseUrl); + } + return new ExportOptionsMapper5_5and6_1(baseUrl); + } + + public ExecutionRequestOptions transform(ReportExportOptions options) { + ExecutionRequestOptions resultOptions = ExecutionRequestOptions.create(); + + ReportFormat format = options.getFormat(); + resultOptions.withOutputFormat(format.toString().toLowerCase()); + + PageRange pageRange = options.getPageRange(); + if (pageRange != null) { + resultOptions.withPages(pageRange.toString()); + } + + String prefix = options.getAttachmentPrefix(); + if (prefix != null) { + resultOptions.withAttachmentsPrefix(escapeAttachmentPrefix(prefix)); + } + + resultOptions.withIgnorePagination(options.getIgnorePagination()); + resultOptions.withAnchor(options.getAnchor()); + resultOptions.withAllowInlineScripts(options.getAllowInlineScripts()); + resultOptions.withBaseUrl(mBaseUrl); + return resultOptions; + } + + private String escapeAttachmentPrefix(String prefix) { + try { + return URLEncoder.encode(prefix, "UTF-8"); + } catch (UnsupportedEncodingException exception) { + return prefix; + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper5_5and6_1.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper5_5and6_1.java new file mode 100644 index 00000000..7e053f95 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper5_5and6_1.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ExportOptionsMapper5_5and6_1 extends ExportOptionsMapper { + ExportOptionsMapper5_5and6_1(String baseUrl) { + super(baseUrl); + } + + @Override + public ExecutionRequestOptions transform(ReportExportOptions criteria) { + ExecutionRequestOptions options = super.transform(criteria); + options.withIgnorePagination(null); + return options; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper6_2.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper6_2.java new file mode 100644 index 00000000..8de0d033 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportOptionsMapper6_2.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ExportOptionsMapper6_2 extends ExportOptionsMapper { + protected ExportOptionsMapper6_2(String baseUrl) { + super(baseUrl); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java new file mode 100644 index 00000000..f738b414 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ProxyReportService extends ReportService { + private final ReportServiceFactory mServiceFactory; + private ReportService mDelegate; + + ProxyReportService(ReportServiceFactory serviceFactory) { + mServiceFactory = serviceFactory; + } + + @NotNull + @Override + public ReportExecution run(@NotNull String reportUri, + @NotNull ReportExecutionOptions execOptions) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(execOptions, "Criteria should not be null"); + if (mDelegate == null) { + mDelegate = mServiceFactory.newService(); + } + return mDelegate.run(reportUri, execOptions); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index aa7846d1..efcf0d8f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -1,24 +1,24 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ @@ -26,40 +26,13 @@ import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; /** * @author Tom Koptel * @since 2.0 */ -public final class ReportAttachment { - private final String mFileName; - private final String mExecutionId; - private final String mExportId; - - private final RunExportCriteria mCriteria; - private final ReportExportUseCase mExportUseCase; - - ReportAttachment(String fileName, - String executionId, - String exportId, - RunExportCriteria criteria, - ReportExportUseCase exportUseCase) { - mFileName = fileName; - mExecutionId = executionId; - mExportId = exportId; - mCriteria = criteria; - mExportUseCase = exportUseCase; - } - +public interface ReportAttachment { @NotNull - public ResourceOutput download() throws ServiceException { - return mExportUseCase.requestExportAttachmentOutput( - mCriteria, - mExecutionId, - mExportId, - mFileName - ); - } + ResourceOutput download() throws ServiceException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentImpl.java similarity index 54% rename from core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentImpl.java index 2e17bd7f..6eaceab4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentImpl.java @@ -22,31 +22,39 @@ * . */ -package com.jaspersoft.android.sdk.service.repository; +package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; - -import java.util.Collection; +import org.jetbrains.annotations.NotNull; /** * @author Tom Koptel * @since 2.0 */ -interface SearchStrategy { - Collection searchNext() throws ServiceException; - boolean hasNext(); +final class ReportAttachmentImpl implements ReportAttachment { + private final ExportExecutionApi mExportExecutionApi; + private final String mExecutionId; + private final String mExportId; + private final String mFileName; + + ReportAttachmentImpl(ExportExecutionApi exportExecutionApi, + String executionId, + String exportId, + String fileName) { + mExportExecutionApi = exportExecutionApi; + mExecutionId = executionId; + mExportId = exportId; + mFileName = fileName; + } - class Factory { - public static SearchStrategy get(SearchUseCase searchUseCase, InternalCriteria criteria, ServerVersion version) { - if (version.lessThanOrEquals(ServerVersion.v5_5)) { - return new EmeraldMR2SearchStrategy(criteria, searchUseCase); - } - if (version.greaterThanOrEquals(ServerVersion.v5_6)) { - return new EmeraldMR3SearchStrategy(criteria, searchUseCase); - } - throw new UnsupportedOperationException("Could not resolve searchNext strategy for serverVersion: " + version); - } + @NotNull + @Override + public ResourceOutput download() throws ServiceException { + return mExportExecutionApi.downloadAttachment( + mExecutionId, + mExportId, + mFileName + ); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 66ec3d23..090c5c9a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -1,44 +1,34 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -46,163 +36,13 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportExecution { - private final long mDelay; - - private final ReportExecutionUseCase mExecutionUseCase; - private final ReportExportUseCase mExportUseCase; - - private final String mExecutionId; - private final String mReportUri; - private final ExportFactory mExportFactory; - private final ReportService mService; - private final RunReportCriteria mCriteria; - private final InfoCacheManager mInfoCacheManager; - - @TestOnly - ReportExecution(ReportService service, - RunReportCriteria criteria, - InfoCacheManager infoCacheManager, - long delay, - ReportExecutionUseCase executionUseCase, - ReportExportUseCase exportUseCase, - String executionId, - String reportUri) { - mService = service; - mCriteria = criteria; - mInfoCacheManager = infoCacheManager; - - mDelay = delay; - mExecutionUseCase = executionUseCase; - mExportUseCase = exportUseCase; - - mExecutionId = executionId; - mReportUri = reportUri; - - mExportFactory = new ExportFactory(exportUseCase, mExecutionId); - } - - @NotNull - public ReportMetadata waitForReportCompletion() throws ServiceException { - return performAwaitFoReport(); - } - +public interface ReportExecution { @NotNull - public ReportExecution updateExecution(List newParameters) throws ServiceException { - ServerInfo info = mInfoCacheManager.getInfo(); - ServerVersion version = info.getVersion(); - if (version.lessThanOrEquals(ServerVersion.v5_5)) { - RunReportCriteria criteria = mCriteria.newBuilder() - .params(newParameters) - .create(); - return mService.run(mReportUri, criteria); - } else { - mExecutionUseCase.updateExecution(mExecutionId, newParameters); - mService.waitForReportExecutionStart(mReportUri, mExecutionId); - return this; - } - } - - @NotNull - public ReportExport export(RunExportCriteria criteria) throws ServiceException { - try { - return performExport(criteria); - } catch (ServiceException ex) { - boolean isCancelled = (ex.code() == StatusCodes.EXPORT_EXECUTION_CANCELLED || - ex.code() == StatusCodes.REPORT_EXECUTION_CANCELLED); - if (isCancelled) { - /** - * Cancelled by technical reason. User applied Jive(for e.g. have applied new filter). - * Cancelled when report execution finished. This event flags that we need rerun export. - */ - return performExport(criteria); - } - throw ex; - } - } - - @NotNull - private ReportMetadata performAwaitFoReport() throws ServiceException { - ReportExecutionDescriptor completeDetails = waitForReportReadyStart(); - return new ReportMetadata(mReportUri, - completeDetails.getTotalPages()); - } - - @NotNull - private ReportExport performExport(RunExportCriteria criteria) throws ServiceException { - ExportExecutionDescriptor exportDetails = runExport(criteria); - String exportId = exportDetails.getExportId(); - waitForExportReadyStatus(exportId); - ReportExecutionDescriptor currentDetails = requestExecutionDetails(); - return mExportFactory.create(criteria, currentDetails, exportDetails); - } - - private void waitForExportReadyStatus(String exportId) throws ServiceException { - ExecutionStatus executionStatus; - ErrorDescriptor descriptor; - Status status; - do { - executionStatus = mExportUseCase.checkExportExecutionStatus(mExecutionId, exportId); - status = Status.wrap(executionStatus.getStatus()); - descriptor = executionStatus.getErrorDescriptor(); - if (status.isCancelled()) { - throw new ServiceException( - String.format("Export for report '%s' execution cancelled", mReportUri), null, - StatusCodes.EXPORT_EXECUTION_CANCELLED); - } - if (status.isFailed()) { - String message = "Failed to perform report export"; - if (descriptor != null) { - message = descriptor.getMessage(); - } - throw new ServiceException(message, null, StatusCodes.EXPORT_EXECUTION_FAILED); - } - try { - Thread.sleep(mDelay); - } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); - } - } while (!status.isReady()); - } - - @NotNull - private ReportExecutionDescriptor waitForReportReadyStart() throws ServiceException { - ReportExecutionDescriptor nextDetails; - ErrorDescriptor descriptor; - Status status; - do { - nextDetails = requestExecutionDetails(); - descriptor = nextDetails.getErrorDescriptor(); - status = Status.wrap(nextDetails.getStatus()); - - if (status.isCancelled()) { - throw new ServiceException( - String.format("Report '%s' execution cancelled", mReportUri), null, - StatusCodes.REPORT_EXECUTION_CANCELLED); - } - if (status.isFailed()) { - String message = "Failed to perform report execute"; - if (descriptor != null) { - message = descriptor.getMessage(); - } - throw new ServiceException(message, null, StatusCodes.REPORT_EXECUTION_FAILED); - } - try { - Thread.sleep(mDelay); - } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); - } - } while (!status.isReady()); - return nextDetails; - } + ReportExport export(@NotNull ReportExportOptions options) throws ServiceException; @NotNull - private ExportExecutionDescriptor runExport(RunExportCriteria criteria) throws ServiceException { - return mExportUseCase.runExport(mExecutionId, criteria); - } + ReportMetadata waitForReportCompletion() throws ServiceException; @NotNull - private ReportExecutionDescriptor requestExecutionDetails() throws ServiceException { - return mExecutionUseCase.requestExecutionDetails(mExecutionId); - } + ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java new file mode 100644 index 00000000..05aca6a1 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java @@ -0,0 +1,87 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExecution5_5 extends AbstractReportExecution { + private final ExportExecutionApi mExportExecutionApi; + private final ExportFactory mExportFactory; + private final ReportExecutionOptions mReportExecutionOptions; + + ReportExecution5_5(ExportExecutionApi exportExecutionApi, + ReportExecutionApi reportExecutionRestApi, + ExportFactory exportFactory, ReportExecutionOptions reportExecutionOptions, + String execId, + String reportUri, + long delay) { + super(reportExecutionRestApi, execId, reportUri, delay); + mExportExecutionApi = exportExecutionApi; + mExportFactory = exportFactory; + mReportExecutionOptions = reportExecutionOptions; + } + + @NotNull + @Override + public ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + ExportExecutionDescriptor exportDetails = mExportExecutionApi.start(mExecId, options); + String exportId = exportDetails.getExportId(); + ReportExecutionDescriptor reportDescriptor = mReportExecutionApi.getDetails(mExecId); + return mExportFactory.create(reportDescriptor, mExecId, exportId); + } + + @NotNull + @Override + public ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + ReportExecutionOptions criteria = mReportExecutionOptions.newBuilder() + .withParams(newParameters) + .build(); + ReportExecutionDescriptor descriptor = mReportExecutionApi.start(mReportUri, criteria); + + String executionId = descriptor.getExecutionId(); + mReportExecutionApi.awaitStatus(executionId, mReportUri, mDelay, Status.execution(), Status.ready()); + + return new ReportExecution5_5( + mExportExecutionApi, + mReportExecutionApi, + mExportFactory, + criteria, + executionId, + mReportUri, + mDelay + ); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java new file mode 100644 index 00000000..40161301 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java @@ -0,0 +1,74 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExecution5_6Plus extends AbstractReportExecution { + private final ExportExecutionApi mExportExecutionApi; + private final ExportFactory mExportFactory; + + ReportExecution5_6Plus(ExportExecutionApi exportExecutionApi, + ReportExecutionApi reportExecutionRestApi, + ExportFactory exportFactory, + String execId, + String reportUri, + long delay) { + super(reportExecutionRestApi, execId, reportUri, delay); + mExportExecutionApi = exportExecutionApi; + mExportFactory = exportFactory; + } + + @NotNull + @Override + public ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + ExportExecutionDescriptor exportDetails = mExportExecutionApi.start(mExecId, options); + String exportId = exportDetails.getExportId(); + + mExportExecutionApi.awaitReadyStatus(mExecId, exportId, mReportUri, mDelay); + ReportExecutionDescriptor reportDescriptor = mReportExecutionApi.getDetails(mExecId); + + return mExportFactory.create(reportDescriptor, mExecId, exportId); + } + + @NotNull + @Override + public ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + mReportExecutionApi.update(mExecId, newParameters); + mReportExecutionApi.awaitStatus(mExecId, mReportUri, mDelay, Status.execution(), Status.ready()); + return this; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java new file mode 100644 index 00000000..4c6d6b7b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java @@ -0,0 +1,46 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +interface ReportExecutionApi { + ReportExecutionDescriptor start(String reportUri, ReportExecutionOptions execOptions) throws ServiceException; + + void update(String executionId, List params) throws ServiceException; + + ReportExecutionDescriptor getDetails(String execId) throws ServiceException; + + ExecutionStatus awaitStatus(String execId, String reportUri, long delay, Status... statuses) throws ServiceException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java new file mode 100644 index 00000000..93052c65 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java @@ -0,0 +1,137 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExecutionApiImpl implements ReportExecutionApi { + private final ServiceExceptionMapper mExceptionMapper; + private final ReportExecutionRestApi mReportExecutionRestApi; + private final ReportOptionsMapper mReportOptionsMapper; + + ReportExecutionApiImpl( + ServiceExceptionMapper exceptionMapper, + ReportExecutionRestApi reportExecutionRestApi, + ReportOptionsMapper reportOptionsMapper) { + mExceptionMapper = exceptionMapper; + mReportExecutionRestApi = reportExecutionRestApi; + mReportOptionsMapper = reportOptionsMapper; + } + + @Override + public ReportExecutionDescriptor start(String reportUri, ReportExecutionOptions execOptions) throws ServiceException { + ReportExecutionRequestOptions options = mReportOptionsMapper.transform(reportUri, execOptions); + try { + return mReportExecutionRestApi.runReportExecution(options); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + @Override + public void update(String executionId, List params) throws ServiceException { + try { + mReportExecutionRestApi.updateReportExecution(executionId, params); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + @Override + public ReportExecutionDescriptor getDetails(String execId) throws ServiceException { + try { + return mReportExecutionRestApi.requestReportExecutionDetails(execId); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + @Override + public ExecutionStatus awaitStatus(String execId, String reportUri, long delay, Status... statuses) throws ServiceException { + ExecutionStatus nextDetails; + ErrorDescriptor descriptor; + Status status; + + List expectedStatuses = Arrays.asList(statuses); + do { + nextDetails = getStatus(execId); + descriptor = nextDetails.getErrorDescriptor(); + status = Status.wrap(nextDetails.getStatus()); + + if (status.isCancelled()) { + throw new ServiceException( + String.format("Report '%s' execution cancelled", reportUri), null, + StatusCodes.REPORT_EXECUTION_CANCELLED); + } + if (status.isFailed()) { + String message = "Failed to perform report execute"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.REPORT_EXECUTION_FAILED); + } + try { + Thread.sleep(delay); + } catch (InterruptedException ex) { + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); + } + } while (!expectedStatuses.contains(status)); + + return nextDetails; + } + + private ExecutionStatus getStatus(String execId) throws ServiceException { + try { + return mReportExecutionRestApi.requestReportExecutionStatus(execId); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptions.java new file mode 100644 index 00000000..003835fb --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptions.java @@ -0,0 +1,328 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExecutionOptions { + private final Boolean mFreshData; + private final Boolean mSaveSnapshot; + private final Boolean mInteractive; + private final Boolean mIgnorePagination; + private final Boolean mAllowInlineScripts; + private final String mTransformerKey; + private final String mAttachmentPrefix; + private final String mAnchor; + private final ReportMarkup mMarkupType; + private final ReportFormat mFormat; + private final PageRange mPageRange; + private final List mParams; + + @TestOnly + ReportExecutionOptions(Boolean freshData, + Boolean saveSnapshot, + Boolean interactive, + Boolean ignorePagination, + Boolean allowInlineScripts, + String transformerKey, + String attachmentPrefix, + String anchor, + ReportMarkup markupType, + ReportFormat format, + PageRange pageRange, + List params) { + mFreshData = freshData; + mSaveSnapshot = saveSnapshot; + mInteractive = interactive; + mIgnorePagination = ignorePagination; + mAllowInlineScripts = allowInlineScripts; + mTransformerKey = transformerKey; + mAttachmentPrefix = attachmentPrefix; + mAnchor = anchor; + mMarkupType = markupType; + mFormat = format; + mPageRange = pageRange; + mParams = params; + } + + + @NotNull + public Builder newBuilder() { + return new Builder() + .withFreshData(mFreshData) + .withSaveSnapshot(mSaveSnapshot) + .withInteractive(mInteractive) + .withIgnorePagination(mIgnorePagination) + .withAllowInlineScripts(mAllowInlineScripts) + .withTransformerKey(mTransformerKey) + .withAttachmentPrefix(mAttachmentPrefix) + .withAnchor(mAnchor) + .withMarkupType(mMarkupType) + .withFormat(mFormat) + .withPageRange(mPageRange) + .withParams(mParams); + } + + @NotNull + public static Builder builder() { + return new Builder(); + } + + @Nullable + public Boolean getFreshData() { + return mFreshData; + } + + @Nullable + public Boolean getSaveSnapshot() { + return mSaveSnapshot; + } + + @Nullable + public Boolean getInteractive() { + return mInteractive; + } + + @Nullable + public Boolean getIgnorePagination() { + return mIgnorePagination; + } + + @Nullable + public Boolean getAllowInlineScripts() { + return mAllowInlineScripts; + } + + @Nullable + public String getTransformerKey() { + return mTransformerKey; + } + + @Nullable + public String getAttachmentPrefix() { + return mAttachmentPrefix; + } + + @Nullable + public String getAnchor() { + return mAnchor; + } + + @Nullable + public ReportMarkup getMarkupType() { + return mMarkupType; + } + + @Nullable + public ReportFormat getFormat() { + return mFormat; + } + + @Nullable + public PageRange getPageRange() { + return mPageRange; + } + + @Nullable + public List getParams() { + return mParams; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ReportExecutionOptions criteria = (ReportExecutionOptions) o; + + if (mAllowInlineScripts != null ? !mAllowInlineScripts.equals(criteria.mAllowInlineScripts) : criteria.mAllowInlineScripts != null) + return false; + if (mAnchor != null ? !mAnchor.equals(criteria.mAnchor) : criteria.mAnchor != null) return false; + if (mAttachmentPrefix != null ? !mAttachmentPrefix.equals(criteria.mAttachmentPrefix) : criteria.mAttachmentPrefix != null) + return false; + if (mFormat != criteria.mFormat) return false; + if (mFreshData != null ? !mFreshData.equals(criteria.mFreshData) : criteria.mFreshData != null) return false; + if (mIgnorePagination != null ? !mIgnorePagination.equals(criteria.mIgnorePagination) : criteria.mIgnorePagination != null) + return false; + if (mInteractive != null ? !mInteractive.equals(criteria.mInteractive) : criteria.mInteractive != null) + return false; + if (mMarkupType != criteria.mMarkupType) return false; + if (mPageRange != null ? !mPageRange.equals(criteria.mPageRange) : criteria.mPageRange != null) return false; + if (mParams != null ? !mParams.equals(criteria.mParams) : criteria.mParams != null) return false; + if (mSaveSnapshot != null ? !mSaveSnapshot.equals(criteria.mSaveSnapshot) : criteria.mSaveSnapshot != null) + return false; + if (mTransformerKey != null ? !mTransformerKey.equals(criteria.mTransformerKey) : criteria.mTransformerKey != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = mFreshData != null ? mFreshData.hashCode() : 0; + result = 31 * result + (mSaveSnapshot != null ? mSaveSnapshot.hashCode() : 0); + result = 31 * result + (mInteractive != null ? mInteractive.hashCode() : 0); + result = 31 * result + (mIgnorePagination != null ? mIgnorePagination.hashCode() : 0); + result = 31 * result + (mAllowInlineScripts != null ? mAllowInlineScripts.hashCode() : 0); + result = 31 * result + (mTransformerKey != null ? mTransformerKey.hashCode() : 0); + result = 31 * result + (mAttachmentPrefix != null ? mAttachmentPrefix.hashCode() : 0); + result = 31 * result + (mAnchor != null ? mAnchor.hashCode() : 0); + result = 31 * result + (mMarkupType != null ? mMarkupType.hashCode() : 0); + result = 31 * result + (mFormat != null ? mFormat.hashCode() : 0); + result = 31 * result + (mPageRange != null ? mPageRange.hashCode() : 0); + result = 31 * result + (mParams != null ? mParams.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "RunReportCriteria{" + + "freshData=" + mFreshData + + ", saveSnapshot=" + mSaveSnapshot + + ", interactive=" + mInteractive + + ", ignorePagination=" + mIgnorePagination + + ", allowInlineScripts=" + mAllowInlineScripts + + ", transformerKey='" + mTransformerKey + '\'' + + ", attachmentPrefix='" + mAttachmentPrefix + '\'' + + ", anchor='" + mAnchor + '\'' + + ", markupType=" + mMarkupType + + ", format=" + mFormat + + ", pageRange=" + mPageRange + + '}'; + } + + public static class Builder { + private Boolean mFreshData; + private Boolean mSaveSnapshot; + private Boolean mInteractive; + private Boolean mIgnorePagination; + private Boolean mAllowInlineScripts; + private String mTransformerKey; + private String mAttachmentPrefix; + private String mAnchor; + private ReportMarkup mMarkupType; + private ReportFormat mFormat; + private PageRange mPageRange; + private List mParams; + + public Builder() { + mInteractive = true; + } + + public Builder withFreshData(@Nullable Boolean freshData) { + this.mFreshData = freshData; + return this; + } + + public Builder withSaveSnapshot(@Nullable Boolean saveSnapshot) { + mSaveSnapshot = saveSnapshot; + return this; + } + + /** + * Configuration for report interactiveness + *

+ * NOTICE: This flag ignored for JRS 5.6 where we are forcing disable state + * + * @param interactive weather report should be mInteractive or not + * @return builder instance + */ + public Builder withInteractive(@Nullable Boolean interactive) { + mInteractive = interactive; + return this; + } + + public Builder withIgnorePagination(@Nullable Boolean ignorePagination) { + mIgnorePagination = ignorePagination; + return this; + } + + public Builder withAllowInlineScripts(@Nullable Boolean allowInlineScripts) { + mAllowInlineScripts = allowInlineScripts; + return this; + } + + public Builder withTransformerKey(@Nullable String transformerKey) { + mTransformerKey = transformerKey; + return this; + } + + public Builder withAttachmentPrefix(@Nullable String prefix) { + mAttachmentPrefix = prefix; + return this; + } + + public Builder withAnchor(@Nullable String anchor) { + mAnchor = anchor; + return this; + } + + public Builder withMarkupType(@Nullable ReportMarkup markup) { + mMarkupType = markup; + return this; + } + + public Builder withFormat(@Nullable ReportFormat format) { + mFormat = format; + return this; + } + + public Builder withPageRange(@Nullable PageRange pageRange) { + mPageRange = pageRange; + return this; + } + + public Builder withParams(@Nullable List params) { + mParams = params; + return this; + } + + public ReportExecutionOptions build() { + return new ReportExecutionOptions( + mFreshData, + mSaveSnapshot, + mInteractive, + mIgnorePagination, + mAllowInlineScripts, + mTransformerKey, + mAttachmentPrefix, + mAnchor, + mMarkupType, + mFormat, + mPageRange, + mParams); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java deleted file mode 100644 index 7f3b6615..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCase.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Call; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class ReportExecutionUseCase { - private final ReportExecutionRestApi mExecutionApi; - private final CallExecutor mCallExecutor; - private final ExecutionOptionsDataMapper mExecutionOptionsMapper; - private final InfoCacheManager mCacheManager; - - ReportExecutionUseCase(ReportExecutionRestApi executionApi, - CallExecutor callExecutor, - InfoCacheManager cacheManager, - ExecutionOptionsDataMapper executionOptionsMapper) { - mExecutionApi = executionApi; - mCallExecutor = callExecutor; - mCacheManager = cacheManager; - mExecutionOptionsMapper = executionOptionsMapper; - } - - @NotNull - public ReportExecutionDescriptor runReportExecution(final String reportUri, final RunReportCriteria criteria) throws ServiceException { - ServerInfo info = mCacheManager.getInfo(); - final ServerVersion version = info.getVersion(); - Call call = new Call() { - @Override - public ReportExecutionDescriptor perform() throws IOException, HttpException { - ReportExecutionRequestOptions options = - mExecutionOptionsMapper.transformRunReportOptions(reportUri, version, criteria); - return mExecutionApi.runReportExecution(options); - } - }; - return mCallExecutor.execute(call); - } - - @NotNull - public ExecutionStatus requestStatus(final String executionId) throws ServiceException { - Call call = new Call() { - @Override - public ExecutionStatus perform() throws IOException, HttpException { - return mExecutionApi.requestReportExecutionStatus(executionId); - } - }; - return mCallExecutor.execute(call); - } - - @NotNull - public ReportExecutionDescriptor requestExecutionDetails(final String executionId) throws ServiceException { - Call call = new Call() { - @Override - public ReportExecutionDescriptor perform() throws IOException, HttpException { - return mExecutionApi.requestReportExecutionDetails(executionId); - } - }; - return mCallExecutor.execute(call); - } - - public void updateExecution(final String executionId, final List newParameters) throws ServiceException { - Call call = new Call() { - @Override - public Void perform() throws IOException, HttpException { - mExecutionApi.updateReportExecution(executionId, newParameters); - return null; - } - }; - mCallExecutor.execute(call); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 7b89698b..76c460b8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -1,30 +1,30 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.service.data.report.ReportOutput; +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; @@ -34,32 +34,10 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportExport { - private final List mAttachments; - private final String mExecutionId; - private final String mExportId; - private final ReportExportUseCase mExportUseCase; - private final RunExportCriteria mCriteria; - - ReportExport(String executionId, - String exportId, - List attachments, - RunExportCriteria criteria, - ReportExportUseCase exportUseCase) { - mExecutionId = executionId; - mExportId = exportId; - mAttachments = attachments; - mCriteria = criteria; - mExportUseCase = exportUseCase; - } - +public interface ReportExport { @NotNull - public List getAttachments() { - return mAttachments; - } + List getAttachments(); @NotNull - public ReportOutput download() throws ServiceException { - return mExportUseCase.requestExportOutput(mCriteria, mExecutionId, mExportId); - } + ReportExportOutput download() throws ServiceException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java new file mode 100644 index 00000000..94a64364 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportExportImpl implements ReportExport { + private final ExportExecutionApi mExportExecutionApi; + private final List mAttachments; + private final String mExecutionId; + private final String mExportId; + + ReportExportImpl(ExportExecutionApi exportExecutionApi, + List attachments, + String executionId, + String exportId) { + mExportExecutionApi = exportExecutionApi; + mAttachments = attachments; + mExecutionId = executionId; + mExportId = exportId; + } + + @NotNull + @Override + public List getAttachments() { + return mAttachments; + } + + @NotNull + @Override + public ReportExportOutput download() throws ServiceException { + return mExportExecutionApi.downloadExport(mExecutionId, mExportId); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportMapper.java similarity index 53% rename from core/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportMapper.java index 923861fb..3ff38a3b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/OutputDataMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportMapper.java @@ -1,34 +1,32 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.jaspersoft.android.sdk.service.data.report.PageRange; -import com.jaspersoft.android.sdk.service.data.report.ReportOutput; -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; import java.io.IOException; import java.io.InputStream; @@ -37,9 +35,9 @@ * @author Tom Koptel * @since 2.0 */ -final class OutputDataMapper { - public static ReportOutput transform(final ExportOutputResource outputResource) { - return new ReportOutput() { +class ReportExportMapper { + public ReportExportOutput transform(final ExportOutputResource outputResource) { + return new ReportExportOutput() { @Override public boolean isFinal() { return outputResource.isFinal(); @@ -47,7 +45,7 @@ public boolean isFinal() { @Override public PageRange getPages() { - return new PageRange(outputResource.getPages()); + return PageRange.parse(outputResource.getPages()); } @Override @@ -56,13 +54,4 @@ public InputStream getStream() throws IOException { } }; } - - public static ResourceOutput transform(final OutputResource resource) { - return new ResourceOutput() { - @Override - public InputStream getStream() throws IOException { - return resource.getStream(); - } - }; - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportOptions.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportOptions.java new file mode 100644 index 00000000..0d58761f --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportOptions.java @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class ReportExportOptions { + private final ReportFormat mFormat; + + private final PageRange mPageRange; + private final String mAttachmentPrefix; + private final String mAnchor; + + private final Boolean mIgnorePagination; + private final Boolean mAllowInlineScripts; + + @TestOnly + ReportExportOptions(ReportFormat format, + PageRange pageRange, + String attachmentPrefix, + String anchor, + Boolean ignorePagination, + Boolean allowInlineScripts) { + mFormat = format; + mPageRange = pageRange; + mAttachmentPrefix = attachmentPrefix; + mAnchor = anchor; + mIgnorePagination = ignorePagination; + mAllowInlineScripts = allowInlineScripts; + } + + @NotNull + public static Builder builder() { + return new Builder(); + } + + @NotNull + public ReportFormat getFormat() { + return mFormat; + } + + @Nullable + public PageRange getPageRange() { + return mPageRange; + } + + @Nullable + public String getAttachmentPrefix() { + return mAttachmentPrefix; + } + + @Nullable + public String getAnchor() { + return mAnchor; + } + + @Nullable + public Boolean getIgnorePagination() { + return mIgnorePagination; + } + + @Nullable + public Boolean getAllowInlineScripts() { + return mAllowInlineScripts; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ReportExportOptions that = (ReportExportOptions) o; + + if (mAllowInlineScripts != null ? !mAllowInlineScripts.equals(that.mAllowInlineScripts) : that.mAllowInlineScripts != null) + return false; + if (mAnchor != null ? !mAnchor.equals(that.mAnchor) : that.mAnchor != null) return false; + if (mAttachmentPrefix != null ? !mAttachmentPrefix.equals(that.mAttachmentPrefix) : that.mAttachmentPrefix != null) + return false; + if (mFormat != that.mFormat) return false; + if (mIgnorePagination != null ? !mIgnorePagination.equals(that.mIgnorePagination) : that.mIgnorePagination != null) + return false; + if (mPageRange != null ? !mPageRange.equals(that.mPageRange) : that.mPageRange != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = mFormat != null ? mFormat.hashCode() : 0; + result = 31 * result + (mPageRange != null ? mPageRange.hashCode() : 0); + result = 31 * result + (mAttachmentPrefix != null ? mAttachmentPrefix.hashCode() : 0); + result = 31 * result + (mAnchor != null ? mAnchor.hashCode() : 0); + result = 31 * result + (mIgnorePagination != null ? mIgnorePagination.hashCode() : 0); + result = 31 * result + (mAllowInlineScripts != null ? mAllowInlineScripts.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "RunExportCriteria{" + + "format=" + mFormat + + ", pages='" + mPageRange + '\'' + + ", attachmentPrefix='" + mAttachmentPrefix + '\'' + + ", anchor='" + mAnchor + '\'' + + ", ignorePagination=" + mIgnorePagination + + ", allowInlineScripts=" + mAllowInlineScripts + + '}'; + } + + public static class Builder { + private ReportFormat mFormat; + + private PageRange mPageRange; + private String mAttachmentPrefix; + private String mAnchor; + + private Boolean mIgnorePagination; + private Boolean mAllowInlineScripts; + + private Builder() { + } + + public Builder withFormat(@NotNull ReportFormat format) { + mFormat = Preconditions.checkNotNull(format, "Format should not be null"); + return this; + } + + public Builder withPageRange(@Nullable PageRange pages) { + mPageRange = pages; + return this; + } + + public Builder withAttachmentPrefix(@Nullable String prefix) { + mAttachmentPrefix = prefix; + return this; + } + + public Builder withAnchor(@Nullable String anchor) { + mAnchor = anchor; + return this; + } + + public Builder withIgnorePagination(boolean ignorePagination) { + mIgnorePagination = ignorePagination; + return this; + } + + public Builder withAllowInlineScripts(boolean allowInlineScripts) { + mAllowInlineScripts = allowInlineScripts; + return this; + } + + public ReportExportOptions build() { + if (mFormat == null) { + throw new IllegalStateException("Format should be supplied"); + } + return new ReportExportOptions( + mFormat, + mPageRange, + mAttachmentPrefix, + mAnchor, + mIgnorePagination, + mAllowInlineScripts + ); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java deleted file mode 100644 index ff1ecaf2..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCase.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.data.report.ReportOutput; -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Call; -import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -class ReportExportUseCase { - private final ReportExportRestApi mExportApi; - private final CallExecutor mCallExecutor; - private final ExecutionOptionsDataMapper mExecutionOptionsMapper; - private final InfoCacheManager mCacheManager; - - ReportExportUseCase(ReportExportRestApi exportApi, - CallExecutor callExecutor, - InfoCacheManager cacheManager, - ExecutionOptionsDataMapper executionOptionsMapper) { - mExportApi = exportApi; - mCallExecutor = callExecutor; - mCacheManager = cacheManager; - mExecutionOptionsMapper = executionOptionsMapper; - } - - @NotNull - public ExportExecutionDescriptor runExport(final String executionId, final RunExportCriteria criteria) throws ServiceException { - ServerInfo info = mCacheManager.getInfo(); - final ServerVersion version = info.getVersion(); - - Call call = new Call() { - @Override - public ExportExecutionDescriptor perform() throws IOException, HttpException { - ExecutionRequestOptions options = mExecutionOptionsMapper.transformExportOptions(criteria, version); - return mExportApi.runExportExecution(executionId, options); - } - }; - return mCallExecutor.execute(call); - } - - @NotNull - public ExecutionStatus checkExportExecutionStatus(final String executionId, - final String exportId) throws ServiceException { - ServerInfo info = mCacheManager.getInfo(); - final ServerVersion version = info.getVersion(); - if (version.lessThanOrEquals(ServerVersion.v5_5)) { - return ExecutionStatus.readyStatus(); - } - - Call call = new Call() { - @Override - public ExecutionStatus perform() throws IOException, HttpException { - return mExportApi.checkExportExecutionStatus(executionId, exportId); - } - }; - return mCallExecutor.execute(call); - } - - @NotNull - public ReportOutput requestExportOutput(RunExportCriteria exportCriteria, - final String executionId, - String exportId) throws ServiceException { - exportId = adaptExportId(exportCriteria, exportId); - final String resultId = exportId; - - Call call = new Call() { - @Override - public ReportOutput perform() throws IOException, HttpException { - ExportOutputResource result = mExportApi.requestExportOutput(executionId, resultId); - return OutputDataMapper.transform(result); - } - }; - return mCallExecutor.execute(call); - } - - @NotNull - public ResourceOutput requestExportAttachmentOutput(RunExportCriteria exportCriteria, - final String executionId, - String exportId, - final String fileName) throws ServiceException { - exportId = adaptExportId(exportCriteria, exportId); - final String resultId = exportId; - - Call call = new Call() { - @Override - public ResourceOutput perform() throws IOException, HttpException { - OutputResource result = mExportApi.requestExportAttachment( - executionId, resultId, fileName); - return OutputDataMapper.transform(result); - } - }; - return mCallExecutor.execute(call); - } - - private String adaptExportId(RunExportCriteria exportCriteria, String exportId) throws ServiceException { - ServerInfo info = mCacheManager.getInfo(); - final ServerVersion version = info.getVersion(); - - if (version.lessThanOrEquals(ServerVersion.v5_5)) { - exportId = String.format("%s;pages=%s", exportCriteria.getFormat(), exportCriteria.getPages()); - exportId = exportId.toLowerCase(); - } - return exportId; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportFormat.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportFormat.java new file mode 100644 index 00000000..bf212478 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportFormat.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum ReportFormat { + HTML, PDF, XLS +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportMarkup.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportMarkup.java new file mode 100644 index 00000000..1375306f --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportMarkup.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum ReportMarkup { + FULL, EMBEDDABLE +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper.java new file mode 100644 index 00000000..a6042c0f --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper.java @@ -0,0 +1,97 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +/** + * @author Tom Koptel + * @since 2.0 + */ +abstract class ReportOptionsMapper { + private final String mBaseUrl; + + protected ReportOptionsMapper(String baseUrl) { + mBaseUrl = baseUrl; + } + + public static ReportOptionsMapper create(ServerVersion serverVersion, String baseUrl) { + if (serverVersion.lessThanOrEquals(ServerVersion.v5_5)) { + return new ReportOptionsMapper5_5(baseUrl); + } + if (serverVersion.equals(ServerVersion.v5_6)) { + return new ReportOptionsMapper5_6(baseUrl); + } + return new ReportOptionsMapper5_6Plus(baseUrl); + } + + public ReportExecutionRequestOptions transform(String reportUri, ReportExecutionOptions criteria) { + ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest(reportUri); + options.withBaseUrl(mBaseUrl); + options.withFreshData(criteria.getFreshData()); + options.withSaveDataSnapshot(criteria.getSaveSnapshot()); + options.withInteractive(criteria.getInteractive()); + options.withIgnorePagination(criteria.getIgnorePagination()); + options.withAllowInlineScripts(criteria.getAllowInlineScripts()); + options.withTransformerKey(criteria.getTransformerKey()); + options.withAnchor(criteria.getAnchor()); + options.withParameters(criteria.getParams()); + + String attachmentPrefix = criteria.getAttachmentPrefix(); + if (attachmentPrefix != null) { + options.withAttachmentsPrefix(escapeAttachmentPrefix(attachmentPrefix)); + } + + ReportMarkup markupType = criteria.getMarkupType(); + if (markupType != null) { + options.withMarkupType(markupType.toString().toLowerCase()); + } + + ReportFormat format = criteria.getFormat(); + if (format != null) { + options.withOutputFormat(format.toString().toLowerCase()); + } + + PageRange pageRange = criteria.getPageRange(); + if (pageRange != null) { + options.withPages(pageRange.toString()); + } + + return options; + } + + private String escapeAttachmentPrefix(String prefix) { + try { + return URLEncoder.encode(prefix, "UTF-8"); + } catch (UnsupportedEncodingException exception) { + return prefix; + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5.java new file mode 100644 index 00000000..b710546b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportOptionsMapper5_5 extends ReportOptionsMapper { + protected ReportOptionsMapper5_5(String baseUrl) { + super(baseUrl); + } + + @Override + public ReportExecutionRequestOptions transform(String reportUri, ReportExecutionOptions criteria) { + ReportExecutionRequestOptions options = super.transform(reportUri, criteria); + options.withBaseUrl(null); + options.withAnchor(null); + options.withAllowInlineScripts(null); + options.withMarkupType(null); + if (options.getOutputFormat() == null) { + String format = ReportFormat.HTML.toString().toLowerCase(); + options.withOutputFormat(format); + } + return options; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6.java new file mode 100644 index 00000000..3dda777c --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportOptionsMapper5_6 extends ReportOptionsMapper { + protected ReportOptionsMapper5_6(String baseUrl) { + super(baseUrl); + } + + @Override + public ReportExecutionRequestOptions transform(String reportUri, ReportExecutionOptions criteria) { + ReportExecutionRequestOptions options = super.transform(reportUri, criteria); + options.withInteractive(false); + return options; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Plus.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Plus.java new file mode 100644 index 00000000..20702726 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Plus.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportOptionsMapper5_6Plus extends ReportOptionsMapper { + protected ReportOptionsMapper5_6Plus(String baseUrl) { + super(baseUrl); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 2ef9a427..9c7b7715 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -1,41 +1,38 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.AuthorizedClient; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.internal.*; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.internal.ReportExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.info.InMemoryInfoCache; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; import java.util.concurrent.TimeUnit; @@ -43,90 +40,26 @@ * @author Tom Koptel * @since 2.0 */ -public final class ReportService { - - private final ReportExecutionUseCase mExecutionUseCase; - private final InfoCacheManager mInfoCacheManager; - private final ReportExportUseCase mExportUseCase; - private final long mDelay; - - @TestOnly - ReportService( - long delay, - InfoCacheManager infoCacheManager, - ReportExecutionUseCase executionUseCase, - ReportExportUseCase exportUseCase) { - mDelay = delay; - mInfoCacheManager = infoCacheManager; - mExecutionUseCase = executionUseCase; - mExportUseCase = exportUseCase; - } - - public static ReportService create(AuthorizedClient client, InfoCache infoCache) { - ReportExecutionRestApi executionApi = client.reportExecutionApi(); - ReportExportRestApi exportApi = client.reportExportApi(); - - ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); - ServiceExceptionMapper reportExMapper = new ReportExceptionMapper(defaultExMapper); - CallExecutor callExecutor = new DefaultCallExecutor(reportExMapper); - - ExecutionOptionsDataMapper executionOptionsMapper = new ExecutionOptionsDataMapper(client.getBaseUrl()); - - InfoCacheManager cacheManager = InfoCacheManager.create(client, infoCache); - ReportExecutionUseCase reportExecutionUseCase = - new ReportExecutionUseCase(executionApi, callExecutor, cacheManager, executionOptionsMapper); - ReportExportUseCase reportExportUseCase = - new ReportExportUseCase(exportApi, callExecutor, cacheManager, executionOptionsMapper); - - return new ReportService( - TimeUnit.SECONDS.toMillis(1), - cacheManager, - reportExecutionUseCase, - reportExportUseCase); - } - - public ReportExecution run(String reportUri, RunReportCriteria criteria) throws ServiceException { - return performRun(reportUri, criteria); - } - +public abstract class ReportService { @NotNull - private ReportExecution performRun(String reportUri, RunReportCriteria criteria) throws ServiceException { - ReportExecutionDescriptor details = mExecutionUseCase.runReportExecution(reportUri, criteria); + public abstract ReportExecution run(@NotNull String reportUri, @NotNull ReportExecutionOptions execOptions) throws ServiceException; - waitForReportExecutionStart(reportUri, details.getExecutionId()); - - return new ReportExecution( - this, - criteria, - mInfoCacheManager, - mDelay, - mExecutionUseCase, - mExportUseCase, - details.getExecutionId(), - details.getReportURI()); - } - - void waitForReportExecutionStart(String reportUri, String executionId) throws ServiceException { - Status status; - do { - ExecutionStatus statusDetails = mExecutionUseCase.requestStatus(executionId); - status = Status.wrap(statusDetails.getStatus()); - ErrorDescriptor descriptor = statusDetails.getErrorDescriptor(); - - if (status.isCancelled()) { - throw new ServiceException( - String.format("Report '%s' execution cancelled", reportUri), null, - StatusCodes.REPORT_EXECUTION_CANCELLED); - } - if (status.isFailed()) { - throw new ServiceException(descriptor.getMessage(), null, StatusCodes.REPORT_EXECUTION_FAILED); - } - try { - Thread.sleep(mDelay); - } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); - } - - } while (!status.isReady() && !status.isExecution()); + @NotNull + public static ReportService newService(@NotNull AuthorizedClient client) { + Preconditions.checkNotNull(client, "Client should not be null"); + + InfoCacheManager cacheManager = InfoCacheManager.create(client, new InMemoryInfoCache()); + ServiceExceptionMapper defaultMapper = new DefaultExceptionMapper(); + ServiceExceptionMapper reportMapper = new ReportExceptionMapper(defaultMapper); + + ReportServiceFactory reportServiceFactory = new ReportServiceFactory(cacheManager, + client.reportExecutionApi(), + client.reportExportApi(), + reportMapper, + client.getBaseUrl(), + TimeUnit.SECONDS.toMillis(1) + ); + + return new ProxyReportService(reportServiceFactory); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java new file mode 100644 index 00000000..df81fdd4 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportService5_5 extends AbstractReportService { + protected ReportService5_5(ExportExecutionApi exportExecutionApi, + ReportExecutionApi reportExecutionApi, + ExportFactory exportFactory, + long delay) { + super(exportExecutionApi, reportExecutionApi, exportFactory, delay); + } + + @Override + protected ReportExecution buildExecution(String reportUri, String executionId, ReportExecutionOptions execOptions) { + ReportExecution reportExecution = new ReportExecution5_5( + mExportExecutionApi, + mReportExecutionApi, + mExportFactory, + execOptions, + executionId, + reportUri, + mDelay); + return new RetryReportExecution(reportExecution); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java new file mode 100644 index 00000000..84ad7cde --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ReportService5_6Plus extends AbstractReportService { + protected ReportService5_6Plus(ExportExecutionApi exportExecutionApi, + ReportExecutionApi reportExecutionApi, + ExportFactory exportFactory, + long delay) { + super(exportExecutionApi, reportExecutionApi, exportFactory, delay); + } + + @Override + protected ReportExecution buildExecution(String reportUri, String executionId, ReportExecutionOptions execOptions) { + ReportExecution reportExecution = new ReportExecution5_6Plus( + mExportExecutionApi, + mReportExecutionApi, + mExportFactory, + executionId, + reportUri, + mDelay); + return new RetryReportExecution(reportExecution); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java new file mode 100644 index 00000000..651a9581 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java @@ -0,0 +1,93 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class ReportServiceFactory { + private final InfoCacheManager mCacheManager; + private final ReportExecutionRestApi mReportExecutionRestApi; + private final ReportExportRestApi mReportExportRestApi; + private final ServiceExceptionMapper mExceptionMapper; + private final String mBaseUrl; + private final long mDelay; + + + ReportServiceFactory(InfoCacheManager cacheManager, + ReportExecutionRestApi reportExecutionRestApi, + ReportExportRestApi reportExportRestApi, + ServiceExceptionMapper exceptionMapper, + String baseUrl, long delay) { + mCacheManager = cacheManager; + mReportExecutionRestApi = reportExecutionRestApi; + mReportExportRestApi = reportExportRestApi; + mExceptionMapper = exceptionMapper; + mBaseUrl = baseUrl; + mDelay = delay; + } + + public ReportService newService() throws ServiceException { + ServerInfo info = mCacheManager.getInfo(); + ServerVersion version = info.getVersion(); + + ExportOptionsMapper exportOptionsMapper = ExportOptionsMapper.create(version, mBaseUrl); + ReportOptionsMapper reportOptionsMapper = ReportOptionsMapper.create(version, mBaseUrl); + + ExportExecutionApi exportExecutionApi = createExportExecApi(exportOptionsMapper); + ReportExecutionApi reportExecutionApi = createReportExecApi(reportOptionsMapper); + + AttachmentsFactory attachmentsFactory = new AttachmentsFactory(exportExecutionApi); + ExportFactory exportFactory = new ExportFactory(exportExecutionApi, attachmentsFactory); + + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + return new ReportService5_5(exportExecutionApi, reportExecutionApi, exportFactory, mDelay); + } else { + return new ReportService5_6Plus(exportExecutionApi, reportExecutionApi,exportFactory, mDelay); + } + } + + @NotNull + private ReportExecutionApi createReportExecApi(ReportOptionsMapper reportOptionsMapper) { + return new ReportExecutionApiImpl(mExceptionMapper, mReportExecutionRestApi, reportOptionsMapper); + } + + @NotNull + private ExportExecutionApi createExportExecApi(ExportOptionsMapper exportOptionsMapper) { + ReportExportMapper reportExportMapper = new ReportExportMapper(); + AttachmentExportMapper attachmentExportMapper = new AttachmentExportMapper(); + return new ExportExecutionApiImpl(mExceptionMapper, mReportExportRestApi, exportOptionsMapper, reportExportMapper, attachmentExportMapper); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java new file mode 100644 index 00000000..fa8302b0 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java @@ -0,0 +1,77 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RetryReportExecution implements ReportExecution { + private final ReportExecution mDelegate; + + RetryReportExecution(ReportExecution delegate) { + mDelegate = delegate; + } + + @NotNull + @Override + public ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + try { + return mDelegate.export(options); + } catch (ServiceException ex) { + boolean isCancelled = (ex.code() == StatusCodes.EXPORT_EXECUTION_CANCELLED || + ex.code() == StatusCodes.REPORT_EXECUTION_CANCELLED); + if (isCancelled) { + /** + * Cancelled by technical reason. User applied Jive(for e.g. have applied new filter). + * Cancelled when report execution finished. This event flags that we need rerun export. + */ + return mDelegate.export(options); + } + throw ex; + } + } + + @NotNull + @Override + public ReportMetadata waitForReportCompletion() throws ServiceException { + return mDelegate.waitForReportCompletion(); + } + + @NotNull + @Override + public ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + return mDelegate.updateExecution(newParameters); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java deleted file mode 100644 index df0b4ec2..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunExportCriteria.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class RunExportCriteria extends ExecutionCriteria { - private RunExportCriteria(boolean freshData, boolean interactive, boolean saveSnapshot, Format format, String pages, String attachmentPrefix) { - super(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); - } - - @NotNull - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private boolean freshData; - private boolean interactive; - private boolean saveSnapshot; - private Format format; - private String pages; - private String attachmentPrefix; - - public Builder() { - interactive = true; - } - - public Builder freshData(boolean freshData) { - this.freshData = freshData; - return this; - } - - /** - * Configuration for report interactiveness - * - * NOTICE: This flag ignored for JRS 5.6 where we are forcing disable state - * - * @param interactive weather report should be interactive or not - * @return builder instance - */ - public Builder interactive(boolean interactive) { - this.interactive = interactive; - return this; - } - - public Builder saveSnapshot(boolean saveSnapshot) { - this.saveSnapshot = saveSnapshot; - return this; - } - - public Builder format(Format format) { - this.format = format; - return this; - } - - public Builder pages(@Nullable String pages) { - this.pages = pages; - return this; - } - - - public Builder attachmentPrefix(String prefix) { - this.attachmentPrefix = prefix; - return this; - } - - public RunExportCriteria create() { - return new RunExportCriteria(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java deleted file mode 100644 index f68c65f1..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RunReportCriteria.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class RunReportCriteria extends ExecutionCriteria { - private final List mParams; - - private RunReportCriteria(boolean freshData, - boolean interactive, - boolean saveSnapshot, - Format format, - String pages, - String attachmentPrefix, - List params - ) { - super(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix); - mParams = params; - } - - @NotNull - public Builder newBuilder() { - return new Builder() - .freshData(mFreshData) - .interactive(mInteractive) - .saveSnapshot(mSaveSnapshot) - .format(mFormat) - .pages(mPages) - .params(mParams) - .attachmentPrefix(mAttachmentPrefix); - } - - @NotNull - public static Builder builder() { - return new Builder(); - } - - @Nullable - public List getParams() { - return mParams; - } - - public static class Builder { - private boolean freshData; - private boolean interactive; - private boolean saveSnapshot; - private Format format; - private String pages; - private List params; - private String attachmentPrefix; - - public Builder() { - interactive = true; - } - - public Builder freshData(boolean freshData) { - this.freshData = freshData; - return this; - } - - /** - * Configuration for report interactiveness - * - * NOTICE: This flag ignored for JRS 5.6 where we are forcing disable state - * - * @param interactive weather report should be interactive or not - * @return builder instance - */ - public Builder interactive(boolean interactive) { - this.interactive = interactive; - return this; - } - - public Builder saveSnapshot(boolean saveSnapshot) { - this.saveSnapshot = saveSnapshot; - return this; - } - - public Builder format(Format format) { - this.format = format; - return this; - } - - public Builder pages(@Nullable String pages) { - this.pages = pages; - return this; - } - - public Builder params(List params) { - this.params = params; - return this; - } - - public Builder attachmentPrefix(String prefix) { - this.attachmentPrefix = prefix; - return this; - } - - public RunReportCriteria create() { - return new RunReportCriteria(freshData, interactive, saveSnapshot, format, pages, attachmentPrefix, params); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java index 3f608881..3dfc4f75 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/Status.java @@ -39,6 +39,14 @@ public static Status wrap(String status) { return new Status(status); } + public static Status execution() { + return new Status("execution"); + } + + public static Status ready() { + return new Status("ready"); + } + public boolean isQueued() { return mStatus.equals("queued"); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java index 8ad8c16d..a2e534b1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java @@ -76,7 +76,7 @@ public static Map map(InternalCriteria criteria) { } if (criteria.getSortBy() != null) { - params.put("sortBy", criteria.getSortBy()); + params.put("sortBy", criteria.getSortBy().toString()); } if (criteria.getFolderUri() != null) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index 7b1c15b7..d3116618 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -42,7 +42,7 @@ class InternalCriteria { private final Boolean mForceFullPage; private final Boolean mForceTotalCount; private final String mQuery; - private final String mSortBy; + private final SortType mSortBy; private final String mFolderUri; private InternalCriteria(Builder builder) { @@ -112,7 +112,8 @@ public int getResourceMask() { return mResourceMask; } - public String getSortBy() { + @Nullable + public SortType getSortBy() { return mSortBy; } @@ -212,7 +213,7 @@ public static class Builder { @Nullable private String query; @Nullable - private String sort; + private SortType sort; @Nullable private String folderUri; @@ -251,7 +252,7 @@ public Builder folderUri(@Nullable String folderUri) { * @param sort either 'label' or 'creationDate' * @return chain builder instance */ - public Builder sortBy(String sort) { + public Builder sortBy(SortType sort) { this.sort = sort; return this; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java similarity index 50% rename from core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java index 62c0b3a1..d7d6e203 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java @@ -24,65 +24,32 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; -import java.util.Collection; - /** * @author Tom Koptel * @since 2.0 */ -final class SearchTaskImpl implements SearchTask { - private final InternalCriteria mCriteria; +final class ProxyRepositoryService extends RepositoryService { private final SearchUseCase mSearchUseCase; private final InfoCacheManager mInfoCacheManager; - @Nullable - private SearchStrategy strategy; - @TestOnly - SearchTaskImpl(InternalCriteria criteria, - SearchUseCase searchUseCase, - InfoCacheManager infoCacheManager) { - mCriteria = criteria; + ProxyRepositoryService(SearchUseCase searchUseCase, InfoCacheManager infoCacheManager) { mSearchUseCase = searchUseCase; mInfoCacheManager = infoCacheManager; } @NotNull @Override - public Collection nextLookup() throws ServiceException { - return defineSearchStrategy().searchNext(); - } - - @Override - public boolean hasNext() { - /** - * Strategy not defined only, if user has not made any lookup requests. - * There is no 100% guarantee that API has items until we made request. - */ - if (strategy != null) { - return strategy.hasNext(); - } - return true; - } - - private SearchStrategy defineSearchStrategy() throws ServiceException { - if (strategy == null) { - ServerVersion version = mInfoCacheManager.getInfo().getVersion(); - - strategy = SearchStrategy.Factory.get( - mSearchUseCase, - mCriteria, - version - ); - } - return strategy; + public SearchTask search(@Nullable SearchCriteria criteria) { + Preconditions.checkNotNull(criteria, "Criteria should not be null"); + InternalCriteria internalCriteria = InternalCriteria.from(criteria); + SearchTaskFactory searchTaskFactory = new SearchTaskFactory(internalCriteria, mSearchUseCase, mInfoCacheManager); + return new SearchTaskProxy(searchTaskFactory); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index edc4c75e..8c9a069b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -1,24 +1,24 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ @@ -26,25 +26,25 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.info.InfoCache; import com.jaspersoft.android.sdk.service.internal.*; -import org.jetbrains.annotations.TestOnly; +import com.jaspersoft.android.sdk.service.internal.info.InMemoryInfoCache; +import com.jaspersoft.android.sdk.service.internal.info.InfoCache; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; +import org.jetbrains.annotations.NotNull; /** * @author Tom Koptel * @since 2.0 */ -public class RepositoryService { - private final SearchUseCase mSearchUseCase; - private final InfoCacheManager mInfoCacheManager; +public abstract class RepositoryService { + @NotNull + public abstract SearchTask search(@NotNull SearchCriteria criteria); - @TestOnly - RepositoryService(SearchUseCase searchUseCase, InfoCacheManager infoCacheManager) { - mSearchUseCase = searchUseCase; - mInfoCacheManager = infoCacheManager; - } + @NotNull + public static RepositoryService newService(@NotNull AuthorizedClient client) { + Preconditions.checkNotNull(client, "Client should not be null"); - public static RepositoryService create(AuthorizedClient client, InfoCache cache) { + InfoCache cache = new InMemoryInfoCache(); RepositoryRestApi repositoryRestApi = client.repositoryApi(); ServiceExceptionMapper defaultExMapper = new DefaultExceptionMapper(); CallExecutor callExecutor = new DefaultCallExecutor(defaultExMapper); @@ -57,10 +57,6 @@ public static RepositoryService create(AuthorizedClient client, InfoCache cache) cacheManager, callExecutor ); - return new RepositoryService(searchUseCase, cacheManager); - } - - public SearchTask search(SearchCriteria criteria) { - return new SearchTaskImpl(InternalCriteria.from(criteria), mSearchUseCase, mInfoCacheManager); + return new ProxyRepositoryService(searchUseCase, cacheManager); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java index 6f9afd9c..0d537bdb 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java @@ -28,7 +28,6 @@ import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.ResourceType; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,6 +36,7 @@ import java.util.Collection; import java.util.Date; import java.util.LinkedList; +import java.util.List; /** * @author Tom Koptel @@ -45,8 +45,8 @@ class ResourceMapper { @NotNull - public Collection transform(Collection resources, SimpleDateFormat dateTimeFormat) { - Collection result = new LinkedList<>(); + public List transform(Collection resources, SimpleDateFormat dateTimeFormat) { + List result = new LinkedList<>(); for (ResourceLookup lookup : resources) { if (lookup != null) { result.add(transform(lookup, dateTimeFormat)); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 55e71bff..96356eec 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -34,8 +34,8 @@ * @since 2.0 */ public final class SearchCriteria { - static final int DEFAULT_OFFSET = 0; - static final int DEFAULT_LIMIT = 100; + public static final int DEFAULT_OFFSET = 0; + public static final int DEFAULT_LIMIT = 100; public static int ALL = 1; public static int REPORT = (1 << 1); @@ -48,7 +48,7 @@ public final class SearchCriteria { private final Boolean mRecursive; private final String mQuery; - private final String mSortBy; + private final SortType mSort; private final String mFolderUri; private SearchCriteria(Builder builder) { @@ -57,7 +57,7 @@ private SearchCriteria(Builder builder) { mResourceMask = builder.resourceMask; mRecursive = builder.recursive; mQuery = builder.query; - mSortBy = builder.sort; + mSort = builder.sortType; mFolderUri = builder.folderUri; } @@ -68,7 +68,7 @@ public static Builder builder() { @NotNull public static SearchCriteria none() { - return builder().create(); + return builder().build(); } public int getLimit() { @@ -90,8 +90,8 @@ public Boolean getRecursive() { } @Nullable - public String getSortBy() { - return mSortBy; + public SortType getSortBy() { + return mSort; } public int getResourceMask() { @@ -113,53 +113,48 @@ public static class Builder { @Nullable private String query; @Nullable - private String sort; - @Nullable private String folderUri; + @Nullable + private SortType sortType; - public Builder limit(int limit) { + public Builder withLimit(int limit) { checkArgument(limit >= 0, "Limit should be positive"); this.limit = limit; return this; } - public Builder offset(int offset) { + public Builder withOffset(int offset) { checkArgument(offset >= 0, "Offset should be positive"); this.offset = offset; return this; } - public Builder resourceMask(int resourceMask) { + public Builder withResourceMask(int resourceMask) { this.resourceMask = resourceMask; return this; } - public Builder recursive(boolean recursive) { + public Builder withRecursive(boolean recursive) { this.recursive = recursive; return this; } - public Builder query(@Nullable String query) { + public Builder withQuery(@Nullable String query) { this.query = query; return this; } - public Builder sortByLabel() { - this.sort = "label"; - return this; - } - - public Builder sortByCreationDate() { - this.sort = "creationDate"; + public Builder withSortType(@Nullable SortType sortType) { + this.sortType = sortType; return this; } - public Builder folderUri(@Nullable String folderUri) { + public Builder withFolderUri(@Nullable String folderUri) { this.folderUri = folderUri; return this; } - public SearchCriteria create() { + public SearchCriteria build() { return new SearchCriteria(this); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 09e16814..502e82b8 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -26,10 +26,9 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; -import java.util.Collection; +import java.util.List; /** * @author Tom Koptel @@ -37,6 +36,6 @@ */ public interface SearchTask { @NotNull - Collection nextLookup() throws ServiceException; + List nextLookup() throws ServiceException; boolean hasNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactory.java new file mode 100644 index 00000000..de20e7df --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactory.java @@ -0,0 +1,55 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class SearchTaskFactory { + private final InternalCriteria mInternalCriteria; + private final SearchUseCase mSearchUseCase; + private final InfoCacheManager mCacheManager; + + SearchTaskFactory(InternalCriteria internalCriteria, SearchUseCase searchUseCase, InfoCacheManager cacheManager) { + mInternalCriteria = internalCriteria; + mSearchUseCase = searchUseCase; + mCacheManager = cacheManager; + } + + public SearchTask create() throws ServiceException { + ServerInfo serverInfo = mCacheManager.getInfo(); + ServerVersion version = serverInfo.getVersion(); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { + return new SearchTaskV5_5(mInternalCriteria, mSearchUseCase); + } + return new SearchTaskV5_6Plus(mInternalCriteria, mSearchUseCase); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java new file mode 100644 index 00000000..4d4f63c7 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class SearchTaskProxy implements SearchTask { + private final SearchTaskFactory mSearchTaskFactory; + + private SearchTask mDelegate; + + SearchTaskProxy(SearchTaskFactory searchTaskFactory) { + mSearchTaskFactory = searchTaskFactory; + } + + @NotNull + @Override + public List nextLookup() throws ServiceException { + if (mDelegate == null) { + mDelegate = mSearchTaskFactory.create(); + } + return mDelegate.nextLookup(); + } + + @Override + public boolean hasNext() { + return mDelegate != null && mDelegate.hasNext(); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5.java similarity index 77% rename from core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5.java index 5f0f8092..fd10fd9a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5.java @@ -1,37 +1,34 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.repository; - import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; -import java.util.Collection; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -40,8 +37,8 @@ * @author Tom Koptel * @since 2.0 */ -final class EmeraldMR2SearchStrategy implements SearchStrategy { - private static final Collection EMPTY_RESPONSE = Collections.emptyList(); +final class SearchTaskV5_5 implements SearchTask { + private static final List EMPTY_RESPONSE = Collections.emptyList(); private static final int MAX_RETRY_COUNT = 5; private final InternalCriteria mInitialCriteria; @@ -51,16 +48,15 @@ final class EmeraldMR2SearchStrategy implements SearchStrategy { private int mServerDisposition; private boolean mEndReached; - public EmeraldMR2SearchStrategy(InternalCriteria criteria, - SearchUseCase searchUseCase) { - + public SearchTaskV5_5(InternalCriteria criteria, SearchUseCase searchUseCase) { mSearchUserCase = searchUseCase; mInitialCriteria = criteria; mEndReached = false; } + @NotNull @Override - public Collection searchNext() throws ServiceException { + public List nextLookup() throws ServiceException { int limit = mInitialCriteria.getLimit(); int offset = mInitialCriteria.getOffset(); @@ -84,7 +80,7 @@ private void calculateDisposition(int offset) throws ServiceException { } @NotNull - private Collection internalSearch(int limit) throws ServiceException { + private List internalSearch(int limit) throws ServiceException { int count = 0; while (mBuffer.size() < limit && hasNext()) { SearchResult response = performSearch(limit); @@ -106,7 +102,7 @@ private Collection internalSearch(int limit) throws ServiceException { } int median = Math.min(limit, mBuffer.size()); - Collection result = mBuffer.subList(0, median); + List result = mBuffer.subList(0, median); mBuffer = mBuffer.subList(median, mBuffer.size()); return result; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6Plus.java similarity index 78% rename from core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java rename to core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6Plus.java index a4d7a9a3..e1653bec 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6Plus.java @@ -1,24 +1,24 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ @@ -27,18 +27,17 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.exception.ServiceException; - import org.jetbrains.annotations.NotNull; -import java.util.Collection; import java.util.Collections; +import java.util.List; /** * @author Tom Koptel * @since 2.0 */ -final class EmeraldMR3SearchStrategy implements SearchStrategy { - public static final Collection EMPTY_RESPONSE = Collections.emptyList(); +final class SearchTaskV5_6Plus implements SearchTask { + public static final List EMPTY_RESPONSE = Collections.emptyList(); private final static int UNDEFINED = -1; private final InternalCriteria mInitialCriteria; @@ -48,7 +47,7 @@ final class EmeraldMR3SearchStrategy implements SearchStrategy { private int mInternalOffset = UNDEFINED; private boolean mEndReached; - public EmeraldMR3SearchStrategy(InternalCriteria criteria, SearchUseCase searchUseCase) { + public SearchTaskV5_6Plus(InternalCriteria criteria, SearchUseCase searchUseCase) { mSearchUseCase = searchUseCase; // Internally enabling 'forceFullPageFlag' @@ -58,8 +57,9 @@ public EmeraldMR3SearchStrategy(InternalCriteria criteria, SearchUseCase searchU mUserOffset = criteria.getOffset(); } + @NotNull @Override - public Collection searchNext() throws ServiceException { + public List nextLookup() throws ServiceException { if (mEndReached || mInitialCriteria.getLimit() == 0){ return EMPTY_RESPONSE; } @@ -76,7 +76,7 @@ public boolean hasNext() { } @NotNull - private Collection performLookup() throws ServiceException { + private List performLookup() throws ServiceException { InternalCriteria newSearchCriteria = createNextCriteria(); SearchResult result = performApiCall(newSearchCriteria); updateInternalOffset(result); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 62f08b7b..7733dd9f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -32,12 +32,12 @@ import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Call; import com.jaspersoft.android.sdk.service.internal.CallExecutor; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.text.SimpleDateFormat; -import java.util.Collection; +import java.util.List; import java.util.Map; /** @@ -72,7 +72,7 @@ public SearchResult perform() throws IOException, HttpException { SearchResult searchResult = new SearchResult(); searchResult.setNextOffset(response.getNextOffset()); - Collection resources = mDataMapper.transform(response.getResources(), dateTimeFormat); + List resources = mDataMapper.transform(response.getResources(), dateTimeFormat); searchResult.setResources(resources); return searchResult; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SortType.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SortType.java new file mode 100644 index 00000000..9fe592cb --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SortType.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum SortType { + LABEL("label"), DESCRIPTION("description"), CREATION_DATE("creationDate"); + + private final String mValue; + + SortType(String value) { + mValue = value; + } + + @Override + public String toString() { + return mValue; + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java index 96260bdc..e7161cf1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java @@ -62,7 +62,7 @@ public class AuthenticationRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Server server = Server.newBuilder() + Server server = Server.builder() .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index c1b6014a..82b67a82 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -72,7 +72,7 @@ public class InputControlRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Server server = Server.newBuilder() + Server server = Server.builder() .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java index 2294b251..19843eeb 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithmTest.java @@ -24,12 +24,11 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.JSEncryptionAlgorithm; - import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Test; -import static junit.framework.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; /** * @author Tom Koptel @@ -45,6 +44,6 @@ public void testGenerateKey() throws Exception { JSEncryptionAlgorithm keyGenerator = JSEncryptionAlgorithm. create(new BouncyCastleProvider()); String encryptedPass = keyGenerator.encrypt(MODULUS, PUBLIC_EXPONENT, "superuser"); - assertTrue(RESULT.equals(encryptedPass)); + assertThat("Failed to decrypt result", RESULT, is(encryptedPass)); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index d2370afb..331d1777 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -83,7 +83,7 @@ public class ReportExecutionRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Server server = Server.newBuilder() + Server server = Server.builder() .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index 54ec7d1a..c65f0857 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -66,7 +66,7 @@ public class ReportExportRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Server server = Server.newBuilder() + Server server = Server.builder() .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index ac8d8962..02a0d638 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -70,7 +70,7 @@ public class ReportOptionRestApiTest { @Before public void setup() { TestResourceInjector.inject(this); - Server server = Server.newBuilder() + Server server = Server.builder() .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index dee55417..c027154a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -70,7 +70,7 @@ public class RepositoryRestApiTest { public void setup() { MockitoAnnotations.initMocks(this); TestResourceInjector.inject(this); - Server server = Server.newBuilder() + Server server = Server.builder() .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java index 105faf9d..6f634fb2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java @@ -51,7 +51,7 @@ public class ServerRestApiTest { @Before public void setup() { - Server server = Server.newBuilder() + Server server = Server.builder() .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java index d278d677..05d91796 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java @@ -38,7 +38,6 @@ import java.util.Map; import java.util.TimeZone; -import static org.mockito.Matchers.anyMap; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; @@ -81,11 +80,11 @@ public void setup() throws Exception { ); credentials = SpringCredentials.builder() - .username("user") - .password("1234") - .organization("organization") - .locale(Locale.US) - .timeZone(mTimeZone) + .withUsername("user") + .withPassword("1234") + .withOrganization("organization") + .withLocale(Locale.US) + .withTimeZone(mTimeZone) .build(); when(mRestApi.requestEncryptionMetadata()).thenReturn(mKey); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java index 1047b424..cf1214c1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java @@ -24,9 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; - -import com.jaspersoft.android.sdk.network.SpringCredentials; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -61,7 +58,7 @@ public void builderShouldNotAllowNullUsername() { mException.expect(NullPointerException.class); mException.expectMessage("username == null"); - objectUnderTest.username(null); + objectUnderTest.withUsername(null); } @Test @@ -69,7 +66,7 @@ public void builderShouldNotAllowNullPassword() { mException.expect(NullPointerException.class); mException.expectMessage("password == null"); - objectUnderTest.password(null); + objectUnderTest.withPassword(null); } @Test @@ -77,7 +74,7 @@ public void builderShouldNotAllowNullLocale() { mException.expect(NullPointerException.class); mException.expectMessage("locale == null"); - objectUnderTest.locale(null); + objectUnderTest.withLocale(null); } @Test @@ -85,7 +82,7 @@ public void builderShouldNotAllowNullTimeZone() { mException.expect(NullPointerException.class); mException.expectMessage("timeZone == null"); - objectUnderTest.timeZone(null); + objectUnderTest.withTimeZone(null); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/report/PageRangeTest.java similarity index 69% rename from core/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/data/report/PageRangeTest.java index bfad7f78..06ef3d76 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/data/PageRangeTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/report/PageRangeTest.java @@ -22,10 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.service.data; - -import com.jaspersoft.android.sdk.service.data.report.PageRange; +package com.jaspersoft.android.sdk.service.data.report; +import nl.jqno.equalsverifier.EqualsVerifier; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -44,39 +43,61 @@ public class PageRangeTest { @Test public void shouldParseRange() { - PageRange pageRange = new PageRange("1-10"); + PageRange pageRange = PageRange.parse("1-10"); assertThat(pageRange.getLowerBound(), is(1)); assertThat(pageRange.getUpperBound(), is(10)); } @Test public void upperBoundUndefinedIfMissing() { - PageRange pageRange = new PageRange("1"); + PageRange pageRange = PageRange.parse("1"); assertThat(pageRange.getLowerBound(), is(1)); assertThat(pageRange.getUpperBound(), is(Integer.MAX_VALUE)); } @Test public void shouldNotBeRangeIfUpperBoundIsMissing() { - PageRange pageRange = new PageRange("1"); + PageRange pageRange = PageRange.parse("1"); assertThat(pageRange.isRange(), is(false)); } @Test public void shouldNotBeRangeIfHasUpperBound() { - PageRange pageRange = new PageRange("1-10"); + PageRange pageRange = PageRange.parse("1-10"); assertThat(pageRange.isRange(), is(true)); } @Test public void throwsNumberFormatExceptionIfLowerBoundNotANumber() { mExpectedException.expect(NumberFormatException.class); - new PageRange("q"); + PageRange.parse("q"); } @Test public void throwsNumberFormatExceptionIfUpperBoundNotANumber() { mExpectedException.expect(NumberFormatException.class); - new PageRange("1-q"); + PageRange.parse("1-q"); + } + + @Test + public void should_not_allow_null() throws Exception { + mExpectedException.expect(NullPointerException.class); + mExpectedException.expectMessage("Pages should not be null"); + PageRange.parse(null); + } + + @Test + public void testRangeToString() throws Exception { + assertThat(PageRange.parse("1-10").toString(), is("1-10")); + } + + @Test + public void testPageToString() throws Exception { + assertThat(PageRange.parse("10").toString(), is("10")); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(PageRange.class).verify(); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceTest.java similarity index 66% rename from core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceTest.java index 102f4bfa..7cc1916b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceTest.java @@ -22,23 +22,26 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service.info; +import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.ServerRestApi; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; - import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Mockito.*; /** * @author Tom Koptel @@ -57,12 +60,18 @@ public class ServerInfoServiceTest { @Mock ServiceExceptionMapper mockServiceExceptionMapper; - private ServerInfoService serviceUnderTest; + @Mock + AnonymousClient mClient; + + @Rule + public ExpectedException expected = none(); + + private ServerInfoServiceImpl serviceUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - serviceUnderTest = new ServerInfoService(mockApi, mockTransformer, mockServiceExceptionMapper); + serviceUnderTest = new ServerInfoServiceImpl(mockApi, mockTransformer, mockServiceExceptionMapper); } @Test @@ -74,4 +83,19 @@ public void requestInfoShouldProvideServerInfoDataObject() throws Exception { verify(mockTransformer, times(1)).transform(mockResponse); verify(mockApi, times(1)).requestServerInfo(); } + + @Test + public void should_create_proxy_instance() throws Exception { + ServerInfoService service = ServerInfoService.newService(mClient); + assertThat("Should be instance of proxy service", service, is(instanceOf(ServerInfoServiceImpl.class))); + assertThat(service, is(notNullValue())); + } + + @Test + public void should_reject_null_client() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + + ServerInfoService.newService(null); + } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoTransformerTest.java similarity index 96% rename from core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoTransformerTest.java index d2fe9c33..45a54516 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/server/ServerInfoTransformerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoTransformerTest.java @@ -22,9 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.service.server; +package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; +import com.jaspersoft.android.sdk.service.info.ServerInfoTransformer; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import org.junit.Before; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/FakeCallExecutor.java similarity index 97% rename from core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/FakeCallExecutor.java index e809d714..f3eb7228 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/FakeCallExecutor.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/FakeCallExecutor.java @@ -22,7 +22,7 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCacheTest.java similarity index 91% rename from core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCacheTest.java index 25ff6260..a818d870 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/InMemoryInfoCacheTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCacheTest.java @@ -22,11 +22,9 @@ * . */ -package com.jaspersoft.android.sdk.service; +package com.jaspersoft.android.sdk.service.internal.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.info.InMemoryInfoCache; -import com.jaspersoft.android.sdk.service.info.InfoCache; import org.junit.Before; import org.junit.Test; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/info/InfoCacheManagerTest.java similarity index 93% rename from core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/internal/info/InfoCacheManagerTest.java index 7200baf4..75fa9636 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/internal/InfoCacheManagerTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/internal/info/InfoCacheManagerTest.java @@ -22,11 +22,10 @@ * . */ -package com.jaspersoft.android.sdk.service.internal; +package com.jaspersoft.android.sdk.service.internal.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.info.InfoCache; -import com.jaspersoft.android.sdk.service.server.ServerInfoService; +import com.jaspersoft.android.sdk.service.info.ServerInfoService; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -36,7 +35,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - public class InfoCacheManagerTest { @Mock ServerInfoService mInfoService; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java new file mode 100644 index 00000000..f1a2c503 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java @@ -0,0 +1,92 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ReportExecutionDescriptor.class}) +public class AbstractReportExecutionTest { + + private static final String EXEC_ID = "exec_id"; + private static final String REPORT_URI = "my/uri"; + private static final int TOTAL_PAGES = 9999; + + @Mock + ReportExecutionApi mReportExecutionApi; + @Mock + ReportExecutionDescriptor mReportExecutionDescriptor; + + private AbstractReportExecution abstractReportExecution; + + @Before + public void setUp() throws Exception { + initMocks(this); + abstractReportExecution = new AbstractReportExecution(mReportExecutionApi, EXEC_ID, REPORT_URI, 0) { + @NotNull + @Override + public ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + return null; + } + + @NotNull + @Override + public ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + return null; + } + }; + when(mReportExecutionApi.getDetails(anyString())).thenReturn(mReportExecutionDescriptor); + when(mReportExecutionDescriptor.getTotalPages()).thenReturn(TOTAL_PAGES); + } + + @Test + public void testWaitForReportCompletion() throws Exception { + ReportMetadata metadata = abstractReportExecution.waitForReportCompletion(); + assertThat("Failed to create report metadata with exact total pages", metadata.getUri(), is(REPORT_URI)); + assertThat("Failed to create report metadata with exact report uri", metadata.getTotalPages(), is(TOTAL_PAGES)); + verify(mReportExecutionApi).awaitStatus(EXEC_ID, REPORT_URI, 0, Status.ready()); + verify(mReportExecutionApi).getDetails(EXEC_ID); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java new file mode 100644 index 00000000..38b5bf2d --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java @@ -0,0 +1,94 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static com.jaspersoft.android.sdk.service.report.Status.execution; +import static com.jaspersoft.android.sdk.service.report.Status.ready; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ReportExecutionDescriptor.class, +}) +public class AbstractReportServiceTest { + + private static final String REPORT_URI = "my/uri"; + private static final String EXEC_ID = "exec_id"; + + @Mock + ExportExecutionApi mExportExecutionApi; + @Mock + ReportExecutionApi mReportExecutionApi; + @Mock + ExportFactory mExportFactory; + + @Mock + ReportExecutionDescriptor mReportExecutionDescriptor; + + private AbstractReportService reportService; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + reportService = new AbstractReportService( + mExportExecutionApi, + mReportExecutionApi, + mExportFactory, + 0){ + @Override + protected ReportExecution buildExecution(String reportUri, + String executionId, + ReportExecutionOptions criteria) { + return null; + } + }; + reportService = spy(reportService); + when(mReportExecutionApi.start(anyString(), any(ReportExecutionOptions.class))).thenReturn(mReportExecutionDescriptor); + when(mReportExecutionDescriptor.getExecutionId()).thenReturn(EXEC_ID); + } + + @Test + public void testRun() throws Exception { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + reportService.run(REPORT_URI, criteria); + + verify(mReportExecutionApi).start(REPORT_URI, criteria); + verify(mReportExecutionApi).awaitStatus(EXEC_ID, REPORT_URI, 0, execution(), ready()); + verify(reportService).buildExecution(REPORT_URI, EXEC_ID, criteria); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapperTest.java new file mode 100644 index 00000000..a62ee577 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentExportMapperTest.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.io.InputStream; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class AttachmentExportMapperTest { + + private AttachmentExportMapper mapper; + + @Mock + OutputResource mOutputResource; + @Mock + InputStream mStream; + + @Before + public void setUp() throws Exception { + initMocks(this); + mapper = new AttachmentExportMapper(); + } + + @Test + public void testTransform() throws Exception { + when(mOutputResource.getStream()).thenReturn(mStream); + ResourceOutput result = mapper.transform(mOutputResource); + assertThat(result.getStream(), is(mStream)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactoryTest.java new file mode 100644 index 00000000..cb4655b2 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactoryTest.java @@ -0,0 +1,84 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.AttachmentDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ExportDescriptor.class, + AttachmentDescriptor.class, +}) +public class AttachmentsFactoryTest { + + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + private static final String ATTACHMENT_ID = "img.png"; + + @Mock + ExportExecutionApi mExportExecutionApi; + @Mock + ExportDescriptor mExportDescriptor; + @Mock + AttachmentDescriptor mAttachmentDescriptor; + + private AttachmentsFactory attachmentsFactory; + + @Before + public void setUp() throws Exception { + initMocks(this); + attachmentsFactory = new AttachmentsFactory(mExportExecutionApi); + } + + @Test + public void testCreate() throws Exception { + when(mExportDescriptor.getId()).thenReturn(EXPORT_ID); + when(mAttachmentDescriptor.getFileName()).thenReturn(ATTACHMENT_ID); + when(mExportDescriptor.getAttachments()).thenReturn(Collections.singleton(mAttachmentDescriptor)); + + List result = attachmentsFactory.create(mExportDescriptor, EXEC_ID); + assertThat(result.size(), is(1)); + + verify(mExportDescriptor).getId(); + verify(mExportDescriptor).getAttachments(); + verify(mAttachmentDescriptor).getFileName(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java deleted file mode 100644 index 94be8dd6..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExecutionOptionsDataMapperTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import org.junit.Before; -import org.junit.Test; -import org.mockito.MockitoAnnotations; - -import java.util.Collections; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ExecutionOptionsDataMapperTest { - - private static final String REPORT_URI = "/report/uri"; - private static final String BASE_URL = "http:://localhost"; - public static final List REPORT_PARAMS = Collections.singletonList(null); - - private ExecutionOptionsDataMapper mapper; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - mapper = new ExecutionOptionsDataMapper(BASE_URL); - } - - @Test - public void testTransformReportOptions() throws Exception { - RunReportCriteria criteria = RunReportCriteria.builder() - .format(ExecutionCriteria.Format.HTML) - .freshData(true) - .interactive(false) - .saveSnapshot(true) - .pages("1-100") - .params(REPORT_PARAMS) - .attachmentPrefix("./") - .create(); - ReportExecutionRequestOptions options = mapper.transformRunReportOptions(REPORT_URI, ServerVersion.v6, criteria); - assertThat(options.getReportUnitUri(), is(REPORT_URI)); - assertThat(options.getParameters(), is(REPORT_PARAMS)); - assertThat(options.getAsync(), is(true)); - assertOptions(options); - } - - @Test - public void testTransformExportOptions() throws Exception { - RunExportCriteria criteria = RunExportCriteria.builder() - .format(ExecutionCriteria.Format.HTML) - .freshData(true) - .interactive(false) - .saveSnapshot(true) - .pages("1-100") - .attachmentPrefix("./") - .create(); - ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v6); - assertOptions(options); - } - - @Test - public void testReportExecutionFieldsReducedForServer5_5() throws Exception { - RunReportCriteria criteria = RunReportCriteria.builder() - .freshData(true) - .interactive(false) - .saveSnapshot(true) - .create(); - ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); - assertThat("Should reduce 'baseUrl' from options", options.getBaseUrl(), is(nullValue())); - assertThat("Should reduce 'allowInteractive' from options", options.getAllowInlineScripts(), is(nullValue())); - } - - @Test - public void testInteractivenessDisabledForReportRun5_6() throws Exception { - RunReportCriteria criteria = RunReportCriteria.builder() - .interactive(true) - .create(); - ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_6, criteria); - assertThat("Should put false for 'interactive' option", options.getInteractive(), is(Boolean.FALSE)); - } - - @Test - public void testInteractivenessDisabledForExportRun5_6() throws Exception { - RunExportCriteria criteria = RunExportCriteria.builder() - .interactive(true) - .create(); - ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_6); - assertThat("Should put false for 'interactive' option", options.getInteractive(), is(Boolean.FALSE)); - } - - @Test - public void testExportExecutionFieldsReducedForServer5_5() throws Exception { - RunExportCriteria criteria = RunExportCriteria.builder() - .freshData(true) - .interactive(false) - .saveSnapshot(true) - .create(); - ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_5); - assertThat("Should reduce 'baseUrl' from options", options.getBaseUrl(), is(nullValue())); - assertThat("Should reduce 'allowInteractive' from options", options.getAllowInlineScripts(), is(nullValue())); - assertThat("Should reduce 'freshData' from options",options.getFreshData(), is(nullValue())); - assertThat("Should reduce 'interactive' from options",options.getInteractive(), is(nullValue())); - assertThat("Should reduce 'saveDataSnapshot' from options",options.getSaveDataSnapshot(), is(nullValue())); - } - - @Test - public void testExportExecutionSetsHtmlFormatIfOneUnspecified5_5() throws Exception { - RunExportCriteria criteria = RunExportCriteria.builder().create(); - ExecutionRequestOptions options = mapper.transformExportOptions(criteria, ServerVersion.v5_5); - assertThat("Should set 'HTML' format", options.getOutputFormat(), is("HTML")); - } - - @Test - public void testReportExecutionSetsHtmlFormatIfOneUnspecified5_5() throws Exception { - RunReportCriteria criteria = RunReportCriteria.builder().create(); - ReportExecutionRequestOptions options = mapper.transformRunReportOptions("/my/uri", ServerVersion.v5_5, criteria); - assertThat("Should set 'HTML' format", options.getOutputFormat(), is("HTML")); - } - - private void assertOptions(ExecutionRequestOptions options) { - assertThat(options.getFreshData(), is(true)); - assertThat(options.getSaveDataSnapshot(), is(true)); - assertThat(options.getInteractive(), is(false)); - assertThat(options.getSaveDataSnapshot(), is(true)); - - assertThat(options.getAllowInlineScripts(), is(nullValue())); - assertThat(options.getTransformerKey(), is(nullValue())); - - assertThat(options.getBaseUrl(), is(BASE_URL)); - assertThat(options.getAttachmentsPrefix(), is(".%2F")); - assertThat(options.getOutputFormat(), is("HTML")); - assertThat(options.getPages(), is("1-100")); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java new file mode 100644 index 00000000..44cba779 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java @@ -0,0 +1,184 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.test.Chain; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * @author Tom Koptel + * @since 2.0 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ExecutionStatus.class, + ExportOutputResource.class, +}) +public class ExportExecutionApiTest { + + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + private static final String ATTACHMENT_ID = "img.png"; + private static final String REPORT_URI = "my/uri"; + + @Mock + ServiceExceptionMapper mServiceExceptionMapper; + @Mock + ReportExportRestApi mReportExportRestApi; + @Mock + ExportOptionsMapper mExportOptionsMapper; + + @Mock + AttachmentExportMapper mAttachmentExportMapper; + @Mock + ReportExportMapper mReportExportMapper; + + @Mock + ExportOutputResource export; + @Mock + OutputResource attachment; + + @Mock + ExecutionStatus mExecutionStatusResponse; + @Mock + ExecutionRequestOptions mExecutionRequestOptions; + + private ExportExecutionApiImpl exportExecutionApi; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + exportExecutionApi = new ExportExecutionApiImpl( + mServiceExceptionMapper, + mReportExportRestApi, + mExportOptionsMapper, + mReportExportMapper, + mAttachmentExportMapper + ); + } + + @Test + public void testStart() throws Exception { + when(mExportOptionsMapper.transform(any(ReportExportOptions.class))).thenReturn(mExecutionRequestOptions); + + ReportExportOptions criteria = FakeOptions.export(); + exportExecutionApi.start(EXEC_ID, criteria); + verify(mReportExportRestApi).runExportExecution(EXEC_ID, mExecutionRequestOptions); + } + + @Test + public void testDownloadExport() throws Exception { + when(mReportExportRestApi.requestExportOutput(anyString(), anyString())).thenReturn(export); + + exportExecutionApi.downloadExport(EXEC_ID, EXPORT_ID); + verify(mReportExportRestApi).requestExportOutput(EXEC_ID, EXPORT_ID); + verify(mReportExportMapper).transform(export); + } + + @Test + public void testDownloadAttachment() throws Exception { + when(mReportExportRestApi.requestExportAttachment(anyString(), anyString(), anyString())).thenReturn(attachment); + + exportExecutionApi.downloadAttachment(EXEC_ID, EXPORT_ID, ATTACHMENT_ID); + verify(mReportExportRestApi).requestExportAttachment(EXEC_ID, EXPORT_ID, ATTACHMENT_ID); + verify(mAttachmentExportMapper).transform(attachment); + } + + @Test(timeout = 2000) + public void should_finish_if_status_ready() throws Exception { + mockCheckExportExecStatus("ready"); + waitForReady(); + verify(mReportExportRestApi).checkExportExecutionStatus(eq(EXEC_ID), eq(EXPORT_ID)); + } + + @Test(timeout = 2000) + public void should_throw_if_status_failed() throws Exception { + mockCheckExportExecStatus("failed"); + + try { + waitForReady(); + fail("Should throw Status exception"); + } catch (ServiceException ex) { + assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); + } + } + + @Test(timeout = 2000) + public void should_throw_if_status_cancelled() throws Exception { + mockCheckExportExecStatus("cancelled"); + + try { + waitForReady(); + fail("Should throw Status exception"); + } catch (ServiceException ex) { + assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_CANCELLED)); + } + } + + @Test(timeout = 2000) + public void should_loop_if_status_queue() throws Exception { + mockCheckExportExecStatus("queued", "ready"); + waitForReady(); + verify(mReportExportRestApi, times(2)).checkExportExecutionStatus(eq(EXEC_ID), eq(EXPORT_ID)); + } + + @Test(timeout = 2000) + public void should_loop_if_status_execution() throws Exception { + mockCheckExportExecStatus("execution", "ready"); + waitForReady(); + verify(mReportExportRestApi, times(2)).checkExportExecutionStatus(eq(EXEC_ID), eq(EXPORT_ID)); + } + + private void waitForReady() throws ServiceException { + exportExecutionApi.awaitReadyStatus(EXEC_ID, EXPORT_ID, REPORT_URI, 0); + } + + private void mockCheckExportExecStatus(String... statusChain) throws Exception { + when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); + when(mReportExportRestApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java new file mode 100644 index 00000000..83b8e7c3 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java @@ -0,0 +1,96 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import static java.util.Collections.singleton; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ReportExecutionDescriptor.class, + ExportDescriptor.class, +}) +public class ExportFactoryTest { + + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + + @Mock + ExportExecutionApi mExportExecutionApi; + @Mock + AttachmentsFactory mAttachmentsFactory; + + @Mock + ReportExecutionDescriptor mReportExecutionDescriptor; + @Mock + ExportDescriptor mExportDescriptor; + + private ExportFactory exportFactory; + + @Before + public void setUp() throws Exception { + exportFactory = new ExportFactory(mExportExecutionApi, mAttachmentsFactory); + + when(mExportDescriptor.getId()).thenReturn(EXPORT_ID); + when(mReportExecutionDescriptor.getExports()).thenReturn(singleton(mExportDescriptor)); + } + + @Test + public void should_create_export_if_details_fulfilled() throws Exception { + ReportExport result = exportFactory.create(mReportExecutionDescriptor, EXEC_ID, EXPORT_ID); + assertThat(result, is(notNullValue())); + assertThat(result, is(instanceOf(ReportExportImpl.class))); + + verify(mAttachmentsFactory).create(mExportDescriptor, EXEC_ID); + } + + @Test + public void should_throw_if_details_missing() throws Exception { + when(mExportDescriptor.getId()).thenReturn("123122"); + + try { + exportFactory.create(mReportExecutionDescriptor, EXEC_ID, EXPORT_ID); + fail("Should throw ServiceException"); + } catch (ServiceException ex) { + assertThat(ex.getMessage(), is("Server returned malformed export details")); + assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/FakeOptions.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/FakeOptions.java new file mode 100644 index 00000000..bbbd38fd --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/FakeOptions.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum FakeOptions { + INSTANCE; + + private final ReportExportOptions mExportOptions; + private final ReportExecutionOptions mReportExecutionOptions; + + FakeOptions() { + mExportOptions = ReportExportOptions.builder().withFormat(ReportFormat.PDF).build(); + mReportExecutionOptions = ReportExecutionOptions.builder().build(); + } + + public static ReportExportOptions export() { + return INSTANCE.mExportOptions; + } + + public static ReportExecutionOptions report() { + return INSTANCE.mReportExecutionOptions; + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 57fdbe42..87f2b912 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -38,9 +38,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.*; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.powermock.api.mockito.PowerMockito.when; @@ -52,31 +50,34 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({OutputResource.class}) public class ReportAttachmentTest { + + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + private static final String ATTACHMENT_ID = "img.png"; + @Mock ReportExportRestApi mExportRestApi; @Mock - ResourceOutput input; - @Mock - ReportExportUseCase mReportExportUseCase; + ResourceOutput attachment; @Mock - RunExportCriteria mRunExportCriteria; + ExportExecutionApi mExportExecutionApi; - private ReportAttachment objectUnderTest; + private ReportAttachmentImpl objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new ReportAttachment("1.jpg", "exec_id", "export_id", mRunExportCriteria, mReportExportUseCase); + objectUnderTest = new ReportAttachmentImpl(mExportExecutionApi, EXEC_ID, EXPORT_ID, ATTACHMENT_ID); } @Test public void testDownload() throws Exception { - when(mReportExportUseCase.requestExportAttachmentOutput(any(RunExportCriteria.class), anyString(), anyString(), anyString())).thenReturn(input); + when(mExportExecutionApi.downloadAttachment(anyString(), anyString(), anyString())).thenReturn(attachment); ResourceOutput result = objectUnderTest.download(); assertThat(result, is(notNullValue())); - verify(mReportExportUseCase).requestExportAttachmentOutput(eq(mRunExportCriteria), eq("exec_id"), eq("export_id"), eq("1.jpg")); - verifyNoMoreInteractions(mReportExportUseCase); + verify(mExportExecutionApi).downloadAttachment(EXEC_ID, EXPORT_ID, ATTACHMENT_ID); + verifyNoMoreInteractions(mExportExecutionApi); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5Test.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5Test.java new file mode 100644 index 00000000..b3b23bc3 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5Test.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.mockito.AdditionalMatchers.not; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; +import static org.mockito.MockitoAnnotations.initMocks; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ExportExecutionDescriptor.class, + ReportExecutionDescriptor.class, + ReportExecutionOptions.class, +}) +public class ReportExecution5_5Test { + private static final ReportExecutionOptions REPORT_OPTIONS = FakeOptions.report(); + private static final ReportExportOptions EXPORT_OPTIONS = FakeOptions.export(); + private static final List REPORT_PARAMS = Collections.emptyList(); + + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + private static final String REPORT_URI = "my/uri"; + + @Mock + ExportExecutionApi mExportExecutionApi; + @Mock + ReportExecutionApi mReportExecutionApi; + @Mock + ExportFactory mExportFactory; + + @Mock + ExportExecutionDescriptor exportDescriptor; + @Mock + ReportExecutionDescriptor reportDescriptor; + + private ReportExecution5_5 reportExecution; + + @Before + public void setUp() throws Exception { + initMocks(this); + reportExecution = new ReportExecution5_5( + mExportExecutionApi, + mReportExecutionApi, + mExportFactory, + REPORT_OPTIONS, + EXEC_ID, + REPORT_URI, + 0); + } + + @Test + public void testExport() throws Exception { + when(mReportExecutionApi.getDetails(anyString())).thenReturn(reportDescriptor); + when(exportDescriptor.getExportId()).thenReturn(EXPORT_ID); + when(mExportExecutionApi.start(anyString(), any(ReportExportOptions.class))).thenReturn(exportDescriptor); + + reportExecution.export(EXPORT_OPTIONS); + + verify(mExportExecutionApi).start(EXEC_ID, EXPORT_OPTIONS); + verify(mReportExecutionApi).getDetails(EXEC_ID); + verify(mExportFactory).create(reportDescriptor, EXEC_ID, EXPORT_ID); + } + + @Test + public void testUpdateExecution() throws Exception { + ReportExecutionOptions criteria = spy(REPORT_OPTIONS); + ReportExecutionOptions.Builder builder = spy(criteria.newBuilder()); + ReportExecutionOptions newCriteria = builder.withParams(REPORT_PARAMS).build(); + + when(builder.build()).thenReturn(newCriteria); + when(criteria.newBuilder()).thenReturn(builder); + + when(mReportExecutionApi.start(anyString(), any(ReportExecutionOptions.class))).thenReturn(reportDescriptor); + when(reportDescriptor.getExecutionId()).thenReturn(EXEC_ID); + + ReportExecution newExecution = reportExecution.updateExecution(REPORT_PARAMS); + + assertThat(newExecution, is(instanceOf(ReportExecution5_5.class))); + assertThat(newExecution, is(notNullValue())); + + verify(criteria).newBuilder(); + verify(builder).withParams(REPORT_PARAMS); + verify(builder).build(); + + verify(mReportExecutionApi).start(eq(REPORT_URI), not(eq(REPORT_OPTIONS))); + verify(mReportExecutionApi).awaitStatus(EXEC_ID, REPORT_URI, 0, Status.execution(), Status.ready()); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6PlusTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6PlusTest.java new file mode 100644 index 00000000..6e135b54 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6PlusTest.java @@ -0,0 +1,112 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ExportExecutionDescriptor.class, + ReportExecutionDescriptor.class, +}) +public class ReportExecution5_6PlusTest { + private static final ReportExportOptions EXPORT_OPTIONS = FakeOptions.export(); + private static final List REPORT_PARAMS = Collections.emptyList(); + + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + private static final String REPORT_URI = "my/uri"; + + @Mock + ExportExecutionApi mExportExecutionApi; + @Mock + ReportExecutionApi mReportExecutionApi; + @Mock + ExportFactory mExportFactory; + + @Mock + ExportExecutionDescriptor exportDescriptor; + @Mock + ReportExecutionDescriptor reportDescriptor; + + @Mock + ReportExecutionOptions.Builder mCriteriaBuilder; + + private ReportExecution reportExecution; + + @Before + public void setUp() throws Exception { + initMocks(this); + reportExecution = new ReportExecution5_6Plus( + mExportExecutionApi, + mReportExecutionApi, + mExportFactory, + EXEC_ID, + REPORT_URI, + 0); + } + + @Test + public void testExport() throws Exception { + when(mReportExecutionApi.getDetails(anyString())).thenReturn(reportDescriptor); + when(exportDescriptor.getExportId()).thenReturn(EXPORT_ID); + when(mExportExecutionApi.start(anyString(), any(ReportExportOptions.class))).thenReturn(exportDescriptor); + + reportExecution.export(EXPORT_OPTIONS); + + verify(mExportExecutionApi).start(EXEC_ID, EXPORT_OPTIONS); + verify(mExportExecutionApi).awaitReadyStatus(EXEC_ID, EXPORT_ID, REPORT_URI, 0); + verify(mReportExecutionApi).getDetails(EXEC_ID); + verify(mExportFactory).create(reportDescriptor, EXEC_ID, EXPORT_ID); + } + + @Test + public void testUpdateExecution() throws Exception { + ReportExecution newExecution = reportExecution.updateExecution(REPORT_PARAMS); + assertThat("For servers 5.6+ we return same report execution", newExecution, is(reportExecution)); + + verify(mReportExecutionApi).update(EXEC_ID, REPORT_PARAMS); + verify(mReportExecutionApi).awaitStatus(EXEC_ID, REPORT_URI, 0, Status.execution(), Status.ready()); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptionsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptionsTest.java new file mode 100644 index 00000000..fc676cac --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionOptionsTest.java @@ -0,0 +1,87 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Test; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class ReportExecutionOptionsTest { + @Test + public void testNewBuilder() throws Exception { + boolean freshData = true; + boolean saveSnapshot = true; + boolean interactive = true; + boolean ignorePagination = true; + boolean allowInlineScripts = true; + String key = "key"; + String prefix = "./"; + String anchor = "anchor"; + ReportMarkup embeddable = ReportMarkup.EMBEDDABLE; + ReportFormat format = ReportFormat.PDF; + PageRange range = PageRange.parse("1-10"); + List params = Collections.emptyList(); + + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withFreshData(freshData) + .withSaveSnapshot(saveSnapshot) + .withInteractive(interactive) + .withIgnorePagination(ignorePagination) + .withAllowInlineScripts(allowInlineScripts) + .withTransformerKey(key) + .withAttachmentPrefix(prefix) + .withAnchor(anchor) + .withMarkupType(embeddable) + .withFormat(format) + .withPageRange(range) + .withParams(params) + .build(); + ReportExecutionOptions newCriteria = criteria.newBuilder().build(); + assertThat("Failed to map 'freshData'", newCriteria.getFreshData(), is(freshData)); + assertThat("Failed to map 'saveSnapshot'", newCriteria.getSaveSnapshot(), is(saveSnapshot)); + assertThat("Failed to map 'interactive'", newCriteria.getInteractive(), is(interactive)); + assertThat("Failed to map 'ignorePagination'", newCriteria.getIgnorePagination(), is(ignorePagination)); + assertThat("Failed to map 'allowInlineScripts'", newCriteria.getAllowInlineScripts(), is(allowInlineScripts)); + assertThat("Failed to map 'key'", newCriteria.getTransformerKey(), is(key)); + assertThat("Failed to map 'prefix'", newCriteria.getAttachmentPrefix(), is(prefix)); + assertThat("Failed to map 'anchor'", newCriteria.getAnchor(), is(anchor)); + assertThat("Failed to map 'embeddable'", newCriteria.getMarkupType(), is(embeddable)); + assertThat("Failed to map 'format'", newCriteria.getFormat(), is(format)); + assertThat("Failed to map 'range'", newCriteria.getPageRange(), is(range)); + assertThat("Failed to map 'params'", newCriteria.getParams(), is(params)); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(ReportExecutionOptions.class).verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java deleted file mode 100644 index cd95b563..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ExportDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; -import com.jaspersoft.android.sdk.test.Chain; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import static com.jaspersoft.android.sdk.test.Chain.of; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; -import static org.powermock.api.mockito.PowerMockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ - ReportExecutionDescriptor.class, - ExecutionOptionsDataMapper.class, - ExportExecutionDescriptor.class, - ReportExecutionUseCase.class, - ExportDescriptor.class, - ExecutionStatus.class, - ErrorDescriptor.class, - ExecutionOptionsDataMapper.class, - ReportService.class, -}) -public class ReportExecutionTest { - - @Mock - RunExportCriteria exportCriteria; - @Mock - ExportExecutionDescriptor mExportExecDetails; - @Mock - ReportExecutionDescriptor mReportExecDetails1; - @Mock - ReportExecutionDescriptor mReportExecDetails2; - @Mock - ExportDescriptor mExportExecution; - @Mock - ExecutionStatus mExecutionStatusResponse; - @Mock - ErrorDescriptor mDescriptor; - - @Mock - ReportExecutionUseCase mReportExecutionUseCase; - @Mock - ReportExportUseCase mReportExportUseCase; - - @Mock - ReportService mReportService; - @Mock - RunReportCriteria mReportCriteria; - - @Mock - InfoCacheManager mInfoCacheManager; - @Mock - ServerInfo mServerInfo; - - private ReportExecution objectUnderTest; - - @Rule - public ExpectedException mException = ExpectedException.none(); - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - when(mReportExecDetails1.getExecutionId()).thenReturn("execution_id"); - when(mReportExecDetails1.getReportURI()).thenReturn("/report/uri"); - - when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); - - objectUnderTest = new ReportExecution( - mReportService, - mReportCriteria, - mInfoCacheManager, - TimeUnit.SECONDS.toMillis(0), - mReportExecutionUseCase, - mReportExportUseCase, - "execution_id", - "/report/uri"); - } - - @Test(timeout = 2000) - public void testRequestExportIdealCase() throws Exception { - mockRunExportExecution("queued"); - mockCheckExportExecStatus("ready"); - mockReportExecutionDetails("ready"); - - objectUnderTest.export(exportCriteria); - - verify(mReportExportUseCase).runExport(eq("execution_id"), any(RunExportCriteria.class)); - verify(mReportExecutionUseCase).requestExecutionDetails(eq("execution_id")); - } - - @Test(timeout = 2000) - public void testRunThrowsFailedStatusImmediately() throws Exception { - // export run request - mockRunExportExecution("queued"); - mockCheckExportExecStatus("failed"); - - try { - objectUnderTest.export(exportCriteria); - fail("Should throw Status exception"); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); - } - } - - @Test(timeout = 2000) - public void testRunShouldThrowFailedIfStatusFailed() throws Exception { - mockRunExportExecution("queued"); - mockCheckExportExecStatus("failed"); - try { - objectUnderTest.export(exportCriteria); - fail("Should throw Status exception"); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_FAILED)); - } - } - - @Test(timeout = 2000) - public void testRunThrowsCancelledStatusImmediately() throws Exception { - // export run request - mockRunExportExecution("queued"); - mockCheckExportExecStatus("cancelled"); - - try { - objectUnderTest.export(exportCriteria); - fail("Should throw Status exception"); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_CANCELLED)); - } - } - - @Test(timeout = 2000) - public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { - mockRunExportExecution("queued"); - mockCheckExportExecStatus("cancelled"); - - try { - objectUnderTest.export(exportCriteria); - fail("Should throw Status exception"); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.EXPORT_EXECUTION_CANCELLED)); - } - } - - @Test(timeout = 2000) - public void testRunReportPendingCase() throws Exception { - mockRunExportExecution("queued"); - mockCheckExportExecStatus("queued", "ready"); - mockReportExecutionDetails("ready"); - - objectUnderTest.export(exportCriteria); - - verify(mReportExportUseCase, times(2)).checkExportExecutionStatus(eq("execution_id"), eq("export_id")); - } - - @Test(timeout = 2000) - public void ensureThatExportCancelledEventWillBeResolved() throws Exception { - mockRunExportExecution("queued"); - mockCheckExportExecStatus("cancelled", "ready"); - mockReportExecutionDetails("ready"); - - objectUnderTest.export(exportCriteria); - - verify(mReportExportUseCase, times(2)).runExport(eq("execution_id"), any(RunExportCriteria.class)); - } - - @Test(timeout = 2000) - public void testAwaitCompleteReport() throws Exception { - when(mReportExecDetails1.getTotalPages()).thenReturn(100); - mockReportExecutionDetails("ready"); - - ReportMetadata metadata = objectUnderTest.waitForReportCompletion(); - assertThat(metadata.getTotalPages(), is(100)); - assertThat(metadata.getUri(), is("/report/uri")); - - verify(mReportExecutionUseCase).requestExecutionDetails(anyString()); - verifyNoMoreInteractions(mReportExecutionUseCase); - } - - @Test(timeout = 2000) - public void testAwaitCompleteReportShouldLoopCalls() throws Exception { - mockReportExecutionDetails("execution", "ready"); - - objectUnderTest.waitForReportCompletion(); - - verify(mReportExecutionUseCase, times(2)).requestExecutionDetails(anyString()); - verifyNoMoreInteractions(mReportExecutionUseCase); - } - - @Test(timeout = 2000) - public void testAwaitCompleteReportThrowCancelledIfStatusCancelled() throws Exception { - mockReportExecutionDetails("execution", "cancelled"); - - try { - objectUnderTest.waitForReportCompletion(); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); - } - } - - @Test(timeout = 2000) - public void testAwaitCompleteReportThrowFailedIfStatusFailed() throws Exception { - mockReportExecutionDetails("execution", "failed"); - - try { - objectUnderTest.waitForReportCompletion(); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); - } - } - - @Test(timeout = 2000) - public void testUpdateExecution() throws Exception { - List params = Collections.emptyList(); - objectUnderTest.updateExecution(params); - verify(mReportExecutionUseCase).updateExecution("execution_id", params); - } - - private void mockCheckExportExecStatus(String... statusChain) throws Exception { - ensureChain(statusChain); - when(mExecutionStatusResponse.getStatus()).then(Chain.of(statusChain)); - when(mReportExportUseCase.checkExportExecutionStatus(anyString(), anyString())).thenReturn(mExecutionStatusResponse); - } - - private void mockRunExportExecution(String... statusChain) throws Exception { - ensureChain(statusChain); - when(mExportExecDetails.getExportId()).thenReturn("export_id"); - when(mExportExecDetails.getStatus()).then(of(statusChain)); - when(mExportExecDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(mReportExportUseCase.runExport(anyString(), any(RunExportCriteria.class))).thenReturn(mExportExecDetails); - } - - private void mockReportExecutionDetails(String firstStatus, String... statusChain) throws Exception { - Set exports = Collections.singleton(mExportExecution); - when(mExportExecution.getStatus()).thenReturn("execution"); - when(mExportExecution.getId()).thenReturn("export_id"); - - when(mReportExecDetails1.getStatus()).thenReturn(firstStatus); - when(mReportExecDetails1.getExports()).thenReturn(exports); - when(mReportExecDetails1.getErrorDescriptor()).thenReturn(mDescriptor); - - when(mReportExecDetails2.getStatus()).then(of(statusChain)); - when(mReportExecDetails2.getExports()).thenReturn(exports); - when(mReportExecDetails2.getErrorDescriptor()).thenReturn(mDescriptor); - - when(mReportExecutionUseCase.requestExecutionDetails(anyString())) - .then(of(mReportExecDetails1, mReportExecDetails2)); - } - - private void ensureChain(String[] statusChain) { - if (statusChain.length == 0) { - throw new IllegalArgumentException("You should supply at least one status: ready, queued, execution, cancelled, failed"); - } - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java deleted file mode 100644 index 34f4bad9..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExecutionUseCaseTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.Collections; -import java.util.List; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ExecutionOptionsDataMapper.class}) -public class ReportExecutionUseCaseTest { - - private static final String EXECUTION_ID = "execution_id"; - - @Mock - ReportExecutionRestApi mExecutionRestApi; - @Mock - ExecutionOptionsDataMapper mDataMapper; - @Mock - InfoCacheManager mInfoCacheManager; - @Mock - ServerInfo mServerInfo; - - private ReportExecutionUseCase executionUseCase; - private final FakeCallExecutor fakeCallExecutor = new FakeCallExecutor(); - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); - executionUseCase = - new ReportExecutionUseCase(mExecutionRestApi, fakeCallExecutor, mInfoCacheManager, mDataMapper); - } - - @Test - public void testRunReportExecution() throws Exception { - RunReportCriteria criteria = RunReportCriteria.builder().create(); - executionUseCase.runReportExecution("/my/uri", criteria); - verify(mDataMapper).transformRunReportOptions("/my/uri", ServerVersion.v6, criteria); - verify(mExecutionRestApi).runReportExecution(any(ReportExecutionRequestOptions.class)); - } - - @Test - public void testRequestStatus() throws Exception { - executionUseCase.requestStatus(EXECUTION_ID); - verify(mExecutionRestApi).requestReportExecutionStatus(EXECUTION_ID); - } - - @Test - public void testRequestExecutionDetails() throws Exception { - executionUseCase.requestExecutionDetails(EXECUTION_ID); - verify(mExecutionRestApi).requestReportExecutionDetails(EXECUTION_ID); - } - - @Test - public void testUpdateExecution() throws Exception { - List params = Collections.emptyList(); - executionUseCase.updateExecution(EXECUTION_ID, params); - verify(mExecutionRestApi).updateReportExecution(EXECUTION_ID, params); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportMapperTest.java new file mode 100644 index 00000000..1250257d --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportMapperTest.java @@ -0,0 +1,82 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.io.InputStream; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ExportOutputResource.class, +}) +public class ReportExportMapperTest { + + private static final String TOTAL_PAGES = "9999"; + private static final PageRange PAGE_RANGE = PageRange.parse(TOTAL_PAGES); + + @Mock + ExportOutputResource mExportOutputResource; + @Mock + OutputResource mOutput; + @Mock + InputStream mStream; + + private ReportExportMapper mapper; + + @Before + public void setUp() throws Exception { + initMocks(this); + mapper = new ReportExportMapper(); + } + + @Test + public void testTransform() throws Exception { + when(mExportOutputResource.getPages()).thenReturn(TOTAL_PAGES); + when(mExportOutputResource.isFinal()).thenReturn(Boolean.FALSE); + + when(mOutput.getStream()).thenReturn(mStream); + when(mExportOutputResource.getOutputResource()).thenReturn(mOutput); + + ReportExportOutput export = mapper.transform(mExportOutputResource); + assertThat(export.getPages(), is(PAGE_RANGE)); + assertThat(export.isFinal(), is(Boolean.FALSE)); + assertThat(export.getStream(), is(mStream)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper5_5And6_1Test.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper5_5And6_1Test.java new file mode 100644 index 00000000..2626fb37 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper5_5And6_1Test.java @@ -0,0 +1,114 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +public class ReportExportOptionsMapper5_5And6_1Test { + private static final String BASE_URL = "http://localhost"; + + private ExportOptionsMapper5_5and6_1 mapper; + + @Before + public void setUp() throws Exception { + mapper = new ExportOptionsMapper5_5and6_1(BASE_URL); + } + + @Test + public void should_map_format() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'format' option", options.getOutputFormat(), is("pdf")); + } + + @Test + public void should_map_pages() { + PageRange range = PageRange.parse("1-10"); + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withPageRange(range) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'pages' option", options.getPages(), is("1-10")); + } + + @Test + public void should_include_ignore_pagination_flag() throws Exception { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withIgnorePagination(true) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to remove 'ignorePagination' option", options.getIgnorePagination(), is(nullValue())); + } + + @Test + public void should_map_anchor() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withAnchor("anchor") + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'anchor' option", options.getAnchor(), is("anchor")); + } + + @Test + public void should_map_decoded_attachmentPrefix() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withAttachmentPrefix("./") + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'attachmentPrefix' option", options.getAttachmentsPrefix(), is(".%2F")); + } + + @Test + public void should_map_allowInlineScripts() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withAllowInlineScripts(true) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'allowInlineScripts' option", options.getAllowInlineScripts(), is(true)); + } + + @Test + public void should_map_baseUrl() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'baseUrl' option", options.getBaseUrl(), is(BASE_URL)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper6_2Test.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper6_2Test.java new file mode 100644 index 00000000..abdebdfb --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapper6_2Test.java @@ -0,0 +1,113 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class ReportExportOptionsMapper6_2Test { + private static final String BASE_URL = "http://localhost"; + + private ExportOptionsMapper6_2 mapper; + + @Before + public void setUp() throws Exception { + mapper = new ExportOptionsMapper6_2(BASE_URL); + } + + @Test + public void should_map_format() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'format' option", options.getOutputFormat(), is("pdf")); + } + + @Test + public void should_map_pages() { + PageRange range = PageRange.parse("1-10"); + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withPageRange(range) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'pages' option", options.getPages(), is("1-10")); + } + + @Test + public void should_include_ignore_pagination_flag() throws Exception { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withIgnorePagination(true) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'ignorePagination' option", options.getIgnorePagination(), is(true)); + } + + @Test + public void should_map_anchor() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withAnchor("anchor") + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'anchor' option", options.getAnchor(), is("anchor")); + } + + @Test + public void should_map_decoded_attachmentPrefix() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withAttachmentPrefix("./") + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'attachmentPrefix' option", options.getAttachmentsPrefix(), is(".%2F")); + } + + @Test + public void should_map_allowInlineScripts() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .withAllowInlineScripts(true) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'allowInlineScripts' option", options.getAllowInlineScripts(), is(true)); + } + + @Test + public void should_map_baseUrl() { + ReportExportOptions criteria = ReportExportOptions.builder() + .withFormat(ReportFormat.PDF) + .build(); + ExecutionRequestOptions options = mapper.transform(criteria); + assertThat("Failed to map 'baseUrl' option", options.getBaseUrl(), is(BASE_URL)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapperTest.java new file mode 100644 index 00000000..5b6f94f9 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsMapperTest.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; + +@RunWith(JUnitParamsRunner.class) +public class ReportExportOptionsMapperTest { + private static final String BASE_URL = "http://localhost"; + + @Test + public void should_create_6_2_mapper() throws Exception { + ExportOptionsMapper mapper = ExportOptionsMapper.create(ServerVersion.v6_2, BASE_URL); + assertThat(mapper, is(instanceOf(ExportOptionsMapper6_2.class))); + } + + @Test + @Parameters({ + "v5_5", + "v5_6", + "v5_6_1", + "v6", + "v6_0_1", + "v6_1", + "v6_1_1", + }) + public void should_create_default_mapper_for(String rawVersion) throws Exception { + ServerVersion version = (ServerVersion) ServerVersion.class.getField(rawVersion).get(null); + ExportOptionsMapper mapper = ExportOptionsMapper.create(version, BASE_URL); + assertThat(mapper, is(instanceOf(ExportOptionsMapper5_5and6_1.class))); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsTest.java new file mode 100644 index 00000000..4007c0d5 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportOptionsTest.java @@ -0,0 +1,96 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class ReportExportOptionsTest { + + private ReportExportOptions.Builder criteriaBuilder; + + @Before + public void setUp() throws Exception { + criteriaBuilder = ReportExportOptions.builder().withFormat(ReportFormat.PDF); + } + + @Test(expected = IllegalStateException.class) + public void should_not_build_with_null_format() throws Exception { + ReportExportOptions.builder().build(); + } + + @Test(expected = NullPointerException.class) + public void should_not_accept_null_format() throws Exception { + criteriaBuilder.withFormat(null).build(); + } + + + @Test + public void testGetFormat() throws Exception { + ReportExportOptions criteria = criteriaBuilder.withFormat(ReportFormat.PDF).build(); + assertThat(criteria.getFormat(), is(ReportFormat.PDF)); + } + + @Test + public void testGetPages() throws Exception { + PageRange pageRange = PageRange.parse("1-10"); + ReportExportOptions criteria = criteriaBuilder.withPageRange(pageRange).build(); + assertThat(criteria.getPageRange(), is(pageRange)); + } + + @Test + public void testGetAttachmentPrefix() throws Exception { + ReportExportOptions criteria = criteriaBuilder.withAttachmentPrefix("./").build(); + assertThat(criteria.getAttachmentPrefix(), is("./")); + } + + @Test + public void testGetAnchor() throws Exception { + ReportExportOptions criteria = criteriaBuilder.withAnchor("anchor").build(); + assertThat(criteria.getAnchor(), is("anchor")); + } + + @Test + public void testGetIgnorePagination() throws Exception { + ReportExportOptions criteria = criteriaBuilder.withIgnorePagination(true).build(); + assertThat(criteria.getIgnorePagination(), is(true)); + } + + @Test + public void testGetAllowInlineScripts() throws Exception { + ReportExportOptions criteria = criteriaBuilder.withAllowInlineScripts(true).build(); + assertThat(criteria.getAllowInlineScripts(), is(true)); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(ReportExportOptions.class).verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index fc178398..639863ab 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -31,7 +31,6 @@ import java.util.Collections; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -40,24 +39,26 @@ * @since 2.0 */ public class ReportExportTest { + + private static final String EXEC_ID = "exec_id"; + private static final String EXPORT_ID = "export_id"; + @Mock - ReportExportUseCase mReportExportUseCase; - @Mock - RunExportCriteria mCriteria; + ExportExecutionApi mExportExecutionApi; - private ReportExport objectUnderTest; + private ReportExportImpl objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new ReportExport("report_execution_id", "export_id", - Collections.emptyList(), mCriteria, mReportExportUseCase); + objectUnderTest = new ReportExportImpl(mExportExecutionApi, + Collections.emptyList(), EXEC_ID, EXPORT_ID); } @Test public void testDownload() throws Exception { objectUnderTest.download(); - verify(mReportExportUseCase).requestExportOutput(eq(mCriteria), eq("report_execution_id"), eq("export_id")); - verifyNoMoreInteractions(mReportExportUseCase); + verify(mExportExecutionApi).downloadExport(EXEC_ID, EXPORT_ID); + verifyNoMoreInteractions(mExportExecutionApi); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java deleted file mode 100644 index 235a922e..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportUseCaseTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import static com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus.cancelledStatus; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; - -public class ReportExportUseCaseTest { - private static final String EXEC_ID = "exec_id"; - private static final String EXPORT_ID = "export_id"; - private static final String LEGACY_EXPORT_ID = "html;pages=1"; - - @Mock - ReportExportRestApi mExportApi; - @Mock - ExecutionOptionsDataMapper mExecutionOptionsMapper; - - @Mock - InfoCacheManager mCacheManager; - @Mock - ServerInfo mServerInfo; - - private static final RunExportCriteria EXPORT_HTML_PAGE_1 = RunExportCriteria.builder() - .format(ExecutionCriteria.Format.HTML) - .pages("1") - .create(); - - private ReportExportUseCase useCase; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - when(mCacheManager.getInfo()).thenReturn(mServerInfo); - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v6); - - FakeCallExecutor callExecutor = new FakeCallExecutor(); - useCase = new ReportExportUseCase(mExportApi, callExecutor, mCacheManager, mExecutionOptionsMapper); - } - - @Test - public void testRequestExportOutputOnServer5_5() throws Exception { - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); - useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); - verify(mExportApi).requestExportOutput(eq(EXEC_ID), eq(LEGACY_EXPORT_ID)); - verify(mCacheManager).getInfo(); - verify(mServerInfo).getVersion(); - } - - @Test - public void testRequestExportOutputOnServer5_6() throws Exception { - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); - useCase.requestExportOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID); - verify(mExportApi).requestExportOutput(eq(EXEC_ID), eq(EXPORT_ID)); - verify(mCacheManager).getInfo(); - } - - @Test - public void testRunExport() throws Exception { - useCase.runExport(EXEC_ID, EXPORT_HTML_PAGE_1); - verify(mCacheManager).getInfo(); - verify(mServerInfo).getVersion(); - verify(mExecutionOptionsMapper).transformExportOptions(EXPORT_HTML_PAGE_1, ServerVersion.v6); - verify(mExportApi).runExportExecution(eq(EXEC_ID), any(ExecutionRequestOptions.class)); - } - - @Test - public void testCheckExportExecutionStatusOnServer5_5() throws Exception { - when(mExportApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(cancelledStatus()); - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); - - ExecutionStatus execStatus = useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); - assertThat("For server 5.5 status of export always ready", execStatus.getStatus(), is("ready")); - verify(mCacheManager).getInfo(); - verify(mServerInfo).getVersion(); - verifyZeroInteractions(mExportApi); - } - - @Test - public void testCheckExportExecutionStatusOnServer5_6() throws Exception { - when(mExportApi.checkExportExecutionStatus(anyString(), anyString())).thenReturn(cancelledStatus()); - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); - - useCase.checkExportExecutionStatus(EXEC_ID, EXPORT_ID); - verify(mCacheManager).getInfo(); - verify(mServerInfo).getVersion(); - verify(mExportApi).checkExportExecutionStatus(eq(EXEC_ID), eq(EXPORT_ID)); - } - - @Test - public void testRequestExportAttachmentOutputOnServer5_5() throws Exception { - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); - - useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); - verify(mExportApi).requestExportAttachment(eq(EXEC_ID), eq(LEGACY_EXPORT_ID), eq("nay")); - verify(mCacheManager).getInfo(); - verify(mServerInfo).getVersion(); - } - - @Test - public void testRequestExportAttachmentOutputOnServer5_6() throws Exception { - when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); - - useCase.requestExportAttachmentOutput(EXPORT_HTML_PAGE_1, EXEC_ID, EXPORT_ID, "nay"); - verify(mExportApi).requestExportAttachment(eq(EXEC_ID), eq(EXPORT_ID), eq("nay")); - verify(mCacheManager).getInfo(); - verify(mServerInfo).getVersion(); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5Test.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5Test.java new file mode 100644 index 00000000..ee3305db --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_5Test.java @@ -0,0 +1,188 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import org.junit.Before; +import org.junit.Test; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +public class ReportOptionsMapper5_5Test { + + private static final String BASE_URL = "http://localhost"; + private static final String REPORT_URI = "my/uri"; + + private ReportOptionsMapper5_5 mapper; + + @Before + public void setUp() throws Exception { + mapper = new ReportOptionsMapper5_5(BASE_URL); + } + + @Test + public void should_map_format() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withFormat(ReportFormat.PDF) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'format' option", options.getOutputFormat(), is("pdf")); + } + + @Test + public void should_map_html_by_default() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + ReportExecutionRequestOptions options = map(criteria); + assertThat("Failed to map HTML to 'format' option", options.getOutputFormat(), is("html")); + } + + @Test + public void should_not_map_markup() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withMarkupType(ReportMarkup.EMBEDDABLE) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to remove 'markup' option", options.getMarkupType(), is(nullValue())); + } + + @Test + public void should_map_params() { + List params = Collections.emptyList(); + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withParams(params) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'params' option", options.getParameters(), is(params)); + } + + @Test + public void should_map_pages() { + PageRange range = PageRange.parse("1-10"); + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withPageRange(range) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'pages' option", options.getPages(), is("1-10")); + } + + @Test + public void should_not_map_anchor() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAnchor("anchor") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to remove 'anchor' option", options.getAnchor(), is(nullValue())); + } + + + @Test + public void should_map_attachmentPrefix() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAttachmentPrefix("./") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'attachmentPrefix' option", options.getAttachmentsPrefix(), is(".%2F")); + } + + @Test + public void should_not_map_allowInlineScripts_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAllowInlineScripts(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to remove 'allowInlineScripts' option", options.getAllowInlineScripts(), is(nullValue())); + } + + @Test + public void should_map_fresh_data_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withFreshData(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'freshData' option", options.getFreshData(), is(true)); + } + + @Test + public void should_map_save_snapshot_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withSaveSnapshot(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'saveSnapshot' option", options.getSaveDataSnapshot(), is(true)); + } + + @Test + public void should_map_interactiveness_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withInteractive(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'interactiveness' option", options.getInteractive(), is(true)); + } + + @Test + public void should_map_ignore_pagination_flag() throws Exception { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withIgnorePagination(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'ignorePagination' option", options.getIgnorePagination(), is(true)); + } + + @Test + public void should_map_transformer_key() throws Exception { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withTransformerKey("key") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'transformerKey' option", options.getTransformerKey(), is("key")); + } + + @Test + public void should_not_map_baseUrl() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + ReportExecutionRequestOptions options = map(criteria); + assertThat("Failed to remove 'baseUrl' option", options.getBaseUrl(), is(nullValue())); + } + + @Test + public void should_map_report_uri() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + ReportExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'baseUrl' option", options.getReportUnitUri(), is(REPORT_URI)); + } + + private ReportExecutionRequestOptions map(ReportExecutionOptions criteria) { + return mapper.transform(REPORT_URI, criteria); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6PlusTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6PlusTest.java new file mode 100644 index 00000000..376d750d --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6PlusTest.java @@ -0,0 +1,179 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import org.junit.Before; +import org.junit.Test; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class ReportOptionsMapper5_6PlusTest { + private static final String BASE_URL = "http://localhost"; + private static final String REPORT_URI = "my/uri"; + + private ReportOptionsMapper5_6Plus mapper; + + @Before + public void setUp() throws Exception { + mapper = new ReportOptionsMapper5_6Plus(BASE_URL); + } + + @Test + public void should_map_format() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withFormat(ReportFormat.PDF) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'format' option", options.getOutputFormat(), is("pdf")); + } + + @Test + public void should_map_markup() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withMarkupType(ReportMarkup.EMBEDDABLE) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'markup' option", options.getMarkupType(), is("embeddable")); + } + + @Test + public void should_map_params() { + List params = Collections.emptyList(); + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withParams(params) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'params' option", options.getParameters(), is(params)); + } + + @Test + public void should_map_pages() { + PageRange range = PageRange.parse("1-10"); + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withPageRange(range) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'pages' option", options.getPages(), is("1-10")); + } + + @Test + public void should_map_anchor() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAnchor("anchor") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'anchor' option", options.getAnchor(), is("anchor")); + } + + + @Test + public void should_map_attachmentPrefix() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAttachmentPrefix("./") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'attachmentPrefix' option", options.getAttachmentsPrefix(), is(".%2F")); + } + + @Test + public void should_map_allowInlineScripts_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAllowInlineScripts(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'allowInlineScripts' option", options.getAllowInlineScripts(), is(true)); + } + + @Test + public void should_map_fresh_data_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withFreshData(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'freshData' option", options.getFreshData(), is(true)); + } + + @Test + public void should_map_save_snapshot_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withSaveSnapshot(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'saveSnapshot' option", options.getSaveDataSnapshot(), is(true)); + } + + @Test + public void should_map_interactiveness_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withInteractive(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'interactiveness' option", options.getInteractive(), is(true)); + } + + @Test + public void should_map_ignore_pagination_flag() throws Exception { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withIgnorePagination(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'ignorePagination' option", options.getIgnorePagination(), is(true)); + } + + @Test + public void should_map_transformer_key() throws Exception { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withTransformerKey("key") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'transformerKey' option", options.getTransformerKey(), is("key")); + } + + @Test + public void should_map_baseUrl() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + ReportExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'baseUrl' option", options.getBaseUrl(), is(BASE_URL)); + } + + @Test + public void should_map_report_uri() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + ReportExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'baseUrl' option", options.getReportUnitUri(), is(REPORT_URI)); + } + + private ReportExecutionRequestOptions map(ReportExecutionOptions criteria) { + return mapper.transform(REPORT_URI, criteria); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Test.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Test.java new file mode 100644 index 00000000..f0f93682 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsMapper5_6Test.java @@ -0,0 +1,179 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.PageRange; +import org.junit.Before; +import org.junit.Test; + +import java.util.Collections; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class ReportOptionsMapper5_6Test { + private static final String BASE_URL = "http://localhost"; + private static final String REPORT_URI = "my/uri"; + + private ReportOptionsMapper5_6 mapper; + + @Before + public void setUp() throws Exception { + mapper = new ReportOptionsMapper5_6(BASE_URL); + } + + @Test + public void should_map_format() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withFormat(ReportFormat.PDF) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'format' option", options.getOutputFormat(), is("pdf")); + } + + @Test + public void should_map_markup() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withMarkupType(ReportMarkup.EMBEDDABLE) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'markup' option", options.getMarkupType(), is("embeddable")); + } + + @Test + public void should_map_params() { + List params = Collections.emptyList(); + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withParams(params) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'params' option", options.getParameters(), is(params)); + } + + @Test + public void should_map_pages() { + PageRange range = PageRange.parse("1-10"); + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withPageRange(range) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'pages' option", options.getPages(), is("1-10")); + } + + @Test + public void should_map_anchor() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAnchor("anchor") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'anchor' option", options.getAnchor(), is("anchor")); + } + + + @Test + public void should_map_attachmentPrefix() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAttachmentPrefix("./") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'attachmentPrefix' option", options.getAttachmentsPrefix(), is(".%2F")); + } + + @Test + public void should_map_allowInlineScripts_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withAllowInlineScripts(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'allowInlineScripts' option", options.getAllowInlineScripts(), is(true)); + } + + @Test + public void should_map_fresh_data_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withFreshData(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'freshData' option", options.getFreshData(), is(true)); + } + + @Test + public void should_map_save_snapshot_flag() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withSaveSnapshot(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'saveSnapshot' option", options.getSaveDataSnapshot(), is(true)); + } + + @Test + public void should_always_disable_interactiveness() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withInteractive(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to disable 'interactiveness' option", options.getInteractive(), is(false)); + } + + @Test + public void should_map_ignore_pagination_flag() throws Exception { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withIgnorePagination(true) + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'ignorePagination' option", options.getIgnorePagination(), is(true)); + } + + @Test + public void should_map_transformer_key() throws Exception { + ReportExecutionOptions criteria = ReportExecutionOptions.builder() + .withTransformerKey("key") + .build(); + ExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'transformerKey' option", options.getTransformerKey(), is("key")); + } + + @Test + public void should_map_baseUrl() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + ReportExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'baseUrl' option", options.getBaseUrl(), is(BASE_URL)); + } + + @Test + public void should_map_report_uri() { + ReportExecutionOptions criteria = ReportExecutionOptions.builder().build(); + ReportExecutionRequestOptions options = map(criteria); + assertThat("Failed to map 'baseUrl' option", options.getReportUnitUri(), is(REPORT_URI)); + } + + private ReportExecutionRequestOptions map(ReportExecutionOptions criteria) { + return mapper.transform(REPORT_URI, criteria); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java index a228bb61..7bffde57 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportServiceTest.java @@ -1,181 +1,65 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.report; -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; -import com.jaspersoft.android.sdk.test.Chain; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.concurrent.TimeUnit; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; -import static org.powermock.api.mockito.PowerMockito.when; +import static org.hamcrest.Matchers.*; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.MockitoAnnotations.initMocks; -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ - ExecutionStatus.class, - ErrorDescriptor.class, - ReportExecutionDescriptor.class, - ExecutionOptionsDataMapper.class}) public class ReportServiceTest { - - @Mock - ErrorDescriptor mDescriptor; - - @Mock - RunReportCriteria configuration; - @Mock - ReportExecutionDescriptor initDetails; - @Mock - ExecutionStatus statusDetails; - @Mock - ReportExecutionUseCase mReportExecutionUseCase; - @Mock - ReportExportUseCase mReportExportUseCase; - - @Mock - InfoCacheManager mInfoCacheManager; - - ReportService objectUnderTest; + AuthorizedClient mClient; @Rule - public ExpectedException mException = ExpectedException.none(); + public ExpectedException expected = none(); @Before public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - objectUnderTest = new ReportService( - TimeUnit.MILLISECONDS.toMillis(0), - mInfoCacheManager, - mReportExecutionUseCase, - mReportExportUseCase); - } - - @Test - public void testRunShouldCreateActiveSession() throws Exception { - mockRunReportExecution("queue"); - mockReportExecutionStatus("execution", "ready"); - - ReportExecution session = objectUnderTest.run("/report/uri", configuration); - assertThat(session, is(notNullValue())); - - verify(mReportExecutionUseCase).runReportExecution(anyString(), any(RunReportCriteria.class)); - } - - @Test - public void testRunThrowsFailedStatusImmediately() throws Exception { - mockRunReportExecution("queue"); - mockReportExecutionStatus("failed"); - - try { - objectUnderTest.run("/report/uri", configuration); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); - } - } - - @Test - public void testRunShouldThrowFailedIfStatusFailed() throws Exception { - mockRunReportExecution("queued"); - mockReportExecutionStatus("failed"); - - try { - objectUnderTest.run("/report/uri", configuration); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_FAILED)); - } + initMocks(this); } @Test - public void testRunThrowsCancelledStatusImmediately() throws Exception { - mockRunReportExecution("queue"); - mockReportExecutionStatus("cancelled"); - - try { - objectUnderTest.run("/report/uri", configuration); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); - } - } - - @Test - public void testRunShouldThrowCancelledIfStatusCancelled() throws Exception { - mockRunReportExecution("queued"); - mockReportExecutionStatus("cancelled"); - - try { - objectUnderTest.run("/report/uri", configuration); - } catch (ServiceException ex) { - assertThat(ex.code(), is(StatusCodes.REPORT_EXECUTION_CANCELLED)); - } + public void should_create_proxy_instance() throws Exception { + ReportService service = ReportService.newService(mClient); + assertThat("Should be instance of proxy service", service, is(instanceOf(ProxyReportService.class))); + assertThat(service, is(notNullValue())); } @Test - public void testRunShouldLoopUntilStatusExecution() throws Exception { - mockRunReportExecution("queued"); - mockReportExecutionStatus("queued", "execution"); - - objectUnderTest.run("/report/uri", configuration); - verify(mReportExecutionUseCase, times(2)).requestStatus(eq("exec_id")); - } - - private void mockReportExecutionStatus(String... statusChain) throws Exception { - when(statusDetails.getStatus()).then(Chain.of(statusChain)); - when(statusDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(mReportExecutionUseCase.requestStatus(anyString())).thenReturn(statusDetails); - } + public void should_reject_null_client() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); - private void mockRunReportExecution(String execution) throws Exception { - when(initDetails.getStatus()).thenReturn(execution); - when(initDetails.getErrorDescriptor()).thenReturn(mDescriptor); - when(initDetails.getExecutionId()).thenReturn("exec_id"); - when(mReportExecutionUseCase.runReportExecution(anyString(), any(RunReportCriteria.class))).thenReturn(initDetails); + ReportService.newService(null); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/RetryReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RetryReportExecutionTest.java new file mode 100644 index 00000000..38fd24d1 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/RetryReportExecutionTest.java @@ -0,0 +1,102 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import java.util.Collections; +import java.util.List; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class RetryReportExecutionTest { + + private static final ReportExportOptions EXPORT_CRITERIA = FakeOptions.export(); + private static final ServiceException CANCELLED_EXCEPTION = new ServiceException(null, null, StatusCodes.EXPORT_EXECUTION_CANCELLED); + private static final List REPORT_PARAMS = Collections.emptyList(); + + @Mock + ReportExecution mDelegate; + @Mock + ReportExport mReportExport; + + private RetryReportExecution reportExecution; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + reportExecution = new RetryReportExecution(mDelegate); + } + + @Test + public void should_retry_export_if_cancelled_on_first_run() throws Exception { + when(mDelegate.export(any(ReportExportOptions.class))).then(crashOnFirstRun()); + reportExecution.export(EXPORT_CRITERIA); + verify(mDelegate, times(2)).export(EXPORT_CRITERIA); + } + + @Test(expected = ServiceException.class) + public void should_throw_if_cancelled_on_second_run() throws Exception { + when(mDelegate.export(any(ReportExportOptions.class))).thenThrow(CANCELLED_EXCEPTION); + reportExecution.export(EXPORT_CRITERIA); + } + + @Test + public void should_delegate_waitForReportCompletion() throws Exception { + reportExecution.waitForReportCompletion(); + verify(mDelegate).waitForReportCompletion(); + } + + @Test + public void should_delegate_updateExecution() throws Exception { + reportExecution.updateExecution(REPORT_PARAMS); + verify(mDelegate).updateExecution(REPORT_PARAMS); + } + + private Answer crashOnFirstRun() { + return new Answer() { + private boolean thrown; + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + if (!thrown) { + thrown = true; + throw CANCELLED_EXCEPTION; + } + return mReportExport; + } + }; + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java index a5b0e829..163c04bf 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java @@ -24,17 +24,12 @@ package com.jaspersoft.android.sdk.service.repository; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; +import java.util.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -133,7 +128,7 @@ public void shouldIncludeFolderUriInParams() { @Test public void shouldIncludeSortByInParams() { InternalCriteria criteria = InternalCriteria.builder() - .sortBy("description") + .sortBy(SortType.DESCRIPTION) .create(); Map resultMap = new HashMap<>(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java index dd892f8e..1e629378 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java @@ -87,10 +87,10 @@ public void newBuilderShouldCopyRecursiveFlag() { @Test public void newBuilderShouldCopySortBy() { InternalCriteria searchCriteria = InternalCriteria.builder() - .sortBy("creationDate") + .sortBy(SortType.CREATION_DATE) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); - assertThat(newCriteria.getSortBy(), is("creationDate")); + assertThat(newCriteria.getSortBy(), is(SortType.CREATION_DATE)); } @Test @@ -122,50 +122,50 @@ public void newBuilderShouldCopyFolderUri() { @Test public void shouldAdaptFromUserCriteriaFieldLimit() { - SearchCriteria searchCriteria = SearchCriteria.builder().limit(1).create(); + SearchCriteria searchCriteria = SearchCriteria.builder().withLimit(1).build(); InternalCriteria criteria = InternalCriteria.from(searchCriteria); assertThat(criteria.getLimit(), is(1)); } @Test public void shouldAdaptFromUserCriteriaFieldOffset() { - SearchCriteria searchCriteria = SearchCriteria.builder().offset(2).create(); + SearchCriteria searchCriteria = SearchCriteria.builder().withOffset(2).build(); InternalCriteria criteria = InternalCriteria.from(searchCriteria); assertThat(criteria.getOffset(), is(2)); } @Test public void shouldAdaptFromUserCriteriaFieldResourceMask() { - SearchCriteria searchCriteria = SearchCriteria.builder().resourceMask(SearchCriteria.REPORT).create(); + SearchCriteria searchCriteria = SearchCriteria.builder().withResourceMask(SearchCriteria.REPORT).build(); InternalCriteria criteria = InternalCriteria.from(searchCriteria); assertThat(criteria.getResourceMask(), is(SearchCriteria.REPORT)); } @Test public void shouldAdaptFromUserCriteriaFieldRecursive() { - SearchCriteria searchCriteria = SearchCriteria.builder().recursive(true).create(); + SearchCriteria searchCriteria = SearchCriteria.builder().withRecursive(true).build(); InternalCriteria criteria = InternalCriteria.from(searchCriteria); assertThat(criteria.getRecursive(), is(true)); } @Test public void shouldAdaptFromUserCriteriaFieldFolderUri() { - SearchCriteria searchCriteria = SearchCriteria.builder().folderUri("/").create(); + SearchCriteria searchCriteria = SearchCriteria.builder().withFolderUri("/").build(); InternalCriteria criteria = InternalCriteria.from(searchCriteria); assertThat(criteria.getFolderUri(), is("/")); } @Test public void shouldAdaptFromUserCriteriaFieldQuery() { - SearchCriteria searchCriteria = SearchCriteria.builder().query("query").create(); + SearchCriteria searchCriteria = SearchCriteria.builder().withQuery("query").build(); InternalCriteria criteria = InternalCriteria.from(searchCriteria); assertThat(criteria.getQuery(), is("query")); } @Test public void shouldAdaptFromUserCriteriaFieldSortBy() { - SearchCriteria searchCriteria = SearchCriteria.builder().sortByCreationDate().create(); + SearchCriteria searchCriteria = SearchCriteria.builder().withSortType(SortType.CREATION_DATE).build(); InternalCriteria criteria = InternalCriteria.from(searchCriteria); - assertThat(criteria.getSortBy(), is("creationDate")); + assertThat(criteria.getSortBy(), is(SortType.CREATION_DATE)); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java similarity index 53% rename from core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java index b9225f17..c68e3c6f 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java @@ -24,48 +24,42 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNull.notNullValue; /** * @author Tom Koptel * @since 2.0 */ -@RunWith(JUnitParamsRunner.class) -public class SearchStrategyTest { - private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); - +public class ProxyRepositoryServiceTest { + @Mock + SearchUseCase mCase; @Mock - SearchUseCase mSearchUseCase; + InfoCacheManager mInfoCacheManager; + + private ProxyRepositoryService objectUnderTest; + + @Rule + public ExpectedException mExpectedException = ExpectedException.none(); @Before - public void before() { + public void setup() { MockitoAnnotations.initMocks(this); + objectUnderTest = new ProxyRepositoryService(mCase, mInfoCacheManager); } @Test - public void factoryCreatesEmeraldMR2Strategy() { - SearchStrategy searchStrategy = SearchStrategy.Factory.get(mSearchUseCase, CRITERIA, ServerVersion.v5_5); - assertThat(searchStrategy, instanceOf(EmeraldMR2SearchStrategy.class)); - } - - @Test - @Parameters({ - "v6", - "v6_1" - }) - public void factoryCreatesEmeraldMR3Strategy(String versionName) throws Exception { - ServerVersion version = (ServerVersion) ServerVersion.class.getField(versionName).get(null); - SearchStrategy searchStrategy = SearchStrategy.Factory.get(mSearchUseCase, CRITERIA, version); - assertThat(searchStrategy, instanceOf(EmeraldMR3SearchStrategy.class)); + public void shouldProvideListOfResources() { + SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); + assertThat(searchTask, is(notNullValue())); } -} +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index c10379e2..1dc9de55 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -1,65 +1,65 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.network.AuthorizedClient; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsNull.notNullValue; +import static org.hamcrest.Matchers.*; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.MockitoAnnotations.initMocks; -/** - * @author Tom Koptel - * @since 2.0 - */ public class RepositoryServiceTest { @Mock - SearchUseCase mCase; - @Mock - InfoCacheManager mInfoCacheManager; - - private RepositoryService objectUnderTest; + AuthorizedClient mClient; @Rule - public ExpectedException mExpectedException = ExpectedException.none(); + public ExpectedException expected = none(); @Before - public void setup() { - MockitoAnnotations.initMocks(this); - objectUnderTest = new RepositoryService(mCase, mInfoCacheManager); + public void setUp() throws Exception { + initMocks(this); } @Test - public void shouldProvideListOfResources() { - SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); - assertThat(searchTask, is(notNullValue())); + public void should_create_proxy_instance() throws Exception { + RepositoryService service = RepositoryService.newService(mClient); + assertThat("Should be instance of proxy service", service, is(instanceOf(ProxyRepositoryService.class))); + assertThat(service, is(notNullValue())); + } + + @Test + public void should_reject_null_client() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + + RepositoryService.newService(null); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java index f7adda4d..13cf78f6 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchCriteriaTest.java @@ -42,30 +42,30 @@ public class SearchCriteriaTest { @Test public void shouldIncludeSortByLabelInParams() { SearchCriteria criteria = SearchCriteria.builder() - .sortByLabel() - .create(); - assertThat(criteria.getSortBy(), is("label")); + .withSortType(SortType.LABEL) + .build(); + assertThat(criteria.getSortBy(), is(SortType.LABEL)); } @Test public void shouldIncludeSortByCreationDateInParams() { SearchCriteria criteria = SearchCriteria.builder() - .sortByCreationDate() - .create(); - assertThat(criteria.getSortBy(), is("creationDate")); + .withSortType(SortType.CREATION_DATE) + .build(); + assertThat(criteria.getSortBy(), is(SortType.CREATION_DATE)); } @Test public void shouldNotAcceptNegativeOffset() { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Offset should be positive"); - SearchCriteria.builder().offset(-1).create(); + SearchCriteria.builder().withOffset(-1).build(); } @Test public void shouldNotAcceptNegativeLimit() { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Limit should be positive"); - SearchCriteria.builder().limit(-1).create(); + SearchCriteria.builder().withLimit(-1).build(); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java new file mode 100644 index 00000000..e66a2895 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java @@ -0,0 +1,75 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.data.server.ServerVersion; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.when; + +public class SearchTaskFactoryTest { + + @Mock + InfoCacheManager mInfoCacheManager; + @Mock + SearchUseCase mSearchUseCase; + @Mock + ServerInfo mServerInfo; + + private static final InternalCriteria CRITERIA = + InternalCriteria.builder().create(); + private SearchTaskFactory searchTaskFactory; + + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); + + searchTaskFactory = new SearchTaskFactory(CRITERIA, mSearchUseCase, mInfoCacheManager); + } + + @Test + public void testShouldReturnLegacySearchTask() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_5); + SearchTask task = searchTaskFactory.create(); + assertThat(task, is(instanceOf(SearchTaskV5_5.class))); + } + + @Test + public void testShouldReturnNewSearchTask() throws Exception { + when(mServerInfo.getVersion()).thenReturn(ServerVersion.v5_6); + SearchTask task = searchTaskFactory.create(); + assertThat(task, is(instanceOf(SearchTaskV5_6Plus.class))); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java deleted file mode 100644 index 3306aaee..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskImplTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.network.RepositoryRestApi; -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.data.server.ServerVersion; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.Collections; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - -/** - * @author Tom Koptel - * @since 2.0 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(SearchStrategy.Factory.class) -public class SearchTaskImplTest { - private static final InternalCriteria CRITERIA = InternalCriteria.from(SearchCriteria.none()); - - @Mock - RepositoryRestApi mRepoApi; - @Mock - SearchStrategy mSearchStrategy; - @Mock - InfoCacheManager mInfoCacheManager; - @Mock - ServerInfo mServerInfo; - - @Mock - SearchUseCase mSearchUseCase; - - private SearchTaskImpl objectUnderTest; - - @Before - public void setup() throws Exception { - MockitoAnnotations.initMocks(this); - objectUnderTest = new SearchTaskImpl(CRITERIA, mSearchUseCase, mInfoCacheManager); - - when(mInfoCacheManager.getInfo()).thenReturn(mServerInfo); - when(mSearchStrategy.searchNext()).thenReturn(Collections.emptyList()); - - PowerMockito.mockStatic(SearchStrategy.Factory.class); - - - PowerMockito.when( - SearchStrategy.Factory.get( - any(SearchUseCase.class), - any(InternalCriteria.class), - any(ServerVersion.class) - ) - ).thenReturn(mSearchStrategy); - } - - @Test - public void nextLookupShouldDefineSearchStrategy() throws Exception { - objectUnderTest.nextLookup(); - - verify(mSearchStrategy).searchNext(); - verify(mInfoCacheManager).getInfo(); - } - - @Test - public void secondLookupShouldUseCachedStrategy() throws Exception { - objectUnderTest.nextLookup(); - objectUnderTest.nextLookup(); - - verify(mInfoCacheManager).getInfo(); - verify(mSearchStrategy, times(2)).searchNext(); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxyTest.java new file mode 100644 index 00000000..096fe86c --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxyTest.java @@ -0,0 +1,74 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +public class SearchTaskProxyTest { + + @Mock + SearchTaskFactory mSearchTaskFactory; + @Mock + SearchTask mDelegate; + + private SearchTaskProxy searchTask; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + when(mSearchTaskFactory.create()).thenReturn(mDelegate); + searchTask = new SearchTaskProxy(mSearchTaskFactory); + } + + @Test + public void testNextLookup() throws Exception { + searchTask.nextLookup(); + verify(mSearchTaskFactory).create(); + + searchTask.nextLookup(); + verifyNoMoreInteractions(mSearchTaskFactory); + } + + @Test + public void testHasNext() throws Exception { + when(mDelegate.hasNext()).thenReturn(true); + + assertThat("Has next returns false by default", searchTask.hasNext(), is(false)); + searchTask.nextLookup(); + assertThat("Has next returns true from delegate", searchTask.hasNext(), is(true)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5Test.java similarity index 87% rename from core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5Test.java index 304f5f0c..368e31a2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR2SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5Test.java @@ -58,7 +58,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest({SearchUseCase.class}) -public class EmeraldMR2SearchStrategyTest { +public class SearchTaskV5_5Test { @Mock SearchUseCase mSearchUseCase; @@ -68,8 +68,8 @@ public class EmeraldMR2SearchStrategyTest { /** * Objects under test */ - private EmeraldMR2SearchStrategy search10itemsStrategy; - private EmeraldMR2SearchStrategy search10itemsStrategyWithUserOffset5; + private SearchTask search10itemsStrategy; + private SearchTask search10itemsStrategyWithUserOffset5; public static final List FIVE_ITEMS = Arrays.asList(null, null, null, null, null); @Before @@ -79,17 +79,17 @@ public void setupMocks() throws Exception { when(mSearchUseCase.performSearch(Matchers.any(InternalCriteria.class))).thenReturn(mResponse); InternalCriteria criteria = InternalCriteria.builder().limit(10).create(); - search10itemsStrategy = new EmeraldMR2SearchStrategy(criteria, mSearchUseCase); + search10itemsStrategy = new SearchTaskV5_5(criteria, mSearchUseCase); InternalCriteria userCriteria = criteria.newBuilder().offset(5).create(); - search10itemsStrategyWithUserOffset5 = new EmeraldMR2SearchStrategy(userCriteria, mSearchUseCase); + search10itemsStrategyWithUserOffset5 = new SearchTaskV5_5(userCriteria, mSearchUseCase); } @Test public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.nextLookup(); assertThat(result.size(), is(10)); InternalCriteria criteria1 = InternalCriteria.builder().limit(10).create(); @@ -104,7 +104,7 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce public void willRetry5timesIfApiReturnsNoElements() throws Exception { when(mResponse.getResources()).thenReturn(Collections.emptyList()); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.nextLookup(); assertThat(search10itemsStrategy.hasNext(), is(false)); assertThat(result, is(empty())); @@ -115,7 +115,7 @@ public void willRetry5timesIfApiReturnsNoElements() throws Exception { public void willReturnAsMuchElementsAsLeftIfEndReached() throws Exception { when(mResponse.getResources()).then(OnlyTwoItems.INSTANCE); - Collection result = search10itemsStrategy.searchNext(); + Collection result = search10itemsStrategy.nextLookup(); assertThat(result.size(), is(2)); verify(mSearchUseCase, times(6)).performSearch(Matchers.any(InternalCriteria.class)); @@ -125,7 +125,7 @@ public void willReturnAsMuchElementsAsLeftIfEndReached() throws Exception { public void forCustomOffsetShouldCalculateServerDisposition() throws Exception { when(mResponse.getResources()).thenReturn(FIVE_ITEMS); - search10itemsStrategyWithUserOffset5.searchNext(); + search10itemsStrategyWithUserOffset5.nextLookup(); InternalCriteria criteria1 = InternalCriteria.builder() @@ -148,9 +148,9 @@ public void forCustomOffsetShouldCalculateServerDisposition() throws Exception { @Test public void shouldReturnEmptyCollectionForZeroLimit() throws Exception { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - EmeraldMR2SearchStrategy strategy = new EmeraldMR2SearchStrategy(userCriteria, mSearchUseCase); + SearchTask strategy = new SearchTaskV5_5(userCriteria, mSearchUseCase); - Collection result = strategy.searchNext(); + List result = strategy.nextLookup(); assertThat(result, is(empty())); verifyZeroInteractions(mSearchUseCase); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6PlusTest.java similarity index 81% rename from core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6PlusTest.java index 4ffb6f58..38a58376 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/EmeraldMR3SearchStrategyTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6PlusTest.java @@ -26,7 +26,6 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; - import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; @@ -44,10 +43,7 @@ import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; /** * @author Tom Koptel @@ -55,7 +51,7 @@ */ @RunWith(PowerMockRunner.class) @PrepareForTest(SearchUseCase.class) -public class EmeraldMR3SearchStrategyTest { +public class SearchTaskV5_6PlusTest { private static final InternalCriteria NO_CRITERIA = InternalCriteria.from(SearchCriteria.none()); @Mock @@ -76,9 +72,9 @@ public void setupMocks() throws Exception { @Test public void shouldMakeImmediateCallOnApiForUserOffsetZero() throws Exception { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); + SearchTask strategy = new SearchTaskV5_6Plus(searchCriteria, mSearchUseCase); - strategy.searchNext(); + strategy.nextLookup(); InternalCriteria internalCriteria = InternalCriteria.builder() .offset(0) @@ -90,9 +86,9 @@ public void shouldMakeImmediateCallOnApiForUserOffsetZero() throws Exception { @Test public void makesAdditionalCallOnApiIfUserOffsetNotZero() throws Exception { InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); + SearchTask strategy = new SearchTaskV5_6Plus(searchCriteria, mSearchUseCase); - strategy.searchNext(); + strategy.nextLookup(); InternalCriteria internalCriteria = InternalCriteria.builder() .limit(5) @@ -104,13 +100,13 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() throws Exception { @Test public void secondSearchLookupShouldUseNextOffset() throws Exception { InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(searchCriteria, mSearchUseCase); + SearchTask strategy = new SearchTaskV5_6Plus(searchCriteria, mSearchUseCase); when(mResponse.getNextOffset()).thenReturn(133); - strategy.searchNext(); + strategy.nextLookup(); when(mResponse.getNextOffset()).thenReturn(233); - strategy.searchNext(); + strategy.nextLookup(); InternalCriteria internalCriteria = InternalCriteria.builder() @@ -125,15 +121,15 @@ public void secondSearchLookupShouldUseNextOffset() throws Exception { @Test public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() throws Exception { - EmeraldMR3SearchStrategy strategy = new EmeraldMR3SearchStrategy(NO_CRITERIA, mSearchUseCase); + SearchTask strategy = new SearchTaskV5_6Plus(NO_CRITERIA, mSearchUseCase); when(mResponse.getNextOffset()).thenReturn(133); - strategy.searchNext(); + strategy.nextLookup(); when(mResponse.getNextOffset()).thenReturn(0); - strategy.searchNext(); + strategy.nextLookup(); - Collection response = strategy.searchNext(); + Collection response = strategy.nextLookup(); assertThat(response, is(empty())); assertThat(strategy.hasNext(), is(false)); @@ -144,9 +140,9 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() throws @Test public void shouldReturnEmptyCollectionForZeroLimit() throws Exception { InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); - SearchStrategy strategy = new EmeraldMR3SearchStrategy(userCriteria, mSearchUseCase); + SearchTask strategy = new SearchTaskV5_6Plus(userCriteria, mSearchUseCase); - Collection result = strategy.searchNext(); + Collection result = strategy.nextLookup(); assertThat(result, Matchers.is(Matchers.empty())); verifyZeroInteractions(mSearchUseCase); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java index e14dd947..206c5ba7 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchUseCaseTest.java @@ -27,25 +27,27 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.network.entity.resource.ResourceLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import com.jaspersoft.android.sdk.service.FakeCallExecutor; +import com.jaspersoft.android.sdk.service.internal.FakeCallExecutor; import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.internal.InfoCacheManager; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.junit.Before; import org.junit.Test; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collection; +import java.util.List; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.*; +import static org.mockito.Matchers.anyCollectionOf; +import static org.mockito.Matchers.anyMapOf; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -94,16 +96,16 @@ public void setup() throws Exception { @Test public void shouldProvideAndAdaptSearchResult() throws Exception { when(mResult.getNextOffset()).thenReturn(100); - when(mRepositoryRestApi.searchResources(anyMap())).thenReturn(mResult); + when(mRepositoryRestApi.searchResources(anyMapOf(String.class, Object.class))).thenReturn(mResult); - Collection resources = new ArrayList(); - when(mDataMapper.transform(anyCollection(), any(SimpleDateFormat.class))).thenReturn(resources); + List resources = new ArrayList(); + when(mDataMapper.transform(anyCollectionOf(ResourceLookup.class), Matchers.any(SimpleDateFormat.class))).thenReturn(resources); SearchResult result = objectUnderTest.performSearch(mCriteria); assertThat(result, is(not(nullValue()))); assertThat(result.getNextOffset(), is(100)); assertThat(result.getResources(), is(resources)); - verify(mRepositoryRestApi).searchResources(anyMap()); + verify(mRepositoryRestApi).searchResources(anyMapOf(String.class, Object.class)); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SortTypeTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SortTypeTest.java new file mode 100644 index 00000000..82d15b67 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SortTypeTest.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class SortTypeTest { + @Test + public void testLabelEnum() throws Exception { + assertThat(SortType.LABEL.toString(), is("label")); + } + + @Test + public void testDescriptionEnum() throws Exception { + assertThat(SortType.DESCRIPTION.toString(), is("description")); + } + + @Test + public void testCreationDateEnum() throws Exception { + assertThat(SortType.CREATION_DATE.toString(), is("creationDate")); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java index 71d85719..1d8c0ae1 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/JrsMetadata.java @@ -86,9 +86,9 @@ public String toString() { public Credentials getCredentials() { return SpringCredentials.builder() - .password(password) - .username(username) - .organization(organization) + .withPassword(password) + .withUsername(username) + .withOrganization(organization) .build(); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java index f13741d3..4228a629 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/LazyClient.java @@ -47,7 +47,7 @@ public LazyClient(JrsMetadata jrsMetadata) { } public static Server getServer(String serverUrl) { - Server.OptionalBuilder serverBuilder = Server.newBuilder() + Server.OptionalBuilder serverBuilder = Server.builder() .withBaseUrl(serverUrl); if (isProxyReachable()) { Proxy proxy = new Proxy(Proxy.Type.HTTP, CHARLES_ADDRESS); From dc135b5dd8c0667a8177a81986d854a3b699a5aa Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 30 Dec 2015 16:32:26 +0200 Subject: [PATCH 378/457] Add AuthorizationService/AuthorizationClient API Implement AuthorizationClient Expose InMemoryCookieStore Add high level AuthorizationService Fix JavaDoc warnign for JSEncryptionAlgorithm#byteArrayToHexString() --- .../android/sdk/network/AuthStrategy.java | 18 ++-- .../sdk/network/AuthorizationClient.java | 35 ++++++ .../sdk/network/AuthorizationClientImpl.java | 44 ++++++++ .../sdk/network/InMemoryCookieStore.java | 2 +- .../sdk/network/JSEncryptionAlgorithm.java | 15 +-- .../android/sdk/network/Server.java | 37 ++++++- .../sdk/network/SpringAuthService.java | 2 +- .../sdk/network/SpringAuthServiceFactory.java | 45 ++++++++ .../service/auth/AuthorizationService.java | 48 +++++++++ .../auth/ProxyAuthorizationService.java | 61 +++++++++++ .../android/sdk/network/AuthStrategyTest.java | 64 +++++++++++ .../AuthorizationClientTestImplTest.java | 54 ++++++++++ .../network/SpringAuthServiceFactoryTest.java | 52 +++++++++ .../auth/AuthorizationServiceTest.java | 66 ++++++++++++ .../auth/ProxyAuthorizationServiceTest.java | 101 ++++++++++++++++++ .../api/AuthorizationClientTest.java | 53 +++++++++ 16 files changed, 673 insertions(+), 24 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClientImpl.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/AuthStrategyTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactoryTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java index 49ac7cf8..e6b77e88 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthStrategy.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import retrofit.Retrofit; +import org.jetbrains.annotations.TestOnly; import java.io.IOException; @@ -36,24 +36,20 @@ */ class AuthStrategy { @NotNull - private final Retrofit mRetrofit; + private final SpringAuthServiceFactory mSpringAuthServiceFactory; + @Nullable private SpringAuthService springAuthService; - AuthStrategy(@NotNull Retrofit retrofit) { - mRetrofit = retrofit; + @TestOnly + AuthStrategy(@NotNull SpringAuthServiceFactory springAuthServiceFactory) { + mSpringAuthServiceFactory = springAuthServiceFactory; } void apply(SpringCredentials credentials) throws IOException, HttpException { if (springAuthService == null) { - springAuthService = createSpringAuthService(); + springAuthService = mSpringAuthServiceFactory.create(); } springAuthService.authenticate(credentials); } - - private SpringAuthService createSpringAuthService() { - AuthenticationRestApi restApi = new AuthenticationRestApi(mRetrofit); - JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); - return new SpringAuthService(restApi, encryptionAlgorithm); - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java new file mode 100644 index 00000000..511d218c --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface AuthorizationClient { + public void authorize(Credentials credentials) throws IOException, HttpException; +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClientImpl.java new file mode 100644 index 00000000..6bf6b3b9 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClientImpl.java @@ -0,0 +1,44 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class AuthorizationClientImpl implements AuthorizationClient { + private final AuthStrategy mAuthStrategy; + + AuthorizationClientImpl(AuthStrategy authStrategy) { + mAuthStrategy = authStrategy; + } + + @Override + public void authorize(Credentials credentials) throws IOException, HttpException { + credentials.apply(mAuthStrategy); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java index 417c5c51..faa3f029 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InMemoryCookieStore.java @@ -35,7 +35,7 @@ * Implementation cf {@link java.net.CookieStore} copied from internal sources. * Used exclusively for anonymous session handling */ -final class InMemoryCookieStore implements CookieStore { +public final class InMemoryCookieStore implements CookieStore { // the in-memory representation of cookies private List cookieJar = null; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java b/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java index 9ce6844c..a9a08dbb 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/JSEncryptionAlgorithm.java @@ -24,19 +24,14 @@ package com.jaspersoft.android.sdk.network; +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; import java.math.BigInteger; import java.net.URLEncoder; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.PublicKey; +import java.security.*; import java.security.spec.InvalidKeySpecException; import java.security.spec.RSAPublicKeySpec; -import javax.crypto.Cipher; -import javax.crypto.NoSuchPaddingException; - /** * @author Tom Koptel * @since 2.0 @@ -96,8 +91,8 @@ private PublicKey createPublicKey(String modulus, String exponent) /** * Convert byteArr to hex sting. * - * @param byteArr - * @return + * @param byteArr The byte array to convert. + * @return The hex string. */ private static String byteArrayToHexString(byte[] byteArr) { StringBuffer sb = new StringBuffer(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index 621dec82..da05b7c7 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -55,6 +55,11 @@ public static Builder builder() { return new Builder(); } + @NotNull + public AuthorizationClientBuilder newAuthorizationClient() { + return new AuthorizationClientBuilder(this); + } + @NotNull public AnonymousClientBuilder newClient() { return new AnonymousClientBuilder(this); @@ -195,7 +200,9 @@ private AuthStrategy configureAuthStrategy(OkHttpClient client) { Retrofit authRetrofit = mServer.newRetrofit() .client(authClient) .build(); - return new AuthStrategy(authRetrofit); + + SpringAuthServiceFactory springAuthServiceFactory = new SpringAuthServiceFactory(authRetrofit); + return new AuthStrategy(springAuthServiceFactory); } private void configureAuthenticator(OkHttpClient client, AuthStrategy authStrategy) { @@ -209,4 +216,32 @@ private void configureAuthenticator(OkHttpClient client, AuthStrategy authStrate client.setAuthenticator(authenticator); } } + + public static class AuthorizationClientBuilder { + private final Server mServer; + private CookieHandler mCookieHandler = new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER); + + private AuthorizationClientBuilder(Server server) { + mServer = server; + } + + public AuthorizationClientBuilder withCookieHandler(CookieHandler cookieHandler) { + mCookieHandler = cookieHandler; + return this; + } + + public AuthorizationClient create() { + OkHttpClient authClient = mServer.client().clone(); + authClient.setFollowRedirects(false); + authClient.setCookieHandler(mCookieHandler); + + Retrofit authRetrofit = mServer.newRetrofit() + .client(authClient) + .build(); + + SpringAuthServiceFactory springAuthServiceFactory = new SpringAuthServiceFactory(authRetrofit); + AuthStrategy authStrategy = new AuthStrategy(springAuthServiceFactory); + return new AuthorizationClientImpl(authStrategy); + } + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java index 4ae7f263..fa92311c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java @@ -38,7 +38,7 @@ * @author Tom Koptel * @since 2.0 */ -final class SpringAuthService { +class SpringAuthService { private final AuthenticationRestApi mRestApi; private final JSEncryptionAlgorithm mEncryptionAlgorithm; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java new file mode 100644 index 00000000..33c9ac51 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import retrofit.Retrofit; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class SpringAuthServiceFactory { + private final Retrofit mRetrofit; + + SpringAuthServiceFactory(Retrofit retrofit) { + mRetrofit = retrofit; + } + + public SpringAuthService create() { + AuthenticationRestApi restApi = new AuthenticationRestApi(mRetrofit); + JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); + return new SpringAuthService(restApi, encryptionAlgorithm); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java new file mode 100644 index 00000000..15b134a6 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.jetbrains.annotations.NotNull; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class AuthorizationService { + public abstract void authorize(Credentials credentials) throws ServiceException; + + @NotNull + public static AuthorizationService newService(@NotNull AuthorizationClient client) { + Preconditions.checkNotNull(client, "Client should not be null"); + ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); + return new ProxyAuthorizationService(client, serviceExceptionMapper); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java new file mode 100644 index 00000000..0e5b43ca --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.jetbrains.annotations.TestOnly; + +import java.io.IOException; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class ProxyAuthorizationService extends AuthorizationService { + private final AuthorizationClient mClient; + private final ServiceExceptionMapper mServiceExceptionMapper; + + @TestOnly + ProxyAuthorizationService(AuthorizationClient client, + ServiceExceptionMapper mapper) { + mServiceExceptionMapper = mapper; + mClient = client; + } + + @Override + public void authorize(Credentials credentials) throws ServiceException { + try { + mClient.authorize(credentials); + } catch (IOException e) { + throw mServiceExceptionMapper.transform(e); + } catch (HttpException e) { + throw mServiceExceptionMapper.transform(e); + } + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthStrategyTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthStrategyTest.java new file mode 100644 index 00000000..454c2e2f --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthStrategyTest.java @@ -0,0 +1,64 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class AuthStrategyTest { + + @Mock + SpringAuthServiceFactory mSpringAuthServiceFactory; + @Mock + SpringAuthService mSpringAuthService; + + private AuthStrategy authStrategy; + + @Before + public void setUp() throws Exception { + initMocks(this); + when(mSpringAuthServiceFactory.create()).thenReturn(mSpringAuthService); + authStrategy = new AuthStrategy(mSpringAuthServiceFactory); + } + + @Test + public void testApply() throws Exception { + SpringCredentials springCredentials = SpringCredentials.builder() + .withUsername("user") + .withPassword("1234") + .build(); + authStrategy.apply(springCredentials); + verify(mSpringAuthServiceFactory).create(); + + authStrategy.apply(springCredentials); + verifyNoMoreInteractions(mSpringAuthServiceFactory); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java new file mode 100644 index 00000000..0ccbc008 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import static org.mockito.Mockito.verify; +import static org.mockito.MockitoAnnotations.initMocks; + +public class AuthorizationClientTestImplTest { + + @Mock + AuthStrategy mAuthStrategy; + @Mock + Credentials mCredentials; + + private AuthorizationClientImpl authorization; + + @Before + public void setUp() throws Exception { + initMocks(this); + authorization = new AuthorizationClientImpl(mAuthStrategy); + } + + @Test + public void testAuthorize() throws Exception { + authorization.authorize(mCredentials); + verify(mCredentials).apply(mAuthStrategy); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactoryTest.java new file mode 100644 index 00000000..91d6df4b --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactoryTest.java @@ -0,0 +1,52 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import org.junit.Before; +import org.junit.Test; +import retrofit.Retrofit; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +public class SpringAuthServiceFactoryTest { + + private SpringAuthServiceFactory authServiceFactory; + + @Before + public void setUp() throws Exception { + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://localhost") + .build(); + authServiceFactory = new SpringAuthServiceFactory(retrofit); + } + + @Test + public void testCreate() throws Exception { + SpringAuthService service = authServiceFactory.create(); + assertThat(service, is(notNullValue())); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java new file mode 100644 index 00000000..15b2938f --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +import com.jaspersoft.android.sdk.network.AuthorizationClient; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.MockitoAnnotations.initMocks; + +public class AuthorizationServiceTest { + + @Mock + AuthorizationClient mAuthorizationClient; + @Rule + public ExpectedException expected = none(); + + @Before + public void setUp() throws Exception { + initMocks(this); + } + + @Test + public void should_not_allow_null_client() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Client should not be null"); + AuthorizationService.newService(null); + } + + @Test + public void should_create_new_proxy_service() throws Exception { + AuthorizationService service = AuthorizationService.newService(mAuthorizationClient); + assertThat(service, is(instanceOf(ProxyAuthorizationService.class))); + assertThat(service, is(notNullValue())); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java new file mode 100644 index 00000000..61f77826 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java @@ -0,0 +1,101 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.auth; + +import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.io.IOException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ProxyAuthorizationServiceTest { + + @Mock + AuthorizationClient mAuthorizationClient; + @Mock + ServiceExceptionMapper mServiceExceptionMapper; + @Mock + Credentials mCredentials; + + @Mock + HttpException mHttpException; + @Mock + IOException mIOException; + @Mock + ServiceException mServiceException; + + private ProxyAuthorizationService authorizationService; + + @Before + public void setUp() throws Exception { + initMocks(this); + authorizationService = new ProxyAuthorizationService(mAuthorizationClient, mServiceExceptionMapper); + } + + @Test + public void testAuthorize() throws Exception { + authorizationService.authorize(mCredentials); + verify(mAuthorizationClient).authorize(mCredentials); + verifyZeroInteractions(mServiceExceptionMapper); + } + + @Test + public void testShouldMapHttpException() throws Exception { + when(mServiceExceptionMapper.transform(any(HttpException.class))).thenReturn(mServiceException); + doThrow(mHttpException).when(mAuthorizationClient).authorize(any(Credentials.class)); + + try { + authorizationService.authorize(mCredentials); + fail("Should fail with service exception"); + } catch (ServiceException ex) { + assertThat(ex, is(mServiceException)); + } + } + + @Test + public void testShouldMapIOException() throws Exception { + when(mServiceExceptionMapper.transform(any(IOException.class))).thenReturn(mServiceException); + doThrow(mIOException).when(mAuthorizationClient).authorize(any(Credentials.class)); + + try { + authorizationService.authorize(mCredentials); + fail("Should fail with service exception"); + } catch (ServiceException ex) { + assertThat(ex, is(mServiceException)); + } + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java new file mode 100644 index 00000000..0c7605b4 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java @@ -0,0 +1,53 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.test.integration.api; + +import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.Server; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class AuthorizationClientTest { + + private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); + private AuthorizationClient mClient; + + @Before + public void setUp() throws Exception { + Server server = Server.builder() + .withBaseUrl(mMetadata.getServerUrl()) + .build(); + mClient = server.newAuthorizationClient().create(); + } + + @Test + public void testAuthorize() throws Exception { + mClient.authorize(mMetadata.getCredentials()); + } +} From 9505046888ecd347cb59e8b05231a55841caae4f Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Thu, 31 Dec 2015 10:24:40 +0200 Subject: [PATCH 379/457] Implementing RX module for SDK Setup RX artifact module Rx implementation for ReportService API Add null checks for RxReport api Add null checks for core report service API Rx implementation for RepositoryService API Allow nullability for repository API Rx implementation for InfoService API Rx implementation for AuthorizationService API --- NOTICES.txt | 1 + client/build.gradle | 2 +- .../service/data/report/ReportMetadata.java | 20 ++ .../report/AbstractReportExecution.java | 33 ++- .../service/report/AbstractReportService.java | 9 +- .../service/report/ReportExecution5_5.java | 4 +- .../report/ReportExecution5_6Plus.java | 5 +- .../sdk/service/report/ReportService.java | 3 +- .../repository/ProxyRepositoryService.java | 6 +- .../service/repository/RepositoryService.java | 3 +- .../data/report/ReportMetadataTest.java | 36 ++++ .../report/AbstractReportExecutionTest.java | 27 ++- .../report/AbstractReportServiceTest.java | 24 ++- .../ProxyRepositoryServiceTest.java | 6 + licenses/Rxjava-1.1.0-LICENSE.txt | 202 ++++++++++++++++++ rx/build.gradle | 52 +++++ .../rx/auth/RxAuthorizationService.java | 49 +++++ .../rx/auth/RxAuthorizationServiceImpl.java | 62 ++++++ .../service/rx/info/RxServerInfoService.java | 48 +++++ .../rx/info/RxServerInfoServiceImpl.java | 60 ++++++ .../service/rx/report/RxReportAttachment.java | 39 ++++ .../rx/report/RxReportAttachmentImpl.java | 62 ++++++ .../service/rx/report/RxReportExecution.java | 49 +++++ .../rx/report/RxReportExecutionImpl.java | 105 +++++++++ .../sdk/service/rx/report/RxReportExport.java | 43 ++++ .../service/rx/report/RxReportExportImpl.java | 85 ++++++++ .../service/rx/report/RxReportService.java | 49 +++++ .../rx/report/RxReportServiceImpl.java | 68 ++++++ .../rx/repository/RxRepositoryService.java | 50 +++++ .../repository/RxRepositoryServiceImpl.java | 54 +++++ .../service/rx/repository/RxSearchTask.java | 43 ++++ .../rx/repository/RxSearchTaskImpl.java | 75 +++++++ .../rx/auth/RxAuthorizationServiceTest.java | 108 ++++++++++ .../rx/info/RxServerInfoServiceTest.java | 109 ++++++++++ .../rx/report/RxReportAttachmentTest.java | 82 +++++++ .../rx/report/RxReportExecutionTest.java | 174 +++++++++++++++ .../service/rx/report/RxReportExportTest.java | 105 +++++++++ .../rx/report/RxReportServiceTest.java | 129 +++++++++++ .../repository/RxRepositoryServiceTest.java | 103 +++++++++ .../rx/repository/RxSearchTaskTest.java | 97 +++++++++ settings.gradle | 2 + 41 files changed, 2266 insertions(+), 17 deletions(-) create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadataTest.java create mode 100644 licenses/Rxjava-1.1.0-LICENSE.txt create mode 100644 rx/build.gradle create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java diff --git a/NOTICES.txt b/NOTICES.txt index fceb29b6..3cf9ec5f 100644 --- a/NOTICES.txt +++ b/NOTICES.txt @@ -28,6 +28,7 @@ This software includes third party software subject to the associated copyrights * Software for developing case - Intellij Annotations 12.0 (Apache 2.0) - http://mvnrepository.com/artifact/com.intellij/annotations/12.0 - Retrofit 2.0.0-beta1 (Apache 2.0) - https://github.com/square/retrofit/blob/master/LICENSE.txt +- Rxjava 1.1.0 (Apache 2.0) - https://raw.githubusercontent.com/ReactiveX/RxJava/1.x/LICENSE * Software for testing case - Equalsverifier 1.7.5 (Apache 2.0) - https://github.com/jqno/equalsverifier/blob/master/LICENSE.md diff --git a/client/build.gradle b/client/build.gradle index e9bf1236..10f3b434 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -34,7 +34,7 @@ ext { } dependencies { - compile project(':js-android-sdk-core') + compile project(':js-android-sdk-rx') } apply from: '../scripts/release-artifact.gradle' \ No newline at end of file diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java index be3a0539..81d498dc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadata.java @@ -52,4 +52,24 @@ public String toString() { ", totalPages=" + totalPages + '}'; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ReportMetadata that = (ReportMetadata) o; + + if (totalPages != that.totalPages) return false; + if (uri != null ? !uri.equals(that.uri) : that.uri != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = uri != null ? uri.hashCode() : 0; + result = 31 * result + totalPages; + return result; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java index 36357f73..93f1d2f2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java @@ -25,9 +25,15 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.List; /** * @author Tom Koptel @@ -40,9 +46,9 @@ abstract class AbstractReportExecution implements ReportExecution { protected final long mDelay; protected AbstractReportExecution(ReportExecutionApi reportExecutionApi, - String execId, - String reportUri, - long delay) { + String execId, + String reportUri, + long delay) { mReportExecutionApi = reportExecutionApi; mExecId = execId; mReportUri = reportUri; @@ -56,4 +62,25 @@ public final ReportMetadata waitForReportCompletion() throws ServiceException { ReportExecutionDescriptor reportDescriptor = mReportExecutionApi.getDetails(mExecId); return new ReportMetadata(mReportUri, reportDescriptor.getTotalPages()); } + + @NotNull + @Override + public final ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + Preconditions.checkNotNull(options, "Export options should not be null"); + return doExport(options); + } + + @NotNull + public final ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + if (newParameters == null) { + newParameters = Collections.emptyList(); + } + return doUpdateExecution(newParameters); + } + + @NotNull + protected abstract ReportExecution doUpdateExecution(@NotNull List newParameters) throws ServiceException; + + @NotNull + protected abstract ReportExport doExport(@NotNull ReportExportOptions options) throws ServiceException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java index b8c0dd8e..d6b38d48 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java @@ -26,7 +26,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Tom Koptel @@ -49,7 +51,12 @@ protected AbstractReportService(ExportExecutionApi exportExecutionApi, @NotNull @Override - public ReportExecution run(@NotNull String reportUri, @NotNull ReportExecutionOptions execOptions) throws ServiceException { + public ReportExecution run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + if (execOptions == null) { + execOptions = ReportExecutionOptions.builder().build(); + } + ReportExecutionDescriptor descriptor = mReportExecutionApi.start(reportUri, execOptions); String executionId = descriptor.getExecutionId(); mReportExecutionApi.awaitStatus(executionId, reportUri, mDelay, Status.execution(), Status.ready()); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java index 05aca6a1..13047968 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_5.java @@ -56,7 +56,7 @@ final class ReportExecution5_5 extends AbstractReportExecution { @NotNull @Override - public ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + protected ReportExport doExport(@NotNull ReportExportOptions options) throws ServiceException { ExportExecutionDescriptor exportDetails = mExportExecutionApi.start(mExecId, options); String exportId = exportDetails.getExportId(); ReportExecutionDescriptor reportDescriptor = mReportExecutionApi.getDetails(mExecId); @@ -65,7 +65,7 @@ public ReportExport export(@NotNull ReportExportOptions options) throws ServiceE @NotNull @Override - public ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + protected ReportExecution doUpdateExecution(@Nullable List newParameters) throws ServiceException { ReportExecutionOptions criteria = mReportExecutionOptions.newBuilder() .withParams(newParameters) .build(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java index 40161301..75866951 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution5_6Plus.java @@ -29,7 +29,6 @@ import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.List; @@ -54,7 +53,7 @@ final class ReportExecution5_6Plus extends AbstractReportExecution { @NotNull @Override - public ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + protected ReportExport doExport(@NotNull ReportExportOptions options) throws ServiceException { ExportExecutionDescriptor exportDetails = mExportExecutionApi.start(mExecId, options); String exportId = exportDetails.getExportId(); @@ -66,7 +65,7 @@ public ReportExport export(@NotNull ReportExportOptions options) throws ServiceE @NotNull @Override - public ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + protected ReportExecution doUpdateExecution(@NotNull List newParameters) throws ServiceException { mReportExecutionApi.update(mExecId, newParameters); mReportExecutionApi.awaitStatus(mExecId, mReportUri, mDelay, Status.execution(), Status.ready()); return this; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 9c7b7715..27016292 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -33,6 +33,7 @@ import com.jaspersoft.android.sdk.service.internal.info.InMemoryInfoCache; import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.concurrent.TimeUnit; @@ -42,7 +43,7 @@ */ public abstract class ReportService { @NotNull - public abstract ReportExecution run(@NotNull String reportUri, @NotNull ReportExecutionOptions execOptions) throws ServiceException; + public abstract ReportExecution run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions) throws ServiceException; @NotNull public static ReportService newService(@NotNull AuthorizedClient client) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java index d7d6e203..6b100220 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java @@ -24,7 +24,6 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,7 +46,10 @@ final class ProxyRepositoryService extends RepositoryService { @NotNull @Override public SearchTask search(@Nullable SearchCriteria criteria) { - Preconditions.checkNotNull(criteria, "Criteria should not be null"); + if (criteria == null) { + criteria = SearchCriteria.none(); + } + InternalCriteria internalCriteria = InternalCriteria.from(criteria); SearchTaskFactory searchTaskFactory = new SearchTaskFactory(internalCriteria, mSearchUseCase, mInfoCacheManager); return new SearchTaskProxy(searchTaskFactory); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 8c9a069b..3c19ff61 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -31,6 +31,7 @@ import com.jaspersoft.android.sdk.service.internal.info.InfoCache; import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Tom Koptel @@ -38,7 +39,7 @@ */ public abstract class RepositoryService { @NotNull - public abstract SearchTask search(@NotNull SearchCriteria criteria); + public abstract SearchTask search(@Nullable SearchCriteria criteria); @NotNull public static RepositoryService newService(@NotNull AuthorizedClient client) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadataTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadataTest.java new file mode 100644 index 00000000..79354802 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/report/ReportMetadataTest.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.report; + +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Before; +import org.junit.Test; + +public class ReportMetadataTest { + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(ReportMetadata.class).verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java index f1a2c503..a2dfa74b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecutionTest.java @@ -31,17 +31,22 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.Collections; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.junit.rules.ExpectedException.none; import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; @@ -61,19 +66,22 @@ public class AbstractReportExecutionTest { private AbstractReportExecution abstractReportExecution; + @Rule + public ExpectedException expected = none(); + @Before public void setUp() throws Exception { initMocks(this); abstractReportExecution = new AbstractReportExecution(mReportExecutionApi, EXEC_ID, REPORT_URI, 0) { @NotNull @Override - public ReportExport export(@NotNull ReportExportOptions options) throws ServiceException { + public ReportExport doExport(@NotNull ReportExportOptions options) throws ServiceException { return null; } @NotNull @Override - public ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException { + public ReportExecution doUpdateExecution(@Nullable List newParameters) throws ServiceException { return null; } }; @@ -89,4 +97,19 @@ public void testWaitForReportCompletion() throws Exception { verify(mReportExecutionApi).awaitStatus(EXEC_ID, REPORT_URI, 0, Status.ready()); verify(mReportExecutionApi).getDetails(EXEC_ID); } + + @Test + public void should_not_run_export_with_null_options() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Export options should not be null"); + + abstractReportExecution.export(null); + } + + @Test + public void should_accept_null_params_for_update() throws Exception { + AbstractReportExecution spy = spy(abstractReportExecution); + spy.updateExecution(null); + verify(spy).doUpdateExecution(Collections.emptyList()); + } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java index 38b5bf2d..8985a5d4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java @@ -26,7 +26,9 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -35,6 +37,10 @@ import static com.jaspersoft.android.sdk.service.report.Status.execution; import static com.jaspersoft.android.sdk.service.report.Status.ready; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.rules.ExpectedException.none; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.spy; @@ -60,6 +66,9 @@ public class AbstractReportServiceTest { @Mock ReportExecutionDescriptor mReportExecutionDescriptor; + @Rule + public ExpectedException expected = none(); + private AbstractReportService reportService; @Before @@ -69,7 +78,7 @@ public void setUp() throws Exception { mExportExecutionApi, mReportExecutionApi, mExportFactory, - 0){ + 0) { @Override protected ReportExecution buildExecution(String reportUri, String executionId, @@ -91,4 +100,17 @@ public void testRun() throws Exception { verify(mReportExecutionApi).awaitStatus(EXEC_ID, REPORT_URI, 0, execution(), ready()); verify(reportService).buildExecution(REPORT_URI, EXEC_ID, criteria); } + + @Test + public void should_not_run_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + + reportService.run(null, null); + } + + @Test + public void should_run_with_null_options() throws Exception { + reportService.run(REPORT_URI, null); + } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java index c68e3c6f..6644cb9f 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java @@ -62,4 +62,10 @@ public void shouldProvideListOfResources() { SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); assertThat(searchTask, is(notNullValue())); } + + @Test + public void should_accept_null_criteria() { + SearchTask searchTask = objectUnderTest.search(null); + assertThat(searchTask, is(notNullValue())); + } } \ No newline at end of file diff --git a/licenses/Rxjava-1.1.0-LICENSE.txt b/licenses/Rxjava-1.1.0-LICENSE.txt new file mode 100644 index 00000000..4841759a --- /dev/null +++ b/licenses/Rxjava-1.1.0-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2012 Netflix, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/rx/build.gradle b/rx/build.gradle new file mode 100644 index 00000000..43dbcb8f --- /dev/null +++ b/rx/build.gradle @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +apply plugin: 'java' + +description = 'js-android-sdk-rx' +version = clientModuleVersion + +sourceCompatibility = 1.7 +targetCompatibility = 1.7 + +ext { + PUBLISH_GROUP_ID = group + PUBLISH_ARTIFACT_ID = description + PUBLISH_VERSION = clientModuleVersion +} + +dependencies { + compile project(':js-android-sdk-core') + compile 'io.reactivex:rxjava:1.1.0' + compile 'junit:junit:4.12' + + + testCompile 'org.hamcrest:hamcrest-integration:1.3' + testCompile('org.mockito:mockito-core:1.10.19') { + exclude group: 'org.hamcrest' + exclude group: 'org.objenesis' + } +} + +apply from: '../scripts/release-artifact.gradle' \ No newline at end of file diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java new file mode 100644 index 00000000..740316ef --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.auth; + +import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.service.auth.AuthorizationService; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; +import rx.Observable; + + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class RxAuthorizationService { + @NotNull + public abstract Observable authorize(@NotNull Credentials credentials); + + @NotNull + public static RxAuthorizationService newService(@NotNull AuthorizationClient authorizationClient) { + Preconditions.checkNotNull(authorizationClient, "Client should not be null"); + AuthorizationService service = AuthorizationService.newService(authorizationClient); + return new RxAuthorizationServiceImpl(service); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java new file mode 100644 index 00000000..98fb1054 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.auth; + +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.service.auth.AuthorizationService; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxAuthorizationServiceImpl extends RxAuthorizationService { + private final AuthorizationService mSyncDelegate; + + @TestOnly + RxAuthorizationServiceImpl(AuthorizationService service) { + mSyncDelegate = service; + } + + @NotNull + @Override + public Observable authorize(@NotNull final Credentials credentials) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + mSyncDelegate.authorize(credentials); + } catch (ServiceException e) { + return Observable.error(e); + } + return Observable.just(null); + } + }); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java new file mode 100644 index 00000000..88d2270e --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.info; + +import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.info.ServerInfoService; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; +import rx.Observable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class RxServerInfoService { + @NotNull + public abstract Observable requestServerInfo(); + + @NotNull + public static RxServerInfoService newService(@NotNull AnonymousClient anonymousClient) { + Preconditions.checkNotNull(anonymousClient, "Client should not be null"); + ServerInfoService service = ServerInfoService.newService(anonymousClient); + return new RxServerInfoServiceImpl(service); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java new file mode 100644 index 00000000..85e47d93 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.info; + +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.info.ServerInfoService; +import org.jetbrains.annotations.NotNull; +import rx.Observable; +import rx.functions.Func0; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxServerInfoServiceImpl extends RxServerInfoService { + private final ServerInfoService mSyncDelegate; + + RxServerInfoServiceImpl(ServerInfoService infoService) { + mSyncDelegate = infoService; + } + + @NotNull + @Override + public Observable requestServerInfo() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ServerInfo serverInfo = mSyncDelegate.requestServerInfo(); + return Observable.just(serverInfo); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java new file mode 100644 index 00000000..b7c06ca6 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import org.jetbrains.annotations.NotNull; +import rx.Observable; + + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RxReportAttachment { + @NotNull + Observable download(); +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java new file mode 100644 index 00000000..eced3a73 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportAttachment; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxReportAttachmentImpl implements RxReportAttachment { + private final ReportAttachment mSyncDelegate; + + @TestOnly + RxReportAttachmentImpl(ReportAttachment attachment) { + mSyncDelegate = attachment; + } + + @NotNull + @Override + public Observable download() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ResourceOutput content = mSyncDelegate.download(); + return Observable.just(content); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java new file mode 100644 index 00000000..41a7d410 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.report.ReportExportOptions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import rx.Observable; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RxReportExecution { + @NotNull + Observable export(@NotNull ReportExportOptions options); + + @NotNull + Observable waitForReportCompletion(); + + @NotNull + Observable updateExecution(@Nullable List newParameters); +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java new file mode 100644 index 00000000..7b2c67fc --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java @@ -0,0 +1,105 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.report.ReportExecution; +import com.jaspersoft.android.sdk.service.report.ReportExport; +import com.jaspersoft.android.sdk.service.report.ReportExportOptions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxReportExecutionImpl implements RxReportExecution { + private final ReportExecution mSyncDelegate; + + @TestOnly + RxReportExecutionImpl(ReportExecution reportExecution) { + mSyncDelegate = reportExecution; + } + + @NotNull + @Override + public Observable export(final @NotNull ReportExportOptions options) { + Preconditions.checkNotNull(options, "Export options should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExport export = mSyncDelegate.export(options); + RxReportExport rxReportExport = new RxReportExportImpl(export); + return Observable.just(rxReportExport); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + @Override + public Observable waitForReportCompletion() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportMetadata data = mSyncDelegate.waitForReportCompletion(); + return Observable.just(data); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + @Override + public Observable updateExecution(@Nullable final List newParameters) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExecution execution = mSyncDelegate.updateExecution(newParameters); + RxReportExecution rxExec = new RxReportExecutionImpl(execution); + return Observable.just(rxExec); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java new file mode 100644 index 00000000..87993a1d --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java @@ -0,0 +1,43 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import org.jetbrains.annotations.NotNull; +import rx.Observable; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RxReportExport { + @NotNull + Observable> getAttachments(); + + @NotNull + Observable download(); +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java new file mode 100644 index 00000000..4c29a3d6 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java @@ -0,0 +1,85 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportAttachment; +import com.jaspersoft.android.sdk.service.report.ReportExport; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxReportExportImpl implements RxReportExport { + private final ReportExport mSyncDelegate; + + @TestOnly + RxReportExportImpl(ReportExport export) { + mSyncDelegate = export; + } + + @NotNull + @Override + public Observable> getAttachments() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + List attachments = mSyncDelegate.getAttachments(); + int size = attachments.size(); + List rxAttachments = new ArrayList<>(size); + for (int i = 0; i < size; i++) { + ReportAttachment attachment = attachments.get(i); + RxReportAttachmentImpl rxAttachment = new RxReportAttachmentImpl(attachment); + rxAttachments.add(rxAttachment); + } + return Observable.just(rxAttachments); + } + }); + } + + @NotNull + @Override + public Observable download() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExportOutput content = mSyncDelegate.download(); + return Observable.just(content); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java new file mode 100644 index 00000000..8e9bff14 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; +import com.jaspersoft.android.sdk.service.report.ReportService; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import rx.Observable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class RxReportService { + @NotNull + public abstract Observable run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions); + + @NotNull + public static RxReportService newService(@NotNull AuthorizedClient authorizedClient) { + Preconditions.checkNotNull(authorizedClient, "Client should not be null"); + ReportService reportService = ReportService.newService(authorizedClient); + return new RxReportServiceImpl(reportService); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java new file mode 100644 index 00000000..e2aa84ec --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java @@ -0,0 +1,68 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.report.ReportExecution; +import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; +import com.jaspersoft.android.sdk.service.report.ReportService; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxReportServiceImpl extends RxReportService { + private final ReportService mSyncDelegate; + + @TestOnly + RxReportServiceImpl(ReportService reportService) { + mSyncDelegate = reportService; + } + + @NotNull + @Override + public Observable run(@NotNull final String reportUri, @Nullable final ReportExecutionOptions execOptions) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExecution execution = mSyncDelegate.run(reportUri, execOptions); + RxReportExecution rxReportExecution = new RxReportExecutionImpl(execution); + return Observable.just(rxReportExecution); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java new file mode 100644 index 00000000..91462fa9 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.repository; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.repository.RepositoryService; +import com.jaspersoft.android.sdk.service.repository.SearchCriteria; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import rx.Observable; + + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class RxRepositoryService { + @NotNull + public abstract Observable search(@Nullable SearchCriteria criteria); + + @NotNull + public static RxRepositoryService newService(@NotNull AuthorizedClient authorizedClient) { + Preconditions.checkNotNull(authorizedClient, "Client should not be null"); + RepositoryService repositoryService = RepositoryService.newService(authorizedClient); + return new RxRepositoryServiceImpl(repositoryService); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java new file mode 100644 index 00000000..ef11eb23 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.repository; + +import com.jaspersoft.android.sdk.service.repository.RepositoryService; +import com.jaspersoft.android.sdk.service.repository.SearchCriteria; +import com.jaspersoft.android.sdk.service.repository.SearchTask; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxRepositoryServiceImpl extends RxRepositoryService { + private final RepositoryService mSyncDelegate; + + @TestOnly + RxRepositoryServiceImpl(RepositoryService repositoryService) { + mSyncDelegate = repositoryService; + } + + @NotNull + @Override + public Observable search(@Nullable SearchCriteria criteria) { + SearchTask searchTask = mSyncDelegate.search(criteria); + RxSearchTask rxSearchTask = new RxSearchTaskImpl(searchTask); + return Observable.just(rxSearchTask); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java new file mode 100644 index 00000000..4a9ff272 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java @@ -0,0 +1,43 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.repository; + +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import org.jetbrains.annotations.NotNull; +import rx.Observable; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public interface RxSearchTask { + @NotNull + Observable> nextLookup(); + + @NotNull + Observable hasNext(); +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java new file mode 100644 index 00000000..8481b65c --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java @@ -0,0 +1,75 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.repository; + +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.repository.SearchTask; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class RxSearchTaskImpl implements RxSearchTask { + private final SearchTask mSyncDelegate; + + @TestOnly + RxSearchTaskImpl(SearchTask searchTask) { + mSyncDelegate = searchTask; + } + + @NotNull + @Override + public Observable> nextLookup() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List result = mSyncDelegate.nextLookup(); + return Observable.just(result); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + @Override + public Observable hasNext() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + return Observable.just(mSyncDelegate.hasNext()); + } + }); + } +} diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java new file mode 100644 index 00000000..85e9dadb --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java @@ -0,0 +1,108 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.auth; + +import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.service.auth.AuthorizationService; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.verify; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxAuthorizationServiceTest { + + @Mock + AuthorizationService mSyncDelegate; + @Mock + AuthorizationClient mAuthorizationClient; + @Mock + ServiceException mServiceException; + @Mock + Credentials mCredentials; + + @Rule + public ExpectedException expected = none(); + + private RxAuthorizationServiceImpl rxAuthorizationService; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxAuthorizationService = new RxAuthorizationServiceImpl(mSyncDelegate); + } + + @Test + public void should_delegate_authorize_call() throws Exception { + TestSubscriber test = new TestSubscriber<>(); + rxAuthorizationService.authorize(mCredentials).subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).authorize(mCredentials); + } + + @Test + public void should_delegate_service_exception_on_authorize_call() throws Exception { + doThrow(mServiceException).when(mSyncDelegate).authorize(any(Credentials.class)); + + TestSubscriber test = new TestSubscriber<>(); + rxAuthorizationService.authorize(mCredentials).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).authorize(mCredentials); + } + + @Test + public void should_provide_impl_with_factory_method() throws Exception { + RxAuthorizationService service = RxAuthorizationService.newService(mAuthorizationClient); + assertThat(service, is(instanceOf(RxAuthorizationServiceImpl.class))); + assertThat(service, is(notNullValue())); + } + + @Test + public void should_not_accept_null_for_factory_method() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + RxAuthorizationService.newService(null); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java new file mode 100644 index 00000000..b1f90bed --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java @@ -0,0 +1,109 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.info; + +import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.info.ServerInfoService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxServerInfoServiceTest { + + @Mock + ServerInfoService mSyncDelegate; + + @Mock + ServerInfo mServerInfo; + @Mock + ServiceException mServiceException; + + @Mock + AnonymousClient mAnonymousClient; + + @Rule + public ExpectedException expected = none(); + + private RxServerInfoServiceImpl rxServerInfoService; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxServerInfoService = new RxServerInfoServiceImpl(mSyncDelegate); + } + + @Test + public void should_delegate_info_request_call() throws Exception { + when(mSyncDelegate.requestServerInfo()).thenReturn(mServerInfo); + + TestSubscriber test = new TestSubscriber<>(); + rxServerInfoService.requestServerInfo().subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).requestServerInfo(); + } + + @Test + public void should_delegate_service_exception_on_info_request_call() throws Exception { + when(mSyncDelegate.requestServerInfo()).thenThrow(mServiceException); + + TestSubscriber test = new TestSubscriber<>(); + rxServerInfoService.requestServerInfo().subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).requestServerInfo(); + } + + @Test + public void should_provide_impl_with_factory_method() throws Exception { + RxServerInfoService service = RxServerInfoService.newService(mAnonymousClient); + assertThat(service, is(instanceOf(RxServerInfoServiceImpl.class))); + assertThat(service, is(notNullValue())); + } + + @Test + public void should_not_accept_null_for_factory_method() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + RxServerInfoService.newService(null); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java new file mode 100644 index 00000000..51de79a3 --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java @@ -0,0 +1,82 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportAttachment; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxReportAttachmentTest { + + @Mock + ReportAttachment mSyncDelegate; + @Mock + ResourceOutput mResourceOutput; + @Mock + ServiceException mServiceException; + + private RxReportAttachmentImpl rxReportAttachment; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxReportAttachment = new RxReportAttachmentImpl(mSyncDelegate); + } + + @Test + public void should_execute_download_as_observable() throws Exception { + when(mSyncDelegate.download()).thenReturn(mResourceOutput); + + TestSubscriber test = TestSubscriber.create(); + rxReportAttachment.download().subscribe(test); + + test.assertNoErrors(); + test.assertValueCount(1); + test.assertCompleted(); + + verify(mSyncDelegate).download(); + } + + @Test + public void should_delegate_service_exception_on_download() throws Exception { + when(mSyncDelegate.download()).thenThrow(mServiceException); + + TestSubscriber test = TestSubscriber.create(); + rxReportAttachment.download().subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).download(); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java new file mode 100644 index 00000000..996fa40c --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java @@ -0,0 +1,174 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportExecution; +import com.jaspersoft.android.sdk.service.report.ReportExport; +import com.jaspersoft.android.sdk.service.report.ReportExportOptions; +import com.jaspersoft.android.sdk.service.report.ReportFormat; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import java.util.Collections; +import java.util.List; + +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyListOf; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxReportExecutionTest { + private static final ReportExportOptions OPTIONS = ReportExportOptions.builder() + .withFormat(ReportFormat.HTML) + .build(); + private static final List PARAMS = Collections.emptyList(); + + @Mock + ReportExecution mSyncDelegate; + @Mock + ServiceException mServiceException; + + @Mock + ReportExport mReportExport; + + @Rule + public ExpectedException expected = none(); + + private final ReportMetadata fakeReportData = new ReportMetadata("/uri", 100); + + private RxReportExecutionImpl rxReportExecution; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxReportExecution = new RxReportExecutionImpl(mSyncDelegate); + } + + @Test + public void should_execute_export_as_observable() throws Exception { + when(mSyncDelegate.export(any(ReportExportOptions.class))).thenReturn(mReportExport); + + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.export(OPTIONS).subscribe(test); + + test.assertNoErrors(); + test.assertValueCount(1); + test.assertCompleted(); + + verify(mSyncDelegate).export(OPTIONS); + } + + @Test + public void should_not_export_with_null_options() { + expected.expect(NullPointerException.class); + expected.expectMessage("Export options should not be null"); + + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.export(null).subscribe(test); + } + + @Test + public void should_delegate_service_exception_on_export() throws Exception { + when(mSyncDelegate.export(any(ReportExportOptions.class))).thenThrow(mServiceException); + + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.export(OPTIONS).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).export(OPTIONS); + } + + @Test + public void should_execute_wait_as_observable() throws Exception { + when(mSyncDelegate.waitForReportCompletion()).thenReturn(fakeReportData); + + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.waitForReportCompletion().subscribe(test); + + test.assertNoErrors(); + test.assertValueCount(1); + test.assertCompleted(); + + verify(mSyncDelegate).waitForReportCompletion(); + } + + @Test + public void should_delegate_service_exception_on_wait() throws Exception { + when(mSyncDelegate.waitForReportCompletion()).thenThrow(mServiceException); + + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.waitForReportCompletion().subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).waitForReportCompletion(); + } + + @Test + public void should_accept_null_params_for_update() throws Exception { + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.updateExecution(null).subscribe(test); + test.assertNoErrors(); + } + + @Test + public void should_execute_update_as_observable() throws Exception { + when(mSyncDelegate.updateExecution(anyListOf(ReportParameter.class))).thenReturn(mSyncDelegate); + + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.updateExecution(PARAMS).subscribe(test); + + test.assertNoErrors(); + test.assertValueCount(1); + test.assertCompleted(); + + verify(mSyncDelegate).updateExecution(PARAMS); + } + + @Test + public void should_delegate_service_exception_on_update() throws Exception { + when(mSyncDelegate.updateExecution(anyListOf(ReportParameter.class))).thenThrow(mServiceException); + + TestSubscriber test = TestSubscriber.create(); + rxReportExecution.updateExecution(PARAMS).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).updateExecution(PARAMS); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java new file mode 100644 index 00000000..1ec009b2 --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java @@ -0,0 +1,105 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportAttachment; +import com.jaspersoft.android.sdk.service.report.ReportExport; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import java.util.Collections; +import java.util.List; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxReportExportTest { + + @Mock + ReportExport mSyncDelegate; + @Mock + ServiceException mServiceException; + + @Mock + ReportAttachment mReportAttachment; + @Mock + ReportExportOutput mReportExportOutput; + + + private RxReportExportImpl rxReportExport; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxReportExport = new RxReportExportImpl(mSyncDelegate); + } + + @Test + public void should_execute_download_as_observable() throws Exception { + when(mSyncDelegate.download()).thenReturn(mReportExportOutput); + + TestSubscriber test = TestSubscriber.create(); + rxReportExport.download().subscribe(test); + + test.assertNoErrors(); + test.assertValueCount(1); + test.assertCompleted(); + + verify(mSyncDelegate).download(); + } + + @Test + public void should_delegate_service_exception_on_download() throws Exception { + when(mSyncDelegate.download()).thenThrow(mServiceException); + + TestSubscriber test = TestSubscriber.create(); + rxReportExport.download().subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).download(); + } + + @Test + public void should_delegate_attachments_call() throws Exception { + List attachments = Collections.singletonList(mReportAttachment); + when(mSyncDelegate.getAttachments()).thenReturn(attachments); + + TestSubscriber> test = TestSubscriber.create(); + rxReportExport.getAttachments().subscribe(test); + + test.assertNoErrors(); + test.assertValueCount(1); + test.assertCompleted(); + + verify(mSyncDelegate).getAttachments(); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java new file mode 100644 index 00000000..265a4934 --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.report; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportExecution; +import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; +import com.jaspersoft.android.sdk.service.report.ReportService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxReportServiceTest { + private static final String REPORT_URI = "my/uri"; + private static final ReportExecutionOptions OPTIONS = ReportExecutionOptions.builder().build(); + + @Mock + ReportService mSyncDelegate; + @Mock + ReportExecution mReportExecution; + @Mock + ServiceException mServiceException; + + @Mock + AuthorizedClient mAuthorizedClient; + + private RxReportServiceImpl rxReportService; + + @Rule + public ExpectedException expected = none(); + + @Before + public void setUp() throws Exception { + initMocks(this); + rxReportService = new RxReportServiceImpl(mSyncDelegate); + } + + @Test + public void should_not_run_with_null_uri() { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + + TestSubscriber test = TestSubscriber.create(); + rxReportService.run(null, null).subscribe(test); + } + + @Test + public void should_run_with_null_options() { + TestSubscriber test = TestSubscriber.create(); + rxReportService.run(REPORT_URI, null).subscribe(test); + test.assertNoErrors(); + } + + @Test + public void should_execute_delegate_as_observable() throws Exception { + when(mSyncDelegate.run(anyString(), any(ReportExecutionOptions.class))).thenReturn(mReportExecution); + + TestSubscriber test = TestSubscriber.create(); + rxReportService.run(REPORT_URI, OPTIONS).subscribe(test); + + test.assertCompleted(); + test.assertNoErrors(); + test.assertValueCount(1); + + verify(mSyncDelegate).run(REPORT_URI, OPTIONS); + } + + @Test + public void should_delegate_service_exception_to_subscription() throws Exception { + when(mSyncDelegate.run(anyString(), any(ReportExecutionOptions.class))).thenThrow(mServiceException); + + TestSubscriber test = TestSubscriber.create(); + rxReportService.run(REPORT_URI, OPTIONS).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).run(REPORT_URI, OPTIONS); + } + + @Test + public void should_provide_impl_with_factory_method() throws Exception { + RxReportService service = RxReportService.newService(mAuthorizedClient); + assertThat(service, is(instanceOf(RxReportServiceImpl.class))); + assertThat(service, is(notNullValue())); + } + + @Test + public void should_not_accept_null_for_factory_method() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + RxReportService.newService(null); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java new file mode 100644 index 00000000..2da07a7a --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java @@ -0,0 +1,103 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.repository; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.service.repository.RepositoryService; +import com.jaspersoft.android.sdk.service.repository.SearchCriteria; +import com.jaspersoft.android.sdk.service.repository.SearchTask; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxRepositoryServiceTest { + + @Mock + AuthorizedClient mAuthorizedClient; + @Mock + RepositoryService mSyncDelegate; + @Mock + SearchTask mSearchTask; + + @Rule + public ExpectedException expected = none(); + + private RxRepositoryServiceImpl rxRepositoryService; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxRepositoryService = new RxRepositoryServiceImpl(mSyncDelegate); + } + + @Test + public void should_delegate_search_call() throws Exception { + when(mSyncDelegate.search(any(SearchCriteria.class))).thenReturn(mSearchTask); + SearchCriteria criteria = SearchCriteria.none(); + + TestSubscriber test = new TestSubscriber<>(); + rxRepositoryService.search(criteria).subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).search(criteria); + } + + @Test + public void should_accept_null_criteria() throws Exception { + TestSubscriber test = new TestSubscriber<>(); + rxRepositoryService.search(null).subscribe(test); + test.assertNoErrors(); + test.assertCompleted(); + } + + + @Test + public void should_provide_impl_with_factory_method() throws Exception { + RxRepositoryService service = RxRepositoryService.newService(mAuthorizedClient); + assertThat(service, is(instanceOf(RxRepositoryServiceImpl.class))); + assertThat(service, is(notNullValue())); + } + + @Test + public void should_not_accept_null_for_factory_method() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + RxRepositoryService.newService(null); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java new file mode 100644 index 00000000..a1cf901a --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java @@ -0,0 +1,97 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.rx.repository; + +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.repository.SearchTask; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import java.util.Collections; +import java.util.List; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxSearchTaskTest { + + @Mock + SearchTask mSyncDelegate; + @Mock + ServiceException mServiceException; + + private RxSearchTaskImpl rxSearchTask; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxSearchTask = new RxSearchTaskImpl(mSyncDelegate); + } + + @Test + public void should_call_delegate_for_lookup() throws Exception { + when(mSyncDelegate.nextLookup()).thenReturn(Collections.emptyList()); + + TestSubscriber> test = new TestSubscriber<>(); + rxSearchTask.nextLookup().subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).nextLookup(); + } + + @Test + public void should_delegate_service_exception_on_nextLookup() throws Exception { + when(mSyncDelegate.nextLookup()).thenThrow(mServiceException); + + TestSubscriber> test = new TestSubscriber<>(); + rxSearchTask.nextLookup().subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).nextLookup(); + } + + @Test + public void should_call_delegate_for_hasNext() throws Exception { + when(mSyncDelegate.hasNext()).thenReturn(true); + + TestSubscriber test = new TestSubscriber<>(); + rxSearchTask.hasNext().subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).hasNext(); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index cf99081d..c4ebab36 100644 --- a/settings.gradle +++ b/settings.gradle @@ -24,5 +24,7 @@ include ':js-android-sdk-client' include ':js-android-sdk-core' +include ':js-android-sdk-rx' project(':js-android-sdk-client').projectDir = "$rootDir/client" as File project(':js-android-sdk-core').projectDir = "$rootDir/core" as File +project(':js-android-sdk-rx').projectDir = "$rootDir/rx" as File From 04e4702d1f6389b2748facd0679e47cd38991c33 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Sun, 3 Jan 2016 19:19:18 +0200 Subject: [PATCH 380/457] Reduce Authorized client API --- .../android/sdk/network/AnonymousClient.java | 1 + .../sdk/network/AnonymousClientImpl.java | 11 ++ .../android/sdk/network/AuthRestApi.java | 142 ++++++++++++++++++ .../sdk/network/AuthenticationRestApi.java | 121 +-------------- ...pl.java => AuthenticationRestApiImpl.java} | 9 +- .../sdk/network/AuthorizationClient.java | 35 ----- .../sdk/network/AuthorizedClientImpl.java | 5 + .../android/sdk/network/Server.java | 34 +---- .../sdk/network/SpringAuthService.java | 4 +- .../sdk/network/SpringAuthServiceFactory.java | 2 +- .../service/auth/AuthorizationService.java | 4 +- .../auth/ProxyAuthorizationService.java | 10 +- ...nRestApiTest.java => AuthRestApiTest.java} | 6 +- .../AuthorizationClientTestImplTest.java | 6 +- .../sdk/network/SpringAuthServiceTest.java | 2 +- .../sdk/network/SpringCredentialsTest.java | 2 +- .../auth/AuthorizationServiceTest.java | 10 +- .../auth/ProxyAuthorizationServiceTest.java | 17 ++- .../api/AuthorizationClientTest.java | 14 +- .../rx/auth/RxAuthorizationService.java | 8 +- .../rx/auth/RxAuthorizationServiceTest.java | 6 +- 21 files changed, 221 insertions(+), 228 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthRestApi.java rename core/src/main/java/com/jaspersoft/android/sdk/network/{AuthorizationClientImpl.java => AuthenticationRestApiImpl.java} (78%) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java rename core/src/test/java/com/jaspersoft/android/sdk/network/{AuthenticationRestApiTest.java => AuthRestApiTest.java} (97%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java index 9abdadd8..a18af99f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java @@ -30,4 +30,5 @@ */ public interface AnonymousClient extends Client { ServerRestApi infoApi(); + AuthenticationRestApi authenticationApi(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java index 15ee2fa8..af345b2c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java @@ -32,6 +32,7 @@ */ final class AnonymousClientImpl extends AbstractClient implements AnonymousClient { private ServerRestApiImpl mServerRestApi; + private AuthenticationRestApiImpl mAuthApi; AnonymousClientImpl(Retrofit retrofit) { super(retrofit); @@ -43,4 +44,14 @@ public ServerRestApi infoApi() { } return mServerRestApi; } + + @Override + public AuthenticationRestApi authenticationApi() { + if (mAuthApi == null) { + SpringAuthServiceFactory authServiceFactory = new SpringAuthServiceFactory(mRetrofit); + AuthStrategy authStrategy = new AuthStrategy(authServiceFactory); + mAuthApi = new AuthenticationRestApiImpl(authStrategy); + } + return mAuthApi; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthRestApi.java new file mode 100644 index 00000000..b3bcfd98 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthRestApi.java @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.network; + +import com.google.gson.JsonSyntaxException; +import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; +import com.squareup.okhttp.*; +import org.jetbrains.annotations.NotNull; +import retrofit.Retrofit; +import retrofit.http.GET; +import retrofit.http.Headers; + +import java.io.IOException; +import java.util.Map; +import java.util.Set; + +/** + * TODO refactor following module in easy testable units + * + * @author Tom Koptel + * @since 2.0 + */ +class AuthRestApi { + @NotNull + private final Retrofit mRetrofit; + + AuthRestApi(@NotNull Retrofit retrofit) { + mRetrofit = retrofit; + } + + public void springAuth(@NotNull final String username, + @NotNull final String password, + final String organization, + final Map params) throws HttpException, IOException { + Request request = createAuthRequest(username, password, organization, params); + Call call = mRetrofit.client().newCall(request); + + com.squareup.okhttp.Response response = call.execute(); + + int statusCode = response.code(); + if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request + String location = response.headers().get("Location"); + HttpUrl url = HttpUrl.parse(location); + String errorQueryParameter = url.queryParameter("error"); + if (errorQueryParameter != null) { + com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() + .protocol(response.protocol()) + .request(response.request()) + .headers(response.headers()) + .body(response.body()) + .code(401) + .build(); + throw HttpException.httpError(response401); + } + } else { + throw HttpException.httpError(response); + } + } + + @NotNull + public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { + RestApi api = mRetrofit.create(RestApi.class); + CallWrapper.wrap(api.requestAnonymousCookie()); + + try { + return CallWrapper.wrap(api.requestEncryptionMetadata()).body(); + } catch (JsonSyntaxException ex) { + /** + * This possible when security option is disabled on JRS side. + * API responds with malformed json. E.g. {Error: Key generation is off}. As you can see no quotes + * As soon as there 2 options to resolve this we decide to swallow exception and return empty object + */ + return EncryptionKey.empty(); + } + } + + private Request createAuthRequest( + @NotNull final String username, + @NotNull final String password, + final String organization, + final Map params) { + + OkHttpClient client = new OkHttpClient(); + client.setFollowRedirects(false); + + FormEncodingBuilder formBody = new FormEncodingBuilder() + .add("j_password", password) + .add("j_username", username); + + if (organization != null) { + formBody.add("orgId", organization); + } + + if (params != null) { + Set> entrySet = params.entrySet(); + for (Map.Entry entry : entrySet) { + formBody.add(entry.getKey(), entry.getValue()); + } + } + /** + * Constructs url http[s]://some.jrs/j_spring_security_check + */ + String baseUrl = mRetrofit.baseUrl().url().toString(); + return new Request.Builder() + .url(baseUrl + "j_spring_security_check") + .post(formBody.build()) + .build(); + } + + private interface RestApi { + @NotNull + @Headers("Accept: text/plain") + @GET("rest_v2/serverInfo/edition") + retrofit.Call requestAnonymousCookie(); + + @NotNull + @GET("GetEncryptionKey") + retrofit.Call requestEncryptionMetadata(); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index 9646cfaf..c822ff95 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -1,142 +1,37 @@ /* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. + * This program is part of TIBCO Jaspersoft Mobile for Android. * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see + * along with TIBCO Jaspersoft Mobile for Android. If not, see * . */ package com.jaspersoft.android.sdk.network; -import com.google.gson.JsonSyntaxException; -import com.jaspersoft.android.sdk.network.entity.server.EncryptionKey; -import com.squareup.okhttp.*; import org.jetbrains.annotations.NotNull; -import retrofit.Retrofit; -import retrofit.http.GET; -import retrofit.http.Headers; import java.io.IOException; -import java.util.Map; -import java.util.Set; /** - * TODO refactor following module in easy testable units - * * @author Tom Koptel * @since 2.0 */ -class AuthenticationRestApi { - @NotNull - private final Retrofit mRetrofit; - - AuthenticationRestApi(@NotNull Retrofit retrofit) { - mRetrofit = retrofit; - } - - public void springAuth(@NotNull final String username, - @NotNull final String password, - final String organization, - final Map params) throws HttpException, IOException { - Request request = createAuthRequest(username, password, organization, params); - Call call = mRetrofit.client().newCall(request); - - com.squareup.okhttp.Response response = call.execute(); - - int statusCode = response.code(); - if (statusCode >= 300 && statusCode < 400) { // 3XX == redirect request - String location = response.headers().get("Location"); - HttpUrl url = HttpUrl.parse(location); - String errorQueryParameter = url.queryParameter("error"); - if (errorQueryParameter != null) { - com.squareup.okhttp.Response response401 = new com.squareup.okhttp.Response.Builder() - .protocol(response.protocol()) - .request(response.request()) - .headers(response.headers()) - .body(response.body()) - .code(401) - .build(); - throw HttpException.httpError(response401); - } - } else { - throw HttpException.httpError(response); - } - } - - @NotNull - public EncryptionKey requestEncryptionMetadata() throws IOException, HttpException { - RestApi api = mRetrofit.create(RestApi.class); - CallWrapper.wrap(api.requestAnonymousCookie()); - - try { - return CallWrapper.wrap(api.requestEncryptionMetadata()).body(); - } catch (JsonSyntaxException ex) { - /** - * This possible when security option is disabled on JRS side. - * API responds with malformed json. E.g. {Error: Key generation is off}. As you can see no quotes - * As soon as there 2 options to resolve this we decide to swallow exception and return empty object - */ - return EncryptionKey.empty(); - } - } - - private Request createAuthRequest( - @NotNull final String username, - @NotNull final String password, - final String organization, - final Map params) { - - OkHttpClient client = new OkHttpClient(); - client.setFollowRedirects(false); - - FormEncodingBuilder formBody = new FormEncodingBuilder() - .add("j_password", password) - .add("j_username", username); - - if (organization != null) { - formBody.add("orgId", organization); - } - - if (params != null) { - Set> entrySet = params.entrySet(); - for (Map.Entry entry : entrySet) { - formBody.add(entry.getKey(), entry.getValue()); - } - } - /** - * Constructs url http[s]://some.jrs/j_spring_security_check - */ - String baseUrl = mRetrofit.baseUrl().url().toString(); - return new Request.Builder() - .url(baseUrl + "j_spring_security_check") - .post(formBody.build()) - .build(); - } - - private interface RestApi { - @NotNull - @Headers("Accept: text/plain") - @GET("rest_v2/serverInfo/edition") - retrofit.Call requestAnonymousCookie(); - - @NotNull - @GET("GetEncryptionKey") - retrofit.Call requestEncryptionMetadata(); - } +public interface AuthenticationRestApi { + public void authenticate(@NotNull Credentials credentials) throws IOException, HttpException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java similarity index 78% rename from core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClientImpl.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java index 6bf6b3b9..b00bea00 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClientImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java @@ -24,21 +24,24 @@ package com.jaspersoft.android.sdk.network; +import org.jetbrains.annotations.Nullable; + import java.io.IOException; /** * @author Tom Koptel * @since 2.0 */ -final class AuthorizationClientImpl implements AuthorizationClient { +final class AuthenticationRestApiImpl implements AuthenticationRestApi { private final AuthStrategy mAuthStrategy; - AuthorizationClientImpl(AuthStrategy authStrategy) { + AuthenticationRestApiImpl(AuthStrategy authStrategy) { mAuthStrategy = authStrategy; } @Override - public void authorize(Credentials credentials) throws IOException, HttpException { + public void authenticate(@Nullable Credentials credentials) throws IOException, HttpException { + Utils.checkNotNull(credentials, "Credentials should not be null"); credentials.apply(mAuthStrategy); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java deleted file mode 100644 index 511d218c..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizationClient.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public interface AuthorizationClient { - public void authorize(Credentials credentials) throws IOException, HttpException; -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java index 63c7c926..53a704fa 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java @@ -83,4 +83,9 @@ public RepositoryRestApi repositoryApi() { public ServerRestApi infoApi() { return mAnonymousClient.infoApi(); } + + @Override + public AuthenticationRestApi authenticationApi() { + return mAnonymousClient.authenticationApi(); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index da05b7c7..25434fe0 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -55,11 +55,6 @@ public static Builder builder() { return new Builder(); } - @NotNull - public AuthorizationClientBuilder newAuthorizationClient() { - return new AuthorizationClientBuilder(this); - } - @NotNull public AnonymousClientBuilder newClient() { return new AnonymousClientBuilder(this); @@ -146,6 +141,7 @@ public AnonymousClientBuilder withCookieHandler(CookieHandler cookieHandler) { public AnonymousClient create() { OkHttpClient anonymousClient = mServer.client().clone(); + anonymousClient.setFollowRedirects(false); anonymousClient.setCookieHandler(mCookieHandler); Retrofit anonymousRetrofit = mServer.newRetrofit() @@ -216,32 +212,4 @@ private void configureAuthenticator(OkHttpClient client, AuthStrategy authStrate client.setAuthenticator(authenticator); } } - - public static class AuthorizationClientBuilder { - private final Server mServer; - private CookieHandler mCookieHandler = new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER); - - private AuthorizationClientBuilder(Server server) { - mServer = server; - } - - public AuthorizationClientBuilder withCookieHandler(CookieHandler cookieHandler) { - mCookieHandler = cookieHandler; - return this; - } - - public AuthorizationClient create() { - OkHttpClient authClient = mServer.client().clone(); - authClient.setFollowRedirects(false); - authClient.setCookieHandler(mCookieHandler); - - Retrofit authRetrofit = mServer.newRetrofit() - .client(authClient) - .build(); - - SpringAuthServiceFactory springAuthServiceFactory = new SpringAuthServiceFactory(authRetrofit); - AuthStrategy authStrategy = new AuthStrategy(springAuthServiceFactory); - return new AuthorizationClientImpl(authStrategy); - } - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java index fa92311c..d07e4092 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthService.java @@ -40,12 +40,12 @@ */ class SpringAuthService { - private final AuthenticationRestApi mRestApi; + private final AuthRestApi mRestApi; private final JSEncryptionAlgorithm mEncryptionAlgorithm; @TestOnly SpringAuthService( - @NotNull AuthenticationRestApi restApi, + @NotNull AuthRestApi restApi, @NotNull JSEncryptionAlgorithm generator) { mEncryptionAlgorithm = generator; mRestApi = restApi; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java index 33c9ac51..f0168a38 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/SpringAuthServiceFactory.java @@ -38,7 +38,7 @@ class SpringAuthServiceFactory { } public SpringAuthService create() { - AuthenticationRestApi restApi = new AuthenticationRestApi(mRetrofit); + AuthRestApi restApi = new AuthRestApi(mRetrofit); JSEncryptionAlgorithm encryptionAlgorithm = JSEncryptionAlgorithm.create(); return new SpringAuthService(restApi, encryptionAlgorithm); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java index 15b134a6..9e913ced 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; @@ -40,7 +40,7 @@ public abstract class AuthorizationService { public abstract void authorize(Credentials credentials) throws ServiceException; @NotNull - public static AuthorizationService newService(@NotNull AuthorizationClient client) { + public static AuthorizationService newService(@NotNull AnonymousClient client) { Preconditions.checkNotNull(client, "Client should not be null"); ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); return new ProxyAuthorizationService(client, serviceExceptionMapper); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java index 0e5b43ca..992c39ec 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java @@ -24,7 +24,8 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -38,11 +39,11 @@ * @since 2.0 */ final class ProxyAuthorizationService extends AuthorizationService { - private final AuthorizationClient mClient; + private final AnonymousClient mClient; private final ServiceExceptionMapper mServiceExceptionMapper; @TestOnly - ProxyAuthorizationService(AuthorizationClient client, + ProxyAuthorizationService(AnonymousClient client, ServiceExceptionMapper mapper) { mServiceExceptionMapper = mapper; mClient = client; @@ -51,7 +52,8 @@ final class ProxyAuthorizationService extends AuthorizationService { @Override public void authorize(Credentials credentials) throws ServiceException { try { - mClient.authorize(credentials); + AuthenticationRestApi authenticationRestApi = mClient.authenticationApi(); + authenticationRestApi.authenticate(credentials); } catch (IOException e) { throw mServiceExceptionMapper.transform(e); } catch (HttpException e) { diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthRestApiTest.java similarity index 97% rename from core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java rename to core/src/test/java/com/jaspersoft/android/sdk/network/AuthRestApiTest.java index e7161cf1..35733ece 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthRestApiTest.java @@ -45,7 +45,7 @@ * @author Tom Koptel * @since 2.0 */ -public class AuthenticationRestApiTest { +public class AuthRestApiTest { private final String LOCATION_SUCCESS = "/scripts/bower_components/js-sdk/src/common/auth/loginSuccess.json;jsessionid=7D86AE28407432B728694DF649DB5E8F"; private final String LOCATION_ERROR = "login.html;jsessionid=395364A98787A1C42D5FEB0E9F58CF9F?error=1"; @@ -54,7 +54,7 @@ public class AuthenticationRestApiTest { @Rule public final ExpectedException mExpectedException = ExpectedException.none(); - private AuthenticationRestApi apiUnderTest; + private AuthRestApi apiUnderTest; @ResourceFile("json/encryption_key.json") TestResource mKey; @@ -67,7 +67,7 @@ public void setup() { .build(); Retrofit retrofit = server.newRetrofit().build(); retrofit.client().setFollowRedirects(false); - apiUnderTest = new AuthenticationRestApi(retrofit); + apiUnderTest = new AuthRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java index 0ccbc008..0d4ab847 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java @@ -38,17 +38,17 @@ public class AuthorizationClientTestImplTest { @Mock Credentials mCredentials; - private AuthorizationClientImpl authorization; + private AuthenticationRestApiImpl authorization; @Before public void setUp() throws Exception { initMocks(this); - authorization = new AuthorizationClientImpl(mAuthStrategy); + authorization = new AuthenticationRestApiImpl(mAuthStrategy); } @Test public void testAuthorize() throws Exception { - authorization.authorize(mCredentials); + authorization.authenticate(mCredentials); verify(mCredentials).apply(mAuthStrategy); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java index 05d91796..50eaae1c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringAuthServiceTest.java @@ -53,7 +53,7 @@ }) public class SpringAuthServiceTest { @Mock - AuthenticationRestApi mRestApi; + AuthRestApi mRestApi; @Mock JSEncryptionAlgorithm mAlgorithm; @Mock diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java index cf1214c1..ee83250b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/SpringCredentialsTest.java @@ -42,7 +42,7 @@ public class SpringCredentialsTest { private SpringCredentials.Builder objectUnderTest; @Mock - AuthenticationRestApi mRestApi; + AuthRestApi mRestApi; @Rule public ExpectedException mException = ExpectedException.none(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java index 15b2938f..9bf2a621 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.AnonymousClient; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -32,16 +32,14 @@ import org.mockito.Mock; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.*; import static org.junit.rules.ExpectedException.none; import static org.mockito.MockitoAnnotations.initMocks; public class AuthorizationServiceTest { @Mock - AuthorizationClient mAuthorizationClient; + AnonymousClient mAnonymousClient; @Rule public ExpectedException expected = none(); @@ -59,7 +57,7 @@ public void should_not_allow_null_client() throws Exception { @Test public void should_create_new_proxy_service() throws Exception { - AuthorizationService service = AuthorizationService.newService(mAuthorizationClient); + AuthorizationService service = AuthorizationService.newService(mAnonymousClient); assertThat(service, is(instanceOf(ProxyAuthorizationService.class))); assertThat(service, is(notNullValue())); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java index 61f77826..5fdbfbf8 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java @@ -24,7 +24,8 @@ package com.jaspersoft.android.sdk.service.auth; -import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -45,7 +46,9 @@ public class ProxyAuthorizationServiceTest { @Mock - AuthorizationClient mAuthorizationClient; + AnonymousClient mAnonymousClient; + @Mock + AuthenticationRestApi mAuthenticationRestApi; @Mock ServiceExceptionMapper mServiceExceptionMapper; @Mock @@ -63,20 +66,22 @@ public class ProxyAuthorizationServiceTest { @Before public void setUp() throws Exception { initMocks(this); - authorizationService = new ProxyAuthorizationService(mAuthorizationClient, mServiceExceptionMapper); + when(mAnonymousClient.authenticationApi()).thenReturn(mAuthenticationRestApi); + authorizationService = new ProxyAuthorizationService(mAnonymousClient, mServiceExceptionMapper); } @Test public void testAuthorize() throws Exception { authorizationService.authorize(mCredentials); - verify(mAuthorizationClient).authorize(mCredentials); + verify(mAnonymousClient).authenticationApi(); + verify(mAuthenticationRestApi).authenticate(mCredentials); verifyZeroInteractions(mServiceExceptionMapper); } @Test public void testShouldMapHttpException() throws Exception { when(mServiceExceptionMapper.transform(any(HttpException.class))).thenReturn(mServiceException); - doThrow(mHttpException).when(mAuthorizationClient).authorize(any(Credentials.class)); + doThrow(mHttpException).when(mAuthenticationRestApi).authenticate(any(Credentials.class)); try { authorizationService.authorize(mCredentials); @@ -89,7 +94,7 @@ public void testShouldMapHttpException() throws Exception { @Test public void testShouldMapIOException() throws Exception { when(mServiceExceptionMapper.transform(any(IOException.class))).thenReturn(mServiceException); - doThrow(mIOException).when(mAuthorizationClient).authorize(any(Credentials.class)); + doThrow(mIOException).when(mAuthenticationRestApi).authenticate(any(Credentials.class)); try { authorizationService.authorize(mCredentials); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java index 0c7605b4..ef806cb3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/AuthorizationClientTest.java @@ -24,8 +24,7 @@ package com.jaspersoft.android.sdk.test.integration.api; -import com.jaspersoft.android.sdk.network.AuthorizationClient; -import com.jaspersoft.android.sdk.network.Server; +import com.jaspersoft.android.sdk.network.AnonymousClient; import org.junit.Before; import org.junit.Test; @@ -36,18 +35,17 @@ public class AuthorizationClientTest { private final JrsMetadata mMetadata = JrsMetadata.createMobileDemo2(); - private AuthorizationClient mClient; + private final LazyClient mLazyClient = new LazyClient(mMetadata); + + private AnonymousClient mClient; @Before public void setUp() throws Exception { - Server server = Server.builder() - .withBaseUrl(mMetadata.getServerUrl()) - .build(); - mClient = server.newAuthorizationClient().create(); + mClient = mLazyClient.getAnonymousClient(); } @Test public void testAuthorize() throws Exception { - mClient.authorize(mMetadata.getCredentials()); + mClient.authenticationApi().authenticate(mMetadata.getCredentials()); } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java index 740316ef..081a83a1 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.rx.auth; -import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.service.auth.AuthorizationService; import com.jaspersoft.android.sdk.service.internal.Preconditions; @@ -41,9 +41,9 @@ public abstract class RxAuthorizationService { public abstract Observable authorize(@NotNull Credentials credentials); @NotNull - public static RxAuthorizationService newService(@NotNull AuthorizationClient authorizationClient) { - Preconditions.checkNotNull(authorizationClient, "Client should not be null"); - AuthorizationService service = AuthorizationService.newService(authorizationClient); + public static RxAuthorizationService newService(@NotNull AnonymousClient client) { + Preconditions.checkNotNull(client, "Client should not be null"); + AuthorizationService service = AuthorizationService.newService(client); return new RxAuthorizationServiceImpl(service); } } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java index 85e9dadb..265858ec 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.service.rx.auth; -import com.jaspersoft.android.sdk.network.AuthorizationClient; +import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.service.auth.AuthorizationService; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -50,7 +50,7 @@ public class RxAuthorizationServiceTest { @Mock AuthorizationService mSyncDelegate; @Mock - AuthorizationClient mAuthorizationClient; + AnonymousClient mAnonymousClient; @Mock ServiceException mServiceException; @Mock @@ -94,7 +94,7 @@ public void should_delegate_service_exception_on_authorize_call() throws Excepti @Test public void should_provide_impl_with_factory_method() throws Exception { - RxAuthorizationService service = RxAuthorizationService.newService(mAuthorizationClient); + RxAuthorizationService service = RxAuthorizationService.newService(mAnonymousClient); assertThat(service, is(instanceOf(RxAuthorizationServiceImpl.class))); assertThat(service, is(notNullValue())); } From a3ab4eeafe14ca693a3d9606297a08dcd6d211ad Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Mon, 4 Jan 2016 12:35:56 +0200 Subject: [PATCH 381/457] Make AuthorizationService return credentials instead void --- .../android/sdk/service/auth/AuthorizationService.java | 2 +- .../sdk/service/auth/ProxyAuthorizationService.java | 3 ++- .../sdk/service/rx/auth/RxAuthorizationService.java | 2 +- .../sdk/service/rx/auth/RxAuthorizationServiceImpl.java | 8 ++++---- .../sdk/service/rx/auth/RxAuthorizationServiceTest.java | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java index 9e913ced..24578627 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java @@ -37,7 +37,7 @@ * @since 2.0 */ public abstract class AuthorizationService { - public abstract void authorize(Credentials credentials) throws ServiceException; + public abstract Credentials authorize(Credentials credentials) throws ServiceException; @NotNull public static AuthorizationService newService(@NotNull AnonymousClient client) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java index 992c39ec..2239b5a9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java @@ -50,10 +50,11 @@ final class ProxyAuthorizationService extends AuthorizationService { } @Override - public void authorize(Credentials credentials) throws ServiceException { + public Credentials authorize(Credentials credentials) throws ServiceException { try { AuthenticationRestApi authenticationRestApi = mClient.authenticationApi(); authenticationRestApi.authenticate(credentials); + return credentials; } catch (IOException e) { throw mServiceExceptionMapper.transform(e); } catch (HttpException e) { diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java index 081a83a1..7b0f4151 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java @@ -38,7 +38,7 @@ */ public abstract class RxAuthorizationService { @NotNull - public abstract Observable authorize(@NotNull Credentials credentials); + public abstract Observable authorize(@NotNull Credentials credentials); @NotNull public static RxAuthorizationService newService(@NotNull AnonymousClient client) { diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java index 98fb1054..4ae0267c 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java @@ -46,16 +46,16 @@ final class RxAuthorizationServiceImpl extends RxAuthorizationService { @NotNull @Override - public Observable authorize(@NotNull final Credentials credentials) { - return Observable.defer(new Func0>() { + public Observable authorize(@NotNull final Credentials credentials) { + return Observable.defer(new Func0>() { @Override - public Observable call() { + public Observable call() { try { mSyncDelegate.authorize(credentials); + return Observable.just(credentials); } catch (ServiceException e) { return Observable.error(e); } - return Observable.just(null); } }); } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java index 265858ec..0799466d 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java @@ -69,7 +69,7 @@ public void setUp() throws Exception { @Test public void should_delegate_authorize_call() throws Exception { - TestSubscriber test = new TestSubscriber<>(); + TestSubscriber test = new TestSubscriber<>(); rxAuthorizationService.authorize(mCredentials).subscribe(test); test.assertNoErrors(); @@ -83,7 +83,7 @@ public void should_delegate_authorize_call() throws Exception { public void should_delegate_service_exception_on_authorize_call() throws Exception { doThrow(mServiceException).when(mSyncDelegate).authorize(any(Credentials.class)); - TestSubscriber test = new TestSubscriber<>(); + TestSubscriber test = new TestSubscriber<>(); rxAuthorizationService.authorize(mCredentials).subscribe(test); test.assertError(mServiceException); From 48e07620434ff6730f2f2c03048f8d5af39e8fef Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 6 Jan 2016 23:56:51 +0200 Subject: [PATCH 382/457] Remove Junit dependency from RX module --- rx/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rx/build.gradle b/rx/build.gradle index 43dbcb8f..c92cc0cb 100644 --- a/rx/build.gradle +++ b/rx/build.gradle @@ -39,9 +39,8 @@ ext { dependencies { compile project(':js-android-sdk-core') compile 'io.reactivex:rxjava:1.1.0' - compile 'junit:junit:4.12' - + testCompile 'junit:junit:4.12' testCompile 'org.hamcrest:hamcrest-integration:1.3' testCompile('org.mockito:mockito-core:1.10.19') { exclude group: 'org.hamcrest' From 3212651650cb2515bf86c62ec6b3b2b64a233bd8 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Tue, 12 Jan 2016 20:25:32 +0200 Subject: [PATCH 383/457] Add support for fetching report resource metadata Add report details request Replace ReportLookup with ReportResource Implement RxRepositoryService#fetchReportDetails(String) Fix broken tests --- .../network/entity/resource/ReportLookup.java | 2 +- .../service/data/report/ReportResource.java | 86 +++++++++++++++++++ .../sdk/service/data/repository/Resource.java | 80 ++++++++++++----- .../repository/ProxyRepositoryService.java | 18 +++- .../repository/ReportResourceMapper.java | 64 ++++++++++++++ .../service/repository/RepositoryService.java | 10 ++- .../service/repository/RepositoryUseCase.java | 71 +++++++++++++++ .../service/repository/ResourceMapper.java | 28 +++--- .../ProxyRepositoryServiceTest.java | 28 +++++- .../repository/ReportResourceMapperTest.java | 80 +++++++++++++++++ .../repository/RepositoryUseCaseTest.java | 79 +++++++++++++++++ .../rx/repository/RxRepositoryService.java | 3 + .../repository/RxRepositoryServiceImpl.java | 19 ++++ .../repository/RxRepositoryServiceTest.java | 39 ++++++++- 14 files changed, 560 insertions(+), 47 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportResource.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCase.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapperTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCaseTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java index 059b2561..8275eb2d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/resource/ReportLookup.java @@ -42,7 +42,7 @@ public String getResourceType() { return "reportUnit"; } - public boolean isAlwaysPromptControls() { + public boolean alwaysPromptControls() { return alwaysPromptControls; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportResource.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportResource.java new file mode 100644 index 00000000..b0b2f6a9 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/report/ReportResource.java @@ -0,0 +1,86 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.data.report; + +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.ResourceType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Date; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportResource extends Resource { + private final boolean mAlwaysPrompt; + + public ReportResource(@Nullable Date creationDate, + @Nullable Date updateDate, + @NotNull ResourceType resourceType, + @NotNull String label, + @NotNull String description, + boolean alwaysPrompt) { + super(creationDate, updateDate, resourceType, label, description); + mAlwaysPrompt = alwaysPrompt; + } + + public boolean alwaysPromptControls() { + return mAlwaysPrompt; + } + + @Override + public final boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + + ReportResource that = (ReportResource) o; + + if (mAlwaysPrompt != that.mAlwaysPrompt) return false; + + return true; + } + + @Override + public final int hashCode() { + int result = super.hashCode(); + result = 31 * result + (mAlwaysPrompt ? 1 : 0); + return result; + } + + @Override + public String toString() { + return "ReportResource{" + + "mCreationDate=" + getCreationDate() + + ", mUpdateDate=" + getUpdateDate() + + ", mResourceType=" + getResourceType() + + ", mLabel='" + getLabel() + '\'' + + ", mDescription='" + getDescription() + '\'' + + ", mAlwaysPrompt=" + mAlwaysPrompt + + '}'; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java index 5107d2d8..88f00232 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/Resource.java @@ -36,56 +36,90 @@ */ public class Resource { @Nullable - private Date mCreationDate; + private final Date mCreationDate; @Nullable - private Date mUpdateDate; + private final Date mUpdateDate; + @NotNull + private final ResourceType mResourceType; + @NotNull + private final String mLabel; + @NotNull + private final String mDescription; - private ResourceType mResourceType; - private String mLabel; - private String mDescription; + public Resource(@Nullable Date creationDate, + @Nullable Date updateDate, + @NotNull ResourceType resourceType, + @NotNull String label, + @NotNull String description) { + mCreationDate = creationDate; + mUpdateDate = updateDate; + mResourceType = resourceType; + mLabel = label; + mDescription = description; + } @Nullable public Date getCreationDate() { return mCreationDate; } - public void setCreationDate(@Nullable Date creationDate) { - mCreationDate = creationDate; - } - @Nullable public Date getUpdateDate() { return mUpdateDate; } - public void setUpdateDate(@Nullable Date updateDate) { - mUpdateDate = updateDate; - } - @NotNull public ResourceType getResourceType() { return mResourceType; } - public void setResourceType(@NotNull ResourceType resourceType) { - mResourceType = resourceType; - } - @NotNull public String getLabel() { return mLabel; } - public void setLabel(@NotNull String label) { - mLabel = label; - } - @NotNull public String getDescription() { return mDescription; } - public void setDescription(@NotNull String description) { - mDescription = description; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Resource resource = (Resource) o; + + if (mCreationDate != null ? !mCreationDate.equals(resource.mCreationDate) : resource.mCreationDate != null) + return false; + if (mDescription != null ? !mDescription.equals(resource.mDescription) : resource.mDescription != null) + return false; + if (mLabel != null ? !mLabel.equals(resource.mLabel) : resource.mLabel != null) return false; + if (mResourceType != resource.mResourceType) return false; + if (mUpdateDate != null ? !mUpdateDate.equals(resource.mUpdateDate) : resource.mUpdateDate != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = mCreationDate != null ? mCreationDate.hashCode() : 0; + result = 31 * result + (mUpdateDate != null ? mUpdateDate.hashCode() : 0); + result = 31 * result + (mResourceType != null ? mResourceType.hashCode() : 0); + result = 31 * result + (mLabel != null ? mLabel.hashCode() : 0); + result = 31 * result + (mDescription != null ? mDescription.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "Resource{" + + "mCreationDate=" + mCreationDate + + ", mUpdateDate=" + mUpdateDate + + ", mResourceType=" + mResourceType + + ", mLabel='" + mLabel + '\'' + + ", mDescription='" + mDescription + '\'' + + '}'; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java index 6b100220..a83bfe17 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java @@ -24,6 +24,10 @@ package com.jaspersoft.android.sdk.service.repository; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,11 +39,16 @@ */ final class ProxyRepositoryService extends RepositoryService { private final SearchUseCase mSearchUseCase; + private final RepositoryUseCase mRepositoryUseCase; private final InfoCacheManager mInfoCacheManager; @TestOnly - ProxyRepositoryService(SearchUseCase searchUseCase, InfoCacheManager infoCacheManager) { + ProxyRepositoryService( + SearchUseCase searchUseCase, + RepositoryUseCase repositoryUseCase, + InfoCacheManager infoCacheManager) { mSearchUseCase = searchUseCase; + mRepositoryUseCase = repositoryUseCase; mInfoCacheManager = infoCacheManager; } @@ -54,4 +63,11 @@ public SearchTask search(@Nullable SearchCriteria criteria) { SearchTaskFactory searchTaskFactory = new SearchTaskFactory(internalCriteria, mSearchUseCase, mInfoCacheManager); return new SearchTaskProxy(searchTaskFactory); } + + @NotNull + @Override + public ReportResource fetchReportDetails(@NotNull String reportUri) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + return mRepositoryUseCase.getReportDetails(reportUri); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapper.java new file mode 100644 index 00000000..7fce013b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapper.java @@ -0,0 +1,64 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.repository.ResourceType; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class ReportResourceMapper { + + public ReportResource transform(ReportLookup lookup, SimpleDateFormat dateTimeFormat) { + Date creationDate; + Date updateDate; + + try { + creationDate = dateTimeFormat.parse(String.valueOf(lookup.getCreationDate())); + updateDate = dateTimeFormat.parse(String.valueOf(lookup.getUpdateDate())); + } catch (ParseException e) { + creationDate = updateDate = null; + } + + String type = lookup.getResourceType(); + ResourceType resourceType = ResourceType.unknown; + if (type != null) { + resourceType = ResourceType.defaultParser().parse(type); + } + return new ReportResource(creationDate, + updateDate, + resourceType, + lookup.getLabel(), + lookup.getDescription(), + lookup.alwaysPromptControls()); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 3c19ff61..f5644ca9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -26,6 +26,8 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.*; import com.jaspersoft.android.sdk.service.internal.info.InMemoryInfoCache; import com.jaspersoft.android.sdk.service.internal.info.InfoCache; @@ -41,6 +43,9 @@ public abstract class RepositoryService { @NotNull public abstract SearchTask search(@Nullable SearchCriteria criteria); + @NotNull + public abstract ReportResource fetchReportDetails(@NotNull String reportUri) throws ServiceException; + @NotNull public static RepositoryService newService(@NotNull AuthorizedClient client) { Preconditions.checkNotNull(client, "Client should not be null"); @@ -58,6 +63,9 @@ public static RepositoryService newService(@NotNull AuthorizedClient client) { cacheManager, callExecutor ); - return new ProxyRepositoryService(searchUseCase, cacheManager); + ReportResourceMapper reportResourceMapper = new ReportResourceMapper(); + RepositoryUseCase repositoryUseCase = new RepositoryUseCase(defaultExMapper, + repositoryRestApi, reportResourceMapper, cacheManager); + return new ProxyRepositoryService(searchUseCase, repositoryUseCase, cacheManager); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCase.java new file mode 100644 index 00000000..d5d12b48 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCase.java @@ -0,0 +1,71 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; + +import java.io.IOException; +import java.text.SimpleDateFormat; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class RepositoryUseCase { + private final ServiceExceptionMapper mServiceExceptionMapper; + private final RepositoryRestApi mRepositoryRestApi; + private final ReportResourceMapper mReportResourceMapper; + private final InfoCacheManager mInfoCacheManager; + + RepositoryUseCase(ServiceExceptionMapper serviceExceptionMapper, + RepositoryRestApi repositoryRestApi, + ReportResourceMapper reportResourceMapper, + InfoCacheManager infoCacheManager) { + mServiceExceptionMapper = serviceExceptionMapper; + mRepositoryRestApi = repositoryRestApi; + mReportResourceMapper = reportResourceMapper; + mInfoCacheManager = infoCacheManager; + } + + public ReportResource getReportDetails(String reportUri) throws ServiceException { + try { + ServerInfo info = mInfoCacheManager.getInfo(); + SimpleDateFormat datetimeFormatPattern = info.getDatetimeFormatPattern(); + ReportLookup reportLookup = mRepositoryRestApi.requestReportResource(reportUri); + return mReportResourceMapper.transform(reportLookup, datetimeFormatPattern); + } catch (HttpException e) { + throw mServiceExceptionMapper.transform(e); + } catch (IOException e) { + throw mServiceExceptionMapper.transform(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java index 0d537bdb..73f588f4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ResourceMapper.java @@ -29,7 +29,6 @@ import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.data.repository.ResourceType; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -57,26 +56,21 @@ public List transform(Collection resources, SimpleDate @NotNull public Resource transform(ResourceLookup lookup, SimpleDateFormat dateTimeFormat) { - Resource resource = new Resource(); - resource.setCreationDate(toDate(lookup.getCreationDate(), dateTimeFormat)); - resource.setUpdateDate(toDate(lookup.getUpdateDate(), dateTimeFormat)); - resource.setDescription(lookup.getDescription()); - resource.setLabel(lookup.getLabel()); - resource.setResourceType(toType(lookup.getResourceType())); - return resource; - } + Date creationDate; + Date updateDate; - @Nullable - private Date toDate(String creationDate, SimpleDateFormat dateTimeFormat) { try { - return dateTimeFormat.parse(String.valueOf(creationDate)); + creationDate = dateTimeFormat.parse(String.valueOf(lookup.getCreationDate())); + updateDate = dateTimeFormat.parse(String.valueOf(lookup.getUpdateDate())); } catch (ParseException e) { - return null; + creationDate = updateDate = null; } - } - @NotNull - private ResourceType toType(String resourceType) { - return ResourceType.defaultParser().parse(String.valueOf(resourceType)); + String type = lookup.getResourceType(); + ResourceType resourceType = ResourceType.unknown; + if (type != null) { + resourceType = ResourceType.defaultParser().parse(type); + } + return new Resource(creationDate, updateDate, resourceType, lookup.getLabel(), lookup.getDescription()); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java index 6644cb9f..235057a9 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java @@ -35,26 +35,35 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Mockito.verify; /** * @author Tom Koptel * @since 2.0 */ public class ProxyRepositoryServiceTest { + private static final String REPORT_URI = "/my/uri"; + + @Mock + SearchUseCase mSearchCase; @Mock - SearchUseCase mCase; + RepositoryUseCase mRepositoryUseCase; @Mock InfoCacheManager mInfoCacheManager; + @Rule + public ExpectedException expected = none(); + private ProxyRepositoryService objectUnderTest; @Rule - public ExpectedException mExpectedException = ExpectedException.none(); + public ExpectedException mExpectedException = none(); @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new ProxyRepositoryService(mCase, mInfoCacheManager); + objectUnderTest = new ProxyRepositoryService(mSearchCase, mRepositoryUseCase, mInfoCacheManager); } @Test @@ -68,4 +77,17 @@ public void should_accept_null_criteria() { SearchTask searchTask = objectUnderTest.search(null); assertThat(searchTask, is(notNullValue())); } + + @Test + public void fetch_should_delegate_request_on_usecase() throws Exception { + objectUnderTest.fetchReportDetails(REPORT_URI); + verify(mRepositoryUseCase).getReportDetails(REPORT_URI); + } + + @Test + public void fetch_report_details_fails_with_null_uri() throws Exception { + expected.expectMessage("Report uri should not be null"); + expected.expect(NullPointerException.class); + objectUnderTest.fetchReportDetails(null); + } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapperTest.java new file mode 100644 index 00000000..661ce057 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ReportResourceMapperTest.java @@ -0,0 +1,80 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.repository.ResourceType; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.text.SimpleDateFormat; +import java.util.Locale; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ReportResourceMapperTest { + public static final String FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss"; + public static final SimpleDateFormat DATE_FORMAT = + new SimpleDateFormat(FORMAT_PATTERN, Locale.getDefault()); + + @Mock + ReportLookup mReportLookup; + private ReportResourceMapper mapper; + + @Before + public void setUp() throws Exception { + initMocks(this); + + mapper = new ReportResourceMapper(); + + when(mReportLookup.getCreationDate()).thenReturn("2013-10-03 16:32:05"); + when(mReportLookup.getUpdateDate()).thenReturn("2013-11-03 16:32:05"); + when(mReportLookup.getResourceType()).thenReturn("reportUnit"); + when(mReportLookup.getDescription()).thenReturn("description"); + when(mReportLookup.getLabel()).thenReturn("label"); + when(mReportLookup.alwaysPromptControls()).thenReturn(false); + } + + @Test + public void testTransform() throws Exception { + long creationTime = DATE_FORMAT.parse("2013-10-03 16:32:05").getTime(); + long updateTime = DATE_FORMAT.parse("2013-11-03 16:32:05").getTime(); + + ReportResource resource = mapper.transform(mReportLookup, DATE_FORMAT); + assertThat(resource.getCreationDate().getTime(), is(creationTime)); + assertThat(resource.getUpdateDate().getTime(), is(updateTime)); + assertThat(resource.getDescription(), is("description")); + assertThat(resource.getLabel(), is("label")); + assertThat(resource.getResourceType(), is(ResourceType.reportUnit)); + assertThat(resource.getResourceType(), is(ResourceType.reportUnit)); + assertThat(resource.alwaysPromptControls(), is(false)); + + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCaseTest.java new file mode 100644 index 00000000..f66b6efd --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryUseCaseTest.java @@ -0,0 +1,79 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.repository; + +import com.jaspersoft.android.sdk.network.RepositoryRestApi; +import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; +import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.text.SimpleDateFormat; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RepositoryUseCaseTest { + private static final String REPORT_URI = "/my/uri"; + + @Mock + ServiceExceptionMapper mServiceExceptionMapper; + @Mock + RepositoryRestApi mRepositoryRestApi; + @Mock + ReportResourceMapper reportResourceMapper; + @Mock + InfoCacheManager infoCacheManager; + @Mock + ServerInfo mServerInfo; + + private RepositoryUseCase useCase; + + @Before + public void setUp() throws Exception { + initMocks(this); + useCase = new RepositoryUseCase( + mServiceExceptionMapper, + mRepositoryRestApi, + reportResourceMapper, + infoCacheManager); + } + + @Test + public void testGetReportDetails() throws Exception { + when(infoCacheManager.getInfo()).thenReturn(mServerInfo); + + useCase.getReportDetails(REPORT_URI); + + verify(infoCacheManager).getInfo(); + verify(reportResourceMapper).transform(any(ReportLookup.class), any(SimpleDateFormat.class)); + verify(mRepositoryRestApi).requestReportResource(REPORT_URI); + } +} \ No newline at end of file diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java index 91462fa9..15171d14 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.rx.repository; import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.repository.SearchCriteria; @@ -40,6 +41,8 @@ public abstract class RxRepositoryService { @NotNull public abstract Observable search(@Nullable SearchCriteria criteria); + @NotNull + public abstract Observable fetchReportDetails(@NotNull String reportUri); @NotNull public static RxRepositoryService newService(@NotNull AuthorizedClient authorizedClient) { diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java index ef11eb23..20d6d53e 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java @@ -24,6 +24,8 @@ package com.jaspersoft.android.sdk.service.rx.repository; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.repository.SearchCriteria; import com.jaspersoft.android.sdk.service.repository.SearchTask; @@ -31,6 +33,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel @@ -51,4 +54,20 @@ public Observable search(@Nullable SearchCriteria criteria) { RxSearchTask rxSearchTask = new RxSearchTaskImpl(searchTask); return Observable.just(rxSearchTask); } + + @NotNull + @Override + public Observable fetchReportDetails(@NotNull final String reportUri) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportResource reportResource = mSyncDelegate.fetchReportDetails(reportUri); + return Observable.just(reportResource); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java index 2da07a7a..25c2cec3 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java @@ -25,6 +25,8 @@ package com.jaspersoft.android.sdk.service.rx.repository; import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.repository.SearchCriteria; import com.jaspersoft.android.sdk.service.repository.SearchTask; @@ -39,18 +41,25 @@ import static org.hamcrest.Matchers.*; import static org.junit.rules.ExpectedException.none; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; public class RxRepositoryServiceTest { + private static final String REPORT_URI = "/my/uri"; + @Mock AuthorizedClient mAuthorizedClient; @Mock RepositoryService mSyncDelegate; @Mock SearchTask mSearchTask; + @Mock + ReportResource mReportResource; + @Mock + ServiceException mServiceException; @Rule public ExpectedException expected = none(); @@ -78,6 +87,33 @@ public void should_delegate_search_call() throws Exception { verify(mSyncDelegate).search(criteria); } + @Test + public void should_delegate_fetch_report_details_call() throws Exception { + when(mSyncDelegate.fetchReportDetails(anyString())).thenReturn(mReportResource); + + TestSubscriber test = new TestSubscriber<>(); + rxRepositoryService.fetchReportDetails(REPORT_URI).subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).fetchReportDetails(REPORT_URI); + } + + @Test + public void should_delegate_service_exception_to_subscription() throws Exception { + when(mSyncDelegate.fetchReportDetails(anyString())).thenThrow(mServiceException); + + TestSubscriber test = new TestSubscriber<>(); + rxRepositoryService.fetchReportDetails(REPORT_URI).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).fetchReportDetails(REPORT_URI); + } + @Test public void should_accept_null_criteria() throws Exception { TestSubscriber test = new TestSubscriber<>(); @@ -86,7 +122,6 @@ public void should_accept_null_criteria() throws Exception { test.assertCompleted(); } - @Test public void should_provide_impl_with_factory_method() throws Exception { RxRepositoryService service = RxRepositoryService.newService(mAuthorizedClient); @@ -100,4 +135,6 @@ public void should_not_accept_null_for_factory_method() throws Exception { expected.expect(NullPointerException.class); RxRepositoryService.newService(null); } + + } \ No newline at end of file From cf70cecf2c5f39e99036af2997212ee993bedea7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 13 Jan 2016 00:04:54 +0200 Subject: [PATCH 384/457] Add listing of root folders API Implementing RepositoryService#fetchRootFolders() Implementing RxRepositoryService#fetchRootFolders() --- .../service/data/repository/SearchResult.java | 17 +++----- .../service/repository/CriteriaMapper.java | 12 +++--- .../service/repository/InternalCriteria.java | 11 ++--- .../repository/ProxyRepositoryService.java | 26 ++++++++++- .../service/repository/RepositoryService.java | 6 +++ .../service/repository/SearchCriteria.java | 1 + .../sdk/service/repository/SearchUseCase.java | 8 +--- .../repository/CriteriaMapperTest.java | 25 +++++------ .../InternalSearchCriteriaTest.java | 18 ++++---- .../ProxyRepositoryServiceTest.java | 43 ++++++++++++++++++- .../repository/SearchTaskFactoryTest.java | 2 +- .../repository/SearchTaskV5_5Test.java | 14 +++--- .../repository/SearchTaskV5_6PlusTest.java | 14 +++--- .../rx/repository/RxRepositoryService.java | 7 +++ .../repository/RxRepositoryServiceImpl.java | 19 ++++++++ .../repository/RxRepositoryServiceTest.java | 34 ++++++++++++++- 16 files changed, 186 insertions(+), 71 deletions(-) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java index 27f01a9f..673e5606 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/repository/SearchResult.java @@ -31,22 +31,19 @@ * @since 2.0 */ public class SearchResult { - private List mResources; - private int mNextOffset; + private final List mResources; + private final int mNextOffset; - public List getResources() { - return mResources; + public SearchResult(List resources, int nextOffset) { + mResources = resources; + mNextOffset = nextOffset; } - public void setResources(List resources) { - mResources = resources; + public List getResources() { + return mResources; } public int getNextOffset() { return mNextOffset; } - - public void setNextOffset(int nextOffset) { - mNextOffset = nextOffset; - } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java index a2e534b1..be6c01a9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapper.java @@ -31,12 +31,7 @@ import java.util.Map; import java.util.Set; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.ALL; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DASHBOARD; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_LIMIT; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.DEFAULT_OFFSET; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.LEGACY_DASHBOARD; -import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.REPORT; +import static com.jaspersoft.android.sdk.service.repository.SearchCriteria.*; /** * @author Tom Koptel @@ -111,6 +106,11 @@ private static Set populateTypes(InternalCriteria criteria) { if (includeLegacyDashboard) { types.add("legacyDashboard"); } + boolean includeFolder = + (resourceMask & FOLDER) == FOLDER || (resourceMask & ALL) == ALL; + if (includeFolder) { + types.add("folder"); + } return types; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java index d3116618..c9a88c97 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/InternalCriteria.java @@ -57,14 +57,9 @@ private InternalCriteria(Builder builder) { mFolderUri = builder.folderUri; } - @NotNull - public static Builder builder() { - return new Builder(); - } - @NotNull public static InternalCriteria from(SearchCriteria criteria) { - return InternalCriteria.builder() + return new InternalCriteria.Builder() .limit(criteria.getLimit()) .offset(criteria.getOffset()) .resourceMask(criteria.getResourceMask()) @@ -119,7 +114,7 @@ public SortType getSortBy() { @NotNull public Builder newBuilder() { - Builder builder = builder(); + Builder builder = new InternalCriteria.Builder(); if (mRecursive != null) { builder.recursive(mRecursive); @@ -209,7 +204,7 @@ public static class Builder { @Nullable private Boolean forceFullPage; @Nullable - public Boolean forceTotalCount; + private Boolean forceTotalCount; @Nullable private String query; @Nullable diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java index a83bfe17..24a1284b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java @@ -24,8 +24,9 @@ package com.jaspersoft.android.sdk.service.repository; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; @@ -33,6 +34,9 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; +import java.util.ArrayList; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 @@ -70,4 +74,24 @@ public ReportResource fetchReportDetails(@NotNull String reportUri) throws Servi Preconditions.checkNotNull(reportUri, "Report uri should not be null"); return mRepositoryUseCase.getReportDetails(reportUri); } + + @NotNull + @Override + public List fetchRootFolders() throws ServiceException { + InternalCriteria rootFolder = new InternalCriteria.Builder() + .folderUri("/") + .resourceMask(SearchCriteria.FOLDER) + .create(); + List folders = new ArrayList<>(10); + SearchResult result = mSearchUseCase.performSearch(rootFolder); + folders.addAll(result.getResources()); + + InternalCriteria publicFolder = rootFolder.newBuilder() + .folderUri("/public") + .create(); + SearchResult publicFoldersResult = mSearchUseCase.performSearch(publicFolder); + folders.addAll(publicFoldersResult.getResources()); + + return folders; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index f5644ca9..7a263ed4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.*; import com.jaspersoft.android.sdk.service.internal.info.InMemoryInfoCache; @@ -35,6 +36,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 @@ -46,6 +49,9 @@ public abstract class RepositoryService { @NotNull public abstract ReportResource fetchReportDetails(@NotNull String reportUri) throws ServiceException; + @NotNull + public abstract List fetchRootFolders() throws ServiceException; + @NotNull public static RepositoryService newService(@NotNull AuthorizedClient client) { Preconditions.checkNotNull(client, "Client should not be null"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java index 96356eec..1a3c1029 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchCriteria.java @@ -41,6 +41,7 @@ public final class SearchCriteria { public static int REPORT = (1 << 1); public static int DASHBOARD = (1 << 2); public static int LEGACY_DASHBOARD = (1 << 3); + public static int FOLDER = (1 << 4); private final int mLimit; private final int mOffset; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java index 7733dd9f..18e90db9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchUseCase.java @@ -68,14 +68,8 @@ public SearchResult performSearch(@NotNull final InternalCriteria internalCriter public SearchResult perform() throws IOException, HttpException { Map criteria = CriteriaMapper.map(internalCriteria); ResourceSearchResult response = mRestApi.searchResources(criteria); - - SearchResult searchResult = new SearchResult(); - searchResult.setNextOffset(response.getNextOffset()); - List resources = mDataMapper.transform(response.getResources(), dateTimeFormat); - searchResult.setResources(resources); - - return searchResult; + return new SearchResult(resources, response.getNextOffset()); } }; return mCallExecutor.execute(call); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java index 163c04bf..2b1e7bdc 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/CriteriaMapperTest.java @@ -43,7 +43,7 @@ public class CriteriaMapperTest { @Test public void shouldIncludeCountInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .limit(101) .create(); @@ -55,7 +55,7 @@ public void shouldIncludeCountInParams() { @Test public void shouldIncludeOffsetInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .offset(100) .create(); @@ -67,7 +67,7 @@ public void shouldIncludeOffsetInParams() { @Test public void shouldIncludeRecursiveInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .recursive(true) .create(); @@ -79,7 +79,7 @@ public void shouldIncludeRecursiveInParams() { @Test public void shouldIncludeForceFullPageInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .forceFullPage(true) .create(); @@ -91,7 +91,7 @@ public void shouldIncludeForceFullPageInParams() { @Test public void shouldIncludeForceTotalCountPageInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .forceTotalCount(true) .create(); @@ -103,7 +103,7 @@ public void shouldIncludeForceTotalCountPageInParams() { @Test public void shouldIncludeQueryPageInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .query("any") .create(); @@ -115,7 +115,7 @@ public void shouldIncludeQueryPageInParams() { @Test public void shouldIncludeFolderUriInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .folderUri("/") .create(); @@ -127,7 +127,7 @@ public void shouldIncludeFolderUriInParams() { @Test public void shouldIncludeSortByInParams() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .sortBy(SortType.DESCRIPTION) .create(); @@ -139,7 +139,7 @@ public void shouldIncludeSortByInParams() { @Test public void shouldIgnoreEmptyQuery() { - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .query("") .create(); @@ -151,8 +151,9 @@ public void shouldIgnoreEmptyQuery() { @Parameters({ "REPORT|reportUnit", "DASHBOARD|dashboard", + "FOLDER|folder", "LEGACY_DASHBOARD|legacyDashboard", - "ALL|reportUnit:dashboard:legacyDashboard", + "ALL|reportUnit:dashboard:legacyDashboard:folder", "REPORT:DASHBOARD|reportUnit:dashboard", }) public void criteriaShouldIncludeTypeInParams(String flags, String types) throws Exception { @@ -165,7 +166,7 @@ public void criteriaShouldIncludeTypeInParams(String flags, String types) throws mask = (Integer) SearchCriteria.class.getField(flags).get(null); } - InternalCriteria criteria = InternalCriteria.builder() + InternalCriteria criteria = new InternalCriteria.Builder() .resourceMask(mask) .create(); @@ -183,7 +184,7 @@ public void criteriaShouldIncludeTypeInParams(String flags, String types) throws @Test public void shouldReturnEmptyParamsIfNoSupplied() { - InternalCriteria criteria = InternalCriteria.builder().create(); + InternalCriteria criteria = new InternalCriteria.Builder().create(); Map resultMap = new HashMap<>(); assertThat(toMap(criteria), is(resultMap)); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java index 1e629378..e71321a2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/InternalSearchCriteriaTest.java @@ -41,7 +41,7 @@ public class InternalSearchCriteriaTest { @Test public void newBuilderShouldCopyCount() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .limit(100) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -50,7 +50,7 @@ public void newBuilderShouldCopyCount() { @Test public void newBuilderShouldCopyOffset() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .offset(100) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -59,7 +59,7 @@ public void newBuilderShouldCopyOffset() { @Test public void newBuilderShouldCopyForceFullPageFlag() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .forceFullPage(true) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -68,7 +68,7 @@ public void newBuilderShouldCopyForceFullPageFlag() { @Test public void newBuilderShouldCopyQuery() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .query("q") .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -77,7 +77,7 @@ public void newBuilderShouldCopyQuery() { @Test public void newBuilderShouldCopyRecursiveFlag() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .recursive(true) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -86,7 +86,7 @@ public void newBuilderShouldCopyRecursiveFlag() { @Test public void newBuilderShouldCopySortBy() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .sortBy(SortType.CREATION_DATE) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -95,7 +95,7 @@ public void newBuilderShouldCopySortBy() { @Test public void newBuilderShouldCopyResourceMask() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .resourceMask(SearchCriteria.REPORT | SearchCriteria.DASHBOARD) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -104,7 +104,7 @@ public void newBuilderShouldCopyResourceMask() { @Test public void newBuilderShouldCopyForceTotalPageFlag() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .forceTotalCount(true) .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); @@ -113,7 +113,7 @@ public void newBuilderShouldCopyForceTotalPageFlag() { @Test public void newBuilderShouldCopyFolderUri() { - InternalCriteria searchCriteria = InternalCriteria.builder() + InternalCriteria searchCriteria = new InternalCriteria.Builder() .folderUri("/") .create(); InternalCriteria newCriteria = searchCriteria.newBuilder().create(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java index 235057a9..69b759aa 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java @@ -24,7 +24,10 @@ package com.jaspersoft.android.sdk.service.repository; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; +import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -32,11 +35,17 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.Collections; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; /** * @author Tom Koptel @@ -46,12 +55,17 @@ public class ProxyRepositoryServiceTest { private static final String REPORT_URI = "/my/uri"; @Mock - SearchUseCase mSearchCase; + SearchUseCase mSearchUseCase; @Mock RepositoryUseCase mRepositoryUseCase; @Mock InfoCacheManager mInfoCacheManager; + @Mock + Resource rootFolder; + @Mock + Resource publicFolder; + @Rule public ExpectedException expected = none(); @@ -63,7 +77,10 @@ public class ProxyRepositoryServiceTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - objectUnderTest = new ProxyRepositoryService(mSearchCase, mRepositoryUseCase, mInfoCacheManager); + + + + objectUnderTest = new ProxyRepositoryService(mSearchUseCase, mRepositoryUseCase, mInfoCacheManager); } @Test @@ -90,4 +107,26 @@ public void fetch_report_details_fails_with_null_uri() throws Exception { expected.expect(NullPointerException.class); objectUnderTest.fetchReportDetails(null); } + + @Test + public void fetch_root_folders_performs_two_lookups() throws Exception { + SearchResult rootFolderLookup = new SearchResult(Collections.singletonList(rootFolder), 0); + SearchResult publicFolderLookup = new SearchResult(Collections.singletonList(publicFolder), 0); + when(mSearchUseCase.performSearch(any(InternalCriteria.class))) + .then(Chain.of(rootFolderLookup, publicFolderLookup)); + List folders = objectUnderTest.fetchRootFolders(); + + assertThat(folders, hasItem(rootFolder)); + assertThat(folders, hasItem(publicFolder)); + + InternalCriteria rootFolder = new InternalCriteria.Builder() + .folderUri("/") + .resourceMask(SearchCriteria.FOLDER) + .create(); + verify(mSearchUseCase).performSearch(rootFolder); + InternalCriteria publicFolder = rootFolder.newBuilder() + .folderUri("/public") + .create(); + verify(mSearchUseCase).performSearch(publicFolder); + } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java index e66a2895..0b635257 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskFactoryTest.java @@ -47,7 +47,7 @@ public class SearchTaskFactoryTest { ServerInfo mServerInfo; private static final InternalCriteria CRITERIA = - InternalCriteria.builder().create(); + new InternalCriteria.Builder().create(); private SearchTaskFactory searchTaskFactory; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5Test.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5Test.java index 368e31a2..8072361b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5Test.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5Test.java @@ -78,7 +78,7 @@ public void setupMocks() throws Exception { when(mSearchUseCase.performSearch(Matchers.any(InternalCriteria.class))).thenReturn(mResponse); - InternalCriteria criteria = InternalCriteria.builder().limit(10).create(); + InternalCriteria criteria = new InternalCriteria.Builder().limit(10).create(); search10itemsStrategy = new SearchTaskV5_5(criteria, mSearchUseCase); InternalCriteria userCriteria = criteria.newBuilder().offset(5).create(); @@ -92,10 +92,10 @@ public void willAlignResponseToLimitIfAPIRespondsWithPartialNumber() throws Exce Collection result = search10itemsStrategy.nextLookup(); assertThat(result.size(), is(10)); - InternalCriteria criteria1 = InternalCriteria.builder().limit(10).create(); + InternalCriteria criteria1 = new InternalCriteria.Builder().limit(10).create(); verify(mSearchUseCase).performSearch(criteria1); - InternalCriteria criteria2 = InternalCriteria.builder() + InternalCriteria criteria2 = new InternalCriteria.Builder() .offset(10).limit(10).create(); verify(mSearchUseCase).performSearch(criteria2); } @@ -128,16 +128,16 @@ public void forCustomOffsetShouldCalculateServerDisposition() throws Exception { search10itemsStrategyWithUserOffset5.nextLookup(); - InternalCriteria criteria1 = InternalCriteria.builder() + InternalCriteria criteria1 = new InternalCriteria.Builder() .limit(5).create(); verify(mSearchUseCase).performSearch(criteria1); - InternalCriteria criteria2 = InternalCriteria.builder() + InternalCriteria criteria2 = new InternalCriteria.Builder() .limit(10).offset(5).create(); verify(mSearchUseCase).performSearch(criteria2); - InternalCriteria criteria3 = InternalCriteria.builder() + InternalCriteria criteria3 = new InternalCriteria.Builder() .limit(10).offset(15).create(); verify(mSearchUseCase).performSearch(criteria3); @@ -147,7 +147,7 @@ public void forCustomOffsetShouldCalculateServerDisposition() throws Exception { @Test public void shouldReturnEmptyCollectionForZeroLimit() throws Exception { - InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); + InternalCriteria userCriteria = new InternalCriteria.Builder().limit(0).offset(5).create(); SearchTask strategy = new SearchTaskV5_5(userCriteria, mSearchUseCase); List result = strategy.nextLookup(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6PlusTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6PlusTest.java index 38a58376..6f794a3d 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6PlusTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6PlusTest.java @@ -71,12 +71,12 @@ public void setupMocks() throws Exception { @Test public void shouldMakeImmediateCallOnApiForUserOffsetZero() throws Exception { - InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); + InternalCriteria searchCriteria = new InternalCriteria.Builder().offset(0).create(); SearchTask strategy = new SearchTaskV5_6Plus(searchCriteria, mSearchUseCase); strategy.nextLookup(); - InternalCriteria internalCriteria = InternalCriteria.builder() + InternalCriteria internalCriteria = new InternalCriteria.Builder() .offset(0) .forceFullPage(true) .create(); @@ -85,12 +85,12 @@ public void shouldMakeImmediateCallOnApiForUserOffsetZero() throws Exception { @Test public void makesAdditionalCallOnApiIfUserOffsetNotZero() throws Exception { - InternalCriteria searchCriteria = InternalCriteria.builder().offset(5).create(); + InternalCriteria searchCriteria = new InternalCriteria.Builder().offset(5).create(); SearchTask strategy = new SearchTaskV5_6Plus(searchCriteria, mSearchUseCase); strategy.nextLookup(); - InternalCriteria internalCriteria = InternalCriteria.builder() + InternalCriteria internalCriteria = new InternalCriteria.Builder() .limit(5) .forceFullPage(true) .create(); @@ -99,7 +99,7 @@ public void makesAdditionalCallOnApiIfUserOffsetNotZero() throws Exception { @Test public void secondSearchLookupShouldUseNextOffset() throws Exception { - InternalCriteria searchCriteria = InternalCriteria.builder().offset(0).create(); + InternalCriteria searchCriteria = new InternalCriteria.Builder().offset(0).create(); SearchTask strategy = new SearchTaskV5_6Plus(searchCriteria, mSearchUseCase); when(mResponse.getNextOffset()).thenReturn(133); @@ -109,7 +109,7 @@ public void secondSearchLookupShouldUseNextOffset() throws Exception { strategy.nextLookup(); - InternalCriteria internalCriteria = InternalCriteria.builder() + InternalCriteria internalCriteria = new InternalCriteria.Builder() .offset(133) .limit(100) .forceFullPage(true) @@ -139,7 +139,7 @@ public void searchWillAlwaysReturnEmptyCollectionIfReachedEndOnApiSide() throws @Test public void shouldReturnEmptyCollectionForZeroLimit() throws Exception { - InternalCriteria userCriteria = InternalCriteria.builder().limit(0).offset(5).create(); + InternalCriteria userCriteria = new InternalCriteria.Builder().limit(0).offset(5).create(); SearchTask strategy = new SearchTaskV5_6Plus(userCriteria, mSearchUseCase); Collection result = strategy.nextLookup(); diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java index 15171d14..42133e0f 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.repository.SearchCriteria; @@ -33,6 +34,8 @@ import org.jetbrains.annotations.Nullable; import rx.Observable; +import java.util.List; + /** * @author Tom Koptel @@ -41,9 +44,13 @@ public abstract class RxRepositoryService { @NotNull public abstract Observable search(@Nullable SearchCriteria criteria); + @NotNull public abstract Observable fetchReportDetails(@NotNull String reportUri); + @NotNull + public abstract Observable> fetchRootFolders(); + @NotNull public static RxRepositoryService newService(@NotNull AuthorizedClient authorizedClient) { Preconditions.checkNotNull(authorizedClient, "Client should not be null"); diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java index 20d6d53e..5eaa38e4 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.service.rx.repository; import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.repository.SearchCriteria; @@ -35,6 +36,8 @@ import rx.Observable; import rx.functions.Func0; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 @@ -70,4 +73,20 @@ public Observable call() { } }); } + + @NotNull + @Override + public Observable> fetchRootFolders() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List resources = mSyncDelegate.fetchRootFolders(); + return Observable.just(resources); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java index 25c2cec3..97c47ac9 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.service.data.report.ReportResource; +import com.jaspersoft.android.sdk.service.data.repository.Resource; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.repository.SearchCriteria; @@ -37,6 +38,9 @@ import org.mockito.Mock; import rx.observers.TestSubscriber; +import java.util.Collections; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.rules.ExpectedException.none; @@ -102,7 +106,7 @@ public void should_delegate_fetch_report_details_call() throws Exception { } @Test - public void should_delegate_service_exception_to_subscription() throws Exception { + public void report_details_call_delegate_service_exception() throws Exception { when(mSyncDelegate.fetchReportDetails(anyString())).thenThrow(mServiceException); TestSubscriber test = new TestSubscriber<>(); @@ -114,6 +118,34 @@ public void should_delegate_service_exception_to_subscription() throws Exception verify(mSyncDelegate).fetchReportDetails(REPORT_URI); } + @Test + public void should_delegate_fetch_root_folders_call() throws Exception { + List folders = Collections.emptyList(); + when(mSyncDelegate.fetchRootFolders()).thenReturn(folders); + + TestSubscriber> test = new TestSubscriber<>(); + rxRepositoryService.fetchRootFolders().subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).fetchRootFolders(); + } + + @Test + public void root_folders_call_delegate_service_exception() throws Exception { + when(mSyncDelegate.fetchRootFolders()).thenThrow(mServiceException); + + TestSubscriber> test = new TestSubscriber<>(); + rxRepositoryService.fetchRootFolders().subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).fetchRootFolders(); + } + @Test public void should_accept_null_criteria() throws Exception { TestSubscriber test = new TestSubscriber<>(); From 6f5a815fb7ee92df7652c30c9852d7bf58f468f7 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 8 Jan 2016 16:33:43 +0200 Subject: [PATCH 385/457] Add input controls API within ReportService Extend ReportService api add support for input controls Add RX api for list controls Remove redundant checks in ReportService Add ReportService#listControlsValues(String, List) Add RxReportService#listControlsValues(String, List) --- .../sdk/network/InputControlRestApi.java | 24 ++- .../sdk/network/InputControlRestApiImpl.java | 29 ++-- .../jaspersoft/android/sdk/network/Utils.java | 41 ----- .../control/InputControlCollection.java | 3 +- .../control/InputControlStateCollection.java | 3 +- .../service/report/AbstractReportService.java | 33 ++-- .../sdk/service/report/ControlsApi.java | 73 +++++++++ .../service/report/ExportExecutionApi.java | 105 ++++++++++++- .../report/ExportExecutionApiImpl.java | 144 ------------------ .../service/report/ProxyReportService.java | 36 ++++- .../service/report/ReportExecutionApi.java | 97 +++++++++++- .../report/ReportExecutionApiImpl.java | 137 ----------------- .../sdk/service/report/ReportService.java | 12 ++ .../sdk/service/report/ReportService5_5.java | 3 +- .../service/report/ReportService5_6Plus.java | 3 +- .../service/report/ReportServiceFactory.java | 24 ++- .../sdk/network/InputControlRestApiTest.java | 15 +- .../report/AbstractReportServiceTest.java | 34 ++--- .../sdk/service/report/ControlsApiTest.java | 129 ++++++++++++++++ .../report/ExportExecutionApiTest.java | 4 +- .../report/ProxyReportServiceTest.java | 90 +++++++++++ .../api/InputControlRestApiTest.java | 10 +- .../service/rx/report/RxReportService.java | 11 ++ .../rx/report/RxReportServiceImpl.java | 43 ++++++ .../rx/report/RxReportServiceTest.java | 66 +++++++- 25 files changed, 753 insertions(+), 416 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ControlsApi.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ControlsApiTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index b259bc44..b5564e25 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -26,13 +26,11 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; - +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; import java.io.IOException; -import java.util.Collection; -import java.util.Map; -import java.util.Set; +import java.util.List; /** * @author Tom Koptel @@ -42,7 +40,7 @@ public interface InputControlRestApi { /** * Returns input controls for associated response. Options can be excluded by additional argument. - * + *

* ATTENTION: Exclude flag works only on JRS instances 6.0+ * * @param reportUri uri of report @@ -50,24 +48,24 @@ public interface InputControlRestApi { * @return unmodifiable list of {@link InputControl} */ @NotNull - Collection requestInputControls(@NotNull String reportUri, - boolean excludeState) throws HttpException, IOException; + List requestInputControls(@NotNull String reportUri, + boolean excludeState) throws HttpException, IOException; @NotNull - Collection requestInputControlsInitialStates(@NotNull String reportUri, - boolean freshData) throws HttpException, IOException; + List requestInputControlsInitialStates(@NotNull String reportUri, + boolean freshData) throws HttpException, IOException; /** * Provides values for specified controls. This API helpful to * delegate cascading resolving for the server, also should handle non-cascading cases * * @param reportUri uri of report - * @param controlsValues map of {control_id: [value, value]} associated input controls metadata + * @param parameters {control_id: [value, value]} associated with input controls * @param freshData whether data should be retrieved from cache or not * @return unmodifiable list of {@link InputControlState} */ @NotNull - Collection requestInputControlsStates(@NotNull String reportUri, - @NotNull Map> controlsValues, - boolean freshData) throws HttpException, IOException; + List requestInputControlsStates(@NotNull String reportUri, + @NotNull List parameters, + boolean freshData) throws HttpException, IOException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java index 556f7a1f..48ab71e5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java @@ -29,6 +29,7 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import retrofit.Call; @@ -36,9 +37,7 @@ import retrofit.http.*; import java.io.IOException; -import java.util.Collection; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Tom Koptel @@ -53,7 +52,7 @@ final class InputControlRestApiImpl implements InputControlRestApi { @NotNull @Override - public Collection requestInputControls(@Nullable String reportUri, + public List requestInputControls(@Nullable String reportUri, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); @@ -65,7 +64,7 @@ public Collection requestInputControls(@Nullable String reportUri, @NotNull @Override - public Collection requestInputControlsInitialStates(@Nullable String reportUri, + public List requestInputControlsInitialStates(@Nullable String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); @@ -76,14 +75,22 @@ public Collection requestInputControlsInitialStates(@Nullable @NotNull @Override - public Collection requestInputControlsStates(@Nullable String reportUri, - @Nullable Map> controlsValues, - boolean freshData) throws IOException, HttpException { + public List requestInputControlsStates(@NotNull String reportUri, + @NotNull List parameters, + boolean freshData) throws HttpException, IOException { Utils.checkNotNull(reportUri, "Report URI should not be null"); - Utils.checkNotNull(controlsValues, "Controls values should not be null"); + Utils.checkNotNull(parameters, "Parameters should not be null"); - String ids = Utils.joinString(";", controlsValues.keySet()); - Call call = mRestApi.requestInputControlsValues(reportUri, ids, controlsValues, freshData); + int capacity = parameters.size(); + Map> params = new HashMap<>(capacity); + for (int i = 0; i < capacity; i++) { + ReportParameter param = parameters.get(i); + params.put(param.getName(), param.getValue()); + } + + String ids = Utils.joinString(";", params.keySet()); + Call call = mRestApi.requestInputControlsValues(reportUri, + ids, params, freshData); InputControlStateCollection response = CallWrapper.wrap(call).body(); return response.get(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Utils.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Utils.java index 8c955e5a..f1cb46f1 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Utils.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Utils.java @@ -24,13 +24,6 @@ package com.jaspersoft.android.sdk.network; -import com.squareup.okhttp.ResponseBody; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - /** * @author Tom Koptel * @since 2.0 @@ -72,40 +65,6 @@ public static String normalizeBaseUrl(String url) { return url + "/"; } - public static String bodyToString(ResponseBody responseBody) { - try { - InputStream inputStream = responseBody.byteStream(); - return streamToString(inputStream); - } catch (IOException ex) { - return null; - } - } - - private static String streamToString(InputStream stream) throws IOException { - if (stream == null) { - return null; - } - - InputStreamReader is = new InputStreamReader(stream); - StringBuilder sb = new StringBuilder(); - BufferedReader br = new BufferedReader(is); - - try { - String read = br.readLine(); - while (read != null) { - sb.append(read); - read = br.readLine(); - } - return sb.toString(); - } finally { - try { - stream.close(); - } catch (IOException e) { - // close quietly - } - } - } - public static String joinString(CharSequence delimiter, Iterable tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java index 6a7fcca5..617f2477 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlCollection.java @@ -27,7 +27,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -import java.util.Collection; import java.util.Collections; import java.util.List; @@ -41,7 +40,7 @@ public final class InputControlCollection { @SerializedName(value = "inputControl") private List mValues = Collections.emptyList(); - public Collection get() { + public List get() { return mValues; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java index 1ad0b264..d1fc0375 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/control/InputControlStateCollection.java @@ -27,7 +27,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; -import java.util.Collection; import java.util.Collections; import java.util.List; @@ -41,7 +40,7 @@ public final class InputControlStateCollection { @SerializedName(value = "inputControlState") private List values = Collections.emptyList(); - public Collection get() { + public List get() { return values; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java index d6b38d48..f04d758e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java @@ -24,11 +24,14 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; + +import java.util.List; /** * @author Tom Koptel @@ -37,26 +40,25 @@ abstract class AbstractReportService extends ReportService { protected final ExportExecutionApi mExportExecutionApi; protected final ReportExecutionApi mReportExecutionApi; + protected final ControlsApi mControlsApi; protected final ExportFactory mExportFactory; protected final long mDelay; protected AbstractReportService(ExportExecutionApi exportExecutionApi, ReportExecutionApi reportExecutionApi, - ExportFactory exportFactory, long delay) { + ControlsApi controlsApi, + ExportFactory exportFactory, + long delay) { mExportExecutionApi = exportExecutionApi; mReportExecutionApi = reportExecutionApi; + mControlsApi = controlsApi; mExportFactory = exportFactory; mDelay = delay; } @NotNull @Override - public ReportExecution run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions) throws ServiceException { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - if (execOptions == null) { - execOptions = ReportExecutionOptions.builder().build(); - } - + public final ReportExecution run(@NotNull String reportUri, @NotNull ReportExecutionOptions execOptions) throws ServiceException { ReportExecutionDescriptor descriptor = mReportExecutionApi.start(reportUri, execOptions); String executionId = descriptor.getExecutionId(); mReportExecutionApi.awaitStatus(executionId, reportUri, mDelay, Status.execution(), Status.ready()); @@ -64,5 +66,18 @@ public ReportExecution run(@NotNull String reportUri, @Nullable ReportExecutionO return buildExecution(reportUri, executionId, execOptions); } + @NotNull + @Override + public final List listControls(@NotNull String reportUri) throws ServiceException { + return mControlsApi.requestControls(reportUri, false); + } + + @NotNull + @Override + public final List listControlsValues(@NotNull String reportUri, + @NotNull List parameters) throws ServiceException { + return mControlsApi.requestControlsValues(reportUri, parameters, true); + } + protected abstract ReportExecution buildExecution(String reportUri, String executionId, ReportExecutionOptions criteria); } \ No newline at end of file diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ControlsApi.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ControlsApi.java new file mode 100644 index 00000000..840dcc11 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ControlsApi.java @@ -0,0 +1,73 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.InputControlRestApi; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; + +import java.io.IOException; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class ControlsApi { + + private final ServiceExceptionMapper mExceptionMapper; + private final InputControlRestApi mRestApi; + + public ControlsApi(ServiceExceptionMapper exceptionMapper, InputControlRestApi restApi) { + mExceptionMapper = exceptionMapper; + mRestApi = restApi; + } + + public List requestControls(String reportUri, boolean excludeState) throws ServiceException { + try { + return mRestApi.requestInputControls(reportUri, excludeState); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + public List requestControlsValues(String reportUri, + List parameters, + boolean fresh) throws ServiceException { + try { + return mRestApi.requestInputControlsStates(reportUri, parameters, fresh); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java index 2ea54935..4b249544 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApi.java @@ -24,22 +24,117 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; +import com.jaspersoft.android.sdk.network.entity.export.OutputResource; import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; + +import java.io.IOException; /** * @author Tom Koptel * @since 2.0 */ -interface ExportExecutionApi { - ExportExecutionDescriptor start(String execId, ReportExportOptions options) throws ServiceException; +class ExportExecutionApi { + private final ServiceExceptionMapper mExceptionMapper; + private final ReportExportRestApi mReportExportRestApi; + private final ExportOptionsMapper mExportOptionsMapper; + + private final ReportExportMapper mReportExportMapper; + private final AttachmentExportMapper mAttachmentExportMapper; + + ExportExecutionApi(ServiceExceptionMapper exceptionMapper, + ReportExportRestApi reportExportRestApi, + ExportOptionsMapper exportOptionsMapper, + ReportExportMapper reportExportMapper, + AttachmentExportMapper attachmentExportMapper) { + mExceptionMapper = exceptionMapper; + mReportExportRestApi = reportExportRestApi; + mExportOptionsMapper = exportOptionsMapper; + mReportExportMapper = reportExportMapper; + mAttachmentExportMapper = attachmentExportMapper; + } + + public ExportExecutionDescriptor start(String execId, ReportExportOptions reportExportOptions) throws ServiceException { + ExecutionRequestOptions options = mExportOptionsMapper.transform(reportExportOptions); + try { + return mReportExportRestApi.runExportExecution(execId, options); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + public ExecutionStatus awaitReadyStatus(String execId, String exportId, String reportUri, long delay) throws ServiceException { + ExecutionStatus executionStatus; + ErrorDescriptor descriptor; + Status status; + + do { + executionStatus = getStatus(execId, exportId); + status = Status.wrap(executionStatus.getStatus()); + descriptor = executionStatus.getErrorDescriptor(); + if (status.isCancelled()) { + throw new ServiceException( + String.format("Export for report '%s' execution cancelled", reportUri), null, + StatusCodes.EXPORT_EXECUTION_CANCELLED); + } + if (status.isFailed()) { + String message = "Failed to perform report export"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.EXPORT_EXECUTION_FAILED); + } + try { + Thread.sleep(delay); + } catch (InterruptedException ex) { + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); + } + } while (!status.isReady()); + + return executionStatus; + } - ExecutionStatus awaitReadyStatus(String execId, String exportId, String reportUri, long delay) throws ServiceException; + public ReportExportOutput downloadExport(String execId, String exportId) throws ServiceException { + try { + ExportOutputResource result = mReportExportRestApi.requestExportOutput(execId, exportId); + return mReportExportMapper.transform(result); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } - ReportExportOutput downloadExport(String execId, String exportId) throws ServiceException; + public ResourceOutput downloadAttachment(String execId, String exportId, String attachmentId) throws ServiceException { + try { + OutputResource result = mReportExportRestApi.requestExportAttachment(execId, exportId, attachmentId); + return mAttachmentExportMapper.transform(result); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } - ResourceOutput downloadAttachment(String execId, String exportId, String attachmentId) throws ServiceException; + private ExecutionStatus getStatus(String execId, String exportId) throws ServiceException { + try { + return mReportExportRestApi.checkExportExecutionStatus(execId, exportId); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java deleted file mode 100644 index ff515ca6..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.ReportExportRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ExportExecutionApiImpl implements ExportExecutionApi { - private final ServiceExceptionMapper mExceptionMapper; - private final ReportExportRestApi mReportExportRestApi; - private final ExportOptionsMapper mExportOptionsMapper; - - private final ReportExportMapper mReportExportMapper; - private final AttachmentExportMapper mAttachmentExportMapper; - - ExportExecutionApiImpl(ServiceExceptionMapper exceptionMapper, - ReportExportRestApi reportExportRestApi, - ExportOptionsMapper exportOptionsMapper, - ReportExportMapper reportExportMapper, - AttachmentExportMapper attachmentExportMapper) { - mExceptionMapper = exceptionMapper; - mReportExportRestApi = reportExportRestApi; - mExportOptionsMapper = exportOptionsMapper; - mReportExportMapper = reportExportMapper; - mAttachmentExportMapper = attachmentExportMapper; - } - - @Override - public ExportExecutionDescriptor start(String execId, ReportExportOptions reportExportOptions) throws ServiceException { - ExecutionRequestOptions options = mExportOptionsMapper.transform(reportExportOptions); - try { - return mReportExportRestApi.runExportExecution(execId, options); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } - - @Override - public ExecutionStatus awaitReadyStatus(String execId, String exportId, String reportUri, long delay) throws ServiceException { - ExecutionStatus executionStatus; - ErrorDescriptor descriptor; - Status status; - - do { - executionStatus = getStatus(execId, exportId); - status = Status.wrap(executionStatus.getStatus()); - descriptor = executionStatus.getErrorDescriptor(); - if (status.isCancelled()) { - throw new ServiceException( - String.format("Export for report '%s' execution cancelled", reportUri), null, - StatusCodes.EXPORT_EXECUTION_CANCELLED); - } - if (status.isFailed()) { - String message = "Failed to perform report export"; - if (descriptor != null) { - message = descriptor.getMessage(); - } - throw new ServiceException(message, null, StatusCodes.EXPORT_EXECUTION_FAILED); - } - try { - Thread.sleep(delay); - } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); - } - } while (!status.isReady()); - - return executionStatus; - } - - @Override - public ReportExportOutput downloadExport(String execId, String exportId) throws ServiceException { - try { - ExportOutputResource result = mReportExportRestApi.requestExportOutput(execId, exportId); - return mReportExportMapper.transform(result); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } - - @Override - public ResourceOutput downloadAttachment(String execId, String exportId, String attachmentId) throws ServiceException { - try { - OutputResource result = mReportExportRestApi.requestExportAttachment(execId, exportId, attachmentId); - return mAttachmentExportMapper.transform(result); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } - - private ExecutionStatus getStatus(String execId, String exportId) throws ServiceException { - try { - return mReportExportRestApi.checkExportExecutionStatus(execId, exportId); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java index f738b414..34c38fe4 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java @@ -24,9 +24,15 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; /** * @author Tom Koptel @@ -42,13 +48,35 @@ final class ProxyReportService extends ReportService { @NotNull @Override - public ReportExecution run(@NotNull String reportUri, - @NotNull ReportExecutionOptions execOptions) throws ServiceException { + public ReportExecution run(@Nullable String reportUri, + @Nullable ReportExecutionOptions execOptions) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + if (execOptions == null) { + execOptions = ReportExecutionOptions.builder().build(); + } + return getDelegate().run(reportUri, execOptions); + } + + @NotNull + @Override + public List listControls(@Nullable String reportUri) throws ServiceException { Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - Preconditions.checkNotNull(execOptions, "Criteria should not be null"); + return getDelegate().listControls(reportUri); + } + + @NotNull + @Override + public List listControlsValues(@Nullable String reportUri, + @Nullable List parameters) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + return getDelegate().listControlsValues(reportUri, parameters); + } + + private ReportService getDelegate() throws ServiceException { if (mDelegate == null) { mDelegate = mServiceFactory.newService(); } - return mDelegate.run(reportUri, execOptions); + return mDelegate; } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java index 4c6d6b7b..fd50905e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApi.java @@ -24,23 +24,110 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; +import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.exception.StatusCodes; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import java.io.IOException; +import java.util.Arrays; import java.util.List; /** * @author Tom Koptel * @since 2.0 */ -interface ReportExecutionApi { - ReportExecutionDescriptor start(String reportUri, ReportExecutionOptions execOptions) throws ServiceException; +class ReportExecutionApi { + private final ServiceExceptionMapper mExceptionMapper; + private final ReportExecutionRestApi mReportExecutionRestApi; + private final ReportOptionsMapper mReportOptionsMapper; - void update(String executionId, List params) throws ServiceException; + ReportExecutionApi( + ServiceExceptionMapper exceptionMapper, + ReportExecutionRestApi reportExecutionRestApi, + ReportOptionsMapper reportOptionsMapper) { + mExceptionMapper = exceptionMapper; + mReportExecutionRestApi = reportExecutionRestApi; + mReportOptionsMapper = reportOptionsMapper; + } - ReportExecutionDescriptor getDetails(String execId) throws ServiceException; + public ReportExecutionDescriptor start(String reportUri, ReportExecutionOptions execOptions) throws ServiceException { + ReportExecutionRequestOptions options = mReportOptionsMapper.transform(reportUri, execOptions); + try { + return mReportExecutionRestApi.runReportExecution(options); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } - ExecutionStatus awaitStatus(String execId, String reportUri, long delay, Status... statuses) throws ServiceException; + public void update(String executionId, List params) throws ServiceException { + try { + mReportExecutionRestApi.updateReportExecution(executionId, params); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + public ReportExecutionDescriptor getDetails(String execId) throws ServiceException { + try { + return mReportExecutionRestApi.requestReportExecutionDetails(execId); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + public ExecutionStatus awaitStatus(String execId, String reportUri, long delay, Status... statuses) throws ServiceException { + ExecutionStatus nextDetails; + ErrorDescriptor descriptor; + Status status; + + List expectedStatuses = Arrays.asList(statuses); + do { + nextDetails = getStatus(execId); + descriptor = nextDetails.getErrorDescriptor(); + status = Status.wrap(nextDetails.getStatus()); + + if (status.isCancelled()) { + throw new ServiceException( + String.format("Report '%s' execution cancelled", reportUri), null, + StatusCodes.REPORT_EXECUTION_CANCELLED); + } + if (status.isFailed()) { + String message = "Failed to perform report execute"; + if (descriptor != null) { + message = descriptor.getMessage(); + } + throw new ServiceException(message, null, StatusCodes.REPORT_EXECUTION_FAILED); + } + try { + Thread.sleep(delay); + } catch (InterruptedException ex) { + throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); + } + } while (!expectedStatuses.contains(status)); + + return nextDetails; + } + + private ExecutionStatus getStatus(String execId) throws ServiceException { + try { + return mReportExecutionRestApi.requestReportExecutionStatus(execId); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java deleted file mode 100644 index 93052c65..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecutionApiImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; -import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ReportExecutionApiImpl implements ReportExecutionApi { - private final ServiceExceptionMapper mExceptionMapper; - private final ReportExecutionRestApi mReportExecutionRestApi; - private final ReportOptionsMapper mReportOptionsMapper; - - ReportExecutionApiImpl( - ServiceExceptionMapper exceptionMapper, - ReportExecutionRestApi reportExecutionRestApi, - ReportOptionsMapper reportOptionsMapper) { - mExceptionMapper = exceptionMapper; - mReportExecutionRestApi = reportExecutionRestApi; - mReportOptionsMapper = reportOptionsMapper; - } - - @Override - public ReportExecutionDescriptor start(String reportUri, ReportExecutionOptions execOptions) throws ServiceException { - ReportExecutionRequestOptions options = mReportOptionsMapper.transform(reportUri, execOptions); - try { - return mReportExecutionRestApi.runReportExecution(options); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } - - @Override - public void update(String executionId, List params) throws ServiceException { - try { - mReportExecutionRestApi.updateReportExecution(executionId, params); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } - - @Override - public ReportExecutionDescriptor getDetails(String execId) throws ServiceException { - try { - return mReportExecutionRestApi.requestReportExecutionDetails(execId); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } - - @Override - public ExecutionStatus awaitStatus(String execId, String reportUri, long delay, Status... statuses) throws ServiceException { - ExecutionStatus nextDetails; - ErrorDescriptor descriptor; - Status status; - - List expectedStatuses = Arrays.asList(statuses); - do { - nextDetails = getStatus(execId); - descriptor = nextDetails.getErrorDescriptor(); - status = Status.wrap(nextDetails.getStatus()); - - if (status.isCancelled()) { - throw new ServiceException( - String.format("Report '%s' execution cancelled", reportUri), null, - StatusCodes.REPORT_EXECUTION_CANCELLED); - } - if (status.isFailed()) { - String message = "Failed to perform report execute"; - if (descriptor != null) { - message = descriptor.getMessage(); - } - throw new ServiceException(message, null, StatusCodes.REPORT_EXECUTION_FAILED); - } - try { - Thread.sleep(delay); - } catch (InterruptedException ex) { - throw new ServiceException("Unexpected error", ex, StatusCodes.UNDEFINED_ERROR); - } - } while (!expectedStatuses.contains(status)); - - return nextDetails; - } - - private ExecutionStatus getStatus(String execId) throws ServiceException { - try { - return mReportExecutionRestApi.requestReportExecutionStatus(execId); - } catch (HttpException e) { - throw mExceptionMapper.transform(e); - } catch (IOException e) { - throw mExceptionMapper.transform(e); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index 27016292..fa29ab3f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -25,6 +25,9 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.Preconditions; @@ -35,6 +38,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; import java.util.concurrent.TimeUnit; /** @@ -45,6 +49,13 @@ public abstract class ReportService { @NotNull public abstract ReportExecution run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions) throws ServiceException; + @NotNull + public abstract List listControls(@NotNull String reportUri) throws ServiceException; + + @NotNull + public abstract List listControlsValues(@NotNull String reportUri, + @NotNull List parameters) throws ServiceException; + @NotNull public static ReportService newService(@NotNull AuthorizedClient client) { Preconditions.checkNotNull(client, "Client should not be null"); @@ -56,6 +67,7 @@ public static ReportService newService(@NotNull AuthorizedClient client) { ReportServiceFactory reportServiceFactory = new ReportServiceFactory(cacheManager, client.reportExecutionApi(), client.reportExportApi(), + client.inputControlApi(), reportMapper, client.getBaseUrl(), TimeUnit.SECONDS.toMillis(1) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java index df81fdd4..efdaf3a5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java @@ -31,9 +31,10 @@ final class ReportService5_5 extends AbstractReportService { protected ReportService5_5(ExportExecutionApi exportExecutionApi, ReportExecutionApi reportExecutionApi, + ControlsApi controlsApi, ExportFactory exportFactory, long delay) { - super(exportExecutionApi, reportExecutionApi, exportFactory, delay); + super(exportExecutionApi, reportExecutionApi, controlsApi, exportFactory, delay); } @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java index 84ad7cde..92b0a090 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java @@ -31,9 +31,10 @@ final class ReportService5_6Plus extends AbstractReportService { protected ReportService5_6Plus(ExportExecutionApi exportExecutionApi, ReportExecutionApi reportExecutionApi, + ControlsApi controlsApi, ExportFactory exportFactory, long delay) { - super(exportExecutionApi, reportExecutionApi, exportFactory, delay); + super(exportExecutionApi, reportExecutionApi, controlsApi, exportFactory, delay); } @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java index 651a9581..34a5637d 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.service.report; +import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; @@ -41,6 +42,7 @@ class ReportServiceFactory { private final InfoCacheManager mCacheManager; private final ReportExecutionRestApi mReportExecutionRestApi; private final ReportExportRestApi mReportExportRestApi; + private final InputControlRestApi mInputControlRestApi; private final ServiceExceptionMapper mExceptionMapper; private final String mBaseUrl; private final long mDelay; @@ -49,11 +51,12 @@ class ReportServiceFactory { ReportServiceFactory(InfoCacheManager cacheManager, ReportExecutionRestApi reportExecutionRestApi, ReportExportRestApi reportExportRestApi, - ServiceExceptionMapper exceptionMapper, + InputControlRestApi inputControlRestApi, ServiceExceptionMapper exceptionMapper, String baseUrl, long delay) { mCacheManager = cacheManager; mReportExecutionRestApi = reportExecutionRestApi; mReportExportRestApi = reportExportRestApi; + mInputControlRestApi = inputControlRestApi; mExceptionMapper = exceptionMapper; mBaseUrl = baseUrl; mDelay = delay; @@ -72,22 +75,33 @@ public ReportService newService() throws ServiceException { AttachmentsFactory attachmentsFactory = new AttachmentsFactory(exportExecutionApi); ExportFactory exportFactory = new ExportFactory(exportExecutionApi, attachmentsFactory); + ControlsApi controlsApi = new ControlsApi(mExceptionMapper, mInputControlRestApi); if (version.lessThanOrEquals(ServerVersion.v5_5)) { - return new ReportService5_5(exportExecutionApi, reportExecutionApi, exportFactory, mDelay); + return new ReportService5_5( + exportExecutionApi, + reportExecutionApi, + controlsApi, + exportFactory, + mDelay); } else { - return new ReportService5_6Plus(exportExecutionApi, reportExecutionApi,exportFactory, mDelay); + return new ReportService5_6Plus( + exportExecutionApi, + reportExecutionApi, + controlsApi, + exportFactory, + mDelay); } } @NotNull private ReportExecutionApi createReportExecApi(ReportOptionsMapper reportOptionsMapper) { - return new ReportExecutionApiImpl(mExceptionMapper, mReportExecutionRestApi, reportOptionsMapper); + return new ReportExecutionApi(mExceptionMapper, mReportExecutionRestApi, reportOptionsMapper); } @NotNull private ExportExecutionApi createExportExecApi(ExportOptionsMapper exportOptionsMapper) { ReportExportMapper reportExportMapper = new ReportExportMapper(); AttachmentExportMapper attachmentExportMapper = new AttachmentExportMapper(); - return new ExportExecutionApiImpl(mExceptionMapper, mReportExportRestApi, exportOptionsMapper, reportExportMapper, attachmentExportMapper); + return new ExportExecutionApi(mExceptionMapper, mReportExportRestApi, exportOptionsMapper, reportExportMapper, attachmentExportMapper); } } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index 82b67a82..d84cbc11 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -26,6 +26,7 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; import com.jaspersoft.android.sdk.test.resource.ResourceFile; @@ -90,13 +91,13 @@ public void requestInputControlsShouldNotAllowNullReportUri() throws Exception { public void requestInputControlsStatesShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); - restApiUnderTest.requestInputControlsStates(null, Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates(null, Collections.emptyList(), true); } @Test public void requestInputControlsStatesShouldNotAllowNullControlParams() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Controls values should not be null"); + mExpectedException.expectMessage("Parameters should not be null"); restApiUnderTest.requestInputControlsStates("any_id", null, true); } @@ -118,7 +119,7 @@ public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() throws public void requestInputControlsStatesShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.requestInputControlsStates("any_id", Collections.EMPTY_MAP, true); + restApiUnderTest.requestInputControlsStates("any_id", Collections.emptyList(), true); } @Test @@ -136,10 +137,10 @@ public void apiShouldProvideListOfInputControlsInitialStatesWithFreshData() thro @Test public void apiShouldProvideFreshStatesForInputControls() throws Exception { - Map> parameters = new HashMap<>(); - Set values = new HashSet<>(); - values.add("19"); - parameters.put("sales_fact_ALL__store_sales_2013_1", values); + List parameters = + Collections.singletonList( + new ReportParameter("sales_fact_ALL__store_sales_2013_1", + Collections.singleton("19"))); MockResponse mockResponse = MockResponseFactory.create200() .setBody(icsStates.asString()); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java index 8985a5d4..18b18779 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java @@ -25,27 +25,23 @@ package com.jaspersoft.android.sdk.service.report; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.Collections; +import java.util.List; + import static com.jaspersoft.android.sdk.service.report.Status.execution; import static com.jaspersoft.android.sdk.service.report.Status.ready; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.rules.ExpectedException.none; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @RunWith(PowerMockRunner.class) @PrepareForTest({ @@ -61,14 +57,13 @@ public class AbstractReportServiceTest { @Mock ReportExecutionApi mReportExecutionApi; @Mock + ControlsApi mControlsApi; + @Mock ExportFactory mExportFactory; @Mock ReportExecutionDescriptor mReportExecutionDescriptor; - @Rule - public ExpectedException expected = none(); - private AbstractReportService reportService; @Before @@ -77,6 +72,7 @@ public void setUp() throws Exception { reportService = new AbstractReportService( mExportExecutionApi, mReportExecutionApi, + mControlsApi, mExportFactory, 0) { @Override @@ -102,15 +98,15 @@ public void testRun() throws Exception { } @Test - public void should_not_run_with_null_uri() throws Exception { - expected.expect(NullPointerException.class); - expected.expectMessage("Report uri should not be null"); - - reportService.run(null, null); + public void should_request_controls() throws Exception { + reportService.listControls(REPORT_URI); + verify(mControlsApi).requestControls(REPORT_URI, false); } @Test - public void should_run_with_null_options() throws Exception { - reportService.run(REPORT_URI, null); + public void should_request_controls_values() throws Exception { + List parameters = Collections.emptyList(); + reportService.listControlsValues(REPORT_URI, parameters); + verify(mControlsApi).requestControlsValues(REPORT_URI, parameters, true); } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ControlsApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ControlsApiTest.java new file mode 100644 index 00000000..6b4f3281 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ControlsApiTest.java @@ -0,0 +1,129 @@ +/* + * Copyright © 2015 TIBCO Software, Inc. All rights reserved. + * http://community.jaspersoft.com/project/jaspermobile-android + * + * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, + * the following license terms apply: + * + * This program is part of TIBCO Jaspersoft Mobile for Android. + * + * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with TIBCO Jaspersoft Mobile for Android. If not, see + * . + */ + +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.InputControlRestApi; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import static junit.framework.TestCase.fail; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ControlsApiTest { + private static final String REPORT_URI = "my/uri"; + private static final List PARAMS = Collections.emptyList(); + + @Mock + ServiceExceptionMapper mExceptionMapper; + @Mock + InputControlRestApi mRestApi; + + @Mock + IOException mIOException; + @Mock + HttpException mHttpException; + @Mock + ServiceException mServiceException; + + private ControlsApi controlsApi; + + @Before + public void setUp() throws Exception { + initMocks(this); + controlsApi = new ControlsApi(mExceptionMapper, mRestApi); + + when(mExceptionMapper.transform(any(HttpException.class))).thenReturn(mServiceException); + when(mExceptionMapper.transform(any(IOException.class))).thenReturn(mServiceException); + } + + @Test + public void should_request_controls() throws Exception { + controlsApi.requestControls(REPORT_URI, false); + verify(mRestApi).requestInputControls(REPORT_URI, false); + } + + @Test + public void request_controls_adapt_io_exception() throws Exception { + when(mRestApi.requestInputControls(anyString(), anyBoolean())).thenThrow(mIOException); + try { + controlsApi.requestControls(REPORT_URI, false); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void request_controls_adapt_http_exception() throws Exception { + when(mRestApi.requestInputControls(anyString(), anyBoolean())).thenThrow(mHttpException); + try { + controlsApi.requestControls(REPORT_URI, false); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + + @Test + public void request_controls_values_adapt_io_exception() throws Exception { + when(mRestApi.requestInputControlsStates(anyString(), anyListOf(ReportParameter.class), anyBoolean())).thenThrow(mIOException); + try { + controlsApi.requestControlsValues(REPORT_URI, PARAMS, false); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void request_controls_values_adapt_http_exception() throws Exception { + when(mRestApi.requestInputControlsStates(anyString(), anyListOf(ReportParameter.class), anyBoolean())).thenThrow(mHttpException); + try { + controlsApi.requestControlsValues(REPORT_URI, PARAMS, false); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + @Test + public void should_request_controls_values() throws Exception { + controlsApi.requestControlsValues(REPORT_URI, PARAMS, false); + verify(mRestApi).requestInputControlsStates(REPORT_URI, PARAMS, false); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java index 44cba779..73ea2631 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportExecutionApiTest.java @@ -87,12 +87,12 @@ public class ExportExecutionApiTest { @Mock ExecutionRequestOptions mExecutionRequestOptions; - private ExportExecutionApiImpl exportExecutionApi; + private ExportExecutionApi exportExecutionApi; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - exportExecutionApi = new ExportExecutionApiImpl( + exportExecutionApi = new ExportExecutionApi( mServiceExceptionMapper, mReportExportRestApi, mExportOptionsMapper, diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java new file mode 100644 index 00000000..833e9b90 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java @@ -0,0 +1,90 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; + +import java.util.Collections; +import java.util.List; + +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ProxyReportServiceTest { + + private static final String REPORT_URI = "/my/uri"; + + @Mock + ReportServiceFactory mReportServiceFactory; + @Mock + ReportService mReportService; + + private ProxyReportService proxyReportService; + + @Rule + public ExpectedException expected = none(); + + @Before + public void setUp() throws Exception { + initMocks(this); + when(mReportServiceFactory.newService()).thenReturn(mReportService); + proxyReportService = new ProxyReportService(mReportServiceFactory); + } + + @Test + public void should_not_run_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + proxyReportService.run(null, null); + } + + @Test + public void should_delegate_run_call() throws Exception { + proxyReportService.run(REPORT_URI, null); + verify(mReportServiceFactory).newService(); + verify(mReportService).run(eq(REPORT_URI), any(ReportExecutionOptions.class)); + } + + @Test + public void should_delegate_list_controls_call() throws Exception { + proxyReportService.listControls(REPORT_URI); + verify(mReportServiceFactory).newService(); + verify(mReportService).listControls(eq(REPORT_URI)); + } + + @Test + public void should_not_list_controls_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + proxyReportService.listControls(null); + } + + @Test + public void should_not_list_controls_values_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Parameters should not be null"); + proxyReportService.listControlsValues(REPORT_URI, null); + } + + @Test + public void should_not_list_controls_with_null_parameters() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + proxyReportService.listControlsValues(null, Collections.emptyList()); + } + + @Test + public void should_delegate_load_cascade_controls_call() throws Exception { + List parameters = Collections.emptyList(); + proxyReportService.listControlsValues(REPORT_URI, parameters); + verify(mReportServiceFactory).newService(); + verify(mReportService).listControlsValues(REPORT_URI, parameters); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java index 4778ed43..80a335c7 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/InputControlRestApiTest.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.junit.BeforeClass; import org.junit.Test; @@ -44,13 +45,8 @@ public class InputControlRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/01._Geographic_Results_by_Segment_Report"; - public static final Map> CONTROL_PARAMETERS = new HashMap<>(); - - static { - Set values = new HashSet<>(); - values.add("19"); - CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); - } + public static final List CONTROL_PARAMETERS = + Collections.singletonList(new ReportParameter("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19"))); private final static LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); private static InputControlRestApi apiUnderTest; diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java index 8e9bff14..3c95c431 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java @@ -25,6 +25,9 @@ package com.jaspersoft.android.sdk.service.rx.report; import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; import com.jaspersoft.android.sdk.service.report.ReportService; @@ -32,6 +35,8 @@ import org.jetbrains.annotations.Nullable; import rx.Observable; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 @@ -40,6 +45,12 @@ public abstract class RxReportService { @NotNull public abstract Observable run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions); + @NotNull + public abstract Observable> listControls(@NotNull String reportUri); + + @NotNull + public abstract Observable> listControlsValues(@NotNull String reportUri, @NotNull List parameters); + @NotNull public static RxReportService newService(@NotNull AuthorizedClient authorizedClient) { Preconditions.checkNotNull(authorizedClient, "Client should not be null"); diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java index e2aa84ec..ee0a84cb 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java @@ -24,6 +24,9 @@ package com.jaspersoft.android.sdk.service.rx.report; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.report.ReportExecution; @@ -35,6 +38,8 @@ import rx.Observable; import rx.functions.Func0; +import java.util.List; + /** * @author Tom Koptel * @since 2.0 @@ -65,4 +70,42 @@ public Observable call() { } }); } + + @NotNull + @Override + public Observable> listControls(@NotNull final String reportUri) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List inputControls = mSyncDelegate.listControls(reportUri); + return Observable.just(inputControls); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + @Override + public Observable> listControlsValues(@NotNull final String reportUri, + @NotNull final List parameters) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List inputControlStates = mSyncDelegate.listControlsValues(reportUri, parameters); + return Observable.just(inputControlStates); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java index 265a4934..e4ca56b4 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java @@ -25,6 +25,9 @@ package com.jaspersoft.android.sdk.service.rx.report; import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.report.ReportExecution; import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; @@ -36,10 +39,14 @@ import org.mockito.Mock; import rx.observers.TestSubscriber; +import java.util.Collections; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.rules.ExpectedException.none; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyListOf; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -48,6 +55,7 @@ public class RxReportServiceTest { private static final String REPORT_URI = "my/uri"; private static final ReportExecutionOptions OPTIONS = ReportExecutionOptions.builder().build(); + private static final List PARAMS = Collections.emptyList(); @Mock ReportService mSyncDelegate; @@ -87,7 +95,7 @@ public void should_run_with_null_options() { } @Test - public void should_execute_delegate_as_observable() throws Exception { + public void should_execute_delegate_as_observable_on_run() throws Exception { when(mSyncDelegate.run(anyString(), any(ReportExecutionOptions.class))).thenReturn(mReportExecution); TestSubscriber test = TestSubscriber.create(); @@ -113,6 +121,62 @@ public void should_delegate_service_exception_to_subscription() throws Exception verify(mSyncDelegate).run(REPORT_URI, OPTIONS); } + + @Test + public void should_delegate_service_exception_to_subscription_on_list_controls() throws Exception { + when(mSyncDelegate.listControls(anyString())).thenThrow(mServiceException); + + TestSubscriber> test = TestSubscriber.create(); + rxReportService.listControls(REPORT_URI).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).listControls(REPORT_URI); + } + + @Test + public void should_execute_delegate_as_observable_on_list_controls() throws Exception { + when(mSyncDelegate.listControls(anyString())).thenReturn(Collections.emptyList()); + + TestSubscriber> test = TestSubscriber.create(); + rxReportService.listControls(REPORT_URI).subscribe(test); + + test.assertCompleted(); + test.assertNoErrors(); + test.assertValueCount(1); + + verify(mSyncDelegate).listControls(REPORT_URI); + } + + @Test + public void should_delegate_service_exception_to_subscription_on_list_controls_values() throws Exception { + when(mSyncDelegate.listControlsValues(anyString(), anyListOf(ReportParameter.class))).thenThrow(mServiceException); + + TestSubscriber> test = TestSubscriber.create(); + rxReportService.listControlsValues(REPORT_URI, PARAMS).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).listControlsValues(REPORT_URI, PARAMS); + } + + @Test + public void should_execute_delegate_as_observable_on_list_controls_values() throws Exception { + when(mSyncDelegate.listControlsValues(anyString(), anyListOf(ReportParameter.class))) + .thenReturn(Collections.emptyList()); + + TestSubscriber> test = TestSubscriber.create(); + rxReportService.listControlsValues(REPORT_URI, PARAMS).subscribe(test); + + test.assertCompleted(); + test.assertNoErrors(); + test.assertValueCount(1); + + verify(mSyncDelegate).listControlsValues(REPORT_URI, PARAMS); + } + @Test public void should_provide_impl_with_factory_method() throws Exception { RxReportService service = RxReportService.newService(mAuthorizedClient); From 7bdd4f316a490150d24125a19c1c362f2ee259c3 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 13 Jan 2016 11:08:38 +0200 Subject: [PATCH 386/457] Add support for report parameters CRUD in ReportService Unify report params mapping Unify report params related argument on Report Options API Add ReportService#listReportOptions(String) Add RxReportService#listReportOptions(String) Add ReportService#createReportOption(String, String, List, Boolean) Add RxReportService#createReportOption(String, String, List, Boolean) Add ReportService#updateReportOption(String, String, List) Add RxReportService#updateReportOption(String, String, List) Add ReportService#deleteReportOption(String, String) Add RxReportService#deleteReportOption(String, String) --- .../sdk/network/InputControlRestApiImpl.java | 8 +- .../sdk/network/ReportOptionRestApi.java | 8 +- .../sdk/network/ReportOptionRestApiImpl.java | 18 +- .../sdk/network/ReportParamsMapper.java | 26 +++ .../entity/report/option/ReportOption.java | 14 +- .../service/report/AbstractReportService.java | 30 +++ .../service/report/ProxyReportService.java | 39 ++++ .../service/report/ReportOptionsUseCase.java | 69 +++++++ .../sdk/service/report/ReportService.java | 22 ++- .../sdk/service/report/ReportService5_5.java | 3 +- .../service/report/ReportService5_6Plus.java | 3 +- .../service/report/ReportServiceFactory.java | 11 +- .../sdk/network/ReportOptionRestApiTest.java | 33 ++-- .../sdk/network/ReportParamsMapperTest.java | 27 +++ .../report/option/ReportOptionTest.java | 14 +- .../report/AbstractReportServiceTest.java | 30 +++ .../report/ProxyReportServiceTest.java | 86 +++++++++ .../report/ReportOptionsUseCaseTest.java | 177 ++++++++++++++++++ .../api/ReportOptionRestApiTest.java | 21 +-- .../service/rx/report/RxReportService.java | 20 ++ .../rx/report/RxReportServiceImpl.java | 82 ++++++++ .../rx/report/RxReportServiceTest.java | 118 +++++++++++- 22 files changed, 794 insertions(+), 65 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ReportParamsMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCase.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/ReportParamsMapperTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCaseTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java index 48ab71e5..e208b83c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java @@ -81,13 +81,7 @@ public List requestInputControlsStates(@NotNull String report Utils.checkNotNull(reportUri, "Report URI should not be null"); Utils.checkNotNull(parameters, "Parameters should not be null"); - int capacity = parameters.size(); - Map> params = new HashMap<>(capacity); - for (int i = 0; i < capacity; i++) { - ReportParameter param = parameters.get(i); - params.put(param.getName(), param.getValue()); - } - + Map> params = ReportParamsMapper.INSTANCE.toMap(parameters); String ids = Utils.joinString(";", params.keySet()); Call call = mRestApi.requestInputControlsValues(reportUri, ids, params, freshData); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java index c7b2597c..f13e58dc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java @@ -24,12 +24,12 @@ package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; - import org.jetbrains.annotations.NotNull; import java.io.IOException; -import java.util.Map; +import java.util.List; import java.util.Set; /** @@ -44,12 +44,12 @@ public interface ReportOptionRestApi { @NotNull ReportOption createReportOption(@NotNull String reportUnitUri, @NotNull String optionLabel, - @NotNull Map> controlsValues, + @NotNull List parameters, boolean overwrite) throws HttpException, IOException; void updateReportOption(@NotNull String reportUnitUri, @NotNull String optionId, - @NotNull Map> controlsValues) throws HttpException, IOException; + @NotNull List parameters) throws HttpException, IOException; void deleteReportOption(@NotNull String reportUnitUri, @NotNull String optionId) throws HttpException, IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java index 7a8e85f5..81f96bc5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java @@ -25,6 +25,7 @@ package com.jaspersoft.android.sdk.network; import com.google.gson.JsonSyntaxException; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; import com.squareup.okhttp.Response; @@ -36,6 +37,7 @@ import java.io.IOException; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; @@ -75,32 +77,32 @@ public Set requestReportOptionsList( public ReportOption createReportOption( @Nullable String reportUnitUri, @Nullable String optionLabel, - @Nullable Map> controlsValues, + @Nullable List parameters, boolean overwrite) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionLabel, "Option label should not be null"); - Utils.checkNotNull(controlsValues, "Controls values should not be null"); + Utils.checkNotNull(parameters, "Parameters values should not be null"); + Map> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite); return CallWrapper.wrap(call).body(); } @Override - public void updateReportOption( - @Nullable String reportUnitUri, + public void updateReportOption(@Nullable String reportUnitUri, @Nullable String optionId, - @Nullable Map> controlsValues) throws IOException, HttpException { + @Nullable List parameters) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); - Utils.checkNotNull(controlsValues, "Controls values should not be null"); + Utils.checkNotNull(parameters, "Parameters values should not be null"); + Map> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues); CallWrapper.wrap(call).body(); } @Override - public void deleteReportOption( - @Nullable String reportUnitUri, + public void deleteReportOption(@Nullable String reportUnitUri, @Nullable String optionId) throws IOException, HttpException { Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); Utils.checkNotNull(optionId, "Option id should not be null"); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportParamsMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportParamsMapper.java new file mode 100644 index 00000000..7e577bae --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportParamsMapper.java @@ -0,0 +1,26 @@ +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +enum ReportParamsMapper { + INSTANCE; + + public Map> toMap(List parameters) { + int capacity = parameters.size(); + Map> params = new HashMap<>(capacity); + for (int i = 0; i < capacity; i++) { + ReportParameter param = parameters.get(i); + params.put(param.getName(), param.getValue()); + } + return params; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java index 59df6651..633fa323 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOption.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.network.entity.report.option; import com.google.gson.annotations.Expose; - import org.jetbrains.annotations.NotNull; /** @@ -63,17 +62,18 @@ public boolean equals(Object o) { ReportOption that = (ReportOption) o; - if (!uri.equals(that.uri)) return false; - if (!id.equals(that.id)) return false; - return label.equals(that.label); + if (id != null ? !id.equals(that.id) : that.id != null) return false; + if (label != null ? !label.equals(that.label) : that.label != null) return false; + if (uri != null ? !uri.equals(that.uri) : that.uri != null) return false; + return true; } @Override public int hashCode() { - int result = uri.hashCode(); - result = 31 * result + id.hashCode(); - result = 31 * result + label.hashCode(); + int result = uri != null ? uri.hashCode() : 0; + result = 31 * result + (id != null ? id.hashCode() : 0); + result = 31 * result + (label != null ? label.hashCode() : 0); return result; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java index f04d758e..1015a939 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportService.java @@ -28,10 +28,12 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; import java.util.List; +import java.util.Set; /** * @author Tom Koptel @@ -40,17 +42,20 @@ abstract class AbstractReportService extends ReportService { protected final ExportExecutionApi mExportExecutionApi; protected final ReportExecutionApi mReportExecutionApi; + protected final ReportOptionsUseCase mReportOptionsUseCase; protected final ControlsApi mControlsApi; protected final ExportFactory mExportFactory; protected final long mDelay; protected AbstractReportService(ExportExecutionApi exportExecutionApi, ReportExecutionApi reportExecutionApi, + ReportOptionsUseCase reportOptionsUseCase, ControlsApi controlsApi, ExportFactory exportFactory, long delay) { mExportExecutionApi = exportExecutionApi; mReportExecutionApi = reportExecutionApi; + mReportOptionsUseCase = reportOptionsUseCase; mControlsApi = controlsApi; mExportFactory = exportFactory; mDelay = delay; @@ -79,5 +84,30 @@ public final List listControlsValues(@NotNull String reportUr return mControlsApi.requestControlsValues(reportUri, parameters, true); } + @NotNull + @Override + public final Set listReportOptions(@NotNull String reportUnitUri) throws ServiceException { + return mReportOptionsUseCase.requestReportOptionsList(reportUnitUri); + } + + @NotNull + @Override + public final ReportOption createReportOption(@NotNull String reportUri, + @NotNull String optionLabel, + @NotNull List parameters, + boolean overwrite) throws ServiceException { + return mReportOptionsUseCase.createReportOption(reportUri, optionLabel, parameters, overwrite); + } + + @Override + public void updateReportOption(@NotNull String reportUri, @NotNull String optionId, @NotNull List parameters) throws ServiceException { + mReportOptionsUseCase.updateReportOption(reportUri, optionId, parameters); + } + + @Override + public void deleteReportOption(@NotNull String reportUri, @NotNull String optionId) throws ServiceException { + mReportOptionsUseCase.deleteReportOption(reportUri, optionId); + } + protected abstract ReportExecution buildExecution(String reportUri, String executionId, ReportExecutionOptions criteria); } \ No newline at end of file diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java index 34c38fe4..9350c4dc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ProxyReportService.java @@ -27,12 +27,14 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Set; /** * @author Tom Koptel @@ -73,6 +75,43 @@ public List listControlsValues(@Nullable String reportUri, return getDelegate().listControlsValues(reportUri, parameters); } + @NotNull + @Override + public Set listReportOptions(@Nullable String reportUri) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + return getDelegate().listReportOptions(reportUri); + } + + @NotNull + @Override + public ReportOption createReportOption(@NotNull String reportUri, + @NotNull String optionLabel, + @NotNull List parameters, + boolean overwrite) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionLabel, "Option label should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + return getDelegate().createReportOption(reportUri, optionLabel, parameters, overwrite); + } + + @Override + public void updateReportOption(@NotNull String reportUri, @NotNull String optionId, @NotNull List parameters) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionId, "Option id should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + getDelegate().updateReportOption(reportUri, optionId, parameters); + } + + @Override + public void deleteReportOption(@NotNull String reportUri, @NotNull String optionId) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionId, "Option id should not be null"); + + getDelegate().deleteReportOption(reportUri, optionId); + } + private ReportService getDelegate() throws ServiceException { if (mDelegate == null) { mDelegate = mServiceFactory.newService(); diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCase.java new file mode 100644 index 00000000..0d4bd36b --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCase.java @@ -0,0 +1,69 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportOptionRestApi; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; + +import java.io.IOException; +import java.util.List; +import java.util.Set; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class ReportOptionsUseCase { + private final ServiceExceptionMapper mExceptionMapper; + private final ReportOptionRestApi mReportOptionRestApi; + + ReportOptionsUseCase(ServiceExceptionMapper exceptionMapper, ReportOptionRestApi reportOptionRestApi) { + mExceptionMapper = exceptionMapper; + mReportOptionRestApi = reportOptionRestApi; + } + + public Set requestReportOptionsList(String reportUnitUri) throws ServiceException { + try { + return mReportOptionRestApi.requestReportOptionsList(reportUnitUri); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + public ReportOption createReportOption(String reportUri, + String optionLabel, + List parameters, + boolean overwrite) throws ServiceException { + try { + return mReportOptionRestApi.createReportOption(reportUri, optionLabel, parameters, overwrite); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + public void updateReportOption(String reportUri, String optionId, List parameters) throws ServiceException { + try { + mReportOptionRestApi.updateReportOption(reportUri, optionId, parameters); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } + + public void deleteReportOption(String reportUri, String optionId) throws ServiceException { + try { + mReportOptionRestApi.deleteReportOption(reportUri, optionId); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java index fa29ab3f..7dc23acc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.Preconditions; @@ -39,6 +40,7 @@ import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; /** @@ -47,7 +49,8 @@ */ public abstract class ReportService { @NotNull - public abstract ReportExecution run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions) throws ServiceException; + public abstract ReportExecution run(@NotNull String reportUri, + @Nullable ReportExecutionOptions execOptions) throws ServiceException; @NotNull public abstract List listControls(@NotNull String reportUri) throws ServiceException; @@ -56,6 +59,22 @@ public abstract class ReportService { public abstract List listControlsValues(@NotNull String reportUri, @NotNull List parameters) throws ServiceException; + @NotNull + public abstract Set listReportOptions(@NotNull String reportUri) throws ServiceException; + + @NotNull + public abstract ReportOption createReportOption(@NotNull String reportUri, + @NotNull String optionLabel, + @NotNull List parameters, + boolean overwrite) throws ServiceException; + + public abstract void updateReportOption(@NotNull String reportUri, + @NotNull String optionId, + @NotNull List parameters) throws ServiceException; + + public abstract void deleteReportOption(@NotNull String reportUri, + @NotNull String optionId) throws ServiceException; + @NotNull public static ReportService newService(@NotNull AuthorizedClient client) { Preconditions.checkNotNull(client, "Client should not be null"); @@ -68,6 +87,7 @@ public static ReportService newService(@NotNull AuthorizedClient client) { client.reportExecutionApi(), client.reportExportApi(), client.inputControlApi(), + client.reportOptionsApi(), reportMapper, client.getBaseUrl(), TimeUnit.SECONDS.toMillis(1) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java index efdaf3a5..743546ca 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_5.java @@ -31,10 +31,11 @@ final class ReportService5_5 extends AbstractReportService { protected ReportService5_5(ExportExecutionApi exportExecutionApi, ReportExecutionApi reportExecutionApi, + ReportOptionsUseCase reportOptionsUseCase, ControlsApi controlsApi, ExportFactory exportFactory, long delay) { - super(exportExecutionApi, reportExecutionApi, controlsApi, exportFactory, delay); + super(exportExecutionApi, reportExecutionApi, reportOptionsUseCase, controlsApi, exportFactory, delay); } @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java index 92b0a090..4209bdba 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportService5_6Plus.java @@ -31,10 +31,11 @@ final class ReportService5_6Plus extends AbstractReportService { protected ReportService5_6Plus(ExportExecutionApi exportExecutionApi, ReportExecutionApi reportExecutionApi, + ReportOptionsUseCase reportOptionsUseCase, ControlsApi controlsApi, ExportFactory exportFactory, long delay) { - super(exportExecutionApi, reportExecutionApi, controlsApi, exportFactory, delay); + super(exportExecutionApi, reportExecutionApi, reportOptionsUseCase, controlsApi, exportFactory, delay); } @Override diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java index 34a5637d..599dbf14 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportServiceFactory.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.InputControlRestApi; import com.jaspersoft.android.sdk.network.ReportExecutionRestApi; import com.jaspersoft.android.sdk.network.ReportExportRestApi; +import com.jaspersoft.android.sdk.network.ReportOptionRestApi; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.data.server.ServerVersion; import com.jaspersoft.android.sdk.service.exception.ServiceException; @@ -43,6 +44,7 @@ class ReportServiceFactory { private final ReportExecutionRestApi mReportExecutionRestApi; private final ReportExportRestApi mReportExportRestApi; private final InputControlRestApi mInputControlRestApi; + private final ReportOptionRestApi mReportOptionRestApi; private final ServiceExceptionMapper mExceptionMapper; private final String mBaseUrl; private final long mDelay; @@ -51,12 +53,15 @@ class ReportServiceFactory { ReportServiceFactory(InfoCacheManager cacheManager, ReportExecutionRestApi reportExecutionRestApi, ReportExportRestApi reportExportRestApi, - InputControlRestApi inputControlRestApi, ServiceExceptionMapper exceptionMapper, + InputControlRestApi inputControlRestApi, + ReportOptionRestApi reportOptionRestApi, + ServiceExceptionMapper exceptionMapper, String baseUrl, long delay) { mCacheManager = cacheManager; mReportExecutionRestApi = reportExecutionRestApi; mReportExportRestApi = reportExportRestApi; mInputControlRestApi = inputControlRestApi; + mReportOptionRestApi = reportOptionRestApi; mExceptionMapper = exceptionMapper; mBaseUrl = baseUrl; mDelay = delay; @@ -76,10 +81,13 @@ public ReportService newService() throws ServiceException { ExportFactory exportFactory = new ExportFactory(exportExecutionApi, attachmentsFactory); ControlsApi controlsApi = new ControlsApi(mExceptionMapper, mInputControlRestApi); + ReportOptionsUseCase reportOptionsUseCase = new ReportOptionsUseCase(mExceptionMapper, mReportOptionRestApi); + if (version.lessThanOrEquals(ServerVersion.v5_5)) { return new ReportService5_5( exportExecutionApi, reportExecutionApi, + reportOptionsUseCase, controlsApi, exportFactory, mDelay); @@ -87,6 +95,7 @@ public ReportService newService() throws ServiceException { return new ReportService5_6Plus( exportExecutionApi, reportExecutionApi, + reportOptionsUseCase, controlsApi, exportFactory, mDelay); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 02a0d638..9e3cc679 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -24,6 +24,7 @@ package com.jaspersoft.android.sdk.network; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.test.MockResponseFactory; import com.jaspersoft.android.sdk.test.WebMockRule; @@ -39,10 +40,7 @@ import org.junit.rules.ExpectedException; import retrofit.Retrofit; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsEmptyCollection.empty; @@ -55,6 +53,12 @@ */ @SuppressWarnings("unchecked") public class ReportOptionRestApiTest { + + private final static List REPORT_PARAMS = + Collections.singletonList( + new ReportParameter("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19")) + ); + @Rule public final WebMockRule mWebMockRule = new WebMockRule(); @Rule @@ -88,20 +92,20 @@ public void requestReportOptionsListShouldNotAllowNullReportUnitUri() throws Exc public void createReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.createReportOption(null, "label", Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption(null, "label", REPORT_PARAMS, false); } @Test public void createReportOptionShouldNotAllowNullOptionLabel() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option label should not be null"); - restApiUnderTest.createReportOption("any_id", null, Collections.EMPTY_MAP, false); + restApiUnderTest.createReportOption("any_id", null, REPORT_PARAMS, false); } @Test public void createReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Controls values should not be null"); + mExpectedException.expectMessage("Parameters values should not be null"); restApiUnderTest.createReportOption("any_id", "label", null, false); } @@ -109,20 +113,20 @@ public void createReportOptionShouldNotAllowNullControlsValues() throws Exceptio public void updateReportOptionShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report uri should not be null"); - restApiUnderTest.updateReportOption(null, "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption(null, "option_id", REPORT_PARAMS); } @Test public void updateReportOptionShouldNotAllowNullOptionId() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Option id should not be null"); - restApiUnderTest.updateReportOption("any_id", null, Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption("any_id", null, REPORT_PARAMS); } @Test public void updateReportOptionShouldNotAllowNullControlsValues() throws Exception { mExpectedException.expect(NullPointerException.class); - mExpectedException.expectMessage("Controls values should not be null"); + mExpectedException.expectMessage("Parameters values should not be null"); restApiUnderTest.updateReportOption("any_id", "option_id", null); } @@ -157,10 +161,7 @@ public void apiShouldCreateReportOption() throws Exception { MockResponse mockResponse = MockResponseFactory.create200().setBody(reportOption.asString()); mWebMockRule.enqueue(mockResponse); - Map> params = new HashMap<>(); - params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19")); - - ReportOption reportOption = restApiUnderTest.createReportOption("/any/uri", "my label", params, true); + ReportOption reportOption = restApiUnderTest.createReportOption("/any/uri", "my label", REPORT_PARAMS, true); assertThat(reportOption.getId(), is("my_label")); assertThat(reportOption.getLabel(), is("my label")); assertThat(reportOption.getUri(), is("/public/Samples/Reports/my_label")); @@ -177,7 +178,7 @@ public void apiShouldUpdateReportOption() throws Exception { Map> params = new HashMap<>(); params.put("sales_fact_ALL__store_sales_2013_1", Collections.singleton("22")); - restApiUnderTest.updateReportOption("/any/uri", "option_id", params); + 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")); @@ -210,7 +211,7 @@ public void updateReportOptionShouldThrowRestErrorFor500() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create500()); - restApiUnderTest.updateReportOption("any_id", "option_id", Collections.EMPTY_MAP); + restApiUnderTest.updateReportOption("any_id", "option_id", REPORT_PARAMS); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportParamsMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportParamsMapperTest.java new file mode 100644 index 00000000..64bb56c6 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportParamsMapperTest.java @@ -0,0 +1,27 @@ +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import org.junit.Test; + +import java.util.*; + +import static org.hamcrest.Matchers.hasItems; +import static org.junit.Assert.assertThat; + + +public class ReportParamsMapperTest { + @Test + public void testToMap() throws Exception { + ReportParameter reportParameter1 = new ReportParameter("a", Collections.singleton("b")); + ReportParameter reportParameter2 = new ReportParameter("c", Collections.singleton("d")); + Map> params = ReportParamsMapper.INSTANCE.toMap( + Arrays.asList(reportParameter1, reportParameter2)); + + Set values = new HashSet<>(); + for (Set sets : params.values()) { + values.addAll(sets); + } + assertThat(params.keySet(), hasItems("a", "c")); + assertThat(values, hasItems("b", "d")); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java index 0a37658d..4b6e5ced 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionTest.java @@ -25,15 +25,15 @@ package com.jaspersoft.android.sdk.network.entity.report.option; import com.google.gson.annotations.Expose; - +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; import org.junit.Test; import org.junit.runner.RunWith; import java.lang.reflect.Field; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; import static org.hamcrest.MatcherAssert.assertThat; @@ -55,4 +55,10 @@ public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFi assertThat(field, hasAnnotation(Expose.class)); } + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(ReportOption.class) + .suppress(Warning.NONFINAL_FIELDS) + .verify(); + } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java index 18b18779..3c9c7372 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/AbstractReportServiceTest.java @@ -51,12 +51,17 @@ public class AbstractReportServiceTest { private static final String REPORT_URI = "my/uri"; private static final String EXEC_ID = "exec_id"; + private static final String OPTION_LABEL = "label"; + private static final String OPTION_ID = OPTION_LABEL; + private static final List REPORT_PARAMETERS = Collections.emptyList(); @Mock ExportExecutionApi mExportExecutionApi; @Mock ReportExecutionApi mReportExecutionApi; @Mock + ReportOptionsUseCase mReportOptionsUseCase; + @Mock ControlsApi mControlsApi; @Mock ExportFactory mExportFactory; @@ -72,6 +77,7 @@ public void setUp() throws Exception { reportService = new AbstractReportService( mExportExecutionApi, mReportExecutionApi, + mReportOptionsUseCase, mControlsApi, mExportFactory, 0) { @@ -109,4 +115,28 @@ public void should_request_controls_values() throws Exception { reportService.listControlsValues(REPORT_URI, parameters); verify(mControlsApi).requestControlsValues(REPORT_URI, parameters, true); } + + @Test + public void should_request_options() throws Exception { + reportService.listReportOptions(REPORT_URI); + verify(mReportOptionsUseCase).requestReportOptionsList(REPORT_URI); + } + + @Test + public void should_create_report_option() throws Exception { + reportService.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + verify(mReportOptionsUseCase).createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + } + + @Test + public void should_update_report_option() throws Exception { + reportService.updateReportOption(REPORT_URI, OPTION_ID, REPORT_PARAMETERS); + verify(mReportOptionsUseCase).updateReportOption(REPORT_URI, OPTION_ID, REPORT_PARAMETERS); + } + + @Test + public void should_delete_report_option() throws Exception { + reportService.deleteReportOption(REPORT_URI, OPTION_ID); + verify(mReportOptionsUseCase).deleteReportOption(REPORT_URI, OPTION_ID); + } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java index 833e9b90..3c87289a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ProxyReportServiceTest.java @@ -20,6 +20,9 @@ public class ProxyReportServiceTest { private static final String REPORT_URI = "/my/uri"; + private static final String OPTION_LABEL = "label"; + private static final String OPTION_ID = OPTION_LABEL; + private static final List REPORT_PARAMETERS = Collections.emptyList(); @Mock ReportServiceFactory mReportServiceFactory; @@ -59,6 +62,26 @@ public void should_delegate_list_controls_call() throws Exception { verify(mReportService).listControls(eq(REPORT_URI)); } + @Test + public void should_delegate_list_report_options_call() throws Exception { + proxyReportService.listReportOptions(REPORT_URI); + verify(mReportServiceFactory).newService(); + verify(mReportService).listReportOptions(eq(REPORT_URI)); + } + + @Test + public void should_delegate_create_report_option_call() throws Exception { + proxyReportService.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + verify(mReportServiceFactory).newService(); + verify(mReportService).createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + } + @Test + public void should_delegate_update_report_option_call() throws Exception { + proxyReportService.updateReportOption(REPORT_URI, OPTION_ID, REPORT_PARAMETERS); + verify(mReportServiceFactory).newService(); + verify(mReportService).updateReportOption(REPORT_URI, OPTION_ID, REPORT_PARAMETERS); + } + @Test public void should_not_list_controls_with_null_uri() throws Exception { expected.expect(NullPointerException.class); @@ -80,6 +103,69 @@ public void should_not_list_controls_with_null_parameters() throws Exception { proxyReportService.listControlsValues(null, Collections.emptyList()); } + @Test + public void should_not_list_report_options_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + proxyReportService.listReportOptions(null); + } + + @Test + public void should_not_create_report_option_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + proxyReportService.createReportOption(null, OPTION_LABEL, REPORT_PARAMETERS, true); + } + + @Test + public void should_not_create_report_option_with_null_option_label() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Option label should not be null"); + proxyReportService.createReportOption(REPORT_URI, null, REPORT_PARAMETERS, true); + } + + @Test + public void should_not_create_report_option_with_null_parameters() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Parameters should not be null"); + proxyReportService.createReportOption(REPORT_URI, OPTION_LABEL, null, true); + } + + @Test + public void should_not_update_report_option_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + proxyReportService.updateReportOption(null, OPTION_ID, REPORT_PARAMETERS); + } + + @Test + public void should_not_update_report_option_with_null_option_id() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Option id should not be null"); + proxyReportService.updateReportOption(REPORT_URI, null, REPORT_PARAMETERS); + } + + @Test + public void should_not_update_report_option_with_null_parameters() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Parameters should not be null"); + proxyReportService.updateReportOption(REPORT_URI, OPTION_ID, null); + } + + @Test + public void should_not_delete_report_option_with_null_uri() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Report uri should not be null"); + proxyReportService.deleteReportOption(null, OPTION_ID); + } + + @Test + public void should_not_delete_report_option_with_null_option_id() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Option id should not be null"); + proxyReportService.deleteReportOption(REPORT_URI, null); + } + @Test public void should_delegate_load_cascade_controls_call() throws Exception { List parameters = Collections.emptyList(); diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCaseTest.java new file mode 100644 index 00000000..4b0bb132 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportOptionsUseCaseTest.java @@ -0,0 +1,177 @@ +package com.jaspersoft.android.sdk.service.report; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportOptionRestApi; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import static junit.framework.TestCase.fail; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ReportOptionsUseCaseTest { + private static final String REPORT_URI = "/my/uri"; + private static final String OPTION_LABEL = "label"; + private static final String OPTION_ID = OPTION_LABEL; + private static final List REPORT_PARAMETERS = Collections.emptyList(); + + @Mock + ServiceExceptionMapper mExceptionMapper; + @Mock + ReportOptionRestApi mReportOptionRestApi; + + @Mock + IOException mIOException; + @Mock + HttpException mHttpException; + @Mock + ServiceException mServiceException; + + private ReportOptionsUseCase reportOptionsUseCase; + + @Before + public void setUp() throws Exception { + initMocks(this); + setupMocks(); + reportOptionsUseCase = new ReportOptionsUseCase(mExceptionMapper, mReportOptionRestApi); + } + + @Test + public void should_list_report_options() throws Exception { + reportOptionsUseCase.requestReportOptionsList(REPORT_URI); + verify(mReportOptionRestApi).requestReportOptionsList(REPORT_URI); + } + + @Test + public void list_report_options_adapts_io_exception() throws Exception { + when(mReportOptionRestApi.requestReportOptionsList(anyString())).thenThrow(mIOException); + try { + reportOptionsUseCase.requestReportOptionsList(REPORT_URI); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void list_report_options_adapts_http_exception() throws Exception { + when(mReportOptionRestApi.requestReportOptionsList(anyString())).thenThrow(mHttpException); + + try { + reportOptionsUseCase.requestReportOptionsList(REPORT_URI); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + @Test + public void should_create_report_option() throws Exception { + reportOptionsUseCase.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + verify(mReportOptionRestApi).createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + } + + + @Test + public void should_update_report_option() throws Exception { + reportOptionsUseCase.updateReportOption(REPORT_URI, OPTION_ID, REPORT_PARAMETERS); + verify(mReportOptionRestApi).updateReportOption(REPORT_URI, OPTION_ID, REPORT_PARAMETERS); + } + + @Test + public void should_delete_report_option() throws Exception { + reportOptionsUseCase.deleteReportOption(REPORT_URI, OPTION_LABEL); + verify(mReportOptionRestApi).deleteReportOption(REPORT_URI, OPTION_ID); + } + + @Test + public void create_report_option_adapts_io_exception() throws Exception { + when(mReportOptionRestApi.createReportOption(anyString(), + anyString(), anyListOf(ReportParameter.class), anyBoolean())).thenThrow(mIOException); + try { + reportOptionsUseCase.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void create_report_option_adapts_http_exception() throws Exception { + when(mReportOptionRestApi.createReportOption(anyString(), + anyString(), anyListOf(ReportParameter.class), anyBoolean())).thenThrow(mHttpException); + + try { + reportOptionsUseCase.createReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS, true); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + + + @Test + public void update_report_option_adapts_io_exception() throws Exception { + doThrow(mIOException).when(mReportOptionRestApi).updateReportOption(anyString(), + anyString(), anyListOf(ReportParameter.class)); + try { + reportOptionsUseCase.updateReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void update_report_option_adapts_http_exception() throws Exception { + doThrow(mHttpException).when(mReportOptionRestApi).updateReportOption(anyString(), + anyString(), anyListOf(ReportParameter.class)); + try { + reportOptionsUseCase.updateReportOption(REPORT_URI, OPTION_LABEL, REPORT_PARAMETERS); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + @Test + public void delete_report_option_adapts_io_exception() throws Exception { + doThrow(mIOException).when(mReportOptionRestApi).deleteReportOption(anyString(), anyString()); + + try { + reportOptionsUseCase.deleteReportOption(REPORT_URI, OPTION_LABEL); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void delete_report_option_adapts_http_exception() throws Exception { + doThrow(mHttpException).when(mReportOptionRestApi).deleteReportOption(anyString(), anyString()); + + try { + reportOptionsUseCase.deleteReportOption(REPORT_URI, OPTION_LABEL); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + private void setupMocks() { + when(mExceptionMapper.transform(any(HttpException.class))).thenReturn(mServiceException); + when(mExceptionMapper.transform(any(IOException.class))).thenReturn(mServiceException); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java index da8220e4..1c3c058b 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/test/integration/api/ReportOptionRestApiTest.java @@ -26,14 +26,12 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.network.ReportOptionRestApi; +import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import org.junit.Before; import org.junit.Ignore; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.nullValue; @@ -47,13 +45,10 @@ public class ReportOptionRestApiTest { private static final String REPORT_URI = "/public/Samples/Reports/1._Geographic_Results_by_Segment_Report"; - public static final Map> CONTROL_PARAMETERS = new HashMap<>(); - - static { - Set values = new HashSet<>(); - values.add("19"); - CONTROL_PARAMETERS.put("sales_fact_ALL__store_sales_2013_1", values); - } + private final static List REPORT_PARAMS = + Collections.singletonList( + new ReportParameter("sales_fact_ALL__store_sales_2013_1", Collections.singleton("19")) + ); private final LazyClient mLazyClient = new LazyClient(JrsMetadata.createMobileDemo2()); private ReportOptionRestApi apiUnderTest; @@ -76,10 +71,10 @@ public void shouldRequestReportOptionsList() throws Exception { // TODO: fix this by providing proper integration tests @Ignore public void apiSupportsCrudForReportOption() throws Exception { - ReportOption response = apiUnderTest.createReportOption(REPORT_URI, "label", CONTROL_PARAMETERS, true); + ReportOption response = apiUnderTest.createReportOption(REPORT_URI, "label", REPORT_PARAMS, true); assertThat(response.getLabel(), is("label")); - apiUnderTest.updateReportOption(REPORT_URI, response.getId(), CONTROL_PARAMETERS); + apiUnderTest.updateReportOption(REPORT_URI, response.getId(), REPORT_PARAMS); apiUnderTest.deleteReportOption(REPORT_URI, response.getId()); } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java index 3c95c431..3cb126ed 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; import com.jaspersoft.android.sdk.service.report.ReportService; @@ -36,6 +37,7 @@ import rx.Observable; import java.util.List; +import java.util.Set; /** * @author Tom Koptel @@ -51,6 +53,24 @@ public abstract class RxReportService { @NotNull public abstract Observable> listControlsValues(@NotNull String reportUri, @NotNull List parameters); + @NotNull + public abstract Observable> listReportOptions(@NotNull String reportUri); + + @NotNull + public abstract Observable createReportOption(@NotNull String reportUri, + @NotNull String optionLabel, + @NotNull List parameters, + boolean overwrite); + + @NotNull + public abstract Observable updateReportOption(@NotNull String reportUri, + @NotNull String optionId, + @NotNull List parameters); + + @NotNull + public abstract Observable deleteReportOption(@NotNull String reportUri, + @NotNull String optionId); + @NotNull public static RxReportService newService(@NotNull AuthorizedClient authorizedClient) { Preconditions.checkNotNull(authorizedClient, "Client should not be null"); diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java index ee0a84cb..ca6c2533 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.report.ReportExecution; @@ -39,6 +40,7 @@ import rx.functions.Func0; import java.util.List; +import java.util.Set; /** * @author Tom Koptel @@ -108,4 +110,84 @@ public Observable> call() { } }); } + + @NotNull + @Override + public Observable> listReportOptions(@NotNull final String reportUri) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + Set reportOptions = mSyncDelegate.listReportOptions(reportUri); + return Observable.just(reportOptions); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + @Override + public Observable createReportOption(@NotNull final String reportUri, + @NotNull final String optionLabel, + @NotNull final List parameters, + final boolean overwrite) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionLabel, "Option label should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportOption reportOption = mSyncDelegate.createReportOption(reportUri, optionLabel, parameters, overwrite); + return Observable.just(reportOption); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + @Override + public Observable updateReportOption(@NotNull final String reportUri, @NotNull final String optionId, @NotNull final List parameters) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionId, "Option id should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + mSyncDelegate.updateReportOption(reportUri, optionId, parameters); + } catch (ServiceException e) { + return Observable.error(e); + } + return Observable.just(null); + } + }); + } + + @NotNull + @Override + public Observable deleteReportOption(@NotNull final String reportUri, @NotNull final String optionId) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionId, "Option id should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + mSyncDelegate.deleteReportOption(reportUri, optionId); + } catch (ServiceException e) { + return Observable.error(e); + } + return Observable.just(null); + } + }); + } } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java index e4ca56b4..cc04a5fb 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControl; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.report.ReportExecution; import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; @@ -41,13 +42,14 @@ import java.util.Collections; import java.util.List; +import java.util.Set; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.rules.ExpectedException.none; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; @@ -56,6 +58,8 @@ public class RxReportServiceTest { private static final String REPORT_URI = "my/uri"; private static final ReportExecutionOptions OPTIONS = ReportExecutionOptions.builder().build(); private static final List PARAMS = Collections.emptyList(); + private static final String OPTION_LABEL = "label"; + private static final String OPTION_ID = OPTION_LABEL; @Mock ReportService mSyncDelegate; @@ -64,6 +68,8 @@ public class RxReportServiceTest { @Mock ServiceException mServiceException; + private ReportOption fakeReportOption = new ReportOption(); + @Mock AuthorizedClient mAuthorizedClient; @@ -177,6 +183,114 @@ public void should_execute_delegate_as_observable_on_list_controls_values() thro verify(mSyncDelegate).listControlsValues(REPORT_URI, PARAMS); } + @Test + public void should_delegate_service_exception_to_subscription_on_list_report_options() throws Exception { + when(mSyncDelegate.listReportOptions(anyString())).thenThrow(mServiceException); + + TestSubscriber> test = TestSubscriber.create(); + rxReportService.listReportOptions(REPORT_URI).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).listReportOptions(REPORT_URI); + } + + @Test + public void should_execute_delegate_as_observable_on_list_report_options() throws Exception { + when(mSyncDelegate.listReportOptions(anyString())) + .thenReturn(Collections.emptySet()); + + TestSubscriber> test = TestSubscriber.create(); + rxReportService.listReportOptions(REPORT_URI).subscribe(test); + + test.assertCompleted(); + test.assertNoErrors(); + test.assertValueCount(1); + + verify(mSyncDelegate).listReportOptions(REPORT_URI); + } + + @Test + public void should_delegate_service_exception_to_subscription_on_create_report_option() throws Exception { + when(mSyncDelegate.createReportOption(anyString(), anyString(), anyListOf(ReportParameter.class), anyBoolean())) + .thenThrow(mServiceException); + + TestSubscriber test = TestSubscriber.create(); + rxReportService.createReportOption(REPORT_URI, OPTION_LABEL, PARAMS, true).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).createReportOption(REPORT_URI, OPTION_LABEL, PARAMS, true); + } + + @Test + public void should_execute_delegate_as_observable_on_create_report_option() throws Exception { + when(mSyncDelegate.createReportOption(anyString(), anyString(), anyListOf(ReportParameter.class), anyBoolean())) + .thenReturn(fakeReportOption); + + TestSubscriber test = TestSubscriber.create(); + rxReportService.createReportOption(REPORT_URI, OPTION_LABEL, PARAMS, true).subscribe(test); + + test.assertCompleted(); + test.assertNoErrors(); + test.assertValueCount(1); + + verify(mSyncDelegate).createReportOption(REPORT_URI, OPTION_LABEL, PARAMS, true); + } + + @Test + public void should_delegate_service_exception_to_subscription_on_update_report_option() throws Exception { + doThrow(mServiceException).when(mSyncDelegate).updateReportOption(anyString(), + anyString(), anyListOf(ReportParameter.class)); + + TestSubscriber test = TestSubscriber.create(); + rxReportService.updateReportOption(REPORT_URI, OPTION_ID, PARAMS).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).updateReportOption(REPORT_URI, OPTION_ID, PARAMS); + } + + @Test + public void should_execute_delegate_as_observable_on_update_report_option() throws Exception { + TestSubscriber test = TestSubscriber.create(); + rxReportService.updateReportOption(REPORT_URI, OPTION_ID, PARAMS).subscribe(test); + + test.assertCompleted(); + test.assertNoErrors(); + test.assertValueCount(1); + + verify(mSyncDelegate).updateReportOption(REPORT_URI, OPTION_ID, PARAMS); + } + + @Test + public void should_delegate_service_exception_to_subscription_on_delete_report_option() throws Exception { + doThrow(mServiceException).when(mSyncDelegate).deleteReportOption(anyString(), anyString()); + + TestSubscriber test = TestSubscriber.create(); + rxReportService.deleteReportOption(REPORT_URI, OPTION_ID).subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).deleteReportOption(REPORT_URI, OPTION_ID); + } + + @Test + public void should_execute_delegate_as_observable_on_delete_report_option() throws Exception { + TestSubscriber test = TestSubscriber.create(); + rxReportService.deleteReportOption(REPORT_URI, OPTION_ID).subscribe(test); + + test.assertCompleted(); + test.assertNoErrors(); + test.assertValueCount(1); + + verify(mSyncDelegate).deleteReportOption(REPORT_URI, OPTION_ID); + } + @Test public void should_provide_impl_with_factory_method() throws Exception { RxReportService service = RxReportService.newService(mAuthorizedClient); From 23947046c893d0ce46a779e01b716a217ad933ad Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 13 Jan 2016 19:17:57 +0200 Subject: [PATCH 387/457] Removed redundant public interfaces from core/rx modules Remove redundant public interfaces from SDK Reduce redundant interfaces within network layer Reduce redundant intefaces from rx module Reduce redundant interfaces from service layer Reduce redundant interfaces within network layer Reduce redundant intefaces from rx module Reduce redundant interfaces from service layer --- .../android/sdk/network/AbstractClient.java | 44 ---- .../android/sdk/network/AnonymousClient.java | 28 ++- .../sdk/network/AnonymousClientImpl.java | 57 ------ .../sdk/network/AuthenticationRestApi.java | 15 +- .../network/AuthenticationRestApiImpl.java | 47 ----- .../android/sdk/network/AuthorizedClient.java | 52 ++++- .../sdk/network/AuthorizedClientImpl.java | 91 --------- .../android/sdk/network/CallWrapper.java | 4 +- .../android/sdk/network/Client.java | 14 +- .../sdk/network/GsonConverterFactory.java | 5 +- .../sdk/network/InputControlRestApi.java | 78 ++++++- .../sdk/network/InputControlRestApiImpl.java | 116 ----------- .../sdk/network/RecoverableAuthenticator.java | 5 - .../sdk/network/ReportExecutionRestApi.java | 102 ++++++++- .../network/ReportExecutionRestApiImpl.java | 151 -------------- .../sdk/network/ReportExportRestApi.java | 99 +++++++-- .../sdk/network/ReportExportRestApiImpl.java | 138 ------------- .../sdk/network/ReportOptionRestApi.java | 107 +++++++++- .../sdk/network/ReportOptionRestApiImpl.java | 145 ------------- .../sdk/network/RepositoryRestApi.java | 94 ++++++++- .../sdk/network/RepositoryRestApiImpl.java | 136 ------------ .../android/sdk/network/Server.java | 9 +- .../android/sdk/network/ServerRestApi.java | 97 +++++++-- .../sdk/network/ServerRestApiImpl.java | 151 -------------- .../sdk/network/StringConverterFactory.java | 3 +- .../entity/report/option/ReportOptionSet.java | 1 - .../network/entity/server/EncryptionKey.java | 1 - .../service/auth/AuthorizationService.java | 31 ++- .../auth/ProxyAuthorizationService.java | 64 ------ .../sdk/service/info/ServerInfoService.java | 34 ++- .../service/info/ServerInfoServiceImpl.java | 66 ------ .../internal/DefaultExceptionMapper.java | 3 +- .../internal/info/InMemoryInfoCache.java | 1 - .../report/AbstractReportExecution.java | 2 +- .../service/report/AttachmentsFactory.java | 2 +- .../sdk/service/report/ExportFactory.java | 2 +- .../sdk/service/report/ReportAttachment.java | 39 +++- .../service/report/ReportAttachmentImpl.java | 60 ------ .../sdk/service/report/ReportExecution.java | 8 +- .../sdk/service/report/ReportExport.java | 39 +++- .../sdk/service/report/ReportExportImpl.java | 64 ------ .../service/report/RetryReportExecution.java | 2 +- .../repository/ProxyRepositoryService.java | 97 --------- .../service/repository/RepositoryService.java | 54 ++++- .../sdk/service/repository/SearchTask.java | 7 +- .../service/repository/SearchTaskProxy.java | 2 +- .../service/repository/SearchTaskV5_5.java | 2 +- .../repository/SearchTaskV5_6Plus.java | 2 +- .../AuthorizationClientTestImplTest.java | 4 +- .../sdk/network/InputControlRestApiTest.java | 2 +- .../network/ReportExecutionRestApiTest.java | 2 +- .../sdk/network/ReportExportRestApiTest.java | 2 +- .../sdk/network/ReportOptionRestApiTest.java | 2 +- .../sdk/network/RepositoryRestApiTest.java | 2 +- .../sdk/network/ServerRestApiTest.java | 2 +- .../auth/AuthorizationServiceTest.java | 71 ++++++- .../auth/ProxyAuthorizationServiceTest.java | 106 ---------- .../service/info/ServerInfoServiceTest.java | 6 +- .../sdk/service/report/ExportFactoryTest.java | 2 +- .../service/report/ReportAttachmentTest.java | 4 +- .../sdk/service/report/ReportExportTest.java | 4 +- .../ProxyRepositoryServiceTest.java | 132 ------------ .../repository/RepositoryServiceTest.java | 82 +++++++- .../rx/auth/RxAuthorizationService.java | 28 ++- .../rx/auth/RxAuthorizationServiceImpl.java | 62 ------ .../service/rx/info/RxServerInfoService.java | 28 ++- .../rx/info/RxServerInfoServiceImpl.java | 60 ------ .../service/rx/report/RxReportAttachment.java | 27 ++- .../rx/report/RxReportAttachmentImpl.java | 62 ------ .../service/rx/report/RxReportExecution.java | 61 +++++- .../rx/report/RxReportExecutionImpl.java | 105 ---------- .../sdk/service/rx/report/RxReportExport.java | 46 ++++- .../service/rx/report/RxReportExportImpl.java | 85 -------- .../service/rx/report/RxReportService.java | 144 +++++++++++-- .../rx/report/RxReportServiceImpl.java | 193 ------------------ .../rx/repository/RxRepositoryService.java | 49 ++++- .../repository/RxRepositoryServiceImpl.java | 92 --------- .../service/rx/repository/RxSearchTask.java | 36 +++- .../rx/repository/RxSearchTaskImpl.java | 75 ------- .../rx/auth/RxAuthorizationServiceTest.java | 6 +- .../rx/info/RxServerInfoServiceTest.java | 6 +- .../rx/report/RxReportAttachmentTest.java | 4 +- .../rx/report/RxReportExecutionTest.java | 4 +- .../service/rx/report/RxReportExportTest.java | 4 +- .../rx/report/RxReportServiceTest.java | 14 +- .../repository/RxRepositoryServiceTest.java | 6 +- .../rx/repository/RxSearchTaskTest.java | 4 +- 87 files changed, 1370 insertions(+), 2625 deletions(-) delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AbstractClient.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java delete mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java delete mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java delete mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AbstractClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AbstractClient.java deleted file mode 100644 index a6ac7f5d..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AbstractClient.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import retrofit.Retrofit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -abstract class AbstractClient implements Client { - protected final Retrofit mRetrofit; - - protected AbstractClient(Retrofit retrofit) { - mRetrofit = retrofit; - } - - @Override - public String getBaseUrl() { - return mRetrofit.baseUrl().url().toString(); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java index a18af99f..bf0d2462 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClient.java @@ -24,11 +24,33 @@ package com.jaspersoft.android.sdk.network; +import retrofit.Retrofit; + /** * @author Tom Koptel * @since 2.0 */ -public interface AnonymousClient extends Client { - ServerRestApi infoApi(); - AuthenticationRestApi authenticationApi(); +public class AnonymousClient extends Client { + private ServerRestApi mServerRestApi; + private AuthenticationRestApi mAuthApi; + + AnonymousClient(Retrofit retrofit) { + super(retrofit); + } + + public ServerRestApi infoApi() { + if (mServerRestApi == null) { + mServerRestApi = new ServerRestApi(mRetrofit); + } + return mServerRestApi; + } + + public AuthenticationRestApi authenticationApi() { + if (mAuthApi == null) { + SpringAuthServiceFactory authServiceFactory = new SpringAuthServiceFactory(mRetrofit); + AuthStrategy authStrategy = new AuthStrategy(authServiceFactory); + mAuthApi = new AuthenticationRestApi(authStrategy); + } + return mAuthApi; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java deleted file mode 100644 index af345b2c..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AnonymousClientImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import retrofit.Retrofit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class AnonymousClientImpl extends AbstractClient implements AnonymousClient { - private ServerRestApiImpl mServerRestApi; - private AuthenticationRestApiImpl mAuthApi; - - AnonymousClientImpl(Retrofit retrofit) { - super(retrofit); - } - - public ServerRestApi infoApi() { - if (mServerRestApi == null) { - mServerRestApi = new ServerRestApiImpl(mRetrofit); - } - return mServerRestApi; - } - - @Override - public AuthenticationRestApi authenticationApi() { - if (mAuthApi == null) { - SpringAuthServiceFactory authServiceFactory = new SpringAuthServiceFactory(mRetrofit); - AuthStrategy authStrategy = new AuthStrategy(authServiceFactory); - mAuthApi = new AuthenticationRestApiImpl(authStrategy); - } - return mAuthApi; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java index c822ff95..6bb0e1cb 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApi.java @@ -24,7 +24,7 @@ package com.jaspersoft.android.sdk.network; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -32,6 +32,15 @@ * @author Tom Koptel * @since 2.0 */ -public interface AuthenticationRestApi { - public void authenticate(@NotNull Credentials credentials) throws IOException, HttpException; +public class AuthenticationRestApi { + private final AuthStrategy mAuthStrategy; + + AuthenticationRestApi(AuthStrategy authStrategy) { + mAuthStrategy = authStrategy; + } + + public void authenticate(@Nullable Credentials credentials) throws IOException, HttpException { + Utils.checkNotNull(credentials, "Credentials should not be null"); + credentials.apply(mAuthStrategy); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java deleted file mode 100644 index b00bea00..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthenticationRestApiImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import org.jetbrains.annotations.Nullable; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class AuthenticationRestApiImpl implements AuthenticationRestApi { - private final AuthStrategy mAuthStrategy; - - AuthenticationRestApiImpl(AuthStrategy authStrategy) { - mAuthStrategy = authStrategy; - } - - @Override - public void authenticate(@Nullable Credentials credentials) throws IOException, HttpException { - Utils.checkNotNull(credentials, "Credentials should not be null"); - credentials.apply(mAuthStrategy); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index 16f415c8..1eeedf7c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -24,19 +24,59 @@ package com.jaspersoft.android.sdk.network; +import retrofit.Retrofit; + /** * @author Tom Koptel * @since 2.0 */ -public interface AuthorizedClient extends AnonymousClient { +public class AuthorizedClient extends AnonymousClient { + + private final AnonymousClient mAnonymousClient; + + private ReportExecutionRestApi mReportExecutionRestApi; + private ReportExportRestApi mReportExportRestApi; + private ReportOptionRestApi mReportOptionRestApi; + private InputControlRestApi mInputControlRestApi; + private RepositoryRestApi mRepositoryRestApi; + + AuthorizedClient(Retrofit retrofit, AnonymousClient anonymousClient) { + super(retrofit); + mAnonymousClient = anonymousClient; + } - ReportExecutionRestApi reportExecutionApi(); + public ReportExecutionRestApi reportExecutionApi() { + if (mReportExecutionRestApi == null) { + mReportExecutionRestApi = new ReportExecutionRestApi(mRetrofit); + } + return mReportExecutionRestApi; + } - ReportExportRestApi reportExportApi(); + public ReportExportRestApi reportExportApi() { + if (mReportExportRestApi == null) { + mReportExportRestApi = new ReportExportRestApi(mRetrofit); + } + return mReportExportRestApi; + } - ReportOptionRestApi reportOptionsApi(); + public ReportOptionRestApi reportOptionsApi() { + if (mReportOptionRestApi == null) { + mReportOptionRestApi = new ReportOptionRestApi(mRetrofit); + } + return mReportOptionRestApi; + } - InputControlRestApi inputControlApi(); + public InputControlRestApi inputControlApi() { + if (mInputControlRestApi == null) { + mInputControlRestApi = new InputControlRestApi(mRetrofit); + } + return mInputControlRestApi; + } - RepositoryRestApi repositoryApi(); + public RepositoryRestApi repositoryApi() { + if (mRepositoryRestApi == null) { + mRepositoryRestApi = new RepositoryRestApi(mRetrofit); + } + return mRepositoryRestApi; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java deleted file mode 100644 index 53a704fa..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClientImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import retrofit.Retrofit; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class AuthorizedClientImpl extends AbstractClient implements AuthorizedClient { - - private final AnonymousClient mAnonymousClient; - - private ReportExecutionRestApi mReportExecutionRestApi; - private ReportExportRestApi mReportExportRestApi; - private ReportOptionRestApi mReportOptionRestApi; - private InputControlRestApi mInputControlRestApi; - private RepositoryRestApi mRepositoryRestApi; - - AuthorizedClientImpl(Retrofit retrofit, AnonymousClient anonymousClient) { - super(retrofit); - mAnonymousClient = anonymousClient; - } - - public ReportExecutionRestApi reportExecutionApi() { - if (mReportExecutionRestApi == null) { - mReportExecutionRestApi = new ReportExecutionRestApiImpl(mRetrofit); - } - return mReportExecutionRestApi; - } - - public ReportExportRestApi reportExportApi() { - if (mReportExportRestApi == null) { - mReportExportRestApi = new ReportExportRestApiImpl(mRetrofit); - } - return mReportExportRestApi; - } - - public ReportOptionRestApi reportOptionsApi() { - if (mReportOptionRestApi == null) { - mReportOptionRestApi = new ReportOptionRestApiImpl(mRetrofit); - } - return mReportOptionRestApi; - } - - public InputControlRestApi inputControlApi() { - if (mInputControlRestApi == null) { - mInputControlRestApi = new InputControlRestApiImpl(mRetrofit); - } - return mInputControlRestApi; - } - - public RepositoryRestApi repositoryApi() { - if (mRepositoryRestApi == null) { - mRepositoryRestApi = new RepositoryRestApiImpl(mRetrofit); - } - return mRepositoryRestApi; - } - - public ServerRestApi infoApi() { - return mAnonymousClient.infoApi(); - } - - @Override - public AuthenticationRestApi authenticationApi() { - return mAnonymousClient.authenticationApi(); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java b/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java index 28116816..f7211184 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/CallWrapper.java @@ -24,11 +24,11 @@ package com.jaspersoft.android.sdk.network; -import java.io.IOException; - import retrofit.Call; import retrofit.Response; +import java.io.IOException; + /** * @author Tom Koptel * @since 2.0 diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java index 3e950d1d..2a8945b9 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Client.java @@ -24,10 +24,20 @@ package com.jaspersoft.android.sdk.network; +import retrofit.Retrofit; + /** * @author Tom Koptel * @since 2.0 */ -public interface Client { - String getBaseUrl(); +public abstract class Client { + protected final Retrofit mRetrofit; + + protected Client(Retrofit retrofit) { + mRetrofit = retrofit; + } + + public String getBaseUrl() { + return mRetrofit.baseUrl().url().toString(); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java index 8525487b..adc86fb2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/GsonConverterFactory.java @@ -29,6 +29,8 @@ import com.squareup.okhttp.MediaType; import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.ResponseBody; +import okio.Buffer; +import retrofit.Converter; import java.io.IOException; import java.io.OutputStreamWriter; @@ -37,9 +39,6 @@ import java.lang.reflect.Type; import java.nio.charset.Charset; -import okio.Buffer; -import retrofit.Converter; - /** * Temporary workaround around {@link TypeAdapter} issue which causes null fields to be parsed. * The issue submitted on following link diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java index b5564e25..2f1ed287 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApi.java @@ -24,19 +24,33 @@ package com.jaspersoft.android.sdk.network; + import com.jaspersoft.android.sdk.network.entity.control.InputControl; +import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; import com.jaspersoft.android.sdk.network.entity.control.InputControlState; +import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; import java.util.List; +import java.util.Map; +import java.util.Set; /** * @author Tom Koptel * @since 2.0 */ -public interface InputControlRestApi { +public class InputControlRestApi { + private final RestApi mRestApi; + + InputControlRestApi(Retrofit restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } /** * Returns input controls for associated response. Options can be excluded by additional argument. @@ -48,12 +62,25 @@ public interface InputControlRestApi { * @return unmodifiable list of {@link InputControl} */ @NotNull - List requestInputControls(@NotNull String reportUri, - boolean excludeState) throws HttpException, IOException; + public List requestInputControls(@Nullable String reportUri, + boolean excludeState) throws IOException, HttpException { + Utils.checkNotNull(reportUri, "Report URI should not be null"); + + String state = (excludeState ? "state" : null); + Call call = mRestApi.requestInputControls(reportUri, state); + InputControlCollection response = CallWrapper.wrap(call).body(); + return response.get(); + } @NotNull - List requestInputControlsInitialStates(@NotNull String reportUri, - boolean freshData) throws HttpException, IOException; + public List requestInputControlsInitialStates(@Nullable String reportUri, + boolean freshData) throws IOException, HttpException { + Utils.checkNotNull(reportUri, "Report URI should not be null"); + + Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); + InputControlStateCollection response = CallWrapper.wrap(call).body(); + return response.get(); + } /** * Provides values for specified controls. This API helpful to @@ -65,7 +92,42 @@ List requestInputControlsInitialStates(@NotNull String report * @return unmodifiable list of {@link InputControlState} */ @NotNull - List requestInputControlsStates(@NotNull String reportUri, - @NotNull List parameters, - boolean freshData) throws HttpException, IOException; + public List requestInputControlsStates(@NotNull String reportUri, + @NotNull List parameters, + boolean freshData) throws HttpException, IOException { + Utils.checkNotNull(reportUri, "Report URI should not be null"); + Utils.checkNotNull(parameters, "Parameters should not be null"); + + Map> params = ReportParamsMapper.INSTANCE.toMap(parameters); + String ids = Utils.joinString(";", params.keySet()); + Call call = mRestApi.requestInputControlsValues(reportUri, + ids, params, freshData); + InputControlStateCollection response = CallWrapper.wrap(call).body(); + return response.get(); + } + + private interface RestApi { + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reports{reportUnitURI}/inputControls") + Call requestInputControls( + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, + @Query("exclude") String state); + + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reports{reportUnitURI}/inputControls/values") + Call requestInputControlsInitialValues( + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, + @Query("freshData") boolean freshData); + + @NotNull + @Headers("Accept: application/json") + @POST("rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") + Call requestInputControlsValues( + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, + @NotNull @Path(value = "controlsId", encoded = true) String ids, + @NotNull @Body Map> controlsValues, + @Query("freshData") boolean freshData); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java deleted file mode 100644 index e208b83c..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/InputControlRestApiImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - - -import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlCollection; -import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.network.entity.control.InputControlStateCollection; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import retrofit.Call; -import retrofit.Retrofit; -import retrofit.http.*; - -import java.io.IOException; -import java.util.*; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class InputControlRestApiImpl implements InputControlRestApi { - private final RestApi mRestApi; - - InputControlRestApiImpl(Retrofit restAdapter) { - mRestApi = restAdapter.create(RestApi.class); - } - - @NotNull - @Override - public List requestInputControls(@Nullable String reportUri, - boolean excludeState) throws IOException, HttpException { - Utils.checkNotNull(reportUri, "Report URI should not be null"); - - String state = (excludeState ? "state" : null); - Call call = mRestApi.requestInputControls(reportUri, state); - InputControlCollection response = CallWrapper.wrap(call).body(); - return response.get(); - } - - @NotNull - @Override - public List requestInputControlsInitialStates(@Nullable String reportUri, - boolean freshData) throws IOException, HttpException { - Utils.checkNotNull(reportUri, "Report URI should not be null"); - - Call call = mRestApi.requestInputControlsInitialValues(reportUri, freshData); - InputControlStateCollection response = CallWrapper.wrap(call).body(); - return response.get(); - } - - @NotNull - @Override - public List requestInputControlsStates(@NotNull String reportUri, - @NotNull List parameters, - boolean freshData) throws HttpException, IOException { - Utils.checkNotNull(reportUri, "Report URI should not be null"); - Utils.checkNotNull(parameters, "Parameters should not be null"); - - Map> params = ReportParamsMapper.INSTANCE.toMap(parameters); - String ids = Utils.joinString(";", params.keySet()); - Call call = mRestApi.requestInputControlsValues(reportUri, - ids, params, freshData); - InputControlStateCollection response = CallWrapper.wrap(call).body(); - return response.get(); - } - - private interface RestApi { - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reports{reportUnitURI}/inputControls") - Call requestInputControls( - @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @Query("exclude") String state); - - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reports{reportUnitURI}/inputControls/values") - Call requestInputControlsInitialValues( - @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @Query("freshData") boolean freshData); - - @NotNull - @Headers("Accept: application/json") - @POST("rest_v2/reports{reportUnitURI}/inputControls/{controlsId}/values") - Call requestInputControlsValues( - @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUri, - @NotNull @Path(value = "controlsId", encoded = true) String ids, - @NotNull @Body Map> controlsValues, - @Query("freshData") boolean freshData); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java index dd61fd99..9bdd0d1e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RecoverableAuthenticator.java @@ -25,16 +25,11 @@ package com.jaspersoft.android.sdk.network; import com.squareup.okhttp.Authenticator; -import com.squareup.okhttp.HttpUrl; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; import java.io.IOException; -import java.net.CookieStore; -import java.net.HttpCookie; import java.net.Proxy; -import java.net.URI; -import java.util.List; /** * @author Tom Koptel diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java index 9caec167..28c88ecc 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApi.java @@ -30,6 +30,11 @@ import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; import java.util.List; @@ -39,23 +44,102 @@ * @author Tom Koptel * @since 2.0 */ -public interface ReportExecutionRestApi { +public class ReportExecutionRestApi { + + private final RestApi mRestApi; + + ReportExecutionRestApi(Retrofit restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } @NotNull - ReportExecutionDescriptor runReportExecution(@NotNull ReportExecutionRequestOptions executionOptions) throws HttpException, IOException; + public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) throws IOException, HttpException { + Utils.checkNotNull(executionOptions, "Execution options should not be null"); + + Call call = mRestApi.runReportExecution(executionOptions); + return CallWrapper.wrap(call).body(); + } @NotNull - ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String executionId) throws HttpException, IOException; + public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String executionId) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + + Call call = mRestApi.requestReportExecutionDetails(executionId); + return CallWrapper.wrap(call).body(); + } @NotNull - ExecutionStatus requestReportExecutionStatus(@NotNull String executionId) throws HttpException, IOException; + public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + + Call call = mRestApi.requestReportExecutionStatus(executionId); + return CallWrapper.wrap(call).body(); + } + + public boolean cancelReportExecution(@Nullable String executionId) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + + Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus()); + Response response = CallWrapper.wrap(call).response(); + int status = response.code(); + return status != 204; + } - boolean cancelReportExecution(@NotNull String executionId) throws HttpException, IOException; + public boolean updateReportExecution(@Nullable String executionId, + @Nullable List params) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(params, "Execution params should not be null"); + Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); - boolean updateReportExecution(@NotNull String executionId, - @NotNull List params) throws HttpException, IOException; + Call call = mRestApi.updateReportExecution(executionId, params); + Response response = CallWrapper.wrap(call).response(); + int status = response.code(); + return status == 204; + } - // TODO: API is broken requires investigation before release @NotNull - ReportExecutionSearchResponse searchReportExecution(Map params) throws HttpException, IOException; + public ReportExecutionSearchResponse searchReportExecution(@Nullable Map params) throws IOException, HttpException { + Utils.checkNotNull(params, "Search params should not be null"); + Utils.checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); + + Call call = mRestApi.searchReportExecution(params); + ReportExecutionSearchResponse body = CallWrapper.wrap(call).body(); + if (body == null) { + return ReportExecutionSearchResponse.empty(); + } + return body; + } + + interface RestApi { + @NotNull + @Headers("Accept: application/json") + @POST("rest_v2/reportExecutions") + Call runReportExecution(@NotNull @Body ReportExecutionRequestOptions executionOptions); + + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reportExecutions/{executionId}") + Call requestReportExecutionDetails(@NotNull @Path(value = "executionId", encoded = true) String executionId); + + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reportExecutions/{executionId}/status") + Call requestReportExecutionStatus(@NotNull @Path(value = "executionId", encoded = true) String executionId); + + @NotNull + @Headers("Accept: application/json") + @POST("rest_v2/reportExecutions/{executionId}/parameters") + Call updateReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, + @NotNull @Body List params); + + @NotNull + @Headers("Accept: application/json") + @PUT("rest_v2/reportExecutions/{executionId}/status") + Call cancelReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, + @NotNull @Body ExecutionStatus statusResponse); + + @Headers("Accept: application/json") + @GET("rest_v2/reportExecutions") + Call searchReportExecution(@Nullable @QueryMap(encoded = true) Map params); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java deleted file mode 100644 index 7e7f7109..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiImpl.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ReportExecutionSearchResponse; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import retrofit.Call; -import retrofit.Response; -import retrofit.Retrofit; -import retrofit.http.*; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ReportExecutionRestApiImpl implements ReportExecutionRestApi { - - private final RestApi mRestApi; - - ReportExecutionRestApiImpl(Retrofit restAdapter) { - mRestApi = restAdapter.create(RestApi.class); - } - - @NotNull - @Override - public ReportExecutionDescriptor runReportExecution(@Nullable ReportExecutionRequestOptions executionOptions) throws IOException, HttpException { - Utils.checkNotNull(executionOptions, "Execution options should not be null"); - - Call call = mRestApi.runReportExecution(executionOptions); - return CallWrapper.wrap(call).body(); - } - - @NotNull - @Override - public ReportExecutionDescriptor requestReportExecutionDetails(@Nullable String executionId) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - - Call call = mRestApi.requestReportExecutionDetails(executionId); - return CallWrapper.wrap(call).body(); - } - - @NotNull - @Override - public ExecutionStatus requestReportExecutionStatus(@Nullable String executionId) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - - Call call = mRestApi.requestReportExecutionStatus(executionId); - return CallWrapper.wrap(call).body(); - } - - @Override - public boolean cancelReportExecution(@Nullable String executionId) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - - Call call = mRestApi.cancelReportExecution(executionId, ExecutionStatus.cancelledStatus()); - Response response = CallWrapper.wrap(call).response(); - int status = response.code(); - return status != 204; - } - - @Override - public boolean updateReportExecution(@Nullable String executionId, - @Nullable List params) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(params, "Execution params should not be null"); - Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); - - Call call = mRestApi.updateReportExecution(executionId, params); - Response response = CallWrapper.wrap(call).response(); - int status = response.code(); - return status == 204; - } - - @NotNull - @Override - public ReportExecutionSearchResponse searchReportExecution(@Nullable Map params) throws IOException, HttpException { - Utils.checkNotNull(params, "Search params should not be null"); - Utils.checkArgument(params.isEmpty(), "Search params should have at lease one key pair"); - - Call call = mRestApi.searchReportExecution(params); - ReportExecutionSearchResponse body = CallWrapper.wrap(call).body(); - if (body == null) { - return ReportExecutionSearchResponse.empty(); - } - return body; - } - - interface RestApi { - @NotNull - @Headers("Accept: application/json") - @POST("rest_v2/reportExecutions") - Call runReportExecution(@NotNull @Body ReportExecutionRequestOptions executionOptions); - - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reportExecutions/{executionId}") - Call requestReportExecutionDetails(@NotNull @Path(value = "executionId", encoded = true) String executionId); - - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reportExecutions/{executionId}/status") - Call requestReportExecutionStatus(@NotNull @Path(value = "executionId", encoded = true) String executionId); - - @NotNull - @Headers("Accept: application/json") - @POST("rest_v2/reportExecutions/{executionId}/parameters") - Call updateReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, - @NotNull @Body List params); - - @NotNull - @Headers("Accept: application/json") - @PUT("rest_v2/reportExecutions/{executionId}/status") - Call cancelReportExecution(@NotNull @Path(value = "executionId", encoded = true) String executionId, - @NotNull @Body ExecutionStatus statusResponse); - - @Headers("Accept: application/json") - @GET("rest_v2/reportExecutions") - Call searchReportExecution(@Nullable @QueryMap(encoded = true) Map params); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java index 85c5349f..e4da3702 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApi.java @@ -24,14 +24,18 @@ package com.jaspersoft.android.sdk.network; - import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; import com.jaspersoft.android.sdk.network.entity.export.OutputResource; - +import com.squareup.okhttp.ResponseBody; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; @@ -39,21 +43,92 @@ * @author Tom Koptel * @since 2.0 */ -public interface ReportExportRestApi { +public class ReportExportRestApi { + private final RestApi mRestApi; + + public ReportExportRestApi(Retrofit restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } + @NotNull - ExportExecutionDescriptor runExportExecution(@NotNull String executionId, - @NotNull ExecutionRequestOptions executionOptions) throws HttpException, IOException; + public ExportExecutionDescriptor runExportExecution(@Nullable String executionId, + @Nullable ExecutionRequestOptions executionOptions) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(executionOptions, "Execution options should not be null"); + + Call call = mRestApi.runReportExportExecution(executionId, executionOptions); + return CallWrapper.wrap(call).body(); + } @NotNull - ExecutionStatus checkExportExecutionStatus(@NotNull String executionId, - @NotNull String exportId) throws HttpException, IOException; + public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, + @Nullable String exportId) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(exportId, "Export id should not be null"); + + + Call call = mRestApi.checkReportExportStatus(executionId, exportId); + return CallWrapper.wrap(call).body(); + } @NotNull - ExportOutputResource requestExportOutput(@NotNull String executionId, - @NotNull String exportId) throws HttpException, IOException; + public ExportOutputResource requestExportOutput(@Nullable String executionId, + @Nullable String exportId) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(exportId, "Export id should not be null"); + + Call call = mRestApi.requestReportExportOutput(executionId, exportId); + Response rawResponse = CallWrapper.wrap(call).response(); + com.squareup.okhttp.Headers headers = rawResponse.headers(); + + RetrofitOutputResource exportInput = new RetrofitOutputResource(rawResponse.body()); + String pages = headers.get("report-pages"); + boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); + + return ExportOutputResource.create(exportInput, pages, isFinal); + } @NotNull - OutputResource requestExportAttachment(@NotNull String executionId, - @NotNull String exportId, - @NotNull String attachmentId) throws HttpException, IOException; + public OutputResource requestExportAttachment(@Nullable String executionId, + @Nullable String exportId, + @Nullable String attachmentId) throws IOException, HttpException { + Utils.checkNotNull(executionId, "Execution id should not be null"); + Utils.checkNotNull(exportId, "Export id should not be null"); + Utils.checkNotNull(attachmentId, "Attachment id should not be null"); + + Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); + Response rawResponse = CallWrapper.wrap(call).response(); + ResponseBody body = rawResponse.body(); + return new RetrofitOutputResource(body); + } + + private interface RestApi { + @NotNull + @Headers("Accept: application/json") + @POST("rest_v2/reportExecutions/{executionId}/exports") + Call runReportExportExecution(@NotNull @Path("executionId") String executionId, + @NotNull @Body ExecutionRequestOptions executionOptions); + + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") + Call checkReportExportStatus(@NotNull @Path("executionId") String executionId, + @NotNull @Path(value = "exportId", encoded = true) String exportId); + + /** + * 'suppressContentDisposition' used due to security implications this header has + */ + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") + Call requestReportExportOutput(@NotNull @Path("executionId") String executionId, + @NotNull @Path(value = "exportId", encoded = true) String exportId); + + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") + Call requestReportExportAttachmentOutput(@NotNull @Path("executionId") String executionId, + @NotNull @Path(value = "exportId", encoded = true) String exportId, + @NotNull @Path("attachmentId") String attachmentId); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java deleted file mode 100644 index a12adb51..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportExportRestApiImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionRequestOptions; -import com.jaspersoft.android.sdk.network.entity.execution.ExecutionStatus; -import com.jaspersoft.android.sdk.network.entity.export.ExportExecutionDescriptor; -import com.jaspersoft.android.sdk.network.entity.export.ExportOutputResource; -import com.jaspersoft.android.sdk.network.entity.export.OutputResource; -import com.squareup.okhttp.ResponseBody; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import retrofit.Call; -import retrofit.Response; -import retrofit.Retrofit; -import retrofit.http.*; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ReportExportRestApiImpl implements ReportExportRestApi { - private final RestApi mRestApi; - - public ReportExportRestApiImpl(Retrofit restAdapter) { - mRestApi = restAdapter.create(RestApi.class); - } - - @NotNull - @Override - public ExportExecutionDescriptor runExportExecution(@Nullable String executionId, - @Nullable ExecutionRequestOptions executionOptions) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(executionOptions, "Execution options should not be null"); - - Call call = mRestApi.runReportExportExecution(executionId, executionOptions); - return CallWrapper.wrap(call).body(); - } - - @NotNull - @Override - public ExecutionStatus checkExportExecutionStatus(@Nullable String executionId, - @Nullable String exportId) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(exportId, "Export id should not be null"); - - - Call call = mRestApi.checkReportExportStatus(executionId, exportId); - return CallWrapper.wrap(call).body(); - } - - @NotNull - @Override - public ExportOutputResource requestExportOutput(@Nullable String executionId, - @Nullable String exportId) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(exportId, "Export id should not be null"); - - Call call = mRestApi.requestReportExportOutput(executionId, exportId); - Response rawResponse = CallWrapper.wrap(call).response(); - com.squareup.okhttp.Headers headers = rawResponse.headers(); - - RetrofitOutputResource exportInput = new RetrofitOutputResource(rawResponse.body()); - String pages = headers.get("report-pages"); - boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); - - return ExportOutputResource.create(exportInput, pages, isFinal); - } - - @NotNull - @Override - public OutputResource requestExportAttachment(@Nullable String executionId, - @Nullable String exportId, - @Nullable String attachmentId) throws IOException, HttpException { - Utils.checkNotNull(executionId, "Execution id should not be null"); - Utils.checkNotNull(exportId, "Export id should not be null"); - Utils.checkNotNull(attachmentId, "Attachment id should not be null"); - - Call call = mRestApi.requestReportExportAttachmentOutput(executionId, exportId, attachmentId); - Response rawResponse = CallWrapper.wrap(call).response(); - ResponseBody body = rawResponse.body(); - return new RetrofitOutputResource(body); - } - - private interface RestApi { - @NotNull - @Headers("Accept: application/json") - @POST("rest_v2/reportExecutions/{executionId}/exports") - Call runReportExportExecution(@NotNull @Path("executionId") String executionId, - @NotNull @Body ExecutionRequestOptions executionOptions); - - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/status") - Call checkReportExportStatus(@NotNull @Path("executionId") String executionId, - @NotNull @Path(value = "exportId", encoded = true) String exportId); - - /** - * 'suppressContentDisposition' used due to security implications this header has - */ - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/outputResource?suppressContentDisposition=true") - Call requestReportExportOutput(@NotNull @Path("executionId") String executionId, - @NotNull @Path(value = "exportId", encoded = true) String exportId); - - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reportExecutions/{executionId}/exports/{exportId}/attachments/{attachmentId}") - Call requestReportExportAttachmentOutput(@NotNull @Path("executionId") String executionId, - @NotNull @Path(value = "exportId", encoded = true) String exportId, - @NotNull @Path("attachmentId") String attachmentId); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java index f13e58dc..9568070a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApi.java @@ -24,33 +24,118 @@ package com.jaspersoft.android.sdk.network; +import com.google.gson.JsonSyntaxException; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; +import com.squareup.okhttp.Response; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; /** * @author Tom Koptel * @since 2.0 */ -public interface ReportOptionRestApi { +public class ReportOptionRestApi { + private final RestApi mRestApi; + + ReportOptionRestApi(Retrofit retrofit) { + mRestApi = retrofit.create(RestApi.class); + } @NotNull - Set requestReportOptionsList(@NotNull String reportUnitUri) throws HttpException, IOException; + public Set requestReportOptionsList( + @Nullable String reportUnitUri) throws IOException, HttpException { + Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); + + Call call = mRestApi.requestReportOptionsList(reportUnitUri); + try { + ReportOptionSet options = CallWrapper.wrap(call).body(); + return options.get(); + } catch (JsonSyntaxException ex) { + /** + * This possible when there is no report options + * API responds with plain/text message: 'No options found for {URI}' + * As soon as there 2 options to reserve this we decide to swallow exception and return empty object + */ + return Collections.emptySet(); + } + } @NotNull - ReportOption createReportOption(@NotNull String reportUnitUri, - @NotNull String optionLabel, - @NotNull List parameters, - boolean overwrite) throws HttpException, IOException; + public ReportOption createReportOption( + @Nullable String reportUnitUri, + @Nullable String optionLabel, + @Nullable List parameters, + boolean overwrite) throws IOException, HttpException { + Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); + Utils.checkNotNull(optionLabel, "Option label should not be null"); + Utils.checkNotNull(parameters, "Parameters values should not be null"); + + Map> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); + Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite); + return CallWrapper.wrap(call).body(); + } + + public void updateReportOption(@Nullable String reportUnitUri, + @Nullable String optionId, + @Nullable List 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"); + + Map> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); + Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues); + CallWrapper.wrap(call).body(); + } + + public void deleteReportOption(@Nullable String reportUnitUri, + @Nullable String optionId) throws IOException, HttpException { + Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); + Utils.checkNotNull(optionId, "Option id should not be null"); + + Call call = mRestApi.deleteReportOption(reportUnitUri, optionId); + CallWrapper.wrap(call).body(); + } + + private interface RestApi { + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/reports{reportUnitUri}/options") + Call requestReportOptionsList( + @NotNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); + + @NotNull + @Headers("Accept: application/json") + @POST("rest_v2/reports{reportUnitURI}/options") + Call createReportOption( + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, + @NotNull @Query("label") String optionLabel, + @NotNull @Body Map> controlsValues, + @Query("overwrite") boolean overwrite); - void updateReportOption(@NotNull String reportUnitUri, - @NotNull String optionId, - @NotNull List parameters) throws HttpException, IOException; + @NotNull + @Headers("Accept: application/json") + @PUT("rest_v2/reports{reportUnitURI}/options/{optionId}") + Call updateReportOption( + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, + @NotNull @Path(value = "optionId", encoded = true) String optionId, + @NotNull @Body Map> controlsValues); - void deleteReportOption(@NotNull String reportUnitUri, - @NotNull String optionId) throws HttpException, IOException; + @NotNull + @Headers("Accept: application/json") + @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") + Call deleteReportOption( + @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, + @NotNull @Path(value = "optionId", encoded = true) String optionI); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java deleted file mode 100644 index 81f96bc5..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiImpl.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.google.gson.JsonSyntaxException; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOptionSet; -import com.squareup.okhttp.Response; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import retrofit.Call; -import retrofit.Retrofit; -import retrofit.http.*; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ReportOptionRestApiImpl implements ReportOptionRestApi { - private final RestApi mRestApi; - - ReportOptionRestApiImpl(Retrofit retrofit) { - mRestApi = retrofit.create(RestApi.class); - } - - @NotNull - @Override - public Set requestReportOptionsList( - @Nullable String reportUnitUri) throws IOException, HttpException { - Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); - - Call call = mRestApi.requestReportOptionsList(reportUnitUri); - try { - ReportOptionSet options = CallWrapper.wrap(call).body(); - return options.get(); - } catch (JsonSyntaxException ex) { - /** - * This possible when there is no report options - * API responds with plain/text message: 'No options found for {URI}' - * As soon as there 2 options to reserve this we decide to swallow exception and return empty object - */ - return Collections.emptySet(); - } - } - - @NotNull - @Override - public ReportOption createReportOption( - @Nullable String reportUnitUri, - @Nullable String optionLabel, - @Nullable List parameters, - boolean overwrite) throws IOException, HttpException { - Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); - Utils.checkNotNull(optionLabel, "Option label should not be null"); - Utils.checkNotNull(parameters, "Parameters values should not be null"); - - Map> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); - Call call = mRestApi.createReportOption(reportUnitUri, optionLabel, controlsValues, overwrite); - return CallWrapper.wrap(call).body(); - } - - @Override - public void updateReportOption(@Nullable String reportUnitUri, - @Nullable String optionId, - @Nullable List 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"); - - Map> controlsValues = ReportParamsMapper.INSTANCE.toMap(parameters); - Call call = mRestApi.updateReportOption(reportUnitUri, optionId, controlsValues); - CallWrapper.wrap(call).body(); - } - - @Override - public void deleteReportOption(@Nullable String reportUnitUri, - @Nullable String optionId) throws IOException, HttpException { - Utils.checkNotNull(reportUnitUri, "Report uri should not be null"); - Utils.checkNotNull(optionId, "Option id should not be null"); - - Call call = mRestApi.deleteReportOption(reportUnitUri, optionId); - CallWrapper.wrap(call).body(); - } - - private interface RestApi { - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/reports{reportUnitUri}/options") - Call requestReportOptionsList( - @NotNull @Path(value = "reportUnitUri", encoded = true) String reportUnitUri); - - @NotNull - @Headers("Accept: application/json") - @POST("rest_v2/reports{reportUnitURI}/options") - Call createReportOption( - @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NotNull @Query("label") String optionLabel, - @NotNull @Body Map> controlsValues, - @Query("overwrite") boolean overwrite); - - @NotNull - @Headers("Accept: application/json") - @PUT("rest_v2/reports{reportUnitURI}/options/{optionId}") - Call updateReportOption( - @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NotNull @Path(value = "optionId", encoded = true) String optionId, - @NotNull @Body Map> controlsValues); - - @NotNull - @Headers("Accept: application/json") - @DELETE("rest_v2/reports{reportUnitURI}/options/{optionId}") - Call deleteReportOption( - @NotNull @Path(value = "reportUnitURI", encoded = true) String reportUnitUri, - @NotNull @Path(value = "optionId", encoded = true) String optionI); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java index 4a39440a..3b4c0789 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApi.java @@ -24,28 +24,110 @@ package com.jaspersoft.android.sdk.network; - import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import retrofit.Call; +import retrofit.Response; +import retrofit.Retrofit; +import retrofit.http.*; import java.io.IOException; +import java.util.HashMap; import java.util.Map; /** * @author Tom Koptel * @since 2.0 */ -public interface RepositoryRestApi { +public class RepositoryRestApi { + private final RestApi mRestApi; + + RepositoryRestApi(Retrofit restAdapter) { + mRestApi = restAdapter.create(RestApi.class); + } + @NotNull - ResourceSearchResult searchResources(@Nullable Map searchParams) throws HttpException, IOException; + public ResourceSearchResult searchResources(@Nullable Map searchParams) throws IOException, HttpException { + Iterable types = null; + Call call; + + if (searchParams == null) { + call = mRestApi.searchResources(null, null); + } else { + Map copy = new HashMap<>(searchParams); + Object typeValues = copy.get("type"); + copy.remove("type"); + + if (typeValues == null) { + types = null; + } + if (typeValues instanceof Iterable) { + types = (Iterable) typeValues; + } + + call = mRestApi.searchResources(copy, types); + } + + Response rawResponse = CallWrapper.wrap(call).response(); + + int status = rawResponse.code(); + ResourceSearchResult entity; + if (status == 204) { + entity = ResourceSearchResult.empty(); + } else { + entity = rawResponse.body(); + com.squareup.okhttp.Headers headers = rawResponse.headers(); + + int resultCount = Utils.headerToInt(headers, "Result-Count"); + int totalCount = Utils.headerToInt(headers, "Total-Count"); + int startIndex = Utils.headerToInt(headers, "Start-Index"); + int nextOffset = Utils.headerToInt(headers, "Next-Offset"); + + entity.setResultCount(resultCount); + entity.setTotalCount(totalCount); + entity.setStartIndex(startIndex); + entity.setNextOffset(nextOffset); + } + return entity; + } @NotNull - ReportLookup requestReportResource(@NotNull String resourceUri) throws HttpException, IOException; + public ReportLookup requestReportResource(@Nullable String resourceUri) throws IOException, HttpException { + Utils.checkNotNull(resourceUri, "Report uri should not be null"); + + Call call = mRestApi.requestReportResource(resourceUri); + return CallWrapper.wrap(call).body(); + } @NotNull - FolderLookup requestFolderResource(@NotNull String resourceUri) throws HttpException, IOException; + public FolderLookup requestFolderResource(@Nullable String resourceUri) throws IOException, HttpException { + Utils.checkNotNull(resourceUri, "Folder uri should not be null"); + + Call call = mRestApi.requestFolderResource(resourceUri); + return CallWrapper.wrap(call).body(); + } + + private interface RestApi { + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/resources") + Call searchResources( + @Nullable @QueryMap Map searchParams, + @Nullable @Query("type") Iterable types); + + @NotNull + @Headers("Accept: application/repository.reportUnit+json") + @GET("rest_v2/resources{resourceUri}") + Call requestReportResource( + @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri); + + @NotNull + @Headers("Accept: application/repository.folder+json") + @GET("rest_v2/resources{resourceUri}") + Call requestFolderResource( + @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java deleted file mode 100644 index 8441f3fa..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/RepositoryRestApiImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.entity.resource.FolderLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ReportLookup; -import com.jaspersoft.android.sdk.network.entity.resource.ResourceSearchResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import retrofit.Call; -import retrofit.Response; -import retrofit.Retrofit; -import retrofit.http.*; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RepositoryRestApiImpl implements RepositoryRestApi { - private final RestApi mRestApi; - - RepositoryRestApiImpl(Retrofit restAdapter) { - mRestApi = restAdapter.create(RestApi.class); - } - - @NotNull - @Override - public ResourceSearchResult searchResources(@Nullable Map searchParams) throws IOException, HttpException { - Iterable types = null; - Call call; - - if (searchParams == null) { - call = mRestApi.searchResources(null, null); - } else { - Map copy = new HashMap<>(searchParams); - Object typeValues = copy.get("type"); - copy.remove("type"); - - if (typeValues == null) { - types = null; - } - if (typeValues instanceof Iterable) { - types = (Iterable) typeValues; - } - - call = mRestApi.searchResources(copy, types); - } - - Response rawResponse = CallWrapper.wrap(call).response(); - - int status = rawResponse.code(); - ResourceSearchResult entity; - if (status == 204) { - entity = ResourceSearchResult.empty(); - } else { - entity = rawResponse.body(); - com.squareup.okhttp.Headers headers = rawResponse.headers(); - - int resultCount = Utils.headerToInt(headers, "Result-Count"); - int totalCount = Utils.headerToInt(headers, "Total-Count"); - int startIndex = Utils.headerToInt(headers, "Start-Index"); - int nextOffset = Utils.headerToInt(headers, "Next-Offset"); - - entity.setResultCount(resultCount); - entity.setTotalCount(totalCount); - entity.setStartIndex(startIndex); - entity.setNextOffset(nextOffset); - } - return entity; - } - - @NotNull - @Override - public ReportLookup requestReportResource(@Nullable String resourceUri) throws IOException, HttpException { - Utils.checkNotNull(resourceUri, "Report uri should not be null"); - - Call call = mRestApi.requestReportResource(resourceUri); - return CallWrapper.wrap(call).body(); - } - - @NotNull - @Override - public FolderLookup requestFolderResource(@Nullable String resourceUri) throws IOException, HttpException { - Utils.checkNotNull(resourceUri, "Folder uri should not be null"); - - Call call = mRestApi.requestFolderResource(resourceUri); - return CallWrapper.wrap(call).body(); - } - - private interface RestApi { - @NotNull - @Headers("Accept: application/json") - @GET("rest_v2/resources") - Call searchResources( - @Nullable @QueryMap Map searchParams, - @Nullable @Query("type") Iterable types); - - @NotNull - @Headers("Accept: application/repository.reportUnit+json") - @GET("rest_v2/resources{resourceUri}") - Call requestReportResource( - @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri); - - @NotNull - @Headers("Accept: application/repository.folder+json") - @GET("rest_v2/resources{resourceUri}") - Call requestFolderResource( - @NotNull @Path(value = "resourceUri", encoded = true) String resourceUri); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java index 25434fe0..dcea8baf 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/Server.java @@ -32,7 +32,10 @@ import org.jetbrains.annotations.Nullable; import retrofit.Retrofit; -import java.net.*; +import java.net.CookieHandler; +import java.net.CookieManager; +import java.net.CookiePolicy; +import java.net.Proxy; import java.util.concurrent.TimeUnit; /** @@ -147,7 +150,7 @@ public AnonymousClient create() { Retrofit anonymousRetrofit = mServer.newRetrofit() .client(anonymousClient) .build(); - return new AnonymousClientImpl(anonymousRetrofit); + return new AnonymousClient(anonymousRetrofit); } } @@ -180,7 +183,7 @@ public AuthorizedClient create() { .build(); AnonymousClient anonymousClient = mServer.newClient().create(); - return new AuthorizedClientImpl(authRetrofit, anonymousClient); + return new AuthorizedClient(authRetrofit, anonymousClient); } private OkHttpClient configureAuthClient(OkHttpClient client) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java index 2400332a..f3e4dead 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApi.java @@ -25,8 +25,11 @@ package com.jaspersoft.android.sdk.network; import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; - import org.jetbrains.annotations.NotNull; +import retrofit.Call; +import retrofit.Retrofit; +import retrofit.http.GET; +import retrofit.http.Headers; import java.io.IOException; @@ -34,35 +37,105 @@ * @author Tom Koptel * @since 2.0 */ -public interface ServerRestApi { +public class ServerRestApi { + + private final RestApi mApi; + + public ServerRestApi(Retrofit retrofit) { + mApi = retrofit.create(RestApi.class); + } @NotNull - ServerInfoData requestServerInfo() throws HttpException, IOException; + public ServerInfoData requestServerInfo() throws IOException, HttpException { + Call call = mApi.requestServerInfo(); + return CallWrapper.wrap(call).body(); + } @NotNull - String requestBuild() throws HttpException, IOException; + public String requestEdition() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestEdition()).body(); + } @NotNull - String requestDateFormatPattern() throws HttpException, IOException; + public String requestVersion() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestVersion()).body(); + } @NotNull - String requestDateTimeFormatPattern() throws HttpException, IOException; + public String requestBuild() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestBuild()).body(); + } @NotNull - String requestEdition() throws HttpException, IOException; + public String requestFeatures() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestFeatures()).body(); + } @NotNull - String requestEditionName() throws HttpException, IOException; + public String requestEditionName() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestEditionName()).body(); + } @NotNull - String requestVersion() throws HttpException, IOException; + public String requestLicenseType() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestLicenseType()).body(); + } @NotNull - String requestFeatures() throws HttpException, IOException; + public String requestExpiration() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestExpiration()).body(); + } @NotNull - String requestLicenseType() throws HttpException, IOException; + public String requestDateFormatPattern() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestDateFormatPattern()).body(); + } @NotNull - String requestExpiration() throws HttpException, IOException; + public String requestDateTimeFormatPattern() throws IOException, HttpException { + return CallWrapper.wrap(mApi.requestDateTimeFormatPattern()).body(); + } + + private interface RestApi { + @NotNull + @Headers("Accept: application/json") + @GET(value = "rest_v2/serverInfo") + Call requestServerInfo(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/edition") + Call requestEdition(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/version") + Call requestVersion(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/build") + Call requestBuild(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/features") + Call requestFeatures(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/editionName") + Call requestEditionName(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/licenseType") + Call requestLicenseType(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/expiration") + Call requestExpiration(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/dateFormatPattern") + Call requestDateFormatPattern(); + + @Headers("Accept: text/plain") + @GET(value = "rest_v2/serverInfo/datetimeFormatPattern") + Call requestDateTimeFormatPattern(); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java deleted file mode 100644 index 6d29403e..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ServerRestApiImpl.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.network; - -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import org.jetbrains.annotations.NotNull; -import retrofit.Call; -import retrofit.Retrofit; -import retrofit.http.GET; -import retrofit.http.Headers; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ServerRestApiImpl implements ServerRestApi { - - private final RestApi mApi; - - public ServerRestApiImpl(Retrofit retrofit) { - mApi = retrofit.create(RestApi.class); - } - - @NotNull - @Override - public ServerInfoData requestServerInfo() throws IOException, HttpException { - Call call = mApi.requestServerInfo(); - return CallWrapper.wrap(call).body(); - } - - @NotNull - @Override - public String requestEdition() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestEdition()).body(); - } - - @NotNull - @Override - public String requestVersion() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestVersion()).body(); - } - - @NotNull - @Override - public String requestBuild() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestBuild()).body(); - } - - @NotNull - @Override - public String requestFeatures() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestFeatures()).body(); - } - - @NotNull - @Override - public String requestEditionName() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestEditionName()).body(); - } - - @NotNull - @Override - public String requestLicenseType() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestLicenseType()).body(); - } - - @NotNull - @Override - public String requestExpiration() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestExpiration()).body(); - } - - @NotNull - @Override - public String requestDateFormatPattern() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestDateFormatPattern()).body(); - } - - @NotNull - @Override - public String requestDateTimeFormatPattern() throws IOException, HttpException { - return CallWrapper.wrap(mApi.requestDateTimeFormatPattern()).body(); - } - - private interface RestApi { - @NotNull - @Headers("Accept: application/json") - @GET(value = "rest_v2/serverInfo") - Call requestServerInfo(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/edition") - Call requestEdition(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/version") - Call requestVersion(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/build") - Call requestBuild(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/features") - Call requestFeatures(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/editionName") - Call requestEditionName(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/licenseType") - Call requestLicenseType(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/expiration") - Call requestExpiration(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/dateFormatPattern") - Call requestDateFormatPattern(); - - @Headers("Accept: text/plain") - @GET(value = "rest_v2/serverInfo/datetimeFormatPattern") - Call requestDateTimeFormatPattern(); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java index 4964fe54..92ecbd03 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/StringConverterFactory.java @@ -28,13 +28,12 @@ import com.squareup.okhttp.MediaType; import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.ResponseBody; +import retrofit.Converter; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; -import retrofit.Converter; - /** * @author Tom Koptel * @since 2.0 diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java index b1833321..27c8379e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/report/option/ReportOptionSet.java @@ -26,7 +26,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; - import org.jetbrains.annotations.NotNull; import java.util.Collections; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java index a15d0c96..17766ea5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/server/EncryptionKey.java @@ -26,7 +26,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; - import org.jetbrains.annotations.NotNull; /** diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java index 24578627..9efc9b3b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/AuthorizationService.java @@ -25,24 +25,49 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + +import java.io.IOException; /** * @author Tom Koptel * @since 2.0 */ -public abstract class AuthorizationService { - public abstract Credentials authorize(Credentials credentials) throws ServiceException; +public class AuthorizationService { + private final AnonymousClient mClient; + private final ServiceExceptionMapper mServiceExceptionMapper; + + @TestOnly + AuthorizationService(AnonymousClient client, + ServiceExceptionMapper mapper) { + mServiceExceptionMapper = mapper; + mClient = client; + } + + public Credentials authorize(Credentials credentials) throws ServiceException { + try { + AuthenticationRestApi authenticationRestApi = mClient.authenticationApi(); + authenticationRestApi.authenticate(credentials); + return credentials; + } catch (IOException e) { + throw mServiceExceptionMapper.transform(e); + } catch (HttpException e) { + throw mServiceExceptionMapper.transform(e); + } + } @NotNull public static AuthorizationService newService(@NotNull AnonymousClient client) { Preconditions.checkNotNull(client, "Client should not be null"); ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - return new ProxyAuthorizationService(client, serviceExceptionMapper); + return new AuthorizationService(client, serviceExceptionMapper); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java deleted file mode 100644 index 2239b5a9..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationService.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.auth; - -import com.jaspersoft.android.sdk.network.AnonymousClient; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.Credentials; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; -import org.jetbrains.annotations.TestOnly; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ProxyAuthorizationService extends AuthorizationService { - private final AnonymousClient mClient; - private final ServiceExceptionMapper mServiceExceptionMapper; - - @TestOnly - ProxyAuthorizationService(AnonymousClient client, - ServiceExceptionMapper mapper) { - mServiceExceptionMapper = mapper; - mClient = client; - } - - @Override - public Credentials authorize(Credentials credentials) throws ServiceException { - try { - AuthenticationRestApi authenticationRestApi = mClient.authenticationApi(); - authenticationRestApi.authenticate(credentials); - return credentials; - } catch (IOException e) { - throw mServiceExceptionMapper.transform(e); - } catch (HttpException e) { - throw mServiceExceptionMapper.transform(e); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java index 49b3dca1..3d513a5a 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoService.java @@ -25,25 +25,53 @@ package com.jaspersoft.android.sdk.service.info; import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ServerRestApi; +import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + +import java.io.IOException; /** * @author Tom Koptel * @since 2.0 */ -public abstract class ServerInfoService { +public class ServerInfoService { + private final ServerRestApi mRestApi; + private final ServerInfoTransformer mTransformer; + private final ServiceExceptionMapper mServiceExceptionMapper; + + @TestOnly + ServerInfoService(ServerRestApi restApi, + ServerInfoTransformer transformer, + ServiceExceptionMapper serviceExceptionMapper) { + mRestApi = restApi; + mTransformer = transformer; + mServiceExceptionMapper = serviceExceptionMapper; + } + @NotNull - public abstract ServerInfo requestServerInfo() throws ServiceException; + public ServerInfo requestServerInfo() throws ServiceException { + try { + ServerInfoData response = mRestApi.requestServerInfo(); + return mTransformer.transform(response); + } catch (HttpException e) { + throw mServiceExceptionMapper.transform(e); + } catch (IOException e) { + throw mServiceExceptionMapper.transform(e); + } + } @NotNull public static ServerInfoService newService(@NotNull AnonymousClient client) { Preconditions.checkNotNull(client, "Client should not be null"); ServiceExceptionMapper serviceExceptionMapper = new DefaultExceptionMapper(); - return new ServerInfoServiceImpl(client.infoApi(), ServerInfoTransformer.get(), serviceExceptionMapper); + return new ServerInfoService(client.infoApi(), ServerInfoTransformer.get(), serviceExceptionMapper); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceImpl.java deleted file mode 100644 index 1278f2a1..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.info; - -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.network.ServerRestApi; -import com.jaspersoft.android.sdk.network.entity.server.ServerInfoData; -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; - -import java.io.IOException; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ServerInfoServiceImpl extends ServerInfoService { - private final ServerRestApi mRestApi; - private final ServerInfoTransformer mTransformer; - private final ServiceExceptionMapper mServiceExceptionMapper; - - @TestOnly - ServerInfoServiceImpl(ServerRestApi restApi, ServerInfoTransformer transformer, ServiceExceptionMapper serviceExceptionMapper) { - mRestApi = restApi; - mTransformer = transformer; - mServiceExceptionMapper = serviceExceptionMapper; - } - - @NotNull - @Override - public ServerInfo requestServerInfo() throws ServiceException { - try { - ServerInfoData response = mRestApi.requestServerInfo(); - return mTransformer.transform(response); - } catch (HttpException e) { - throw mServiceExceptionMapper.transform(e); - } catch (IOException e) { - throw mServiceExceptionMapper.transform(e); - } - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java index c7ab6527..3ce4611e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/DefaultExceptionMapper.java @@ -26,9 +26,8 @@ import com.jaspersoft.android.sdk.network.HttpException; import com.jaspersoft.android.sdk.network.entity.execution.ErrorDescriptor; -import com.jaspersoft.android.sdk.service.exception.StatusCodes; import com.jaspersoft.android.sdk.service.exception.ServiceException; - +import com.jaspersoft.android.sdk.service.exception.StatusCodes; import org.jetbrains.annotations.NotNull; import java.io.IOException; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCache.java b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCache.java index 9bb424c7..f6bdd6b2 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCache.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/internal/info/InMemoryInfoCache.java @@ -25,7 +25,6 @@ package com.jaspersoft.android.sdk.service.internal.info; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.internal.info.InfoCache; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java index 93f1d2f2..62479317 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AbstractReportExecution.java @@ -39,7 +39,7 @@ * @author Tom Koptel * @since 2.0 */ -abstract class AbstractReportExecution implements ReportExecution { +abstract class AbstractReportExecution extends ReportExecution { protected final ReportExecutionApi mReportExecutionApi; protected final String mExecId; protected final String mReportUri; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java index 663b965a..1d11749b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/AttachmentsFactory.java @@ -48,7 +48,7 @@ public List create(ExportDescriptor export, String execId) { List attachments = new ArrayList<>(rawAttachments.size()); for (AttachmentDescriptor attachment : rawAttachments) { String fileName = attachment.getFileName(); - ReportAttachment reportAttachment = new ReportAttachmentImpl( + ReportAttachment reportAttachment = new ReportAttachment( mExportExecutionApi, execId, exportId, diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java index 250e4416..ab515b0e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ExportFactory.java @@ -53,7 +53,7 @@ public ReportExport create(ReportExecutionDescriptor descriptor, String execId, throw new ServiceException("Server returned malformed export details", null, StatusCodes.EXPORT_EXECUTION_FAILED); } List attachments = mAttachmentsFactory.create(export, execId); - return new ReportExportImpl(mExportExecutionApi, attachments, execId, exportId); + return new ReportExport(mExportExecutionApi, attachments, execId, exportId); } @Nullable diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java index efcf0d8f..6f7a1467 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachment.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ @@ -27,12 +27,35 @@ import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; /** * @author Tom Koptel * @since 2.0 */ -public interface ReportAttachment { +public class ReportAttachment { + private final ExportExecutionApi mExportExecutionApi; + private final String mExecutionId; + private final String mExportId; + private final String mFileName; + + @TestOnly + ReportAttachment(ExportExecutionApi exportExecutionApi, + String executionId, + String exportId, + String fileName) { + mExportExecutionApi = exportExecutionApi; + mExecutionId = executionId; + mExportId = exportId; + mFileName = fileName; + } + @NotNull - ResourceOutput download() throws ServiceException; + public ResourceOutput download() throws ServiceException { + return mExportExecutionApi.downloadAttachment( + mExecutionId, + mExportId, + mFileName + ); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentImpl.java deleted file mode 100644 index 6eaceab4..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import org.jetbrains.annotations.NotNull; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ReportAttachmentImpl implements ReportAttachment { - private final ExportExecutionApi mExportExecutionApi; - private final String mExecutionId; - private final String mExportId; - private final String mFileName; - - ReportAttachmentImpl(ExportExecutionApi exportExecutionApi, - String executionId, - String exportId, - String fileName) { - mExportExecutionApi = exportExecutionApi; - mExecutionId = executionId; - mExportId = exportId; - mFileName = fileName; - } - - @NotNull - @Override - public ResourceOutput download() throws ServiceException { - return mExportExecutionApi.downloadAttachment( - mExecutionId, - mExportId, - mFileName - ); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java index 090c5c9a..86c17680 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExecution.java @@ -36,13 +36,13 @@ * @author Tom Koptel * @since 2.0 */ -public interface ReportExecution { +public abstract class ReportExecution { @NotNull - ReportExport export(@NotNull ReportExportOptions options) throws ServiceException; + public abstract ReportExport export(@NotNull ReportExportOptions options) throws ServiceException; @NotNull - ReportMetadata waitForReportCompletion() throws ServiceException; + public abstract ReportMetadata waitForReportCompletion() throws ServiceException; @NotNull - ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException; + public abstract ReportExecution updateExecution(@Nullable List newParameters) throws ServiceException; } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java index 76c460b8..50acdab5 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExport.java @@ -1,24 +1,24 @@ /* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android + * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. + * http://community.jaspersoft.com/project/mobile-sdk-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * - * This program is part of TIBCO Jaspersoft Mobile for Android. + * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify + * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, + * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see + * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * . */ @@ -27,6 +27,7 @@ import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; import com.jaspersoft.android.sdk.service.exception.ServiceException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import java.util.List; @@ -34,10 +35,30 @@ * @author Tom Koptel * @since 2.0 */ -public interface ReportExport { +public class ReportExport { + private final ExportExecutionApi mExportExecutionApi; + private final List mAttachments; + private final String mExecutionId; + private final String mExportId; + + @TestOnly + ReportExport(ExportExecutionApi exportExecutionApi, + List attachments, + String executionId, + String exportId) { + mExportExecutionApi = exportExecutionApi; + mAttachments = attachments; + mExecutionId = executionId; + mExportId = exportId; + } + @NotNull - List getAttachments(); + public List getAttachments() { + return mAttachments; + } @NotNull - ReportExportOutput download() throws ServiceException; + public ReportExportOutput download() throws ServiceException { + return mExportExecutionApi.downloadExport(mExecutionId, mExportId); + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java deleted file mode 100644 index 94a64364..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/ReportExportImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.report; - -import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ReportExportImpl implements ReportExport { - private final ExportExecutionApi mExportExecutionApi; - private final List mAttachments; - private final String mExecutionId; - private final String mExportId; - - ReportExportImpl(ExportExecutionApi exportExecutionApi, - List attachments, - String executionId, - String exportId) { - mExportExecutionApi = exportExecutionApi; - mAttachments = attachments; - mExecutionId = executionId; - mExportId = exportId; - } - - @NotNull - @Override - public List getAttachments() { - return mAttachments; - } - - @NotNull - @Override - public ReportExportOutput download() throws ServiceException { - return mExportExecutionApi.downloadExport(mExecutionId, mExportId); - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java index fa8302b0..5c2e27ec 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/RetryReportExecution.java @@ -37,7 +37,7 @@ * @author Tom Koptel * @since 2.0 */ -final class RetryReportExecution implements ReportExecution { +final class RetryReportExecution extends ReportExecution { private final ReportExecution mDelegate; RetryReportExecution(ReportExecution delegate) { diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java deleted file mode 100644 index 24a1284b..00000000 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryService.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.service.data.report.ReportResource; -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Preconditions; -import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class ProxyRepositoryService extends RepositoryService { - private final SearchUseCase mSearchUseCase; - private final RepositoryUseCase mRepositoryUseCase; - private final InfoCacheManager mInfoCacheManager; - - @TestOnly - ProxyRepositoryService( - SearchUseCase searchUseCase, - RepositoryUseCase repositoryUseCase, - InfoCacheManager infoCacheManager) { - mSearchUseCase = searchUseCase; - mRepositoryUseCase = repositoryUseCase; - mInfoCacheManager = infoCacheManager; - } - - @NotNull - @Override - public SearchTask search(@Nullable SearchCriteria criteria) { - if (criteria == null) { - criteria = SearchCriteria.none(); - } - - InternalCriteria internalCriteria = InternalCriteria.from(criteria); - SearchTaskFactory searchTaskFactory = new SearchTaskFactory(internalCriteria, mSearchUseCase, mInfoCacheManager); - return new SearchTaskProxy(searchTaskFactory); - } - - @NotNull - @Override - public ReportResource fetchReportDetails(@NotNull String reportUri) throws ServiceException { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - return mRepositoryUseCase.getReportDetails(reportUri); - } - - @NotNull - @Override - public List fetchRootFolders() throws ServiceException { - InternalCriteria rootFolder = new InternalCriteria.Builder() - .folderUri("/") - .resourceMask(SearchCriteria.FOLDER) - .create(); - List folders = new ArrayList<>(10); - SearchResult result = mSearchUseCase.performSearch(rootFolder); - folders.addAll(result.getResources()); - - InternalCriteria publicFolder = rootFolder.newBuilder() - .folderUri("/public") - .create(); - SearchResult publicFoldersResult = mSearchUseCase.performSearch(publicFolder); - folders.addAll(publicFoldersResult.getResources()); - - return folders; - } -} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java index 7a263ed4..30481e8b 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/RepositoryService.java @@ -28,6 +28,7 @@ import com.jaspersoft.android.sdk.network.RepositoryRestApi; import com.jaspersoft.android.sdk.service.data.report.ReportResource; import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.*; import com.jaspersoft.android.sdk.service.internal.info.InMemoryInfoCache; @@ -35,22 +36,65 @@ import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; +import java.util.ArrayList; import java.util.List; /** * @author Tom Koptel * @since 2.0 */ -public abstract class RepositoryService { +public class RepositoryService { + private final SearchUseCase mSearchUseCase; + private final RepositoryUseCase mRepositoryUseCase; + private final InfoCacheManager mInfoCacheManager; + + @TestOnly + RepositoryService( + SearchUseCase searchUseCase, + RepositoryUseCase repositoryUseCase, + InfoCacheManager infoCacheManager) { + mSearchUseCase = searchUseCase; + mRepositoryUseCase = repositoryUseCase; + mInfoCacheManager = infoCacheManager; + } + @NotNull - public abstract SearchTask search(@Nullable SearchCriteria criteria); + public SearchTask search(@Nullable SearchCriteria criteria) { + if (criteria == null) { + criteria = SearchCriteria.none(); + } + + InternalCriteria internalCriteria = InternalCriteria.from(criteria); + SearchTaskFactory searchTaskFactory = new SearchTaskFactory(internalCriteria, mSearchUseCase, mInfoCacheManager); + return new SearchTaskProxy(searchTaskFactory); + } @NotNull - public abstract ReportResource fetchReportDetails(@NotNull String reportUri) throws ServiceException; + public ReportResource fetchReportDetails(@NotNull String reportUri) throws ServiceException { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + return mRepositoryUseCase.getReportDetails(reportUri); + } @NotNull - public abstract List fetchRootFolders() throws ServiceException; + public List fetchRootFolders() throws ServiceException { + InternalCriteria rootFolder = new InternalCriteria.Builder() + .folderUri("/") + .resourceMask(SearchCriteria.FOLDER) + .create(); + List folders = new ArrayList<>(10); + SearchResult result = mSearchUseCase.performSearch(rootFolder); + folders.addAll(result.getResources()); + + InternalCriteria publicFolder = rootFolder.newBuilder() + .folderUri("/public") + .create(); + SearchResult publicFoldersResult = mSearchUseCase.performSearch(publicFolder); + folders.addAll(publicFoldersResult.getResources()); + + return folders; + } @NotNull public static RepositoryService newService(@NotNull AuthorizedClient client) { @@ -72,6 +116,6 @@ public static RepositoryService newService(@NotNull AuthorizedClient client) { ReportResourceMapper reportResourceMapper = new ReportResourceMapper(); RepositoryUseCase repositoryUseCase = new RepositoryUseCase(defaultExMapper, repositoryRestApi, reportResourceMapper, cacheManager); - return new ProxyRepositoryService(searchUseCase, repositoryUseCase, cacheManager); + return new RepositoryService(searchUseCase, repositoryUseCase, cacheManager); } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java index 502e82b8..19316f27 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTask.java @@ -34,8 +34,9 @@ * @author Tom Koptel * @since 2.0 */ -public interface SearchTask { +public abstract class SearchTask { @NotNull - List nextLookup() throws ServiceException; - boolean hasNext(); + public abstract List nextLookup() throws ServiceException; + + public abstract boolean hasNext(); } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java index 4d4f63c7..cbc9285c 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskProxy.java @@ -34,7 +34,7 @@ * @author Tom Koptel * @since 2.0 */ -final class SearchTaskProxy implements SearchTask { +final class SearchTaskProxy extends SearchTask { private final SearchTaskFactory mSearchTaskFactory; private SearchTask mDelegate; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5.java index fd10fd9a..87eafba3 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_5.java @@ -37,7 +37,7 @@ * @author Tom Koptel * @since 2.0 */ -final class SearchTaskV5_5 implements SearchTask { +final class SearchTaskV5_5 extends SearchTask { private static final List EMPTY_RESPONSE = Collections.emptyList(); private static final int MAX_RETRY_COUNT = 5; diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6Plus.java b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6Plus.java index e1653bec..901f6d8e 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6Plus.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/repository/SearchTaskV5_6Plus.java @@ -36,7 +36,7 @@ * @author Tom Koptel * @since 2.0 */ -final class SearchTaskV5_6Plus implements SearchTask { +final class SearchTaskV5_6Plus extends SearchTask { public static final List EMPTY_RESPONSE = Collections.emptyList(); private final static int UNDEFINED = -1; diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java index 0d4ab847..f8d073e3 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/AuthorizationClientTestImplTest.java @@ -38,12 +38,12 @@ public class AuthorizationClientTestImplTest { @Mock Credentials mCredentials; - private AuthenticationRestApiImpl authorization; + private AuthenticationRestApi authorization; @Before public void setUp() throws Exception { initMocks(this); - authorization = new AuthenticationRestApiImpl(mAuthStrategy); + authorization = new AuthenticationRestApi(mAuthStrategy); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java index d84cbc11..5a95054a 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/InputControlRestApiTest.java @@ -77,7 +77,7 @@ public void setup() { .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); - restApiUnderTest = new InputControlRestApiImpl(retrofit); + restApiUnderTest = new InputControlRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java index 331d1777..5e853952 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExecutionRestApiTest.java @@ -87,7 +87,7 @@ public void setup() { .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); - restApiUnderTest = new ReportExecutionRestApiImpl(retrofit); + restApiUnderTest = new ReportExecutionRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java index c65f0857..38dacdb8 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportExportRestApiTest.java @@ -70,7 +70,7 @@ public void setup() { .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); - restApiUnderTest = new ReportExportRestApiImpl(retrofit); + restApiUnderTest = new ReportExportRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java index 9e3cc679..7562185c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportOptionRestApiTest.java @@ -78,7 +78,7 @@ public void setup() { .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); - restApiUnderTest = new ReportOptionRestApiImpl(retrofit); + restApiUnderTest = new ReportOptionRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java index c027154a..6183bb8e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/RepositoryRestApiTest.java @@ -74,7 +74,7 @@ public void setup() { .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); - restApiUnderTest = new RepositoryRestApiImpl(retrofit); + restApiUnderTest = new RepositoryRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java index 6f634fb2..483a2a88 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ServerRestApiTest.java @@ -55,7 +55,7 @@ public void setup() { .withBaseUrl(mWebMockRule.getRootUrl()) .build(); Retrofit retrofit = server.newRetrofit().build(); - objectUnderTest = new ServerRestApiImpl(retrofit); + objectUnderTest = new ServerRestApi(retrofit); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java index 9bf2a621..4a80f692 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/AuthorizationServiceTest.java @@ -25,27 +25,91 @@ package com.jaspersoft.android.sdk.service.auth; import com.jaspersoft.android.sdk.network.AnonymousClient; +import com.jaspersoft.android.sdk.network.AuthenticationRestApi; +import com.jaspersoft.android.sdk.network.Credentials; +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mock; +import java.io.IOException; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import static org.junit.Assert.fail; import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; public class AuthorizationServiceTest { @Mock AnonymousClient mAnonymousClient; + @Mock + AuthenticationRestApi mAuthenticationRestApi; + @Mock + ServiceExceptionMapper mServiceExceptionMapper; + @Mock + Credentials mCredentials; + + @Mock + HttpException mHttpException; + @Mock + IOException mIOException; + @Mock + ServiceException mServiceException; + @Rule public ExpectedException expected = none(); + private AuthorizationService authorizationService; + @Before public void setUp() throws Exception { initMocks(this); + when(mAnonymousClient.authenticationApi()).thenReturn(mAuthenticationRestApi); + authorizationService = new AuthorizationService(mAnonymousClient, mServiceExceptionMapper); + } + + @Test + public void testAuthorize() throws Exception { + authorizationService.authorize(mCredentials); + verify(mAnonymousClient).authenticationApi(); + verify(mAuthenticationRestApi).authenticate(mCredentials); + verifyZeroInteractions(mServiceExceptionMapper); + } + + @Test + public void testShouldMapHttpException() throws Exception { + when(mServiceExceptionMapper.transform(any(HttpException.class))).thenReturn(mServiceException); + doThrow(mHttpException).when(mAuthenticationRestApi).authenticate(any(Credentials.class)); + + try { + authorizationService.authorize(mCredentials); + fail("Should fail with service exception"); + } catch (ServiceException ex) { + assertThat(ex, is(mServiceException)); + } + } + + @Test + public void testShouldMapIOException() throws Exception { + when(mServiceExceptionMapper.transform(any(IOException.class))).thenReturn(mServiceException); + doThrow(mIOException).when(mAuthenticationRestApi).authenticate(any(Credentials.class)); + + try { + authorizationService.authorize(mCredentials); + fail("Should fail with service exception"); + } catch (ServiceException ex) { + assertThat(ex, is(mServiceException)); + } } @Test @@ -54,11 +118,4 @@ public void should_not_allow_null_client() throws Exception { expected.expectMessage("Client should not be null"); AuthorizationService.newService(null); } - - @Test - public void should_create_new_proxy_service() throws Exception { - AuthorizationService service = AuthorizationService.newService(mAnonymousClient); - assertThat(service, is(instanceOf(ProxyAuthorizationService.class))); - assertThat(service, is(notNullValue())); - } } \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java deleted file mode 100644 index 5fdbfbf8..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/auth/ProxyAuthorizationServiceTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.auth; - -import com.jaspersoft.android.sdk.network.AnonymousClient; -import com.jaspersoft.android.sdk.network.AuthenticationRestApi; -import com.jaspersoft.android.sdk.network.Credentials; -import com.jaspersoft.android.sdk.network.HttpException; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; - -import java.io.IOException; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.initMocks; - -public class ProxyAuthorizationServiceTest { - - @Mock - AnonymousClient mAnonymousClient; - @Mock - AuthenticationRestApi mAuthenticationRestApi; - @Mock - ServiceExceptionMapper mServiceExceptionMapper; - @Mock - Credentials mCredentials; - - @Mock - HttpException mHttpException; - @Mock - IOException mIOException; - @Mock - ServiceException mServiceException; - - private ProxyAuthorizationService authorizationService; - - @Before - public void setUp() throws Exception { - initMocks(this); - when(mAnonymousClient.authenticationApi()).thenReturn(mAuthenticationRestApi); - authorizationService = new ProxyAuthorizationService(mAnonymousClient, mServiceExceptionMapper); - } - - @Test - public void testAuthorize() throws Exception { - authorizationService.authorize(mCredentials); - verify(mAnonymousClient).authenticationApi(); - verify(mAuthenticationRestApi).authenticate(mCredentials); - verifyZeroInteractions(mServiceExceptionMapper); - } - - @Test - public void testShouldMapHttpException() throws Exception { - when(mServiceExceptionMapper.transform(any(HttpException.class))).thenReturn(mServiceException); - doThrow(mHttpException).when(mAuthenticationRestApi).authenticate(any(Credentials.class)); - - try { - authorizationService.authorize(mCredentials); - fail("Should fail with service exception"); - } catch (ServiceException ex) { - assertThat(ex, is(mServiceException)); - } - } - - @Test - public void testShouldMapIOException() throws Exception { - when(mServiceExceptionMapper.transform(any(IOException.class))).thenReturn(mServiceException); - doThrow(mIOException).when(mAuthenticationRestApi).authenticate(any(Credentials.class)); - - try { - authorizationService.authorize(mCredentials); - fail("Should fail with service exception"); - } catch (ServiceException ex) { - assertThat(ex, is(mServiceException)); - } - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceTest.java index 7cc1916b..c205229e 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/info/ServerInfoServiceTest.java @@ -66,12 +66,12 @@ public class ServerInfoServiceTest { @Rule public ExpectedException expected = none(); - private ServerInfoServiceImpl serviceUnderTest; + private ServerInfoService serviceUnderTest; @Before public void setup() { MockitoAnnotations.initMocks(this); - serviceUnderTest = new ServerInfoServiceImpl(mockApi, mockTransformer, mockServiceExceptionMapper); + serviceUnderTest = new ServerInfoService(mockApi, mockTransformer, mockServiceExceptionMapper); } @Test @@ -87,7 +87,7 @@ public void requestInfoShouldProvideServerInfoDataObject() throws Exception { @Test public void should_create_proxy_instance() throws Exception { ServerInfoService service = ServerInfoService.newService(mClient); - assertThat("Should be instance of proxy service", service, is(instanceOf(ServerInfoServiceImpl.class))); + assertThat("Should be instance of proxy service", service, is(instanceOf(ServerInfoService.class))); assertThat(service, is(notNullValue())); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java index 83b8e7c3..6286dd4c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ExportFactoryTest.java @@ -76,7 +76,7 @@ public void setUp() throws Exception { public void should_create_export_if_details_fulfilled() throws Exception { ReportExport result = exportFactory.create(mReportExecutionDescriptor, EXEC_ID, EXPORT_ID); assertThat(result, is(notNullValue())); - assertThat(result, is(instanceOf(ReportExportImpl.class))); + assertThat(result, is(instanceOf(ReportExport.class))); verify(mAttachmentsFactory).create(mExportDescriptor, EXEC_ID); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java index 87f2b912..6d46a06c 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportAttachmentTest.java @@ -62,12 +62,12 @@ public class ReportAttachmentTest { @Mock ExportExecutionApi mExportExecutionApi; - private ReportAttachmentImpl objectUnderTest; + private ReportAttachment objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new ReportAttachmentImpl(mExportExecutionApi, EXEC_ID, EXPORT_ID, ATTACHMENT_ID); + objectUnderTest = new ReportAttachment(mExportExecutionApi, EXEC_ID, EXPORT_ID, ATTACHMENT_ID); } @Test diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java index 639863ab..a7a376d4 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/ReportExportTest.java @@ -46,12 +46,12 @@ public class ReportExportTest { @Mock ExportExecutionApi mExportExecutionApi; - private ReportExportImpl objectUnderTest; + private ReportExport objectUnderTest; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - objectUnderTest = new ReportExportImpl(mExportExecutionApi, + objectUnderTest = new ReportExport(mExportExecutionApi, Collections.emptyList(), EXEC_ID, EXPORT_ID); } diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java deleted file mode 100644 index 69b759aa..00000000 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/ProxyRepositoryServiceTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2015 TIBCO Jaspersoft Corporation. All rights reserved. - * http://community.jaspersoft.com/project/mobile-sdk-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile SDK for Android. - * - * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile SDK is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.repository; - -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.data.repository.SearchResult; -import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; -import com.jaspersoft.android.sdk.test.Chain; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.util.Collections; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.junit.rules.ExpectedException.none; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -/** - * @author Tom Koptel - * @since 2.0 - */ -public class ProxyRepositoryServiceTest { - private static final String REPORT_URI = "/my/uri"; - - @Mock - SearchUseCase mSearchUseCase; - @Mock - RepositoryUseCase mRepositoryUseCase; - @Mock - InfoCacheManager mInfoCacheManager; - - @Mock - Resource rootFolder; - @Mock - Resource publicFolder; - - @Rule - public ExpectedException expected = none(); - - private ProxyRepositoryService objectUnderTest; - - @Rule - public ExpectedException mExpectedException = none(); - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - - - - objectUnderTest = new ProxyRepositoryService(mSearchUseCase, mRepositoryUseCase, mInfoCacheManager); - } - - @Test - public void shouldProvideListOfResources() { - SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); - assertThat(searchTask, is(notNullValue())); - } - - @Test - public void should_accept_null_criteria() { - SearchTask searchTask = objectUnderTest.search(null); - assertThat(searchTask, is(notNullValue())); - } - - @Test - public void fetch_should_delegate_request_on_usecase() throws Exception { - objectUnderTest.fetchReportDetails(REPORT_URI); - verify(mRepositoryUseCase).getReportDetails(REPORT_URI); - } - - @Test - public void fetch_report_details_fails_with_null_uri() throws Exception { - expected.expectMessage("Report uri should not be null"); - expected.expect(NullPointerException.class); - objectUnderTest.fetchReportDetails(null); - } - - @Test - public void fetch_root_folders_performs_two_lookups() throws Exception { - SearchResult rootFolderLookup = new SearchResult(Collections.singletonList(rootFolder), 0); - SearchResult publicFolderLookup = new SearchResult(Collections.singletonList(publicFolder), 0); - when(mSearchUseCase.performSearch(any(InternalCriteria.class))) - .then(Chain.of(rootFolderLookup, publicFolderLookup)); - List folders = objectUnderTest.fetchRootFolders(); - - assertThat(folders, hasItem(rootFolder)); - assertThat(folders, hasItem(publicFolder)); - - InternalCriteria rootFolder = new InternalCriteria.Builder() - .folderUri("/") - .resourceMask(SearchCriteria.FOLDER) - .create(); - verify(mSearchUseCase).performSearch(rootFolder); - InternalCriteria publicFolder = rootFolder.newBuilder() - .folderUri("/public") - .create(); - verify(mSearchUseCase).performSearch(publicFolder); - } -} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java index 1dc9de55..a8fadfd2 100644 --- a/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/repository/RepositoryServiceTest.java @@ -25,34 +25,55 @@ package com.jaspersoft.android.sdk.service.repository; import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.data.repository.SearchResult; +import com.jaspersoft.android.sdk.service.internal.info.InfoCacheManager; +import com.jaspersoft.android.sdk.test.Chain; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mock; +import java.util.Collections; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; public class RepositoryServiceTest { + private static final String REPORT_URI = "/my/uri"; + @Mock AuthorizedClient mClient; + @Mock + SearchUseCase mSearchUseCase; + @Mock + RepositoryUseCase mRepositoryUseCase; + @Mock + InfoCacheManager mInfoCacheManager; + + @Mock + Resource rootFolder; + @Mock + Resource publicFolder; + @Rule public ExpectedException expected = none(); + private RepositoryService objectUnderTest; + @Before public void setUp() throws Exception { initMocks(this); - } - - @Test - public void should_create_proxy_instance() throws Exception { - RepositoryService service = RepositoryService.newService(mClient); - assertThat("Should be instance of proxy service", service, is(instanceOf(ProxyRepositoryService.class))); - assertThat(service, is(notNullValue())); + objectUnderTest = new RepositoryService(mSearchUseCase, mRepositoryUseCase, mInfoCacheManager); } @Test @@ -62,4 +83,51 @@ public void should_reject_null_client() throws Exception { RepositoryService.newService(null); } + + @Test + public void shouldProvideListOfResources() { + SearchTask searchTask = objectUnderTest.search(SearchCriteria.none()); + assertThat(searchTask, is(notNullValue())); + } + + @Test + public void should_accept_null_criteria() { + SearchTask searchTask = objectUnderTest.search(null); + assertThat(searchTask, is(notNullValue())); + } + + @Test + public void fetch_should_delegate_request_on_usecase() throws Exception { + objectUnderTest.fetchReportDetails(REPORT_URI); + verify(mRepositoryUseCase).getReportDetails(REPORT_URI); + } + + @Test + public void fetch_report_details_fails_with_null_uri() throws Exception { + expected.expectMessage("Report uri should not be null"); + expected.expect(NullPointerException.class); + objectUnderTest.fetchReportDetails(null); + } + + @Test + public void fetch_root_folders_performs_two_lookups() throws Exception { + SearchResult rootFolderLookup = new SearchResult(Collections.singletonList(rootFolder), 0); + SearchResult publicFolderLookup = new SearchResult(Collections.singletonList(publicFolder), 0); + when(mSearchUseCase.performSearch(any(InternalCriteria.class))) + .then(Chain.of(rootFolderLookup, publicFolderLookup)); + List folders = objectUnderTest.fetchRootFolders(); + + assertThat(folders, hasItem(rootFolder)); + assertThat(folders, hasItem(publicFolder)); + + InternalCriteria rootFolder = new InternalCriteria.Builder() + .folderUri("/") + .resourceMask(SearchCriteria.FOLDER) + .create(); + verify(mSearchUseCase).performSearch(rootFolder); + InternalCriteria publicFolder = rootFolder.newBuilder() + .folderUri("/public") + .create(); + verify(mSearchUseCase).performSearch(publicFolder); + } } \ No newline at end of file diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java index 7b0f4151..0ad5f0ac 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationService.java @@ -27,23 +27,45 @@ import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.network.Credentials; import com.jaspersoft.android.sdk.service.auth.AuthorizationService; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel * @since 2.0 */ -public abstract class RxAuthorizationService { +public class RxAuthorizationService { + private final AuthorizationService mSyncDelegate; + + @TestOnly + RxAuthorizationService(AuthorizationService service) { + mSyncDelegate = service; + } + @NotNull - public abstract Observable authorize(@NotNull Credentials credentials); + public Observable authorize(@NotNull final Credentials credentials) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + mSyncDelegate.authorize(credentials); + return Observable.just(credentials); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull public static RxAuthorizationService newService(@NotNull AnonymousClient client) { Preconditions.checkNotNull(client, "Client should not be null"); AuthorizationService service = AuthorizationService.newService(client); - return new RxAuthorizationServiceImpl(service); + return new RxAuthorizationService(service); } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java deleted file mode 100644 index 4ae0267c..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.auth; - -import com.jaspersoft.android.sdk.network.Credentials; -import com.jaspersoft.android.sdk.service.auth.AuthorizationService; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; -import rx.Observable; -import rx.functions.Func0; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxAuthorizationServiceImpl extends RxAuthorizationService { - private final AuthorizationService mSyncDelegate; - - @TestOnly - RxAuthorizationServiceImpl(AuthorizationService service) { - mSyncDelegate = service; - } - - @NotNull - @Override - public Observable authorize(@NotNull final Credentials credentials) { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - mSyncDelegate.authorize(credentials); - return Observable.just(credentials); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } -} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java index 88d2270e..2d751d3d 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoService.java @@ -26,23 +26,45 @@ import com.jaspersoft.android.sdk.network.AnonymousClient; import com.jaspersoft.android.sdk.service.data.server.ServerInfo; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.info.ServerInfoService; import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel * @since 2.0 */ -public abstract class RxServerInfoService { +public class RxServerInfoService { + private final ServerInfoService mSyncDelegate; + + @TestOnly + RxServerInfoService(ServerInfoService infoService) { + mSyncDelegate = infoService; + } + @NotNull - public abstract Observable requestServerInfo(); + public Observable requestServerInfo() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ServerInfo serverInfo = mSyncDelegate.requestServerInfo(); + return Observable.just(serverInfo); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull public static RxServerInfoService newService(@NotNull AnonymousClient anonymousClient) { Preconditions.checkNotNull(anonymousClient, "Client should not be null"); ServerInfoService service = ServerInfoService.newService(anonymousClient); - return new RxServerInfoServiceImpl(service); + return new RxServerInfoService(service); } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java deleted file mode 100644 index 85e47d93..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.info; - -import com.jaspersoft.android.sdk.service.data.server.ServerInfo; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.info.ServerInfoService; -import org.jetbrains.annotations.NotNull; -import rx.Observable; -import rx.functions.Func0; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxServerInfoServiceImpl extends RxServerInfoService { - private final ServerInfoService mSyncDelegate; - - RxServerInfoServiceImpl(ServerInfoService infoService) { - mSyncDelegate = infoService; - } - - @NotNull - @Override - public Observable requestServerInfo() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ServerInfo serverInfo = mSyncDelegate.requestServerInfo(); - return Observable.just(serverInfo); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } -} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java index b7c06ca6..e7445f1c 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachment.java @@ -25,15 +25,38 @@ package com.jaspersoft.android.sdk.service.rx.report; import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportAttachment; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; /** * @author Tom Koptel * @since 2.0 */ -public interface RxReportAttachment { +public class RxReportAttachment { + private final ReportAttachment mSyncDelegate; + + @TestOnly + RxReportAttachment(ReportAttachment attachment) { + mSyncDelegate = attachment; + } + @NotNull - Observable download(); + public Observable download() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ResourceOutput content = mSyncDelegate.download(); + return Observable.just(content); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java deleted file mode 100644 index eced3a73..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.report; - -import com.jaspersoft.android.sdk.service.data.report.ResourceOutput; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.report.ReportAttachment; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; -import rx.Observable; -import rx.functions.Func0; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxReportAttachmentImpl implements RxReportAttachment { - private final ReportAttachment mSyncDelegate; - - @TestOnly - RxReportAttachmentImpl(ReportAttachment attachment) { - mSyncDelegate = attachment; - } - - @NotNull - @Override - public Observable download() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ResourceOutput content = mSyncDelegate.download(); - return Observable.just(content); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } -} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java index 41a7d410..4d026974 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecution.java @@ -26,10 +26,16 @@ import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.report.ReportExecution; +import com.jaspersoft.android.sdk.service.report.ReportExport; import com.jaspersoft.android.sdk.service.report.ReportExportOptions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; import java.util.List; @@ -37,13 +43,60 @@ * @author Tom Koptel * @since 2.0 */ -public interface RxReportExecution { +public class RxReportExecution { + private final ReportExecution mSyncDelegate; + + @TestOnly + RxReportExecution(ReportExecution reportExecution) { + mSyncDelegate = reportExecution; + } + @NotNull - Observable export(@NotNull ReportExportOptions options); + public Observable export(final @NotNull ReportExportOptions options) { + Preconditions.checkNotNull(options, "Export options should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExport export = mSyncDelegate.export(options); + RxReportExport rxReportExport = new RxReportExport(export); + return Observable.just(rxReportExport); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - Observable waitForReportCompletion(); + public Observable waitForReportCompletion() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportMetadata data = mSyncDelegate.waitForReportCompletion(); + return Observable.just(data); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - Observable updateExecution(@Nullable List newParameters); + public Observable updateExecution(@Nullable final List newParameters) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExecution execution = mSyncDelegate.updateExecution(newParameters); + RxReportExecution rxExec = new RxReportExecution(execution); + return Observable.just(rxExec); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java deleted file mode 100644 index 7b2c67fc..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.report; - -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.service.data.report.ReportMetadata; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Preconditions; -import com.jaspersoft.android.sdk.service.report.ReportExecution; -import com.jaspersoft.android.sdk.service.report.ReportExport; -import com.jaspersoft.android.sdk.service.report.ReportExportOptions; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; -import rx.Observable; -import rx.functions.Func0; - -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxReportExecutionImpl implements RxReportExecution { - private final ReportExecution mSyncDelegate; - - @TestOnly - RxReportExecutionImpl(ReportExecution reportExecution) { - mSyncDelegate = reportExecution; - } - - @NotNull - @Override - public Observable export(final @NotNull ReportExportOptions options) { - Preconditions.checkNotNull(options, "Export options should not be null"); - - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ReportExport export = mSyncDelegate.export(options); - RxReportExport rxReportExport = new RxReportExportImpl(export); - return Observable.just(rxReportExport); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable waitForReportCompletion() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ReportMetadata data = mSyncDelegate.waitForReportCompletion(); - return Observable.just(data); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable updateExecution(@Nullable final List newParameters) { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ReportExecution execution = mSyncDelegate.updateExecution(newParameters); - RxReportExecution rxExec = new RxReportExecutionImpl(execution); - return Observable.just(rxExec); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } -} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java index 87993a1d..d62645a9 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExport.java @@ -25,19 +25,59 @@ package com.jaspersoft.android.sdk.service.rx.report; import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.ReportAttachment; +import com.jaspersoft.android.sdk.service.report.ReportExport; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; +import java.util.ArrayList; import java.util.List; /** * @author Tom Koptel * @since 2.0 */ -public interface RxReportExport { +public class RxReportExport { + private final ReportExport mSyncDelegate; + + @TestOnly + RxReportExport(ReportExport export) { + mSyncDelegate = export; + } + @NotNull - Observable> getAttachments(); + public Observable> getAttachments() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + List attachments = mSyncDelegate.getAttachments(); + int size = attachments.size(); + List rxAttachments = new ArrayList<>(size); + for (int i = 0; i < size; i++) { + ReportAttachment attachment = attachments.get(i); + RxReportAttachment rxAttachment = new RxReportAttachment(attachment); + rxAttachments.add(rxAttachment); + } + return Observable.just(rxAttachments); + } + }); + } @NotNull - Observable download(); + public Observable download() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExportOutput content = mSyncDelegate.download(); + return Observable.just(content); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java deleted file mode 100644 index 4c29a3d6..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.report; - -import com.jaspersoft.android.sdk.service.data.report.ReportExportOutput; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.report.ReportAttachment; -import com.jaspersoft.android.sdk.service.report.ReportExport; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; -import rx.Observable; -import rx.functions.Func0; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxReportExportImpl implements RxReportExport { - private final ReportExport mSyncDelegate; - - @TestOnly - RxReportExportImpl(ReportExport export) { - mSyncDelegate = export; - } - - @NotNull - @Override - public Observable> getAttachments() { - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - List attachments = mSyncDelegate.getAttachments(); - int size = attachments.size(); - List rxAttachments = new ArrayList<>(size); - for (int i = 0; i < size; i++) { - ReportAttachment attachment = attachments.get(i); - RxReportAttachmentImpl rxAttachment = new RxReportAttachmentImpl(attachment); - rxAttachments.add(rxAttachment); - } - return Observable.just(rxAttachments); - } - }); - } - - @NotNull - @Override - public Observable download() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ReportExportOutput content = mSyncDelegate.download(); - return Observable.just(content); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } -} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java index 3cb126ed..209e20a6 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportService.java @@ -29,12 +29,16 @@ import com.jaspersoft.android.sdk.network.entity.control.InputControlState; import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.report.ReportExecution; import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; import com.jaspersoft.android.sdk.service.report.ReportService; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; import java.util.List; import java.util.Set; @@ -43,38 +47,148 @@ * @author Tom Koptel * @since 2.0 */ -public abstract class RxReportService { +public class RxReportService { + private final ReportService mSyncDelegate; + + @TestOnly + RxReportService(ReportService reportService) { + mSyncDelegate = reportService; + } + @NotNull - public abstract Observable run(@NotNull String reportUri, @Nullable ReportExecutionOptions execOptions); + public Observable run(@NotNull final String reportUri, @Nullable final ReportExecutionOptions execOptions) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportExecution execution = mSyncDelegate.run(reportUri, execOptions); + RxReportExecution rxReportExecution = new RxReportExecution(execution); + return Observable.just(rxReportExecution); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - public abstract Observable> listControls(@NotNull String reportUri); + public Observable> listControls(@NotNull final String reportUri) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List inputControls = mSyncDelegate.listControls(reportUri); + return Observable.just(inputControls); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - public abstract Observable> listControlsValues(@NotNull String reportUri, @NotNull List parameters); + public Observable> listControlsValues(@NotNull final String reportUri, + @NotNull final List parameters) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List inputControlStates = mSyncDelegate.listControlsValues(reportUri, parameters); + return Observable.just(inputControlStates); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - public abstract Observable> listReportOptions(@NotNull String reportUri); + public Observable> listReportOptions(@NotNull final String reportUri) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + Set reportOptions = mSyncDelegate.listReportOptions(reportUri); + return Observable.just(reportOptions); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - public abstract Observable createReportOption(@NotNull String reportUri, - @NotNull String optionLabel, - @NotNull List parameters, - boolean overwrite); + public Observable createReportOption(@NotNull final String reportUri, + @NotNull final String optionLabel, + @NotNull final List parameters, + final boolean overwrite) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionLabel, "Option label should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportOption reportOption = mSyncDelegate.createReportOption(reportUri, optionLabel, parameters, overwrite); + return Observable.just(reportOption); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - public abstract Observable updateReportOption(@NotNull String reportUri, - @NotNull String optionId, - @NotNull List parameters); + public Observable updateReportOption(@NotNull final String reportUri, @NotNull final String optionId, @NotNull final List parameters) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionId, "Option id should not be null"); + Preconditions.checkNotNull(parameters, "Parameters should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + mSyncDelegate.updateReportOption(reportUri, optionId, parameters); + } catch (ServiceException e) { + return Observable.error(e); + } + return Observable.just(null); + } + }); + } @NotNull - public abstract Observable deleteReportOption(@NotNull String reportUri, - @NotNull String optionId); + public Observable deleteReportOption(@NotNull final String reportUri, @NotNull final String optionId) { + Preconditions.checkNotNull(reportUri, "Report uri should not be null"); + Preconditions.checkNotNull(optionId, "Option id should not be null"); + + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + mSyncDelegate.deleteReportOption(reportUri, optionId); + } catch (ServiceException e) { + return Observable.error(e); + } + return Observable.just(null); + } + }); + } @NotNull public static RxReportService newService(@NotNull AuthorizedClient authorizedClient) { Preconditions.checkNotNull(authorizedClient, "Client should not be null"); ReportService reportService = ReportService.newService(authorizedClient); - return new RxReportServiceImpl(reportService); + return new RxReportService(reportService); } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java deleted file mode 100644 index 7c92940e..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceImpl.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.report; - -import com.jaspersoft.android.sdk.network.entity.control.InputControl; -import com.jaspersoft.android.sdk.network.entity.control.InputControlState; -import com.jaspersoft.android.sdk.network.entity.report.ReportParameter; -import com.jaspersoft.android.sdk.network.entity.report.option.ReportOption; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.internal.Preconditions; -import com.jaspersoft.android.sdk.service.report.ReportExecution; -import com.jaspersoft.android.sdk.service.report.ReportExecutionOptions; -import com.jaspersoft.android.sdk.service.report.ReportService; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; -import rx.Observable; -import rx.functions.Func0; - -import java.util.List; -import java.util.Set; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxReportServiceImpl extends RxReportService { - private final ReportService mSyncDelegate; - - @TestOnly - RxReportServiceImpl(ReportService reportService) { - mSyncDelegate = reportService; - } - - @NotNull - @Override - public Observable run(@NotNull final String reportUri, @Nullable final ReportExecutionOptions execOptions) { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ReportExecution execution = mSyncDelegate.run(reportUri, execOptions); - RxReportExecution rxReportExecution = new RxReportExecutionImpl(execution); - return Observable.just(rxReportExecution); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable> listControls(@NotNull final String reportUri) { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - try { - List inputControls = mSyncDelegate.listControls(reportUri); - return Observable.just(inputControls); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable> listControlsValues(@NotNull final String reportUri, - @NotNull final List parameters) { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - Preconditions.checkNotNull(parameters, "Parameters should not be null"); - - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - try { - List inputControlStates = mSyncDelegate.listControlsValues(reportUri, parameters); - return Observable.just(inputControlStates); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable> listReportOptions(@NotNull final String reportUri) { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - try { - Set reportOptions = mSyncDelegate.listReportOptions(reportUri); - return Observable.just(reportOptions); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable createReportOption(@NotNull final String reportUri, - @NotNull final String optionLabel, - @NotNull final List parameters, - final boolean overwrite) { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - Preconditions.checkNotNull(optionLabel, "Option label should not be null"); - Preconditions.checkNotNull(parameters, "Parameters should not be null"); - - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ReportOption reportOption = mSyncDelegate.createReportOption(reportUri, optionLabel, parameters, overwrite); - return Observable.just(reportOption); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable updateReportOption(@NotNull final String reportUri, @NotNull final String optionId, @NotNull final List parameters) { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - Preconditions.checkNotNull(optionId, "Option id should not be null"); - Preconditions.checkNotNull(parameters, "Parameters should not be null"); - - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - mSyncDelegate.updateReportOption(reportUri, optionId, parameters); - } catch (ServiceException e) { - return Observable.error(e); - } - return Observable.just(null); - } - }); - } - - @NotNull - @Override - public Observable deleteReportOption(@NotNull final String reportUri, @NotNull final String optionId) { - Preconditions.checkNotNull(reportUri, "Report uri should not be null"); - Preconditions.checkNotNull(optionId, "Option id should not be null"); - - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - mSyncDelegate.deleteReportOption(reportUri, optionId); - } catch (ServiceException e) { - return Observable.error(e); - } - return Observable.just(null); - } - }); - } -} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java index 42133e0f..ff7b22f9 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java @@ -27,12 +27,16 @@ import com.jaspersoft.android.sdk.network.AuthorizedClient; import com.jaspersoft.android.sdk.service.data.report.ReportResource; import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; import com.jaspersoft.android.sdk.service.internal.Preconditions; import com.jaspersoft.android.sdk.service.repository.RepositoryService; import com.jaspersoft.android.sdk.service.repository.SearchCriteria; +import com.jaspersoft.android.sdk.service.repository.SearchTask; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; import java.util.List; @@ -41,20 +45,55 @@ * @author Tom Koptel * @since 2.0 */ -public abstract class RxRepositoryService { +public class RxRepositoryService { + private final RepositoryService mSyncDelegate; + + @TestOnly + RxRepositoryService(RepositoryService repositoryService) { + mSyncDelegate = repositoryService; + } + @NotNull - public abstract Observable search(@Nullable SearchCriteria criteria); + public Observable search(@Nullable SearchCriteria criteria) { + SearchTask searchTask = mSyncDelegate.search(criteria); + RxSearchTask rxSearchTask = new RxSearchTask(searchTask); + return Observable.just(rxSearchTask); + } @NotNull - public abstract Observable fetchReportDetails(@NotNull String reportUri); + public Observable fetchReportDetails(@NotNull final String reportUri) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + ReportResource reportResource = mSyncDelegate.fetchReportDetails(reportUri); + return Observable.just(reportResource); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - public abstract Observable> fetchRootFolders(); + public Observable> fetchRootFolders() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List resources = mSyncDelegate.fetchRootFolders(); + return Observable.just(resources); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull public static RxRepositoryService newService(@NotNull AuthorizedClient authorizedClient) { Preconditions.checkNotNull(authorizedClient, "Client should not be null"); RepositoryService repositoryService = RepositoryService.newService(authorizedClient); - return new RxRepositoryServiceImpl(repositoryService); + return new RxRepositoryService(repositoryService); } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java deleted file mode 100644 index 5eaa38e4..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.repository; - -import com.jaspersoft.android.sdk.service.data.report.ReportResource; -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.repository.RepositoryService; -import com.jaspersoft.android.sdk.service.repository.SearchCriteria; -import com.jaspersoft.android.sdk.service.repository.SearchTask; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; -import rx.Observable; -import rx.functions.Func0; - -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxRepositoryServiceImpl extends RxRepositoryService { - private final RepositoryService mSyncDelegate; - - @TestOnly - RxRepositoryServiceImpl(RepositoryService repositoryService) { - mSyncDelegate = repositoryService; - } - - @NotNull - @Override - public Observable search(@Nullable SearchCriteria criteria) { - SearchTask searchTask = mSyncDelegate.search(criteria); - RxSearchTask rxSearchTask = new RxSearchTaskImpl(searchTask); - return Observable.just(rxSearchTask); - } - - @NotNull - @Override - public Observable fetchReportDetails(@NotNull final String reportUri) { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - try { - ReportResource reportResource = mSyncDelegate.fetchReportDetails(reportUri); - return Observable.just(reportResource); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable> fetchRootFolders() { - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - try { - List resources = mSyncDelegate.fetchRootFolders(); - return Observable.just(resources); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } -} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java index 4a9ff272..2a66a95b 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTask.java @@ -25,8 +25,12 @@ package com.jaspersoft.android.sdk.service.rx.repository; import com.jaspersoft.android.sdk.service.data.repository.Resource; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.repository.SearchTask; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import rx.Observable; +import rx.functions.Func0; import java.util.List; @@ -34,10 +38,36 @@ * @author Tom Koptel * @since 2.0 */ -public interface RxSearchTask { +public class RxSearchTask { + private final SearchTask mSyncDelegate; + + @TestOnly + RxSearchTask(SearchTask searchTask) { + mSyncDelegate = searchTask; + } + @NotNull - Observable> nextLookup(); + public Observable> nextLookup() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List result = mSyncDelegate.nextLookup(); + return Observable.just(result); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } @NotNull - Observable hasNext(); + public Observable hasNext() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + return Observable.just(mSyncDelegate.hasNext()); + } + }); + } } diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java deleted file mode 100644 index 8481b65c..00000000 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2015 TIBCO Software, Inc. All rights reserved. - * http://community.jaspersoft.com/project/jaspermobile-android - * - * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, - * the following license terms apply: - * - * This program is part of TIBCO Jaspersoft Mobile for Android. - * - * TIBCO Jaspersoft Mobile is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * TIBCO Jaspersoft Mobile is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with TIBCO Jaspersoft Mobile for Android. If not, see - * . - */ - -package com.jaspersoft.android.sdk.service.rx.repository; - -import com.jaspersoft.android.sdk.service.data.repository.Resource; -import com.jaspersoft.android.sdk.service.exception.ServiceException; -import com.jaspersoft.android.sdk.service.repository.SearchTask; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.TestOnly; -import rx.Observable; -import rx.functions.Func0; - -import java.util.List; - -/** - * @author Tom Koptel - * @since 2.0 - */ -final class RxSearchTaskImpl implements RxSearchTask { - private final SearchTask mSyncDelegate; - - @TestOnly - RxSearchTaskImpl(SearchTask searchTask) { - mSyncDelegate = searchTask; - } - - @NotNull - @Override - public Observable> nextLookup() { - return Observable.defer(new Func0>>() { - @Override - public Observable> call() { - try { - List result = mSyncDelegate.nextLookup(); - return Observable.just(result); - } catch (ServiceException e) { - return Observable.error(e); - } - } - }); - } - - @NotNull - @Override - public Observable hasNext() { - return Observable.defer(new Func0>() { - @Override - public Observable call() { - return Observable.just(mSyncDelegate.hasNext()); - } - }); - } -} diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java index 0799466d..7877c98c 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/auth/RxAuthorizationServiceTest.java @@ -59,12 +59,12 @@ public class RxAuthorizationServiceTest { @Rule public ExpectedException expected = none(); - private RxAuthorizationServiceImpl rxAuthorizationService; + private RxAuthorizationService rxAuthorizationService; @Before public void setUp() throws Exception { initMocks(this); - rxAuthorizationService = new RxAuthorizationServiceImpl(mSyncDelegate); + rxAuthorizationService = new RxAuthorizationService(mSyncDelegate); } @Test @@ -95,7 +95,7 @@ public void should_delegate_service_exception_on_authorize_call() throws Excepti @Test public void should_provide_impl_with_factory_method() throws Exception { RxAuthorizationService service = RxAuthorizationService.newService(mAnonymousClient); - assertThat(service, is(instanceOf(RxAuthorizationServiceImpl.class))); + assertThat(service, is(instanceOf(RxAuthorizationService.class))); assertThat(service, is(notNullValue())); } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java index b1f90bed..74d79586 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/info/RxServerInfoServiceTest.java @@ -58,12 +58,12 @@ public class RxServerInfoServiceTest { @Rule public ExpectedException expected = none(); - private RxServerInfoServiceImpl rxServerInfoService; + private RxServerInfoService rxServerInfoService; @Before public void setUp() throws Exception { initMocks(this); - rxServerInfoService = new RxServerInfoServiceImpl(mSyncDelegate); + rxServerInfoService = new RxServerInfoService(mSyncDelegate); } @Test @@ -96,7 +96,7 @@ public void should_delegate_service_exception_on_info_request_call() throws Exce @Test public void should_provide_impl_with_factory_method() throws Exception { RxServerInfoService service = RxServerInfoService.newService(mAnonymousClient); - assertThat(service, is(instanceOf(RxServerInfoServiceImpl.class))); + assertThat(service, is(instanceOf(RxServerInfoService.class))); assertThat(service, is(notNullValue())); } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java index 51de79a3..e48d666a 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportAttachmentTest.java @@ -45,12 +45,12 @@ public class RxReportAttachmentTest { @Mock ServiceException mServiceException; - private RxReportAttachmentImpl rxReportAttachment; + private RxReportAttachment rxReportAttachment; @Before public void setUp() throws Exception { initMocks(this); - rxReportAttachment = new RxReportAttachmentImpl(mSyncDelegate); + rxReportAttachment = new RxReportAttachment(mSyncDelegate); } @Test diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java index 996fa40c..54cf8c8a 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExecutionTest.java @@ -67,12 +67,12 @@ public class RxReportExecutionTest { private final ReportMetadata fakeReportData = new ReportMetadata("/uri", 100); - private RxReportExecutionImpl rxReportExecution; + private RxReportExecution rxReportExecution; @Before public void setUp() throws Exception { initMocks(this); - rxReportExecution = new RxReportExecutionImpl(mSyncDelegate); + rxReportExecution = new RxReportExecution(mSyncDelegate); } @Test diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java index 1ec009b2..430b7c85 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportExportTest.java @@ -53,12 +53,12 @@ public class RxReportExportTest { ReportExportOutput mReportExportOutput; - private RxReportExportImpl rxReportExport; + private RxReportExport rxReportExport; @Before public void setUp() throws Exception { initMocks(this); - rxReportExport = new RxReportExportImpl(mSyncDelegate); + rxReportExport = new RxReportExport(mSyncDelegate); } @Test diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java index cc04a5fb..4cda59dd 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/RxReportServiceTest.java @@ -48,10 +48,10 @@ import static org.hamcrest.Matchers.*; import static org.junit.rules.ExpectedException.none; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyListOf; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; public class RxReportServiceTest { @@ -73,7 +73,7 @@ public class RxReportServiceTest { @Mock AuthorizedClient mAuthorizedClient; - private RxReportServiceImpl rxReportService; + private RxReportService rxReportService; @Rule public ExpectedException expected = none(); @@ -81,7 +81,7 @@ public class RxReportServiceTest { @Before public void setUp() throws Exception { initMocks(this); - rxReportService = new RxReportServiceImpl(mSyncDelegate); + rxReportService = new RxReportService(mSyncDelegate); } @Test @@ -294,7 +294,7 @@ public void should_execute_delegate_as_observable_on_delete_report_option() thro @Test public void should_provide_impl_with_factory_method() throws Exception { RxReportService service = RxReportService.newService(mAuthorizedClient); - assertThat(service, is(instanceOf(RxReportServiceImpl.class))); + assertThat(service, is(instanceOf(RxReportService.class))); assertThat(service, is(notNullValue())); } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java index 97c47ac9..bd616088 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java @@ -68,12 +68,12 @@ public class RxRepositoryServiceTest { @Rule public ExpectedException expected = none(); - private RxRepositoryServiceImpl rxRepositoryService; + private RxRepositoryService rxRepositoryService; @Before public void setUp() throws Exception { initMocks(this); - rxRepositoryService = new RxRepositoryServiceImpl(mSyncDelegate); + rxRepositoryService = new RxRepositoryService(mSyncDelegate); } @Test @@ -157,7 +157,7 @@ public void should_accept_null_criteria() throws Exception { @Test public void should_provide_impl_with_factory_method() throws Exception { RxRepositoryService service = RxRepositoryService.newService(mAuthorizedClient); - assertThat(service, is(instanceOf(RxRepositoryServiceImpl.class))); + assertThat(service, is(instanceOf(RxRepositoryService.class))); assertThat(service, is(notNullValue())); } diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java index a1cf901a..467affd7 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxSearchTaskTest.java @@ -46,12 +46,12 @@ public class RxSearchTaskTest { @Mock ServiceException mServiceException; - private RxSearchTaskImpl rxSearchTask; + private RxSearchTask rxSearchTask; @Before public void setUp() throws Exception { initMocks(this); - rxSearchTask = new RxSearchTaskImpl(mSyncDelegate); + rxSearchTask = new RxSearchTask(mSyncDelegate); } @Test From aa89d2931eca947e1ef5a282b188bc89cff739be Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Wed, 13 Jan 2016 21:32:34 +0200 Subject: [PATCH 388/457] Add intial implmenetation of Scheduling API Add DTO objects for schedule job/jobDescriptor Add ReportScheduleRestApi#searchJob(Map) Setup initial API for ReportScheduleService#search(JobSearchCriteria) Add ReportScheduleService#search(JobSearchCriteria) Implment rx counterpart for ReportScheduleService search Add case when there is no search results Update limit/offset API for JobSearchCriteria Implementing JobSearchCriteriaMapper#transform(JobSearchCriteria) Add ReportScheduleRestApi#createJob(JobForm) Add ReportScheduleService#createJob(JobForm) Add RxReportScheduleService#createJob(JobForm) Remove redundant indirection layer during search --- .../android/sdk/network/AuthorizedClient.java | 8 + .../sdk/network/ReportScheduleRestApi.java | 80 +++++++ .../entity/schedule/JobDescriptor.java | 52 +++++ .../sdk/network/entity/schedule/JobForm.java | 157 ++++++++++++++ .../entity/schedule/JobOutputFormats.java | 18 ++ .../entity/schedule/JobSearchresult.java | 19 ++ .../entity/schedule/JobSimpleTrigger.java | 25 +++ .../network/entity/schedule/JobSource.java | 16 ++ .../sdk/network/entity/schedule/JobState.java | 43 ++++ .../network/entity/schedule/JobTrigger.java | 16 ++ .../sdk/network/entity/schedule/JobUnit.java | 74 +++++++ .../schedule/RepositoryDestination.java | 16 ++ .../sdk/service/data/schedule/JobData.java | 168 +++++++++++++++ .../data/schedule/JobOutputFormat.java | 9 + .../report/schedule/BaseJobSearchTask.java | 54 +++++ .../report/schedule/JobDataMapper.java | 14 ++ .../sdk/service/report/schedule/JobOwner.java | 69 +++++++ .../report/schedule/JobSearchCriteria.java | 195 ++++++++++++++++++ .../schedule/JobSearchCriteriaMapper.java | 51 +++++ .../report/schedule/JobSearchTask.java | 18 ++ .../service/report/schedule/JobSortType.java | 18 ++ .../schedule/ReportScheduleService.java | 56 +++++ .../schedule/ReportScheduleUseCase.java | 58 ++++++ .../network/ReportScheduleRestApiTest.java | 82 ++++++++ .../entity/schedule/JobUnitFormTest.java | 36 ++++ .../schedule/JobUnitOutputFormatsTest.java | 24 +++ .../schedule/JobUnitSimpleTriggerTest.java | 27 +++ .../entity/schedule/JobUnitSourceTest.java | 24 +++ .../network/entity/schedule/JobUnitTest.java | 38 ++++ .../entity/schedule/JobUnitTriggerTest.java | 24 +++ .../schedule/RepositoryDestinationTest.java | 24 +++ .../service/data/schedule/JobDataTest.java | 11 + .../schedule/BaseJobUnitSearchTaskTest.java | 108 ++++++++++ .../report/schedule/JobUnitOwnerTest.java | 39 ++++ .../JobUnitSearchCriteriaMapperTest.java | 95 +++++++++ .../schedule/JobUnitSearchCriteriaTest.java | 122 +++++++++++ .../schedule/ReportScheduleServiceTest.java | 60 ++++++ .../schedule/ReportScheduleUseCaseTest.java | 135 ++++++++++++ .../rx/report/schedule/RxJobSearchTask.java | 49 +++++ .../schedule/RxReportScheduleService.java | 57 +++++ .../rx/repository/RxRepositoryService.java | 5 +- .../schedule/RxJobUnitSearchTaskTest.java | 73 +++++++ .../schedule/RxReportScheduleServiceTest.java | 98 +++++++++ .../repository/RxRepositoryServiceTest.java | 11 +- 44 files changed, 2364 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobDescriptor.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobForm.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobOutputFormats.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSearchresult.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSimpleTrigger.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSource.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobState.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobTrigger.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnit.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestination.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobData.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobOutputFormat.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobSearchTask.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobDataMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobOwner.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteria.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteriaMapper.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchTask.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSortType.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleService.java create mode 100644 core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCase.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApiTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitFormTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitOutputFormatsTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSimpleTriggerTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSourceTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTriggerTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestinationTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/data/schedule/JobDataTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobUnitSearchTaskTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitOwnerTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaMapperTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleServiceTest.java create mode 100644 core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCaseTest.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobSearchTask.java create mode 100644 rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleService.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobUnitSearchTaskTest.java create mode 100644 rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleServiceTest.java diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java index 1eeedf7c..bfa27216 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/AuthorizedClient.java @@ -39,6 +39,7 @@ public class AuthorizedClient extends AnonymousClient { private ReportOptionRestApi mReportOptionRestApi; private InputControlRestApi mInputControlRestApi; private RepositoryRestApi mRepositoryRestApi; + private ReportScheduleRestApi mReportScheduleRestApi; AuthorizedClient(Retrofit retrofit, AnonymousClient anonymousClient) { super(retrofit); @@ -79,4 +80,11 @@ public RepositoryRestApi repositoryApi() { } return mRepositoryRestApi; } + + public ReportScheduleRestApi reportScheduleApi() { + if (mReportScheduleRestApi == null) { + mReportScheduleRestApi = new ReportScheduleRestApi(mRetrofit); + } + return mReportScheduleRestApi; + } } diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java new file mode 100644 index 00000000..583b3af6 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java @@ -0,0 +1,80 @@ +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.network.entity.schedule.JobDescriptor; +import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; +import com.jaspersoft.android.sdk.network.entity.schedule.JobSearchResult; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; +import retrofit.Call; +import retrofit.Retrofit; +import retrofit.http.GET; +import retrofit.http.Headers; +import retrofit.http.PUT; +import retrofit.http.QueryMap; + +import java.io.IOException; +import java.net.URLEncoder; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportScheduleRestApi { + private final RestApi mRestApi; + + @TestOnly + ReportScheduleRestApi(Retrofit retrofit) { + mRestApi = retrofit.create(RestApi.class); + } + + @NotNull + public List searchJob(@Nullable Map searchParams) throws IOException, HttpException { + Map encodedParams = Collections.emptyMap(); + if (searchParams == null) { + searchParams = Collections.emptyMap(); + } + + if (!searchParams.isEmpty()) { + if (searchParams.containsKey("example")) { + throw new IllegalArgumentException("Current version does not support 'example' search parameter"); + } + + encodedParams = new HashMap<>(searchParams.size()); + for (Map.Entry entry : searchParams.entrySet()) { + String rawValue = String.valueOf(entry.getValue()); + String encodedValue = URLEncoder.encode(rawValue, "UTF-8"); + encodedParams.put(entry.getKey(), encodedValue); + } + } + + Call call = mRestApi.searchJob(encodedParams); + JobSearchResult searchResult = CallWrapper.wrap(call).body(); + return searchResult.getJobSummary(); + } + + @NotNull + public JobDescriptor createJob(@NotNull JobForm form) throws IOException, HttpException { + Preconditions.checkNotNull(form, "Job form should not be null"); + Call call = mRestApi.createJob(form); + return CallWrapper.wrap(call).body(); + } + + private interface RestApi { + @NotNull + @Headers("Accept: application/json") + @GET("rest_v2/jobs") + public Call searchJob(@Nullable @QueryMap(encoded = true) Map searchParams); + + @NotNull + @Headers("Accept: application/job+json") + @PUT("rest_v2/jobs") + public Call createJob(@NotNull JobForm descriptor); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobDescriptor.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobDescriptor.java new file mode 100644 index 00000000..6abf1016 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobDescriptor.java @@ -0,0 +1,52 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class JobDescriptor { + @Expose + private String id; + @Expose + private int version; + @Expose + private String username; + @Expose + private String label; + @Expose + private String description; + @Expose + private String creationDate; + @Expose + private JobOutputFormats outputFormats; + + public String getId() { + return id; + } + + public int getVersion() { + return version; + } + + public String getUsername() { + return username; + } + + public String getLabel() { + return label; + } + + public String getDescription() { + return description; + } + + public String getCreationDate() { + return creationDate; + } + + public JobOutputFormats getOutputFormats() { + return outputFormats; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobForm.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobForm.java new file mode 100644 index 00000000..9f948ece --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobForm.java @@ -0,0 +1,157 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class JobForm { + @Expose + private final String label; + + @Expose + private final String description; + + @Expose + private final String baseOutputFilename; + + @Expose + private final JobSource source; + + @Expose + private final RepositoryDestination repositoryDestination; + + @Expose + private final JobOutputFormats outputFormats; + + @Expose + private final JobTrigger trigger; + + JobForm(String label, + String description, + String baseOutputFilename, + JobSource source, + RepositoryDestination repositoryDestination, + JobOutputFormats outputFormats, + JobTrigger trigger) { + this.label = label; + this.description = description; + this.baseOutputFilename = baseOutputFilename; + this.source = source; + this.repositoryDestination = repositoryDestination; + this.outputFormats = outputFormats; + this.trigger = trigger; + } + + public String getBaseOutputFilename() { + return baseOutputFilename; + } + + public String getDescription() { + return description; + } + + public String getLabel() { + return label; + } + + @Override + public final boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof JobForm)) return false; + + JobForm that = (JobForm) o; + + if (baseOutputFilename != null ? !baseOutputFilename.equals(that.baseOutputFilename) : that.baseOutputFilename != null) + return false; + if (description != null ? !description.equals(that.description) : that.description != null) return false; + if (label != null ? !label.equals(that.label) : that.label != null) return false; + if (outputFormats != null ? !outputFormats.equals(that.outputFormats) : that.outputFormats != null) + return false; + if (repositoryDestination != null ? !repositoryDestination.equals(that.repositoryDestination) : that.repositoryDestination != null) + return false; + if (source != null ? !source.equals(that.source) : that.source != null) return false; + if (trigger != null ? !trigger.equals(that.trigger) : that.trigger != null) return false; + + return true; + } + + @Override + public final int hashCode() { + int result = label != null ? label.hashCode() : 0; + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (baseOutputFilename != null ? baseOutputFilename.hashCode() : 0); + result = 31 * result + (source != null ? source.hashCode() : 0); + result = 31 * result + (repositoryDestination != null ? repositoryDestination.hashCode() : 0); + result = 31 * result + (outputFormats != null ? outputFormats.hashCode() : 0); + result = 31 * result + (trigger != null ? trigger.hashCode() : 0); + return result; + } + + public static class Builder { + + private String mLabel; + private String mDescription; + private String mBaseOutputFilename; + private JobSource mSource; + private RepositoryDestination mRepositoryDestination; + private JobTrigger mTrigger; + + private final JobOutputFormats mJobOutputFormats; + private final List outputFormats; + + public Builder() { + outputFormats = new ArrayList<>(); + mJobOutputFormats = new JobOutputFormats(outputFormats); + } + + public Builder withLabel(String label) { + mLabel = label; + return this; + } + + public Builder withDescription(String description) { + mDescription = description; + return this; + } + + public Builder withBaseOutputFilename(String baseOutputFilename) { + mBaseOutputFilename = baseOutputFilename; + return this; + } + + public Builder withSource(String reportUri) { + mSource = new JobSource(reportUri); + return this; + } + + public Builder withRepositoryDestination(String folderUri) { + mRepositoryDestination = new RepositoryDestination(folderUri); + return this; + } + + public Builder addOutputFormat(String format) { + outputFormats.add(format); + return this; + } + + public Builder withSimpleTrigger(JobSimpleTrigger trigger) { + mTrigger = new JobTrigger(trigger); + return this; + } + + public JobForm build() { + return new JobForm(mLabel, + mDescription, + mBaseOutputFilename, + mSource, + mRepositoryDestination, + mJobOutputFormats, + mTrigger); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobOutputFormats.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobOutputFormats.java new file mode 100644 index 00000000..9b0ad674 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobOutputFormats.java @@ -0,0 +1,18 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class JobOutputFormats { + @Expose + private final List outputFormat; + + JobOutputFormats(List outputFormat) { + this.outputFormat = outputFormat; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSearchresult.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSearchresult.java new file mode 100644 index 00000000..2c85ff3d --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSearchresult.java @@ -0,0 +1,19 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +import java.util.Collections; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class JobSearchResult { + @Expose + private List mJobsummary = Collections.emptyList(); + + public List getJobSummary() { + return Collections.unmodifiableList(mJobsummary); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSimpleTrigger.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSimpleTrigger.java new file mode 100644 index 00000000..6f5c3a05 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSimpleTrigger.java @@ -0,0 +1,25 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class JobSimpleTrigger { + @Expose + private final String timezone; + @Expose + private final String startType; + @Expose + private final String startDate; + @Expose + private final int occurrenceCount; + + public JobSimpleTrigger(String timezone, String startType, String startDate, int occurrenceCount) { + this.timezone = timezone; + this.startType = startType; + this.startDate = startDate; + this.occurrenceCount = occurrenceCount; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSource.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSource.java new file mode 100644 index 00000000..415de1e2 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSource.java @@ -0,0 +1,16 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class JobSource { + @Expose + private final String reportUnitURI; + + JobSource(String reportUnitURI) { + this.reportUnitURI = reportUnitURI; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobState.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobState.java new file mode 100644 index 00000000..354d6f87 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobState.java @@ -0,0 +1,43 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class JobState { + @Expose + private String nextFireTime; + @Expose + private String value; + + public String getNextFileTime() { + return nextFireTime; + } + + public String getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + JobState jobState = (JobState) o; + + if (nextFireTime != null ? !nextFireTime.equals(jobState.nextFireTime) : jobState.nextFireTime != null) + return false; + if (value != null ? !value.equals(jobState.value) : jobState.value != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = nextFireTime != null ? nextFireTime.hashCode() : 0; + result = 31 * result + (value != null ? value.hashCode() : 0); + return result; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobTrigger.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobTrigger.java new file mode 100644 index 00000000..d1103c4c --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobTrigger.java @@ -0,0 +1,16 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class JobTrigger { + @Expose + private final JobSimpleTrigger simpleTrigger; + + JobTrigger(JobSimpleTrigger simpleTrigger) { + this.simpleTrigger = simpleTrigger; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnit.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnit.java new file mode 100644 index 00000000..78791a14 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnit.java @@ -0,0 +1,74 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class JobUnit { + @Expose + private String id; + @Expose + private String version; + @Expose + private String reportUnitURI; + @Expose + private String label; + @Expose + private String owner; + @Expose + private JobState state; + + public String getId() { + return id; + } + + public String getVersion() { + return version; + } + + public String getReportUnitURI() { + return reportUnitURI; + } + + public String getLabel() { + return label; + } + + public String getOwner() { + return owner; + } + + public JobState getState() { + return state; + } + + @Override + public final boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof JobUnit)) return false; + + JobUnit jobUnit = (JobUnit) o; + + if (id != null ? !id.equals(jobUnit.id) : jobUnit.id != null) return false; + if (label != null ? !label.equals(jobUnit.label) : jobUnit.label != null) return false; + if (owner != null ? !owner.equals(jobUnit.owner) : jobUnit.owner != null) return false; + if (reportUnitURI != null ? !reportUnitURI.equals(jobUnit.reportUnitURI) : jobUnit.reportUnitURI != null) return false; + if (state != null ? !state.equals(jobUnit.state) : jobUnit.state != null) return false; + if (version != null ? !version.equals(jobUnit.version) : jobUnit.version != null) return false; + + return true; + } + + @Override + public final int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (version != null ? version.hashCode() : 0); + result = 31 * result + (reportUnitURI != null ? reportUnitURI.hashCode() : 0); + result = 31 * result + (label != null ? label.hashCode() : 0); + result = 31 * result + (owner != null ? owner.hashCode() : 0); + result = 31 * result + (state != null ? state.hashCode() : 0); + return result; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestination.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestination.java new file mode 100644 index 00000000..938eb27e --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestination.java @@ -0,0 +1,16 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class RepositoryDestination { + @Expose + private final String folderURI; + + RepositoryDestination(String folderURI) { + this.folderURI = folderURI; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobData.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobData.java new file mode 100644 index 00000000..000b839c --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobData.java @@ -0,0 +1,168 @@ +package com.jaspersoft.android.sdk.service.data.schedule; + +import org.jetbrains.annotations.NotNull; + +import java.util.Date; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class JobData { + @NotNull + private final String mId; + private final int mVersion; + @NotNull + private final String mUsername; + @NotNull + private final String mLabel; + @NotNull + private final String mDescription; + @NotNull + private final Date mCreationDate; + @NotNull + private final List mOutputFormats; + + public JobData(@NotNull String id, + int version, + @NotNull String username, + @NotNull String label, + @NotNull String description, + @NotNull Date creationDate, + @NotNull List outputFormats) { + mId = id; + mVersion = version; + mUsername = username; + mLabel = label; + mDescription = description; + mCreationDate = creationDate; + mOutputFormats = outputFormats; + } + + @NotNull + public String getId() { + return mId; + } + + public int getVersion() { + return mVersion; + } + + @NotNull + public String getUsername() { + return mUsername; + } + + @NotNull + public String getLabel() { + return mLabel; + } + + @NotNull + public String getDescription() { + return mDescription; + } + + @NotNull + public Date getCreationDate() { + return mCreationDate; + } + + @NotNull + public List getOutputFormats() { + return mOutputFormats; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof JobData)) return false; + + JobData jobData = (JobData) o; + + if (mVersion != jobData.mVersion) return false; + if (!mCreationDate.equals(jobData.mCreationDate)) return false; + if (!mDescription.equals(jobData.mDescription)) return false; + if (!mId.equals(jobData.mId)) return false; + if (!mLabel.equals(jobData.mLabel)) return false; + if (!mOutputFormats.equals(jobData.mOutputFormats)) return false; + if (!mUsername.equals(jobData.mUsername)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = mId.hashCode(); + result = 31 * result + mVersion; + result = 31 * result + mUsername.hashCode(); + result = 31 * result + mLabel.hashCode(); + result = 31 * result + mDescription.hashCode(); + result = 31 * result + mCreationDate.hashCode(); + result = 31 * result + mOutputFormats.hashCode(); + return result; + } + + @Override + public String toString() { + return "JobData{" + + "mId='" + mId + '\'' + + ", mVersion=" + mVersion + + ", mUsername='" + mUsername + '\'' + + ", mLabel='" + mLabel + '\'' + + ", mDescription='" + mDescription + '\'' + + ", mCreationDate=" + mCreationDate + + ", mOutputFormats=" + mOutputFormats + + '}'; + } + + public static class Builder { + private String mId; + private int mVersion; + private String mUsername; + private String mLabel; + private String mDescription; + private Date mCreationDate; + private List mOutputFormats; + + public Builder withId(String id) { + mId = id; + return this; + } + + public Builder withVersion(int version) { + mVersion = version; + return this; + } + + public Builder withUsername(@NotNull String username) { + mUsername = username; + return this; + } + + public Builder withLabel(@NotNull String label) { + mLabel = label; + return this; + } + + public Builder withDescription(@NotNull String description) { + mDescription = description; + return this; + } + + public Builder withCreationDate(@NotNull Date creationDate) { + mCreationDate = creationDate; + return this; + } + + public Builder withOutputFormats(@NotNull List outputFormats) { + mOutputFormats = outputFormats; + return this; + } + + public JobData build() { + return new JobData(mId, mVersion, mUsername, mLabel, mDescription, mCreationDate, mOutputFormats); + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobOutputFormat.java b/core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobOutputFormat.java new file mode 100644 index 00000000..d8d3a910 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/data/schedule/JobOutputFormat.java @@ -0,0 +1,9 @@ +package com.jaspersoft.android.sdk.service.data.schedule; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum JobOutputFormat { + PDF, HTML, XLS, RTF, CSV, ODT, TXT, DOCX, ODS, XLSX, XLS_NOPAG, XLSX_NOPAG, DATA_SNAPSHOT, +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobSearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobSearchTask.java new file mode 100644 index 00000000..fc65729d --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobSearchTask.java @@ -0,0 +1,54 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; + +import java.util.Collections; +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +final class BaseJobSearchTask extends JobSearchTask { + @NotNull + private final ReportScheduleUseCase mUseCase; + + private List mBuffer = Collections.emptyList(); + private JobSearchCriteria mCriteria; + private boolean mEndReached; + + @TestOnly + BaseJobSearchTask(@NotNull ReportScheduleUseCase useCase, @NotNull JobSearchCriteria criteria) { + mUseCase = useCase; + mCriteria = criteria; + mEndReached = false; + } + + @NotNull + @Override + public List nextLookup() throws ServiceException { + if (!mEndReached) { + if (!mBuffer.isEmpty()) { + JobSearchCriteria oldCriteria = mCriteria; + mCriteria = oldCriteria.newBuilder() + .withOffset(newOffset(oldCriteria)) + .build(); + } + mBuffer = mUseCase.searchJob(mCriteria); + mEndReached = (mBuffer.size() != mCriteria.getLimit()); + } + return mBuffer; + } + + private int newOffset(JobSearchCriteria criteria) { + return criteria.getOffset() + criteria.getLimit(); + } + + @Override + public boolean hasNext() { + return !mEndReached; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobDataMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobDataMapper.java new file mode 100644 index 00000000..b8fa8624 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobDataMapper.java @@ -0,0 +1,14 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobDescriptor; +import com.jaspersoft.android.sdk.service.data.schedule.JobData; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class JobDataMapper { + public JobData transform(JobDescriptor jobDescriptor) { + throw new UnsupportedOperationException("Not yet implemented"); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobOwner.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobOwner.java new file mode 100644 index 00000000..573c9d6a --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobOwner.java @@ -0,0 +1,69 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class JobOwner { + private static final String SEPARATOR = "|"; + + @NotNull + private final String mUsername; + @Nullable + private final String mOrganization; + + @TestOnly + JobOwner(@NotNull String username, String organization) { + mUsername = username; + mOrganization = organization; + } + + public static JobOwner newOwner(@NotNull String username, @Nullable String organization) { + Preconditions.checkNotNull(username, "Username should not be null"); + return new JobOwner(username, organization); + } + + @NotNull + public String getUsername() { + return mUsername; + } + + @Nullable + public String getOrganization() { + return mOrganization; + } + + @Override + public String toString() { + if (mOrganization == null) { + return mUsername; + } + return mUsername + SEPARATOR + mOrganization; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + JobOwner jobOwner = (JobOwner) o; + + if (mOrganization != null ? !mOrganization.equals(jobOwner.mOrganization) : jobOwner.mOrganization != null) + return false; + if (!mUsername.equals(jobOwner.mUsername)) return false; + + return true; + } + + @Override + public int hashCode() { + int result = mUsername.hashCode(); + result = 31 * result + (mOrganization != null ? mOrganization.hashCode() : 0); + return result; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteria.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteria.java new file mode 100644 index 00000000..ff4cd227 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteria.java @@ -0,0 +1,195 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public final class JobSearchCriteria { + public static int UNLIMITED_ROW_NUMBER = Integer.MAX_VALUE; + + @Nullable + private final String mReportUri; + @Nullable + private final JobOwner mOwner; + @Nullable + private final String mLabel; + private final int mOffset; + private final int mLimit; + @Nullable + private final JobSortType mJobSortType; + @Nullable + private final Boolean mAscending; + + @TestOnly + JobSearchCriteria(@Nullable String reportUri, + @Nullable JobOwner owner, + @Nullable String label, + int offset, + int limit, + @Nullable JobSortType jobSortType, + @Nullable Boolean ascending) { + mReportUri = reportUri; + mOwner = owner; + mLabel = label; + mOffset = offset; + mLimit = limit; + mJobSortType = jobSortType; + mAscending = ascending; + } + + @Nullable + public String getReportUri() { + return mReportUri; + } + + @Nullable + public JobOwner getOwner() { + return mOwner; + } + + @Nullable + public String getLabel() { + return mLabel; + } + + public int getOffset() { + return mOffset; + } + + public int getLimit() { + return mLimit; + } + + @Nullable + public JobSortType getSortType() { + return mJobSortType; + } + + @Nullable + public Boolean getAscending() { + return mAscending; + } + + public Builder newBuilder() { + return new Builder() + .withReportUri(mReportUri) + .withOwner(mOwner) + .withLabel(mLabel) + .withOffset(mOffset) + .withLimit(mLimit) + .withSortType(mJobSortType) + .withAscending(mAscending); + } + + @NotNull + public static Builder builder() { + return new Builder(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + JobSearchCriteria criteria = (JobSearchCriteria) o; + + if (mLimit != criteria.mLimit) return false; + if (mOffset != criteria.mOffset) return false; + if (mAscending != null ? !mAscending.equals(criteria.mAscending) : criteria.mAscending != null) return false; + if (mJobSortType != criteria.mJobSortType) return false; + if (mLabel != null ? !mLabel.equals(criteria.mLabel) : criteria.mLabel != null) return false; + if (mOwner != null ? !mOwner.equals(criteria.mOwner) : criteria.mOwner != null) return false; + if (mReportUri != null ? !mReportUri.equals(criteria.mReportUri) : criteria.mReportUri != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = mReportUri != null ? mReportUri.hashCode() : 0; + result = 31 * result + (mOwner != null ? mOwner.hashCode() : 0); + result = 31 * result + (mLabel != null ? mLabel.hashCode() : 0); + result = 31 * result + mOffset; + result = 31 * result + mLimit; + result = 31 * result + (mJobSortType != null ? mJobSortType.hashCode() : 0); + result = 31 * result + (mAscending != null ? mAscending.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "ScheduleSearchParams{" + + "mReportUri='" + mReportUri + '\'' + + ", mOwner=" + mOwner + + ", mLabel='" + mLabel + '\'' + + ", mOffset=" + mOffset + + ", mLimit=" + mLimit + + ", mJobSortType=" + mJobSortType + + ", mAscending=" + mAscending + + '}'; + } + + @NotNull + public static JobSearchCriteria empty() { + return new Builder().build(); + } + + public static class Builder { + private String mReportUri; + private JobOwner mOwner; + private String mLabel; + private int mOffset = 0; + private int mLimit = UNLIMITED_ROW_NUMBER; + private JobSortType mJobSortType; + private Boolean mAscending; + + private Builder() { + } + + public JobSearchCriteria build() { + return new JobSearchCriteria(mReportUri, mOwner, mLabel, mOffset, mLimit, mJobSortType, mAscending); + } + + public Builder withReportUri(@Nullable String reportUri) { + mReportUri = reportUri; + return this; + } + + public Builder withOwner(@Nullable JobOwner owner) { + mOwner = owner; + return this; + } + + public Builder withLabel(@Nullable String label) { + mLabel = label; + return this; + } + + public Builder withOffset(int startIndex) { + Preconditions.checkArgument(startIndex >= 0, "Start index must be positive"); + mOffset = startIndex; + return this; + } + + public Builder withLimit(int limit) { + Preconditions.checkArgument(limit > 0, "Row number must be positive"); + mLimit = limit; + return this; + } + + public Builder withSortType(@Nullable JobSortType jobSortType) { + mJobSortType = jobSortType; + return this; + } + + public Builder withAscending(@Nullable Boolean ascending) { + mAscending = ascending; + return this; + } + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteriaMapper.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteriaMapper.java new file mode 100644 index 00000000..114048c6 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchCriteriaMapper.java @@ -0,0 +1,51 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class JobSearchCriteriaMapper { + + @NotNull + public Map transform(@NotNull JobSearchCriteria criteria) { + Map searchParams = new HashMap<>(11); + + String reportUri = criteria.getReportUri(); + if (reportUri != null) { + searchParams.put("reportUnitURI", reportUri); + } + + JobOwner owner = criteria.getOwner(); + if (owner != null) { + searchParams.put("owner", owner.toString()); + } + + String label = criteria.getLabel(); + if (label != null) { + searchParams.put("label", label); + } + + int offset = criteria.getOffset(); + searchParams.put("startIndex", String.valueOf(offset)); + + int limit = criteria.getLimit(); + searchParams.put("numberOfRows", String.valueOf(limit)); + + JobSortType jobSortType = criteria.getSortType(); + if (jobSortType != null) { + searchParams.put("sortType", jobSortType.toString()); + } + + Boolean ascending = criteria.getAscending(); + if (ascending != null) { + searchParams.put("isAscending", String.valueOf(ascending)); + } + + return searchParams; + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchTask.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchTask.java new file mode 100644 index 00000000..3caa0667 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSearchTask.java @@ -0,0 +1,18 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public abstract class JobSearchTask { + @NotNull + public abstract List nextLookup() throws ServiceException; + + public abstract boolean hasNext(); +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSortType.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSortType.java new file mode 100644 index 00000000..91373869 --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/JobSortType.java @@ -0,0 +1,18 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public enum JobSortType { + NONE, + SORTBY_JOBID, + SORTBY_JOBNAME, + SORTBY_REPORTURI, + SORTBY_REPORTNAME, + SORTBY_REPORTFOLDER, + SORTBY_OWNER, + SORTBY_STATUS, + SORTBY_LASTRUN, + SORTBY_NEXTRUN, +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleService.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleService.java new file mode 100644 index 00000000..8ca39b1f --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleService.java @@ -0,0 +1,56 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; +import com.jaspersoft.android.sdk.service.data.schedule.JobData; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.DefaultExceptionMapper; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class ReportScheduleService { + + private final ReportScheduleUseCase mUseCase; + + @TestOnly + ReportScheduleService(ReportScheduleUseCase useCase) { + mUseCase = useCase; + } + + @NotNull + public JobSearchTask search(@Nullable JobSearchCriteria criteria) { + if (criteria == null) { + criteria = JobSearchCriteria.empty(); + } + return new BaseJobSearchTask(mUseCase, criteria); + } + + @NotNull + public JobData createJob(@NotNull JobForm form) throws ServiceException { + Preconditions.checkNotNull(form, "Job form should not be null"); + return mUseCase.createJob(form); + } + + @NotNull + public static ReportScheduleService newService(@NotNull AuthorizedClient client) { + Preconditions.checkNotNull(client, "Client should not be null"); + + JobSearchCriteriaMapper criteriaMapper = new JobSearchCriteriaMapper(); + JobDataMapper jobDataMapper = new JobDataMapper(); + ServiceExceptionMapper exceptionMapper = new DefaultExceptionMapper(); + ReportScheduleUseCase reportScheduleUseCase = new ReportScheduleUseCase( + exceptionMapper, + client.reportScheduleApi(), + criteriaMapper, + jobDataMapper + ); + return new ReportScheduleService(reportScheduleUseCase); + } +} diff --git a/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCase.java b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCase.java new file mode 100644 index 00000000..35b65d5a --- /dev/null +++ b/core/src/main/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCase.java @@ -0,0 +1,58 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportScheduleRestApi; +import com.jaspersoft.android.sdk.network.entity.schedule.JobDescriptor; +import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.service.data.schedule.JobData; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @author Tom Koptel + * @since 2.0 + */ +class ReportScheduleUseCase { + private final ServiceExceptionMapper mExceptionMapper; + private final ReportScheduleRestApi mScheduleRestApi; + private final JobSearchCriteriaMapper mSearchCriteriaMapper; + private final JobDataMapper mJobDataMapper; + + ReportScheduleUseCase(ServiceExceptionMapper exceptionMapper, + ReportScheduleRestApi scheduleRestApi, + JobSearchCriteriaMapper searchCriteriaMapper, + JobDataMapper jobDataMapper) { + mExceptionMapper = exceptionMapper; + mScheduleRestApi = scheduleRestApi; + mSearchCriteriaMapper = searchCriteriaMapper; + mJobDataMapper = jobDataMapper; + } + + public List searchJob(JobSearchCriteria criteria) throws ServiceException { + try { + Map searchParams = mSearchCriteriaMapper.transform(criteria); + return mScheduleRestApi.searchJob(searchParams); + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } + } + + public JobData createJob(JobForm form) throws ServiceException { + try { + JobDescriptor jobDescriptor = mScheduleRestApi.createJob(form); + JobData jobData = mJobDataMapper.transform(jobDescriptor); + return jobData; + } catch (IOException e) { + throw mExceptionMapper.transform(e); + } catch (HttpException e) { + throw mExceptionMapper.transform(e); + } + } +} diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApiTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApiTest.java new file mode 100644 index 00000000..a194652d --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApiTest.java @@ -0,0 +1,82 @@ +package com.jaspersoft.android.sdk.network; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.test.MockResponseFactory; +import com.jaspersoft.android.sdk.test.WebMockRule; +import com.squareup.okhttp.mockwebserver.RecordedRequest; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import retrofit.Retrofit; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.rules.ExpectedException.none; + +public class ReportScheduleRestApiTest { + + private final static String SEARCH_RESPONSE = "{ \"jobsummary\": [ { \"id\": 1898, \"version\": 0, \"reportUnitURI\": \"/adhoc/topics/AllAccounts\", \"label\": \"Sample Job Name\", \"owner\": \"jasperadmin|organization_1\", \"state\": { \"previousFireTime\": null, \"nextFireTime\": \"2013-10-12T00:00:00+03:00\", \"value\": \"NORMAL\" } }]}"; + + @Rule + public final WebMockRule mWebMockRule = new WebMockRule(); + + private ReportScheduleRestApi reportScheduleRestApi; + + @Rule + public ExpectedException expected = none(); + + @Before + public void setUp() throws Exception { + Server server = Server.builder() + .withBaseUrl(mWebMockRule.getRootUrl()) + .build(); + Retrofit retrofit = server.newRetrofit().build(); + reportScheduleRestApi = new ReportScheduleRestApi(retrofit); + mWebMockRule.enqueue(MockResponseFactory.create200().setBody(SEARCH_RESPONSE)); + } + + @Test + public void search_encodes_any_param() throws Exception { + Map params = new HashMap<>(); + params.put("reportUnitURI", "/some/report"); + params.put("owner", "jasperadmin|organization_1"); + params.put("label", "Sample Name"); + params.put("startIndex", "1"); + params.put("numberOfRows", "-1"); + params.put("sortType", "NONE"); + params.put("isAscending", "true"); + + List result = reportScheduleRestApi.searchJob(params); + assertThat(result, is(notNullValue())); + + RecordedRequest request = mWebMockRule.get().takeRequest(); + String path = request.getPath(); + + String encodedPath = "/rest_v2/jobs?owner=jasperadmin%7Corganization_1&startIndex=1&sortType=NONE&label=Sample%20Name&numberOfRows=-1&isAscending=true&reportUnitURI=%2Fsome%2Freport"; + assertThat("Should encode all params supplied in map", path, is(encodedPath)); + } + + @Test + public void search_with_no_params() throws Exception { + reportScheduleRestApi.searchJob(null); + RecordedRequest request = mWebMockRule.get().takeRequest(); + String path = request.getPath(); + assertThat("Should send no params", path, is("/rest_v2/jobs")); + } + + @Test + public void search_fails_if_example_field_supplied() throws Exception { + expected.expect(IllegalArgumentException.class); + expected.expectMessage("Current version does not support 'example' search parameter"); + + Map params = new HashMap<>(); + params.put("example", "{}"); + reportScheduleRestApi.searchJob(params); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitFormTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitFormTest.java new file mode 100644 index 00000000..43ea1700 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitFormTest.java @@ -0,0 +1,36 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class JobUnitFormTest { + @Test + @Parameters({ + "label", + "description", + "baseOutputFilename", + "source", + "repositoryDestination", + "outputFormats", + "trigger", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = JobForm.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(JobForm.class).verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitOutputFormatsTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitOutputFormatsTest.java new file mode 100644 index 00000000..ce3b724f --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitOutputFormatsTest.java @@ -0,0 +1,24 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class JobUnitOutputFormatsTest { + @Test + @Parameters({ + "outputFormat", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = JobOutputFormats.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSimpleTriggerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSimpleTriggerTest.java new file mode 100644 index 00000000..f2931a2a --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSimpleTriggerTest.java @@ -0,0 +1,27 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class JobUnitSimpleTriggerTest { + @Test + @Parameters({ + "timezone", + "startType", + "startDate", + "occurrenceCount", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = JobSimpleTrigger.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSourceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSourceTest.java new file mode 100644 index 00000000..4b8eab6d --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitSourceTest.java @@ -0,0 +1,24 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class JobUnitSourceTest { + @Test + @Parameters({ + "folderURI", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = RepositoryDestination.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTest.java new file mode 100644 index 00000000..eab8b3d0 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTest.java @@ -0,0 +1,38 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class JobUnitTest { + @Test + @Parameters({ + "id", + "version", + "reportUnitURI", + "label", + "owner", + "state", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = JobUnit.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(JobUnit.class) + .suppress(Warning.NONFINAL_FIELDS) + .verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTriggerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTriggerTest.java new file mode 100644 index 00000000..44ed4097 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/JobUnitTriggerTest.java @@ -0,0 +1,24 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class JobUnitTriggerTest { + @Test + @Parameters({ + "simpleTrigger", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = JobTrigger.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestinationTest.java b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestinationTest.java new file mode 100644 index 00000000..b710b36a --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/network/entity/schedule/RepositoryDestinationTest.java @@ -0,0 +1,24 @@ +package com.jaspersoft.android.sdk.network.entity.schedule; + +import com.google.gson.annotations.Expose; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; + +import static com.jaspersoft.android.sdk.test.matcher.HasAnnotation.hasAnnotation; +import static org.hamcrest.MatcherAssert.assertThat; + +@RunWith(JUnitParamsRunner.class) +public class RepositoryDestinationTest { + @Test + @Parameters({ + "reportUnitURI", + }) + public void shouldHaveExposeAnnotationForField(String fieldName) throws NoSuchFieldException { + Field field = JobSource.class.getDeclaredField(fieldName); + assertThat(field, hasAnnotation(Expose.class)); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/data/schedule/JobDataTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/data/schedule/JobDataTest.java new file mode 100644 index 00000000..a21fe2f5 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/data/schedule/JobDataTest.java @@ -0,0 +1,11 @@ +package com.jaspersoft.android.sdk.service.data.schedule; + +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Test; + +public class JobDataTest { + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(JobData.class).verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobUnitSearchTaskTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobUnitSearchTaskTest.java new file mode 100644 index 00000000..5d455e21 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/BaseJobUnitSearchTaskTest.java @@ -0,0 +1,108 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.util.ArrayList; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; +import static org.mockito.MockitoAnnotations.initMocks; + +public class BaseJobUnitSearchTaskTest { + private static final JobSearchCriteria CRITERIA = JobSearchCriteria.empty(); + public static final int ROW_NUMBER = 5; + + @Mock + ReportScheduleUseCase mUseCase; + + private BaseJobSearchTask searchTask; + + @Before + public void setUp() throws Exception { + initMocks(this); + } + + @Test + public void should_increment_offset_each_time_if_search_not_exhausted() throws Exception { + mockConstantSearchResponse(); + + JobSearchCriteria initialCriteria = JobSearchCriteria.builder() + .withOffset(ROW_NUMBER) + .withLimit(ROW_NUMBER) + .build(); + + BaseJobSearchTask searchTask = new BaseJobSearchTask(mUseCase, initialCriteria); + searchTask.nextLookup(); + searchTask.nextLookup(); + + verify(mUseCase).searchJob(initialCriteria); + verify(mUseCase).searchJob( + initialCriteria.newBuilder() + .withOffset(ROW_NUMBER * 2) + .build() + ); + } + + @Test + public void should_return_last_cached_values_if_search_exhausted() throws Exception { + mockExhaustedSearchResponse(); + + JobSearchCriteria initialCriteria = JobSearchCriteria.builder() + .withLimit(JobSearchCriteria.UNLIMITED_ROW_NUMBER) + .build(); + BaseJobSearchTask searchTask = new BaseJobSearchTask(mUseCase, initialCriteria); + searchTask.nextLookup(); + searchTask.nextLookup(); + + verify(mUseCase).searchJob(initialCriteria); + verifyNoMoreInteractions(mUseCase); + } + + @Test + public void should_return_empty_result_if_first_run_exhausted() throws Exception { + mockEmptySearchResponse(); + + JobSearchCriteria initialCriteria = JobSearchCriteria.empty(); + BaseJobSearchTask searchTask = new BaseJobSearchTask(mUseCase, initialCriteria); + + List result = searchTask.nextLookup(); + assertThat(result.size(), is(0)); + + searchTask.nextLookup(); + + verify(mUseCase).searchJob(initialCriteria); + verifyNoMoreInteractions(mUseCase); + } + + @Test + public void should_have_next_by_default_true() throws Exception { + BaseJobSearchTask searchTask = new BaseJobSearchTask(mUseCase, JobSearchCriteria.empty()); + assertThat("Should have next values by default", searchTask.hasNext(), is(true)); + } + + private void mockConstantSearchResponse() throws Exception { + mockSearchResponse(ROW_NUMBER); + } + + private void mockEmptySearchResponse() throws Exception { + mockSearchResponse(0); + } + + private void mockExhaustedSearchResponse() throws Exception { + mockSearchResponse(ROW_NUMBER - 1); + } + + private void mockSearchResponse(int number) throws Exception { + List list = new ArrayList<>(); + for (int i = 0; i < number; i++) { + list.add(null); + } + when(mUseCase.searchJob(any(JobSearchCriteria.class))).thenReturn(list); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitOwnerTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitOwnerTest.java new file mode 100644 index 00000000..e01792c9 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitOwnerTest.java @@ -0,0 +1,39 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.rules.ExpectedException.none; + +public class JobUnitOwnerTest { + @Rule + public ExpectedException expected = none(); + + @Test + public void maps_username_organization_toString() throws Exception { + JobOwner jobOwner = JobOwner.newOwner("jasperadmin", "organization_1"); + assertThat(jobOwner.toString(), is("jasperadmin|organization_1")); + } + + @Test + public void maps_username_toString() throws Exception { + JobOwner jobOwner = JobOwner.newOwner("jasperadmin", null); + assertThat(jobOwner.toString(), is("jasperadmin")); + } + + @Test + public void factory_fails_with_null_username() throws Exception { + expected.expect(NullPointerException.class); + expected.expectMessage("Username should not be null"); + JobOwner.newOwner(null, null); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(JobOwner.class).verify(); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaMapperTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaMapperTest.java new file mode 100644 index 00000000..9bc82245 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaMapperTest.java @@ -0,0 +1,95 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import org.junit.Before; +import org.junit.Test; + +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +public class JobUnitSearchCriteriaMapperTest { + + private JobSearchCriteriaMapper mCriteriaMapper; + + @Before + public void setUp() throws Exception { + mCriteriaMapper = new JobSearchCriteriaMapper(); + } + + @Test + public void should_map_report_uri() throws Exception { + JobSearchCriteria criteria = JobSearchCriteria.builder() + .withReportUri("/my/uri") + .build(); + + Map params = performMap(criteria); + assertThat(params.containsKey("reportUnitURI"), is(true)); + assertThat(String.valueOf(params.get("reportUnitURI")), is("/my/uri")); + } + + @Test + public void should_map_owner() throws Exception { + JobSearchCriteria criteria = JobSearchCriteria.builder() + .withOwner(JobOwner.newOwner("jasperadmin", "organization_1")) + .build(); + + Map params = performMap(criteria); + assertThat(params.containsKey("owner"), is(true)); + assertThat(String.valueOf(params.get("owner")), is("jasperadmin|organization_1")); + } + + @Test + public void should_map_label() throws Exception { + JobSearchCriteria criteria = JobSearchCriteria.builder() + .withLabel("my label") + .build(); + Map params = performMap(criteria); + assertThat(params.containsKey("label"), is(true)); + assertThat(String.valueOf(params.get("label")), is("my label")); + } + + @Test + public void should_map_start_index() throws Exception { + JobSearchCriteria criteria = JobSearchCriteria.builder() + .withOffset(100) + .build(); + Map params = performMap(criteria); + assertThat(params.containsKey("startIndex"), is(true)); + assertThat(String.valueOf(params.get("startIndex")), is("100")); + } + + @Test + public void should_map_number_of_rows() throws Exception { + JobSearchCriteria criteria = JobSearchCriteria.builder() + .withLimit(50) + .build(); + Map params = performMap(criteria); + assertThat(params.containsKey("numberOfRows"), is(true)); + assertThat(String.valueOf(params.get("numberOfRows")), is("50")); + } + + @Test + public void should_map_sort_type() throws Exception { + JobSearchCriteria criteria = JobSearchCriteria.builder() + .withSortType(JobSortType.SORTBY_JOBID) + .build(); + Map params = performMap(criteria); + assertThat(params.containsKey("sortType"), is(true)); + assertThat(String.valueOf(params.get("sortType")), is("SORTBY_JOBID")); + } + + @Test + public void should_map_ascending_flag() throws Exception { + JobSearchCriteria criteria = JobSearchCriteria.builder() + .withAscending(true) + .build(); + Map params = performMap(criteria); + assertThat(params.containsKey("isAscending"), is(true)); + assertThat(String.valueOf(params.get("isAscending")), is("true")); + } + + private Map performMap(JobSearchCriteria criteria) { + return mCriteriaMapper.transform(criteria); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaTest.java new file mode 100644 index 00000000..5591dc5b --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/JobUnitSearchCriteriaTest.java @@ -0,0 +1,122 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import nl.jqno.equalsverifier.EqualsVerifier; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.rules.ExpectedException.none; + +public class JobUnitSearchCriteriaTest { + + private JobSearchCriteria.Builder mBuilder; + + @Rule + public ExpectedException expected = none(); + + @Before + public void setUp() throws Exception { + mBuilder = JobSearchCriteria.builder(); + } + + @Test + public void builds_with_reportUnitURI() throws Exception { + mBuilder.withReportUri("/my/uri"); + JobSearchCriteria params = mBuilder.build(); + assertThat("Builder Does not maps report uri", params.getReportUri(), is("/my/uri")); + + JobSearchCriteria newParams = params.newBuilder().build(); + assertThat("New builder should inherit report uri", newParams.getReportUri(), is("/my/uri")); + } + + @Test + public void builds_with_owner() throws Exception { + JobOwner owner = JobOwner.newOwner("user", "org"); + + mBuilder.withOwner(owner); + JobSearchCriteria params = mBuilder.build(); + assertThat("Builder does not maps owner", params.getOwner(), is(owner)); + + JobSearchCriteria newParams = params.newBuilder().build(); + assertThat("New builder should inherit report uri", newParams.getOwner(), is(owner)); + } + + @Test + public void builds_with_label() throws Exception { + mBuilder.withLabel("label"); + JobSearchCriteria params = mBuilder.build(); + assertThat("Builder Does not maps label", params.getLabel(), is("label")); + + JobSearchCriteria newParams = params.newBuilder().build(); + assertThat("New builder should inherit label", newParams.getLabel(), is("label")); + } + + @Test + public void builds_with_startIndex() throws Exception { + mBuilder.withOffset(0); + JobSearchCriteria params = mBuilder.build(); + assertThat("Builder Does not startIndex", params.getOffset(), is(0)); + + JobSearchCriteria newParams = params.newBuilder().build(); + assertThat("New builder should startIndex", newParams.getOffset(), is(0)); + } + + @Test + public void builds_with_numberOfRows() throws Exception { + mBuilder.withLimit(JobSearchCriteria.UNLIMITED_ROW_NUMBER); + JobSearchCriteria params = mBuilder.build(); + assertThat("Builder Does not numberOfRows", params.getLimit(), is(JobSearchCriteria.UNLIMITED_ROW_NUMBER)); + + JobSearchCriteria newParams = params.newBuilder().build(); + assertThat("New builder should numberOfRows", newParams.getLimit(), is(JobSearchCriteria.UNLIMITED_ROW_NUMBER)); + } + + @Test + public void builds_with_sortType() throws Exception { + mBuilder.withSortType(JobSortType.NONE); + JobSearchCriteria params = mBuilder.build(); + assertThat("Builder Does not sortType", params.getSortType(), is(JobSortType.NONE)); + + JobSearchCriteria newParams = params.newBuilder().build(); + assertThat("New builder should sortType", newParams.getSortType(), is(JobSortType.NONE)); + } + + @Test + public void builds_with_isAscending() throws Exception { + mBuilder.withAscending(true); + JobSearchCriteria params = mBuilder.build(); + assertThat("Builder Does not isAscending", params.getAscending(), is(true)); + + JobSearchCriteria newParams = params.newBuilder().build(); + assertThat("New builder should isAscending", newParams.getAscending(), is(true)); + } + + @Test + public void testEquals() throws Exception { + EqualsVerifier.forClass(JobSearchCriteria.class).verify(); + } + + @Test + public void should_not_accept_negative_row_number() throws Exception { + expected.expect(IllegalArgumentException.class); + expected.expectMessage("Row number must be positive"); + mBuilder.withLimit(-1); + } + + @Test + public void should_not_accept_zero_row_number() throws Exception { + expected.expect(IllegalArgumentException.class); + expected.expectMessage("Row number must be positive"); + mBuilder.withLimit(0); + } + + @Test + public void should_not_accept_zero_start_index() throws Exception { + expected.expect(IllegalArgumentException.class); + expected.expectMessage("Start index must be positive"); + mBuilder.withOffset(-1); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleServiceTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleServiceTest.java new file mode 100644 index 00000000..da60bd26 --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleServiceTest.java @@ -0,0 +1,60 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Mockito.verify; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ReportScheduleServiceTest { + private ReportScheduleService scheduleService; + + @Mock + ReportScheduleUseCase mUseCase; + + @Rule + public ExpectedException expected = none(); + + @Before + public void setUp() throws Exception { + initMocks(this); + scheduleService = new ReportScheduleService(mUseCase); + } + + @Test + public void search_creates_new_task() throws Exception { + JobSearchTask task1 = scheduleService.search(JobSearchCriteria.empty()); + JobSearchTask task2 = scheduleService.search(JobSearchCriteria.empty()); + assertThat(task1, is(not(task2))); + } + + @Test + public void should_reject_null_client() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + + ReportScheduleService.newService(null); + } + + @Test + public void should_delegate_job_creation() throws Exception { + JobForm jobForm = new JobForm.Builder().build(); + scheduleService.createJob(jobForm); + verify(mUseCase).createJob(jobForm); + } + + @Test + public void should_reject_null_job_form() throws Exception { + expected.expectMessage("Job form should not be null"); + expected.expect(NullPointerException.class); + scheduleService.createJob(null); + } +} \ No newline at end of file diff --git a/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCaseTest.java b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCaseTest.java new file mode 100644 index 00000000..84f1a65a --- /dev/null +++ b/core/src/test/java/com/jaspersoft/android/sdk/service/report/schedule/ReportScheduleUseCaseTest.java @@ -0,0 +1,135 @@ +package com.jaspersoft.android.sdk.service.report.schedule; + +import com.jaspersoft.android.sdk.network.HttpException; +import com.jaspersoft.android.sdk.network.ReportScheduleRestApi; +import com.jaspersoft.android.sdk.network.entity.schedule.JobDescriptor; +import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; +import com.jaspersoft.android.sdk.service.data.schedule.JobData; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.ServiceExceptionMapper; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; + +import java.io.IOException; +import java.util.Collections; +import java.util.Map; + +import static junit.framework.TestCase.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyMapOf; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ReportScheduleUseCaseTest { + private static final Map SEARCH_PARAMS = Collections.emptyMap(); + private static final JobSearchCriteria CRITERIA = JobSearchCriteria.empty(); + + @Mock + ServiceExceptionMapper mExceptionMapper; + @Mock + JobDataMapper mJobDataMapper; + @Mock + ReportScheduleRestApi mScheduleRestApi; + @Mock + JobSearchCriteriaMapper mSearchCriteriaMapper; + + @Mock + JobData mJobData; + @Mock + JobForm mJobForm; + @Mock + JobDescriptor mJobDescriptor; + + @Mock + IOException mIOException; + @Mock + HttpException mHttpException; + @Mock + ServiceException mServiceException; + + private ReportScheduleUseCase useCase; + + @Before + public void setUp() throws Exception { + initMocks(this); + + setupMocks(); + useCase = new ReportScheduleUseCase(mExceptionMapper, mScheduleRestApi, mSearchCriteriaMapper, mJobDataMapper); + } + + @Test + public void should_perform_search() throws Exception { + useCase.searchJob(CRITERIA); + + verify(mSearchCriteriaMapper).transform(CRITERIA); + verify(mScheduleRestApi).searchJob(SEARCH_PARAMS); + } + + @Test + public void should_perform_create_job() throws Exception { + when(mScheduleRestApi.createJob(any(JobForm.class))).thenReturn(mJobDescriptor); + + useCase.createJob(mJobForm); + + verify(mJobDataMapper).transform(mJobDescriptor); + verify(mScheduleRestApi).createJob(mJobForm); + } + + @Test + public void search_adapts_io_exception() throws Exception { + when(mScheduleRestApi.searchJob(anyMapOf(String.class, Object.class))).thenThrow(mIOException); + try { + useCase.searchJob(CRITERIA); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void search_adapts_http_exception() throws Exception { + when(mScheduleRestApi.searchJob(anyMapOf(String.class, Object.class))).thenThrow(mHttpException); + + try { + useCase.searchJob(CRITERIA); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + @Test + public void create_job_adapts_io_exception() throws Exception { + when(mScheduleRestApi.createJob(any(JobForm.class))).thenThrow(mIOException); + + try { + useCase.createJob(mJobForm); + fail("Should adapt IO exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mIOException); + } + } + + @Test + public void create_job_adapts_http_exception() throws Exception { + when(mScheduleRestApi.createJob(any(JobForm.class))).thenThrow(mHttpException); + + try { + useCase.createJob(mJobForm); + fail("Should adapt HTTP exception"); + } catch (ServiceException ex) { + verify(mExceptionMapper).transform(mHttpException); + } + } + + private void setupMocks() { + when(mSearchCriteriaMapper.transform(any(JobSearchCriteria.class))) + .thenReturn(SEARCH_PARAMS); + when(mJobDataMapper.transform(any(JobDescriptor.class))) + .thenReturn(mJobData); + when(mExceptionMapper.transform(any(HttpException.class))).thenReturn(mServiceException); + when(mExceptionMapper.transform(any(IOException.class))).thenReturn(mServiceException); + } +} \ No newline at end of file diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobSearchTask.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobSearchTask.java new file mode 100644 index 00000000..14412212 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobSearchTask.java @@ -0,0 +1,49 @@ +package com.jaspersoft.android.sdk.service.rx.report.schedule; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.schedule.JobSearchTask; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +import java.util.List; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RxJobSearchTask { + private final JobSearchTask mSyncDelegate; + + @TestOnly + RxJobSearchTask(JobSearchTask syncDelegate) { + mSyncDelegate = syncDelegate; + } + + @NotNull + public Observable> nextLookup() { + return Observable.defer(new Func0>>() { + @Override + public Observable> call() { + try { + List jobUnits = mSyncDelegate.nextLookup(); + return Observable.just(jobUnits); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + public Observable hasNext() { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + return Observable.just(mSyncDelegate.hasNext()); + } + }); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleService.java new file mode 100644 index 00000000..bb7b6d20 --- /dev/null +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleService.java @@ -0,0 +1,57 @@ +package com.jaspersoft.android.sdk.service.rx.report.schedule; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; +import com.jaspersoft.android.sdk.service.data.schedule.JobData; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.internal.Preconditions; +import com.jaspersoft.android.sdk.service.report.schedule.JobSearchCriteria; +import com.jaspersoft.android.sdk.service.report.schedule.JobSearchTask; +import com.jaspersoft.android.sdk.service.report.schedule.ReportScheduleService; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; +import rx.Observable; +import rx.functions.Func0; + +/** + * @author Tom Koptel + * @since 2.0 + */ +public class RxReportScheduleService { + @NotNull + private final ReportScheduleService mSyncDelegate; + + @TestOnly + RxReportScheduleService(@NotNull ReportScheduleService syncDelegate) { + mSyncDelegate = syncDelegate; + } + + @NotNull + public RxJobSearchTask search(@Nullable JobSearchCriteria criteria) { + JobSearchTask searchTask = mSyncDelegate.search(criteria); + return new RxJobSearchTask(searchTask); + } + + @NotNull + public Observable createJob(@NotNull final JobForm form) { + return Observable.defer(new Func0>() { + @Override + public Observable call() { + try { + JobData job = mSyncDelegate.createJob(form); + return Observable.just(job); + } catch (ServiceException e) { + return Observable.error(e); + } + } + }); + } + + @NotNull + public static RxReportScheduleService newService(@NotNull AuthorizedClient client) { + Preconditions.checkNotNull(client, "Client should not be null"); + ReportScheduleService scheduleService = ReportScheduleService.newService(client); + return new RxReportScheduleService(scheduleService); + } +} diff --git a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java index ff7b22f9..872b0853 100644 --- a/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java +++ b/rx/src/main/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryService.java @@ -54,10 +54,9 @@ public class RxRepositoryService { } @NotNull - public Observable search(@Nullable SearchCriteria criteria) { + public RxSearchTask search(@Nullable SearchCriteria criteria) { SearchTask searchTask = mSyncDelegate.search(criteria); - RxSearchTask rxSearchTask = new RxSearchTask(searchTask); - return Observable.just(rxSearchTask); + return new RxSearchTask(searchTask); } @NotNull diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobUnitSearchTaskTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobUnitSearchTaskTest.java new file mode 100644 index 00000000..c7d0e9bb --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxJobUnitSearchTaskTest.java @@ -0,0 +1,73 @@ +package com.jaspersoft.android.sdk.service.rx.report.schedule; + +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.schedule.JobSearchTask; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import java.util.Collections; +import java.util.List; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxJobUnitSearchTaskTest { + + @Mock + JobSearchTask mSyncDelegate; + @Mock + ServiceException mServiceException; + + private RxJobSearchTask rxSearchTask; + + @Before + public void setUp() throws Exception { + initMocks(this); + rxSearchTask = new RxJobSearchTask(mSyncDelegate); + } + + @Test + public void should_call_delegate_for_lookup() throws Exception { + when(mSyncDelegate.nextLookup()).thenReturn(Collections.emptyList()); + + TestSubscriber> test = new TestSubscriber<>(); + rxSearchTask.nextLookup().subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).nextLookup(); + } + + @Test + public void should_delegate_service_exception_on_nextLookup() throws Exception { + when(mSyncDelegate.nextLookup()).thenThrow(mServiceException); + + TestSubscriber> test = new TestSubscriber<>(); + rxSearchTask.nextLookup().subscribe(test); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).nextLookup(); + } + + @Test + public void should_call_delegate_for_hasNext() throws Exception { + when(mSyncDelegate.hasNext()).thenReturn(true); + + TestSubscriber test = new TestSubscriber<>(); + rxSearchTask.hasNext().subscribe(test); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).hasNext(); + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleServiceTest.java new file mode 100644 index 00000000..0622bab8 --- /dev/null +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/report/schedule/RxReportScheduleServiceTest.java @@ -0,0 +1,98 @@ +package com.jaspersoft.android.sdk.service.rx.report.schedule; + +import com.jaspersoft.android.sdk.network.AuthorizedClient; +import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; +import com.jaspersoft.android.sdk.service.data.schedule.JobData; +import com.jaspersoft.android.sdk.service.exception.ServiceException; +import com.jaspersoft.android.sdk.service.report.schedule.ReportScheduleService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import rx.observers.TestSubscriber; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class RxReportScheduleServiceTest { + + @Rule + public ExpectedException expected = none(); + + @Mock + ReportScheduleService mSyncDelegate; + @Mock + ServiceException mServiceException; + + @Mock + AuthorizedClient mAuthorizedClient; + + @Mock + JobForm mJobForm; + @Mock + JobData mJobData; + + private RxReportScheduleService mRxReportScheduleService; + + @Before + public void setUp() throws Exception { + initMocks(this); + mRxReportScheduleService = new RxReportScheduleService(mSyncDelegate); + } + + @Test + public void testSearch() throws Exception { + mRxReportScheduleService.search(null); + } + + @Test + public void should_not_accept_null_for_factory_method() throws Exception { + expected.expectMessage("Client should not be null"); + expected.expect(NullPointerException.class); + RxReportScheduleService.newService(null); + } + + @Test + public void should_create_service_if_client_suplie() throws Exception { + RxReportScheduleService rxReportScheduleService = RxReportScheduleService.newService(mAuthorizedClient); + assertThat(rxReportScheduleService, is(notNullValue())); + } + + @Test + public void should_call_delegate_for_lookup() throws Exception { + when(mSyncDelegate.createJob(any(JobForm.class))).thenReturn(mJobData); + + TestSubscriber test = createJob(); + + test.assertNoErrors(); + test.assertCompleted(); + test.assertValueCount(1); + + verify(mSyncDelegate).createJob(mJobForm); + } + + @Test + public void should_delegate_service_exception_on_nextLookup() throws Exception { + when(mSyncDelegate.createJob(any(JobForm.class))).thenThrow(mServiceException); + + TestSubscriber test = createJob(); + + test.assertError(mServiceException); + test.assertNotCompleted(); + + verify(mSyncDelegate).createJob(mJobForm); + } + + private TestSubscriber createJob() { + TestSubscriber test = new TestSubscriber<>(); + mRxReportScheduleService.createJob(mJobForm).subscribe(test); + return test; + } +} \ No newline at end of file diff --git a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java index bd616088..dcf288f8 100644 --- a/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java +++ b/rx/src/test/java/com/jaspersoft/android/sdk/service/rx/repository/RxRepositoryServiceTest.java @@ -82,11 +82,7 @@ public void should_delegate_search_call() throws Exception { SearchCriteria criteria = SearchCriteria.none(); TestSubscriber test = new TestSubscriber<>(); - rxRepositoryService.search(criteria).subscribe(test); - - test.assertNoErrors(); - test.assertCompleted(); - test.assertValueCount(1); + rxRepositoryService.search(criteria); verify(mSyncDelegate).search(criteria); } @@ -148,10 +144,7 @@ public void root_folders_call_delegate_service_exception() throws Exception { @Test public void should_accept_null_criteria() throws Exception { - TestSubscriber test = new TestSubscriber<>(); - rxRepositoryService.search(null).subscribe(test); - test.assertNoErrors(); - test.assertCompleted(); + rxRepositoryService.search(null); } @Test From b441dc3b3d993fb89061266de718e6b1d67a5a9a Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 15 Jan 2016 11:58:22 +0200 Subject: [PATCH 389/457] Fix git upper case related issue for schedule API --- .../android/sdk/network/ReportScheduleRestApi.java | 10 +++++----- .../{JobSearchresult.java => JobsSearchResult.java} | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) rename core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/{JobSearchresult.java => JobsSearchResult.java} (63%) diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java index 583b3af6..649ddf7f 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/ReportScheduleRestApi.java @@ -1,9 +1,9 @@ package com.jaspersoft.android.sdk.network; -import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; import com.jaspersoft.android.sdk.network.entity.schedule.JobDescriptor; import com.jaspersoft.android.sdk.network.entity.schedule.JobForm; -import com.jaspersoft.android.sdk.network.entity.schedule.JobSearchResult; +import com.jaspersoft.android.sdk.network.entity.schedule.JobUnit; +import com.jaspersoft.android.sdk.network.entity.schedule.JobsSearchResult; import com.jaspersoft.android.sdk.service.internal.Preconditions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,8 +54,8 @@ public List searchJob(@Nullable Map searchParams) throw } } - Call call = mRestApi.searchJob(encodedParams); - JobSearchResult searchResult = CallWrapper.wrap(call).body(); + Call call = mRestApi.searchJob(encodedParams); + JobsSearchResult searchResult = CallWrapper.wrap(call).body(); return searchResult.getJobSummary(); } @@ -70,7 +70,7 @@ private interface RestApi { @NotNull @Headers("Accept: application/json") @GET("rest_v2/jobs") - public Call searchJob(@Nullable @QueryMap(encoded = true) Map searchParams); + public Call searchJob(@Nullable @QueryMap(encoded = true) Map searchParams); @NotNull @Headers("Accept: application/job+json") diff --git a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSearchresult.java b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobsSearchResult.java similarity index 63% rename from core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSearchresult.java rename to core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobsSearchResult.java index 2c85ff3d..0a235fb6 100644 --- a/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobSearchresult.java +++ b/core/src/main/java/com/jaspersoft/android/sdk/network/entity/schedule/JobsSearchResult.java @@ -9,11 +9,11 @@ * @author Tom Koptel * @since 2.0 */ -public class JobSearchResult { +public class JobsSearchResult { @Expose - private List mJobsummary = Collections.emptyList(); + private List jobsummary = Collections.emptyList(); public List getJobSummary() { - return Collections.unmodifiableList(mJobsummary); + return Collections.unmodifiableList(jobsummary); } } From ca18226c363e6c5ba4f08afe907245b9be8aa047 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 15 Jan 2016 12:13:41 +0200 Subject: [PATCH 390/457] Add ReportTestBundle#toString() --- .../com/jaspersoft/android/sdk/env/ReportTestBundle.java | 8 ++++++++ .../com/jaspersoft/android/sdk/env/ServerTestBundle.java | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ReportTestBundle.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ReportTestBundle.java index 34f954df..7dd91344 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ReportTestBundle.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ReportTestBundle.java @@ -27,4 +27,12 @@ public SpringCredentials getCredentials() { public AuthorizedClient getClient() { return serverTestBundle.getClient(); } + + @Override + public String toString() { + return "ReportTestBundle{" + + "server=" + serverTestBundle + + ", reportUri='" + reportUri + '\'' + + '}'; + } } diff --git a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerTestBundle.java b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerTestBundle.java index c300309e..11d98a36 100644 --- a/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerTestBundle.java +++ b/core-integration-tests/src/test/java/com/jaspersoft/android/sdk/env/ServerTestBundle.java @@ -27,13 +27,13 @@ public AuthorizedClient getClient() { @Override public String toString() { String credentials = "Credentials{" + - ", username='" + mCredentials.getUsername() + '\'' + + "username='" + mCredentials.getUsername() + '\'' + ", organization='" + mCredentials.getOrganization() + '\'' + ", password=" + mCredentials.getPassword() + '}'; return "ServerTestBundle{" + - "credentials=" + credentials + - ", url=" + mClient.getBaseUrl() + + "url=" + mClient.getBaseUrl() + + ", credentials=" + credentials + '}'; } } From 986f00f1ddc3d7e330dd8ef4cc91d44905022b25 Mon Sep 17 00:00:00 2001 From: Tom Koptel Date: Fri, 15 Jan 2016 12:59:24 +0200 Subject: [PATCH 391/457] Add tests for report await_complete_event/update_execution/export --- .../testkit/GetReportParametersUseCase.java | 94 ++++++++++--------- .../sdk/testkit/GetResourcesUrisUseCase.java | 3 +- .../android/sdk/testkit/TestKitClient.java | 6 +- .../android/sdk/env/JrsEnvironmentRule.java | 33 +++++-- .../android/sdk/env/ReportTestBundle.java | 20 +++- .../sdk/service/report/ReportServiceTest.java | 40 +++++++- .../android/sdk/network/AuthorizedClient.java | 10 ++ .../android/sdk/network/Server.java | 4 +- 8 files changed, 154 insertions(+), 56 deletions(-) diff --git a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/GetReportParametersUseCase.java b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/GetReportParametersUseCase.java index 755e3ea4..932fd6f9 100644 --- a/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/GetReportParametersUseCase.java +++ b/core-integration-tests/src/main/java/com/jaspersoft/android/sdk/testkit/GetReportParametersUseCase.java @@ -24,6 +24,9 @@ package com.jaspersoft.android.sdk.testkit; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; import com.google.gson.stream.JsonReader; import com.jaspersoft.android.sdk.testkit.exception.HttpException; import com.squareup.okhttp.HttpUrl; @@ -32,16 +35,13 @@ import java.io.IOException; import java.io.InputStreamReader; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Tom Koptel * @since 2.3 */ -final class GetReportParametersUseCase extends HttpUseCase< Map>, ListReportParamsCommand> { +final class GetReportParametersUseCase extends HttpUseCase>, ListReportParamsCommand> { private final String mBaseUrl; public GetReportParametersUseCase(OkHttpClient client, String baseUrl) { @@ -59,54 +59,62 @@ public Map> execute(ListReportParamsCommand command) throws Response response = performRequest(url); Map> params = new HashMap<>(); mapResponse(response, params); - return params; + return Collections.unmodifiableMap(params); } private void mapResponse(Response response, Map> params) throws IOException { JsonReader reader = new JsonReader(new InputStreamReader(response.body().byteStream(), "UTF-8")); - reader.beginObject(); - reader.nextName(); - reader.beginArray(); - while (reader.hasNext()) { - populateParams(params, reader); + Gson gson = new GsonBuilder() + .serializeNulls() + .excludeFieldsWithoutExposeAnnotation() + .create(); + States states = gson.fromJson(reader, States.class); + List inputControlState = states.getInputControlState(); + for (State state : inputControlState) { + List